• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Repository.DiscoDataContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Disco.Data.Repository.DiscoDataContext的典型用法代码示例。如果您正苦于以下问题:C# DiscoDataContext类的具体用法?C# DiscoDataContext怎么用?C# DiscoDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DiscoDataContext类属于Disco.Data.Repository命名空间,在下文中一共展示了DiscoDataContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExecuteTask

 protected override void ExecuteTask()
 {
     using (var database = new DiscoDataContext())
     {
         UpdateDataHistory(database, true);
     }
 }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:DailyOpenedClosed.cs


示例2: Apply

        public override bool Apply(DiscoDataContext Database, Device Device)
        {
            if (this.FieldAction == EntityState.Added ||
                this.FieldAction == EntityState.Modified)
            {

                DeviceDetail detail = Database.DeviceDetails.FirstOrDefault(dd =>
                    dd.DeviceSerialNumber == Device.SerialNumber &&
                    dd.Scope == DeviceDetail.ScopeHardware &&
                    dd.Key == DeviceDetail.HardwareKeyLanMacAddress);

                if (detail == null)
                {
                    detail = new DeviceDetail()
                    {
                        Device = Device,
                        DeviceSerialNumber = Device.SerialNumber,
                        Scope = DeviceDetail.ScopeHardware,
                        Key = DeviceDetail.HardwareKeyLanMacAddress
                    };
                    Database.DeviceDetails.Add(detail);
                }

                detail.Value = parsedValue;
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:garysharp,项目名称:Disco,代码行数:31,代码来源:DetailLanMacAddressImportField.cs


示例3: BuildResponse

        public static WhoAmIResponse BuildResponse(this WhoAmI request)
        {
            if (HttpContext.Current == null)
                throw new PlatformNotSupportedException("This function can only be accessed from within ASP.NET");

            string username = null;
            if (HttpContext.Current.Request.IsAuthenticated)
                username = HttpContext.Current.User.Identity.Name;

            if (username == null)
                throw new InvalidOperationException("Unauthenticated Http Context");

            using (DiscoDataContext database = new DiscoDataContext())
            {
                AuthorizationToken token = UserService.GetAuthorization(username, database, true);

                WhoAmIResponse response = new WhoAmIResponse()
                {
                    Username = token.User.UserId,
                    DisplayName = token.User.DisplayName,
                    Type = token.Has(Claims.ComputerAccount) ? "Computer Account" : "User Account"
                };
                return response;
            }
        }
开发者ID:garysharp,项目名称:Disco,代码行数:25,代码来源:ClientServicesExtensions.cs


示例4: Parse

        public override bool Parse(DiscoDataContext Database, IDeviceImportCache Cache, DeviceImportContext Context, int RecordIndex, string DeviceSerialNumber, Device ExistingDevice, Dictionary<DeviceImportFieldTypes, string> Values, string Value)
        {
            friendlyValue = Value;

            // Validate
            if (string.IsNullOrWhiteSpace(Value))
                this.parsedValue = 1; // Default Model
            else
                if (!int.TryParse(Value, out parsedValue))
                    return Error("The Model Identifier must be a number");

            var m = Cache.DeviceModels.FirstOrDefault(dm => dm.Id == parsedValue);

            if (m == null)
                return Error(string.Format("The identifier ({0}) does not match any Device Model", Value));

            friendlyValue = string.Format("{0} [{1}]", m.Description, m.Id);

            if (ExistingDevice == null)
                return Success(EntityState.Added);
            else if (ExistingDevice != null && ExistingDevice.DeviceModelId != parsedValue)
            {
                friendlyPreviousValue = null;
                if (ExistingDevice.DeviceModelId.HasValue)
                {
                    var previousModel = Cache.DeviceModels.FirstOrDefault(dm => dm.Id == ExistingDevice.DeviceModelId.Value);
                    friendlyPreviousValue = string.Format("{0} [{1}]", previousModel.Description, previousModel.Id);
                }

                return Success(EntityState.Modified);
            }
            else
                return Success(EntityState.Unchanged);
        }
开发者ID:garysharp,项目名称:Disco,代码行数:34,代码来源:ModelIdImportField.cs


示例5: Execute

 public void Execute(IJobExecutionContext context)
 {
     using (DiscoDataContext database = new DiscoDataContext())
     {
         LogContext.ReInitalize(database);
     }
 }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:LogReInitalizeJob.cs


示例6: BeginImport

        public static DeviceImportContext BeginImport(DiscoDataContext Database, string Filename, bool HasHeader, Stream FileContent)
        {
            if (FileContent == null)
                throw new ArgumentNullException("FileContent");

            if (string.IsNullOrWhiteSpace(Filename))
                Filename = "<None Specified>";

            DeviceImportContext context;
            List<Tuple<string, DeviceImportFieldTypes>> header;
            List<string[]> rawData;

            using (TextReader csvTextReader = new StreamReader(FileContent))
            {
                using (CsvReader csvReader = new CsvReader(csvTextReader, HasHeader))
                {
                    csvReader.DefaultParseErrorAction = ParseErrorAction.ThrowException;
                    csvReader.MissingFieldAction = MissingFieldAction.ReplaceByNull;

                    rawData = csvReader.ToList();
                    header = csvReader.GetFieldHeaders().Select(h => Tuple.Create(h, DeviceImportFieldTypes.IgnoreColumn)).ToList();
                }
            }

            context = new DeviceImportContext(Filename, header, rawData);

            context.GuessHeaderTypes(Database);

            return context;
        }
开发者ID:garysharp,项目名称:Disco,代码行数:30,代码来源:DeviceImport.cs


示例7: Parse

        public override bool Parse(DiscoDataContext Database, IDeviceImportCache Cache, DeviceImportContext Context, int RecordIndex, string DeviceSerialNumber, Device ExistingDevice, Dictionary<DeviceImportFieldTypes, string> Values, string Value)
        {
            friendlyValue = Value;

            // Validate
            if (string.IsNullOrWhiteSpace(Value))
                this.parsedValue = Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId;
            else
                if (!int.TryParse(Value, out parsedValue))
                    return Error("The Profile Identifier must be a number");

            var p = Cache.DeviceProfiles.FirstOrDefault(dp => dp.Id == parsedValue);

            if (p == null)
                return Error(string.Format("The identifier ({0}) does not match any Device Profile", Value));

            friendlyValue = string.Format("{0} [{1}]", p.Description, p.Id);

            if (ExistingDevice == null)
                return Success(EntityState.Added);
            else if (ExistingDevice != null && ExistingDevice.DeviceProfileId != parsedValue)
            {
                var previousProfile = Cache.DeviceProfiles.FirstOrDefault(dp => dp.Id == ExistingDevice.DeviceProfileId);
                friendlyPreviousValue = string.Format("{0} [{1}]", previousProfile.Description, previousProfile.Id);

                return Success(EntityState.Modified);
            }
            else
                return Success(EntityState.Unchanged);
        }
开发者ID:garysharp,项目名称:Disco,代码行数:30,代码来源:ProfileIdImportField.cs


示例8: Initialize

        private void Initialize(DiscoDataContext Database)
        {
            // Search Entire Forest (default: true)
            this._SearchAllForestServers = Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers ?? true;

            // Set Search LDAP Filters
            InitializeWildcardSearchSufixOnly(Database.DiscoConfiguration.ActiveDirectory.SearchWildcardSuffixOnly);

            // Determine Site
            var computerSite = ActiveDirectorySite.GetComputerSite();
            this.Site = new ADSite(this, computerSite);

            // Determine Domains
            var computerDomain = Domain.GetComputerDomain();
            this.Domains = computerDomain.Forest.Domains
                .Cast<Domain>()
                .Select(d => new ADDomain(this, d))
                .ToList();
            this.PrimaryDomain = this.Domains.Where(d => d.Name == computerDomain.Name).First();

            // Determine Search Scope Containers
            ReinitializeSearchContainers(Database.DiscoConfiguration.ActiveDirectory.SearchContainers);

            // Determine Domain Controllers
            var siteDomainControllers = computerSite.Servers
                .OfType<DomainController>()
                .Where(dc => dc.IsReachable())
                .Select(dc => new ADDomainController(this, dc, GetDomainByName(dc.Domain.Name), IsSiteServer: true, IsWritable: false));

            Site.UpdateDomainControllers(siteDomainControllers);
            this.Domains.ForEach(domain => domain.UpdateDomainControllers(siteDomainControllers.Where(dc => dc.Domain == domain)));
        }
开发者ID:garysharp,项目名称:Disco,代码行数:32,代码来源:ActiveDirectoryContext.cs


示例9: AvailablePackages

        public static List<DocumentTemplatePackage> AvailablePackages(this Job job, DiscoDataContext Database, User TechnicianUser)
        {
            var packages = new List<DocumentTemplatePackage>();

            foreach (var package in AvailablePackages(Database, AttachmentTypes.Job))
            {
                bool subTypeMatch = true; // default match
                if (package.JobSubTypes != null && package.JobSubTypes.Count > 0)
                {
                    subTypeMatch = false; // enforce match
                    foreach (var subType in job.JobSubTypes)
                    {
                        if (package.JobSubTypes.Contains($"{subType.JobTypeId}_{subType.Id}", StringComparer.OrdinalIgnoreCase))
                        {
                            subTypeMatch = true;
                            break;
                        }
                    }
                }

                if (subTypeMatch)
                {
                    if (package.FilterExpressionMatches(job, Database, TechnicianUser, DateTime.Now, DocumentState.DefaultState()))
                    {
                        packages.Add(package);
                    }
                }
            }

            return packages;
        }
开发者ID:garysharp,项目名称:Disco,代码行数:31,代码来源:DocumentTemplatePackages.cs


示例10: Build

        public static IndexModel Build(DiscoDataContext Database)
        {
            var m = new IndexModel();
            m.DeviceProfiles = Database.DeviceProfiles.OrderBy(dp => dp.Name).Select(dp => new _IndexModelItem()
            {
                Id = dp.Id,
                Name = dp.Name,
                ShortName = dp.ShortName,
                Address = dp.DefaultOrganisationAddress,
                Description = dp.Description,
                DistributionType = dp.DistributionType.Value,
                DeviceCount = dp.Devices.Count,
                DeviceDecommissionedCount = dp.Devices.Count(d => d.DecommissionedDate.HasValue),
                IsLinked = dp.AssignedUsersLinkedGroup != null || dp.DevicesLinkedGroup != null
            }).ToArray().Cast<ConfigDeviceProfileIndexModelItem>().ToList();

            if (DiscoApplication.MultiSiteMode)
            {
                foreach (var dp in m.DeviceProfiles)
                {
                    if (dp.Address.HasValue)
                    {
                        dp.AddressName = Database.DiscoConfiguration.OrganisationAddresses.GetAddress(dp.Address.Value)?.Name;
                    }
                }
            }

            return m;
        }
开发者ID:garysharp,项目名称:Disco,代码行数:29,代码来源:IndexModel.cs


示例11: RequiredFilePath

 private static string RequiredFilePath(DiscoDataContext Database)
 {
     if (Database.DiscoConfiguration.DataStoreLocation != null)
         return Path.Combine(Database.DiscoConfiguration.DataStoreLocation, "_ThumbnailUpdateRequired.txt");
     else
         return null;
 }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:ThumbnailUpdateTask.cs


示例12: ToUserHeldDeviceModel

 public UserHeldDeviceModel ToUserHeldDeviceModel(DiscoDataContext Database)
 {
     var uhdm = new UserHeldDeviceModel()
         {
             UserId = this.UserId,
             UserDisplayName = this.UserDisplayName,
             ReadyForReturn = this.ReadyForReturn,
             WaitingForUserAction = this.WaitingForUserAction,
             DeviceProfileId = this.DeviceProfileId,
             DeviceAddress = (this.DeviceAddressId.HasValue ? Database.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value)?.ShortName : string.Empty)
         };
     var n = DateTime.Now;
     if (!this.ReadyForReturn && this.EstimatedReturnTime.HasValue && this.EstimatedReturnTime.Value > n)
     {
         uhdm.EstimatedReturnTime = this.EstimatedReturnTime.FromNow();
     }
     if (this.ReadyForReturn)
     {
         uhdm.ReadyForReturnSince = this.ReadyForReturnSince.FromNow();
         uhdm.IsAlert = (this.ReadyForReturnSince.Value < DateTime.Now.AddDays(-3));
     }
     if (this.WaitingForUserAction)
     {
         uhdm.WaitingForUserActionSince = this.WaitingForUserActionSince.FromNow();
         uhdm.IsAlert = (this.WaitingForUserActionSince.Value < n.AddDays(-6));
     }
     return uhdm;
 }
开发者ID:garysharp,项目名称:Disco,代码行数:28,代码来源:HeldJobDeviceModel.cs


示例13: Query

        public List<Models.LogLiveEvent> Query(DiscoDataContext Database)
        {
            List<Models.LogLiveEvent> results = new List<LogLiveEvent>();

            // Validate Options
            this.Validate();

            var relevantLogFiles = RelevantLogFiles(Database);
            relevantLogFiles.Reverse();
            foreach (var logFile in relevantLogFiles)
            {
                SqlCeConnectionStringBuilder sqlCeCSB = new SqlCeConnectionStringBuilder();
                sqlCeCSB.DataSource = logFile.Item1;

                var logModules = LogContext.LogModules;

                using (var context = new LogPersistContext(sqlCeCSB.ToString()))
                {
                    var query = this.BuildQuery(context, logFile.Item2, results.Count);
                    IEnumerable<LogEvent> queryResults = query; // Run the Query
                    results.AddRange(queryResults.Select(le => Models.LogLiveEvent.Create(logModules[le.ModuleId], logModules[le.ModuleId].EventTypes[le.EventTypeId], le.Timestamp, le.Arguments)));
                }
                if (this.Take.HasValue && this.Take.Value < results.Count)
                    break;
            }
            return results;
        }
开发者ID:garysharp,项目名称:Disco,代码行数:27,代码来源:ReadLogContext.cs


示例14: ExecuteTask

        protected override void ExecuteTask()
        {
            var forestServers = DiscoverForestServers();
            ADDiscoverForestServers.ForestServers = forestServers;

            // Restrict Searching Entire Forest if to many servers
            using (DiscoDataContext Database = new DiscoDataContext())
            {
                var searchEntireForest = Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers;

                // Check explicitly configured: No
                if (!searchEntireForest.HasValue || searchEntireForest.Value)
                {
                    // Not Configured, or explicitly configured: Yes
                    if (forestServers.Count > ActiveDirectory.MaxForestServerSearch)
                    {
                        // Update Database
                        Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers = false;
                    }
                    else
                    {
                        // Default
                        Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers = true;
                    }

                    Database.SaveChanges();
                }
            }
        }
开发者ID:garysharp,项目名称:Disco,代码行数:29,代码来源:ADDiscoverForestServers.cs


示例15: ComputerNameRender

        public static string ComputerNameRender(this Device device, DiscoDataContext Database, ADDomain Domain)
        {
            if (Domain == null)
                throw new ArgumentNullException("Domain");

            var deviceProfile = device.DeviceProfile;
            Expression computerNameTemplateExpression = null;
            computerNameTemplateExpression = ExpressionCache.GetValue(DeviceProfileExtensions.ComputerNameExpressionCacheModule, deviceProfile.Id.ToString(), () =>
            {
                // Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
                //return Expressions.Expression.TokenizeSingleDynamic(null, deviceProfile.Configuration(context).ComputerNameTemplate, 0);
                return Expression.TokenizeSingleDynamic(null, deviceProfile.ComputerNameTemplate, 0);
            });
            var evaluatorVariables = Expression.StandardVariables(null, Database, UserService.CurrentUser, DateTime.Now, null);
            string rendered;
            try
            {
                rendered = computerNameTemplateExpression.EvaluateFirst<string>(device, evaluatorVariables);
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().AddObject(deviceProfile.ComputerNameTemplate, "ComputerNameTemplate").Submit();
                throw new InvalidOperationException(string.Format("An error occurred rendering the computer name: [{0}] {1}", ex.GetType().Name, ex.Message), ex.InnerException);
            }
            if (rendered == null || rendered.Length > 24)
            {
                throw new InvalidOperationException("The rendered computer name would be invalid or longer than 24 characters");
            }

            return string.Format(@"{0}\{1}", Domain.NetBiosName, rendered);
        }
开发者ID:garysharp,项目名称:Disco,代码行数:31,代码来源:DeviceExtensions.cs


示例16: DefaultNewDeviceBatch

 public static DeviceBatch DefaultNewDeviceBatch(DiscoDataContext Database)
 {
     return new DeviceBatch()
     {
         PurchaseDate = DateTime.Today
     };
 }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:DeviceBatches.cs


示例17: AvailableDocumentTemplates

        public static List<DocumentTemplate> AvailableDocumentTemplates(this Device d, DiscoDataContext Database, User User, DateTime TimeStamp)
        {
            List<DocumentTemplate> ats = Database.DocumentTemplates
                .Where(at => !at.IsHidden && at.Scope == DocumentTemplate.DocumentTemplateScopes.Device).ToList();

            return ats.Where(at => at.FilterExpressionMatches(d, Database, User, TimeStamp, DocumentState.DefaultState())).ToList();
        }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:DeviceExtensions.cs


示例18: RequiredFilePath

 private static string RequiredFilePath(DiscoDataContext Database)
 {
     if (Database.DiscoConfiguration.DataStoreLocation != null)
         return System.IO.Path.Combine(Database.DiscoConfiguration.DataStoreLocation, "_LogMacAddressImportingRequired.txt");
     else
         return null;
 }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:LogMacAddressImportingTask.cs


示例19: UpdateJobQueue

        public static JobQueueToken UpdateJobQueue(DiscoDataContext Database, JobQueue JobQueue)
        {
            // Verify
            if (string.IsNullOrWhiteSpace(JobQueue.Name))
                throw new ArgumentException("The Job Queue Name is required");

            // Name Unique
            if (_cache.GetQueues().Any(q => q.JobQueue.Id != JobQueue.Id && q.JobQueue.Name == JobQueue.Name))
                throw new ArgumentException("Another Job Queue already exists with that name", "JobQueue");

            // Sanitize Subject Ids
            if (string.IsNullOrWhiteSpace(JobQueue.SubjectIds))
            {
                JobQueue.SubjectIds = null;
            }
            else
            {
                var subjectIds = JobQueue.SubjectIds.Split(',');
                foreach (var subjectId in subjectIds)
                {
                    UserService.GetUser(subjectId, Database);
                }
                JobQueue.SubjectIds = string.Join(",", Database.Users.Where(u => subjectIds.Contains(u.UserId)).Select(u => u.UserId));
            }

            Database.SaveChanges();

            return _cache.UpdateQueue(JobQueue);
        }
开发者ID:garysharp,项目名称:Disco,代码行数:29,代码来源:JobQueueService.cs


示例20: UpdateModel

 public void UpdateModel(DiscoDataContext Database)
 {
     if (this.JobTypes == null)
         JobTypes = Database.JobTypes.ToList();
     if (this.JobSubTypes == null)
         JobSubTypes = Database.JobSubTypes.ToList();
 }
开发者ID:garysharp,项目名称:Disco,代码行数:7,代码来源:CreateModel.cs



注:本文中的Disco.Data.Repository.DiscoDataContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Discord.Channel类代码示例发布时间:2022-05-24
下一篇:
C# DirectShowLib.AMMediaType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap