public PersonDal() { _sourceDal = new SourceDal(); _sourceMappingsDal = new SourceMappingsDal(); _parishsBll = new ParishsDal(); _relationsDal = new RelationsDal(); }
public MarriagesDal() { Debug.WriteLine("hello"); _sourceDal = new SourceDal(); // this.Restart(); }
public static void MergeInto(this Person _person, Person newPerson, SourceDal sourceDal) { Guid dummyLocation = new Guid("a813a1ff-6093-4924-a7b2-c5d1af6ff699"); if (_person.SpouseSurname == "") _person.SpouseSurname = newPerson.SpouseSurname; if (_person.SpouseName == "") _person.SpouseName = newPerson.SpouseName; if ((_person.ReferenceLocationId == dummyLocation || _person.ReferenceLocationId == Guid.Empty) && newPerson.ReferenceLocationId != dummyLocation && newPerson.ReferenceLocationId != Guid.Empty) _person.ReferenceLocationId = newPerson.ReferenceLocationId; if ((_person.DeathLocationId == dummyLocation || _person.ReferenceLocationId == Guid.Empty) && newPerson.DeathLocationId != dummyLocation && newPerson.ReferenceLocationId != Guid.Empty) _person.DeathLocationId = newPerson.DeathLocationId; if ((_person.BirthLocationId == dummyLocation || _person.ReferenceLocationId == Guid.Empty) && newPerson.BirthLocationId != dummyLocation && newPerson.ReferenceLocationId != Guid.Empty) _person.BirthLocationId = newPerson.BirthLocationId; if (newPerson.ReferenceLocation != "" && _person.ReferenceLocation == "") _person.ReferenceLocation = newPerson.ReferenceLocation; if (newPerson.ReferenceDateStr != "" && _person.ReferenceDateStr == "") _person.ReferenceDateStr = newPerson.ReferenceDateStr; if (newPerson.Occupation != "" && _person.Occupation == "") { if (_person.Occupation.Trim() == "") { _person.Occupation = newPerson.Occupation; } else { _person.Occupation += " " + newPerson.Occupation; } } if (newPerson.Notes != "") { if (_person.Notes.Trim() == "") { _person.Notes = newPerson.Notes; } else { _person.Notes += " " + newPerson.Notes; } } if (newPerson.MotherSurname != "" && _person.MotherSurname == "") _person.MotherSurname = newPerson.MotherSurname; if (newPerson.MotherChristianName != "" && _person.MotherChristianName == "") _person.MotherChristianName = newPerson.MotherChristianName; if (newPerson.FatherChristianName != "" && _person.FatherChristianName == "") _person.FatherChristianName = newPerson.FatherChristianName; if (newPerson.FatherOccupation != "" && _person.FatherOccupation == "") _person.FatherOccupation = newPerson.FatherOccupation; if (newPerson.DeathCounty != "" && _person.DeathCounty == "") _person.DeathCounty = newPerson.DeathCounty; if (newPerson.DeathDateStr != "" && _person.DeathDateStr == "") _person.DeathDateStr = newPerson.DeathDateStr; if (newPerson.ReferenceDateInt > 0 && _person.ReferenceDateInt == 0) _person.ReferenceDateInt = newPerson.ReferenceDateInt; if (newPerson.DeathInt > 0 && _person.DeathInt == 0) _person.DeathInt = newPerson.DeathInt; if (newPerson.BirthInt > 0 && _person.BirthInt == 0) _person.BirthInt = newPerson.BirthInt; if (newPerson.BapInt > 0 && _person.BapInt == 0) _person.BapInt = newPerson.BapInt; if (newPerson.DeathLocation != "" && _person.DeathLocation == "") _person.DeathLocation = newPerson.DeathLocation; if (newPerson.BirthCounty != "" && _person.BirthCounty == "") _person.BirthCounty = newPerson.BirthCounty; if (newPerson.BirthDateStr != "" && _person.BirthDateStr == "") _person.BirthDateStr = newPerson.BirthDateStr; if (newPerson.BirthLocation != "" && _person.BirthLocation == "") _person.BirthLocation = newPerson.BirthLocation; if (newPerson.BaptismDateStr != "" && _person.BaptismDateStr == "") _person.BaptismDateStr = newPerson.BaptismDateStr; _person.IsMale = newPerson.IsMale; string source = _person.Source + Environment.NewLine + sourceDal.MakeSourceString(newPerson.Person_id); // if(source.Length >49) _person.Source = "Multiple sources"; // else // _person.Source = source; int estBYear = 0; int estDYear =0; bool isEstBYear =false; bool isEstDYear = false; DateTools.CalcEstDates(_person.BirthInt, _person.BapInt, _person.DeathInt, out estBYear, out estDYear, out isEstBYear, out isEstDYear, _person.FatherChristianName, _person.MotherChristianName); _person.EstBirthYearInt = estBYear; _person.EstDeathYearInt = estDYear; _person.IsEstBirth = isEstBYear; _person.IsEstDeath = isEstDYear; }
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; } }