Ejemplo n.º 1
0
        public async Task <IEnumerable <string> > GetPersonerIpregWithNin()
        {
            var client = new TestdataPersonClient(Apikey, Environments.Test01);
            var filter = new PersonSearchFilter
            {
                Registreringskode   = { Død = false },
                Registertilhørighet = { EriPREG = true }
            };
            var result = await client.GetListOfNins(filter, 100);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <RegisterPersonModel> GetPersonpregWithName()
        {
            var client = new TestdataPersonClient(Apikey, Environments.Test01);
            var filter = new PersonSearchFilter
            {
                Registreringskode   = { Død = false },
                Registertilhørighet = { EriPREG = true }
            };
            var result = await client.GetPerson(
                filter);

            return(result);
        }
Ejemplo n.º 3
0
        public ServicePersonObject GetPersons(string _parentId,
            string christianName,
            string surname,
            string fatherChristianName,
            string fatherSurname,
            string motherChristianName,
            string motherSurname,
            string location,
            string county,
            string lowerDate,
            string upperDate,
            string filterTreeResults,
            string filterIncludeBirths,
            string filterIncludeDeaths,
            string filterIncludeSources,
            string filterSource,
            string spouse,
            string parishFilter,

            string page_number,
            string page_size,
            string sort_col)
        {
            string retVal = "";

            Guid parentId = _parentId.ToGuid();

            var spo = new ServicePersonObject();

            var iModel = new PersonSearch(new Security(new WebUser()));

            try
            {

                if (parentId == Guid.Empty)
                {

                    var searchParams = new PersonSearchFilter
                        {
                            CName = christianName,
                            Surname = surname,
                            FatherChristianName = fatherChristianName,
                            FatherSurname = fatherSurname,
                            MotherChristianName = motherChristianName,
                            MotherSurname = motherSurname,
                            Location = location,
                            LowerDate = lowerDate.ToInt32(),
                            UpperDate = upperDate.ToInt32(),
                            IsIncludeBirths = filterIncludeBirths.ToBool(),
                            IsIncludeDeaths = filterIncludeDeaths.ToBool(),
                            IsIncludeSources = filterIncludeSources.ToBool(),
                            SpouseChristianName = spouse,
                            SourceString = filterSource,
                            ParishString = parishFilter
                        };

                    spo = iModel.Search(PersonSearchTypes.Simple, searchParams,
                                  new DataShaping
                                      {
                                          RecordStart = page_number.ToInt32(),
                                          RecordPageSize = page_size.ToInt32()
                                      }, new PersonSearchValidator(searchParams));
                }
                else
                {

                    spo = iModel.Search(PersonSearchTypes.Duplicates, new PersonSearchFilter {ParentId = parentId},
                                        new DataShaping
                                        {
                                            RecordStart = 0,
                                            RecordPageSize=25
                                        });

                }

            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }
            finally
            {
                if (retVal != "") retVal += Environment.NewLine;

                spo.ErrorStatus = retVal;
            }

            return spo;
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public IList<ServicePerson> GetByIdList(PersonSearchFilter personIds)
        {
            using (var context = new GeneralModelContainer())
            {
                var results = context.Persons.Where(m => personIds.Ids.Contains(m.Person_id)).ToList();

                return results.Select(p => new ServicePerson()
                {
                    PersonId = p.Person_id,
                    ChristianName = p.ChristianName,
                    Surname = p.Surname,
                    BirthLocation = p.BirthLocation,
                    Birth = p.BirthDateStr,
                    Baptism = p.BaptismDateStr,
                    Death = p.DeathDateStr,
                    DeathLocation = p.DeathLocation,
                    FatherChristianName = p.FatherChristianName,
                    FatherSurname = p.FatherSurname,
                    MotherChristianName = p.MotherChristianName,
                    MotherSurname = p.MotherSurname,
                    SourceDescription = p.Source,
                    BirthYear = (p.BirthInt == 0) ? p.BapInt : p.BirthInt,
                    DeathYear = p.DeathInt,

                    Occupation = p.Occupation,
                    SpouseChristianName = p.SpouseName,
                    SpouseSurname = p.SpouseSurname,
                    Spouse = p.SpouseName + " " + p.SpouseSurname,
                    FatherOccupation = p.FatherOccupation,
                    Events = p.TotalEvents.ToString(CultureInfo.InvariantCulture),
                    UniqueReference = p.UniqueRef.GetValueOrDefault().ToString(),

                    OthersideChristianName = p.OthersideChristianName,
                    OthersideSurname = p.OthersideSurname,
                    OthersideRelationship = p.OthersideRelationship,
                    ReferenceDate = p.ReferenceDateStr,
                    ReferenceLocation = p.ReferenceLocation,
                    ReferenceYear = p.ReferenceDateInt

                }).ToList();
            }
        }
Ejemplo n.º 6
0
        public List<ServicePerson> GetByFilter(PersonSearchFilter personSearchFilter)
        {
            using (var context = new GeneralModelContainer())
            {
                Guid parishId = personSearchFilter.ParishString.ToGuid();

                if (parishId != Guid.Empty)
                {
                    var sourceBll = new SourceDal();

                    sourceBll.GetParishSourceRecords(parishId)
                        .ForEach(p => personSearchFilter.SourceString += "," + p.SourceId.ToString());

                    personSearchFilter.SourceString = personSearchFilter.SourceString.Substring(1);
                }

                var inMemoryLocFilter = "";
                if (personSearchFilter.Location.Contains(','))
                {
                    inMemoryLocFilter = personSearchFilter.Location;
                    personSearchFilter.Location = "";
                }

                var temp = context.PersonsFiltered2(personSearchFilter.CName, personSearchFilter.Surname,
                    personSearchFilter.FatherChristianName, personSearchFilter.FatherSurname,
                    personSearchFilter.MotherChristianName, personSearchFilter.MotherSurname,
                    personSearchFilter.SourceString, personSearchFilter.Location, personSearchFilter.LowerDate,
                    personSearchFilter.UpperDate, personSearchFilter.County, personSearchFilter.SpouseChristianName,
                    personSearchFilter.OthersideChristianName, personSearchFilter.OthersideSurname,
                    personSearchFilter.OthersideRelationship, personSearchFilter.IsIncludeSources)
                    .Select(p => new ServicePerson
                    {
                        PersonId = p.Person_id,
                        ChristianName = p.ChristianName,
                        Surname = p.Surname,
                        BirthLocation = p.BirthLocation,
                        Birth = p.BirthDateStr,
                        Baptism = p.BaptismDateStr,
                        Death = p.DeathDateStr,
                        DeathLocation = p.DeathLocation,
                        FatherChristianName = p.FatherChristianName,
                        FatherSurname = p.FatherSurname,
                        MotherChristianName = p.MotherChristianName,
                        MotherSurname = p.MotherSurname,
                        SourceDescription = p.Source,
                        BirthYear = (p.BirthInt == 0) ? p.BapInt : p.BirthInt,
                        DeathYear = p.DeathInt,
                        LinkedTrees = p.tree_links,
                        Occupation = p.Occupation,
                        SpouseChristianName = p.SpouseName,
                        SpouseSurname = p.SpouseSurname,
                        Spouse = p.SpouseName + " " + p.SpouseSurname,
                        FatherOccupation = p.FatherOccupation,
                        Events = p.TotalEvents.ToString(CultureInfo.InvariantCulture),
                        UniqueReference = p.UniqueRef.GetValueOrDefault().ToString(),
                        SourceDateInt = p.SourceDateInt,
                        SourceDateStr = p.SourceDateStr,
                        SourceParishName = p.SourceParishName,
                        SourceRef = p.SourceRef,
                        SourceId = p.RefSourceId,
                        OthersideChristianName = p.OthersideChristianName,
                        OthersideSurname = p.OthersideSurname,
                        OthersideRelationship = p.OthersideRelationship,
                        ReferenceDate = p.ReferenceDateStr,
                        ReferenceLocation = p.ReferenceLocation,
                        ReferenceYear = p.ReferenceDateInt,
                        MarriageId = p.marriageId.GetValueOrDefault().ToString()
                    }).ToList();

                if (inMemoryLocFilter.Length > 0)
                {
                    //filter by multiple locations in memory cause the sql is too much a pain
                    temp =
                        temp.Where(
                            servicePerson =>
                                inMemoryLocFilter.Split(',')
                                    .ToList()
                                    .Any(
                                        l =>
                                            servicePerson.BirthLocation.LazyContains(l) ||
                                            servicePerson.DeathLocation.LazyContains(l))).ToList();
                }

                if (personSearchFilter.IsIncludeDeaths) temp = temp.Where(p => p.DeathYear > 0).ToList();

                if (personSearchFilter.IsIncludeBirths) temp = temp.Where(p => p.BirthYear > 0).ToList();

                return temp;
            }
        }
        public IHttpActionResult GetPersons(string ids)
        {
            string retVal = "";

            var spo = new ServicePersonObject();

            var personSearch = new PersonSearch(new Security(new WebUser()));

            try
            {

                var searchParams = new PersonSearchFilter
                {
                    Ids = ids.ParseToGuidList()

                };

                spo = personSearch.Search(PersonSearchTypes.IdList, searchParams,
                                new DataShaping
                                {
                                    RecordStart = 0,
                                    RecordPageSize = 25
                                }, new PersonSearchValidator(searchParams));

            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }
            finally
            {
                if (retVal != "") retVal += Environment.NewLine;

                spo.ErrorStatus = retVal;
            }

            if (retVal != "")
            {
                return Content(HttpStatusCode.BadRequest, retVal);
            }

            return Ok(spo);
        }
        public IHttpActionResult GetFilteredPersons(string parentId,
            string christianName,
            string surname,
            string fatherChristianName,
            string fatherSurname,
            string motherChristianName,
            string motherSurname,
            string location,
            string county,
            string lowerDate,
            string upperDate,
            string filterTreeResults,
            string filterIncludeBirths,
            string filterIncludeDeaths,
            string filterIncludeSources,
            string sourceFilter,
            string spouse,
            string parishFilter,

            string pno,
            string psize,
            string sortcol)
        {
            string retVal = "";

            var spo = new ServicePersonObject();

            var personSearch = new PersonSearch(new Security(new WebUser()));

            try
            {

                if (parentId.ToGuid() == Guid.Empty)
                {

                    var searchParams = new PersonSearchFilter
                    {
                        CName = christianName ?? "",
                        Surname = surname ?? "",
                        FatherChristianName = fatherChristianName ?? "",
                        FatherSurname = fatherSurname ?? "",
                        MotherChristianName = motherChristianName ?? "",
                        MotherSurname = motherSurname ?? "",
                        Location = location ?? "",
                        LowerDate = lowerDate.ToInt32(),
                        UpperDate = upperDate.ToInt32(),
                        IsIncludeBirths = filterIncludeBirths.ToBool(),
                        IsIncludeDeaths = filterIncludeDeaths.ToBool(),
                        IsIncludeSources = filterIncludeSources.ToBool(),
                        SpouseChristianName = spouse ?? "",
                        SourceString = sourceFilter ?? "",
                        ParishString = parishFilter ?? ""
                    };

                    spo = personSearch.Search(PersonSearchTypes.Simple, searchParams,
                                  new DataShaping
                                  {
                                      RecordStart = pno.ToInt32(),
                                      RecordPageSize = psize.ToInt32()
                                  }, new PersonSearchValidator(searchParams));
                }
                else
                {

                    spo = personSearch.Search(PersonSearchTypes.Duplicates, new PersonSearchFilter { ParentId = parentId.ToGuid() },
                                        new DataShaping
                                        {
                                            RecordStart = 0,
                                            RecordPageSize = 25
                                        });

                }

            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }
            finally
            {
                if (retVal != "") retVal += Environment.NewLine;

                spo.ErrorStatus = retVal;
            }

            if (retVal != "")
            {
                return Content(HttpStatusCode.BadRequest, retVal);
            }

            return Ok(spo);
        }
 public PersonSearchValidator(PersonSearchFilter personSearchFilter)
 {
     _sp = personSearchFilter;
 }