public ServiceSourceTypeObject Search(SourceTypeSearchFilter sourceTypeSearchFilter,DataShaping shaper, SourceTypeSearchValidator validator =null) { if (!_security.IsvalidSelect()) return new ServiceSourceTypeObject(); if (validator != null && !validator.ValidEntry()) return new ServiceSourceTypeObject(); return _sourceTypesDal.GetSourceTypeByFilter(sourceTypeSearchFilter).ToServiceSourceTypeObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart); }
public List<ServiceSource> FillSourceTableByFilter(SourceSearchFilter ssf, DataShaping dataShaping) { List<ServiceSource> result; #region booleans bool isCopyHoldLocal; bool isCopyHoldLocalAlt; if (ssf.CopyHeld == null) { isCopyHoldLocal = false; isCopyHoldLocalAlt = true; } else { isCopyHoldLocal = ssf.CopyHeld.Value; isCopyHoldLocalAlt = ssf.CopyHeld.Value; } bool isViewedLocal; bool isViewedLocalAlt; if (ssf.Viewed == null) { isViewedLocal = false; isViewedLocalAlt = true; } else { isViewedLocal = ssf.Viewed.Value; isViewedLocalAlt = ssf.Viewed.Value; } bool isThackrayLocalFound; bool isThackrayLocalFoundAlt; if (ssf.ThackrayFound == null) { isThackrayLocalFound = false; isThackrayLocalFoundAlt = true; } else { isThackrayLocalFound = ssf.ThackrayFound.Value; isThackrayLocalFoundAlt = ssf.ThackrayFound.Value; } #endregion ssf.SourceTypes.RemoveAll(p => p == 0); string listOfSourcesStr =ssf.SourceTypes.ParseToCSV(); int sourceL = ssf.LrStart; int sourceU = ssf.LrEnd; int sourceToL = ssf.UrStart; int sourceToU = ssf.UrEnd; using (var context = new GeneralModelContainer()) { if (listOfSourcesStr == "") { dataShaping.TotalRecords = context.Sources.Count( o => (o.IsCopyHeld == isCopyHoldLocal || o.IsCopyHeld == isCopyHoldLocalAlt) && (o.IsThackrayFound == isThackrayLocalFound || o.IsThackrayFound == isThackrayLocalFoundAlt) && o.SourceDescription.Contains(ssf.Description) && (o.IsViewed == isViewedLocal || o.IsViewed == isViewedLocalAlt) && o.OriginalLocation.Contains(ssf.OriginalLocation) && o.SourceDate >= sourceL && o.SourceDate <= sourceU && o.SourceDateTo >= sourceToL && o.SourceDateTo <= sourceToU && o.SourceRef.Contains(ssf.Ref)); result = context.Sources.Where( o => (o.IsCopyHeld == isCopyHoldLocal || o.IsCopyHeld == isCopyHoldLocalAlt) && (o.IsThackrayFound == isThackrayLocalFound || o.IsThackrayFound == isThackrayLocalFoundAlt) && o.SourceDescription.Contains(ssf.Description) && (o.IsViewed == isViewedLocal || o.IsViewed == isViewedLocalAlt) && o.OriginalLocation.Contains(ssf.OriginalLocation) && o.SourceDate >= sourceL && o.SourceDate <= sourceU && o.SourceDateTo >= sourceToL && o.SourceDateTo <= sourceToU && o.SourceMarriageCount >= ssf.MarriageCount && o.SourcePersonCount >= ssf.PersonCount && o.SourceRef.Contains(ssf.Ref)).Select(p => new ServiceSource { SourceDesc = p.SourceDescription, SourceId = p.SourceId, SourceRef = p.SourceRef, SourceYear = p.SourceDate, SourceYearTo = p.SourceDateTo, MarriageCount = p.SourceMarriageCount, PersonCount = p.SourcePersonCount }) .OrderBy(o => o.SourceId) .Skip(dataShaping.RecordStart*dataShaping.RecordPageSize) .Take(dataShaping.RecordPageSize) .ToList(); } else { result = context.GetSourcesBySourceTypes( ssf.Ref, sourceToU, sourceL, sourceToL, sourceU, 1, ssf.OriginalLocation, new DateTime(2050, 1, 1), new DateTime(1920, 1, 1), isThackrayLocalFound, isThackrayLocalFoundAlt, isViewedLocal, isViewedLocalAlt, isCopyHoldLocal, isCopyHoldLocalAlt, listOfSourcesStr, ssf.MarriageCount, ssf.PersonCount).Select(p => new ServiceSource { SourceDesc = p.SourceDescription, SourceId = p.SourceId, SourceRef = p.SourceRef, SourceYear = p.SourceDate.GetValueOrDefault(), SourceYearTo = p.SourceDateTo.GetValueOrDefault(), MarriageCount = p.SourceMarriageCount, PersonCount = p.SourcePersonCount }).ToList(); dataShaping.TotalRecords = result.Count(); result = result.Skip(dataShaping.RecordStart*dataShaping.RecordPageSize) .Take(dataShaping.RecordPageSize) .ToList(); } return ssf.FileCount.ToInt32() == 0 ? result.Where(o => o.FileCount == 0).ToList() : result.Where(o => o.FileCount >= ssf.FileCount.ToInt32()).ToList(); } }
public ServiceMarriageObject Search(MarriageFilterTypes filterMode, MarriageSearchFilter marriageSearchFilter, DataShaping shaping, IValidator validator = null) { var serviceMarriageObject = new ServiceMarriageObject(); if (!_security.IsvalidSelect()) serviceMarriageObject.ErrorStatus = "Invalid permission to select"; if (validator != null && !validator.ValidEntry()) serviceMarriageObject.ErrorStatus += " Validation failed: " + validator.GetErrors(); if (serviceMarriageObject.ErrorStatus.Length == 0) { if (shaping.Column.Contains("MarriageDate DESC")) { shaping.Column = "MarriageYear DESC"; } else if (shaping.Column.Contains("MarriageDate")) { shaping.Column = "MarriageYear"; } switch (filterMode) { case MarriageFilterTypes.Duplicates: serviceMarriageObject = marriageSearchFilter.ParentId != Guid.Empty ? _marriagesDll.GetDataByUniqueRef(marriageSearchFilter.ParentId) .ToServiceMarriageObject(shaping.Column, shaping.RecordPageSize, shaping.RecordStart) : new ServiceMarriageObject(); break; case MarriageFilterTypes.Standard: serviceMarriageObject = _marriagesDll.GetFilteredMarriages(marriageSearchFilter) .ToServiceMarriageObject(shaping.Column, shaping.RecordPageSize, shaping.RecordStart); break; case MarriageFilterTypes.IdList: serviceMarriageObject = _marriagesDll.GetByListId(marriageSearchFilter.Ids).ToServiceMarriageObject(shaping.Column, shaping.RecordPageSize, shaping.RecordStart); break; } } return serviceMarriageObject; }
public ServiceBatchObject Search(BatchSearchFilter batchSearchFilter, DataShaping shaper, BatchValidator validator = null) { if (!_security.IsvalidSelect()) return new ServiceBatchObject(); if (validator != null && !validator.ValidEntry()) return new ServiceBatchObject(); return _batchDal.GetBatchList(batchSearchFilter).ToServiceBatchObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart); }
public ServiceParishObject StandardSearch(ParishSearchFilter parishSearchFilter,DataShaping shaper, IValidator validator = null) { if (validator != null) _validator = validator; var serviceParishObject = new ServiceParishObject(); string retVal = ""; try { serviceParishObject.serviceParishs = _parishsDal.GetParishByFilter(parishSearchFilter, shaper); serviceParishObject.Batch = shaper.RecordStart; serviceParishObject.BatchLength = shaper.RecordPageSize; serviceParishObject.Total = shaper.TotalRecords; serviceParishObject.serviceParishs = serviceParishObject.serviceParishs; } catch (Exception ex1) { retVal = "Exception: " + ex1.Message; } finally { if (retVal != "") retVal += Environment.NewLine; serviceParishObject.ErrorStatus = retVal; } return serviceParishObject; }
public List<ServiceParish> GetParishByFilter(ParishSearchFilter parishSearchFilter, DataShaping dataShaping) { using (var context = new GeneralModelContainer()) { IQueryable<Parish> parishDataTable; if (parishSearchFilter.Name == "%" && parishSearchFilter.Deposited == "%" && parishSearchFilter.County == "%") { parishDataTable = context.Parishs; } else { parishSearchFilter.Name = parishSearchFilter.Name.Replace('%', ' ').Trim(); parishSearchFilter.Deposited = parishSearchFilter.Deposited.Replace('%', ' ').Trim(); parishSearchFilter.County = parishSearchFilter.County.Replace('%', ' ').Trim(); parishDataTable = context.Parishs.Where(o => o.ParishName.Contains(parishSearchFilter.Name) && o.ParishRegistersDeposited.Contains( parishSearchFilter.Deposited) && o.ParishCounty.Contains(parishSearchFilter.County)); } dataShaping.TotalRecords = parishDataTable.Count(); return parishDataTable.OrderBy(o => o.ParishName) .Skip(dataShaping.RecordStart*dataShaping.RecordPageSize) .Take(dataShaping.RecordPageSize) .Select(p => new ServiceParish { ParishCounty = p.ParishCounty, ParishDeposited = p.ParishRegistersDeposited, ParishId = p.ParishId, ParishEndYear = p.ParishEndYear, ParishStartYear = p.ParishStartYear, ParishName = p.ParishName, ParishParent = p.ParentParish, ParishNote = p.ParishNotes }).ToList(); } //serviceParishObject.serviceParishs.Skip(shaper.RecordStart * shaper.RecordPageSize).Take(shaper.RecordPageSize).ToList(); }
public ServicePersonObject Search(PersonSearchTypes filterMode, PersonSearchFilter personSearchFilter, DataShaping shaper, IValidator validator = null) { if (validator != null && !validator.ValidEntry()) throw new InvalidDataException(validator.GetErrors()); if (!_security.IsvalidSelect()) throw new SecurityException("Missing select permission"); IList<ServicePerson> tpServicePerson = new List<ServicePerson>(); switch (filterMode) { case PersonSearchTypes.Duplicates: if (personSearchFilter.ParentId != Guid.Empty) { tpServicePerson = _personDal.GetByDupeRef(personSearchFilter.ParentId); } break; case PersonSearchTypes.Simple: tpServicePerson = _personDal.GetByFilter(personSearchFilter).OrderBy(o => o.BirthYear).ToList(); break; case PersonSearchTypes.IdList: tpServicePerson = _personDal.GetByIdList(personSearchFilter).OrderBy(o => o.BirthYear).ToList(); break; } return tpServicePerson.ToServicePersonObject(shaper.Column, shaper.RecordPageSize,shaper.RecordStart); }
public ServiceSourceObject Search(SourceSearchTypes param, SourceSearchFilter sourceSearchFilter,DataShaping shaper, IValidator validator = null) { var sourcesDataTable = new ServiceSourceObject(); if(validator== null) validator = new Validator(); if (!_security.IsvalidSelect()) throw new SecurityException("Missing select permission"); if (!validator.ValidEntry()) throw new InvalidDataException(validator.GetErrors()); switch (param) { case SourceSearchTypes.Standard: sourcesDataTable = _sourceDal.FillSourceTableByFilter(sourceSearchFilter, shaper).ToServiceSourceObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart, shaper.TotalRecords); break; case SourceSearchTypes.Treesources: sourcesDataTable = _sourceDal.FillTreeSources(sourceSearchFilter).ToServiceSourceObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart); break; case SourceSearchTypes.Censussource: sourcesDataTable.CensusSources = _sourceDal.Get1841CensuSources(!sourceSearchFilter.Sources.IsNullOrBelowMinSize() ? sourceSearchFilter.Sources.First() : Guid.Empty); break; case SourceSearchTypes.SourceIds: sourcesDataTable = _sourceDal.FillSourceTableBySourceIds(!sourceSearchFilter.Sources.IsNullOrBelowMinSize() ? sourceSearchFilter.Sources : new List<Guid>()) .ToServiceSourceObject(shaper.Column, shaper.RecordPageSize, shaper.RecordStart); break; } return sourcesDataTable; }