Пример #1
0
 private static JobTableModel CloneEmptyJobTableModel(JobTableModel Model)
 {
     return new JobTableModel()
     {
         ShowId = Model.ShowId,
         ShowDeviceAddress = Model.ShowDeviceAddress,
         ShowDates = Model.ShowDates,
         ShowType = Model.ShowType,
         ShowDevice = Model.ShowDevice,
         ShowUser = Model.ShowUser,
         ShowTechnician = Model.ShowTechnician,
         ShowLocation = Model.ShowLocation,
         ShowStatus = Model.ShowStatus,
         ShowLastActivityDate = Model.ShowLastActivityDate,
         IsSmallTable = Model.IsSmallTable,
         HideClosedJobs = Model.HideClosedJobs,
         EnablePaging = Model.EnablePaging,
         EnableFilter = Model.EnableFilter
     };
 }
Пример #2
0
        public static JobTableModel SearchJobsTable(DiscoDataContext Database, string Term, int? LimitCount = ActiveDirectory.DefaultSearchResultLimit, bool IncludeJobStatus = true, bool SearchDetails = false)
        {
            int termInt = default(int);

            IQueryable<Job> query = default(IQueryable<Job>);

            string userIdTerm = Term.Contains('\\') ? Term : ActiveDirectory.ParseDomainAccountId(Term);

            if (int.TryParse(Term, out termInt))
            {
                // Term is a Number (int)
                if (SearchDetails)
                {
                    query = BuildJobTableModel(Database).Where(j =>
                        j.Id == termInt ||
                        j.DeviceHeldLocation.Contains(Term) ||
                        j.Device.SerialNumber.Contains(Term) ||
                        j.Device.AssetNumber.Contains(Term) ||
                        j.User.UserId == userIdTerm ||
                        j.User.Surname.Contains(Term) ||
                        j.User.GivenName.Contains(Term) ||
                        j.User.DisplayName.Contains(Term) ||
                        j.JobLogs.Any(jl => jl.Comments.Contains(Term)) ||
                        j.JobAttachments.Any(ja => ja.Comments.Contains(Term)));
                }
                else
                {
                    query = BuildJobTableModel(Database).Where(j =>
                        j.Id == termInt ||
                        j.DeviceHeldLocation.Contains(Term) ||
                        j.Device.SerialNumber.Contains(Term) ||
                        j.Device.AssetNumber.Contains(Term) ||
                        j.User.UserId == userIdTerm ||
                        j.User.Surname.Contains(Term) ||
                        j.User.GivenName.Contains(Term) ||
                        j.User.DisplayName.Contains(Term));
                }
            }
            else
            {
                if (SearchDetails)
                {
                    query = BuildJobTableModel(Database).Where(j =>
                        j.DeviceHeldLocation.Contains(Term) ||
                        j.Device.SerialNumber.Contains(Term) ||
                        j.Device.AssetNumber.Contains(Term) ||
                        j.User.UserId == userIdTerm ||
                        j.User.Surname.Contains(Term) ||
                        j.User.GivenName.Contains(Term) ||
                        j.User.DisplayName.Contains(Term) ||
                        j.JobLogs.Any(jl => jl.Comments.Contains(Term)) ||
                        j.JobAttachments.Any(ja => ja.Comments.Contains(Term)));
                }
                else
                {
                    query = BuildJobTableModel(Database).Where(j =>
                        j.DeviceHeldLocation.Contains(Term) ||
                        j.Device.SerialNumber.Contains(Term) ||
                        j.Device.AssetNumber.Contains(Term) ||
                        j.User.UserId == userIdTerm ||
                        j.User.Surname.Contains(Term) ||
                        j.User.GivenName.Contains(Term) ||
                        j.User.DisplayName.Contains(Term));
                }
            }

            if (LimitCount.HasValue)
                query = query.Take(LimitCount.Value);

            JobTableModel model = new JobTableModel() { ShowStatus = IncludeJobStatus }
                .Fill(Database, query, true)
                .Score(Term);

            return model;
        }