public bool Process(CensusDate censusDate, bool censusDone, bool checkCensus) { bool result = false; var facts = new List <Fact>(); CensusDate = censusDate; if (IsValidFamily()) // valid family is one where any member is alive on census { if (censusDate == CensusDate.UKCENSUS1841) { Console.Write("break"); } if (IsValidIndividual(Wife, censusDone, true, checkCensus)) { result = true; facts.AddRange(Wife.PersonalFacts); } else { Wife = null; } // overwrite bestLocation by husbands as most commonly the family // end up at husbands location after marriage if (IsValidIndividual(Husband, censusDone, true, checkCensus)) { result = true; facts.AddRange(Husband.PersonalFacts); } else { Husband = null; } // update bestLocation by marriage date as Husband and Wife // locations are often birth locations var marriage = GetPreferredFact(Fact.MARRIAGE); if (marriage != null) { facts.Add(marriage); } var censusChildren = new List <CensusIndividual>(); // sort children oldest first Children.Sort(new CensusAgeComparer()); foreach (var child in Children) { // set location to childs birth location // this will end up setting birth location of last child // as long as the location is at least Parish level if (IsValidIndividual(child, censusDone, false, checkCensus)) { result = true; censusChildren.Add(child); facts.AddRange(child.PersonalFacts); } } Children = censusChildren; BestLocation = FactLocation.BestLocation(facts, censusDate); } return(result); }
public CensusFamily(Family f, CensusDate censusDate) : base(f) { BaseFamily = f; CensusDate = censusDate; BestLocation = null; int position = 1; if (f.Wife != null) { Wife = new CensusIndividual(position++, f.Wife, this, CensusIndividual.WIFE); } if (f.Husband != null) { Husband = new CensusIndividual(position++, f.Husband, this, CensusIndividual.HUSBAND); } Children = new List <CensusIndividual>(); foreach (Individual child in f.Children) { CensusIndividual toAdd = new CensusIndividual(position++, child, this, CensusIndividual.CHILD); Children.Add(toAdd); } FamilyChildren = new List <CensusIndividual>(Children); // Family children is all children alive or dead at census date }
private void CheckResidenceCensusDate() { if (FactDate.IsKnown && CensusDate.IsCensusYear(FactDate, true) && !CensusDate.IsCensusYear(FactDate, false)) { // residence isn't a normal census year but it is a census year if tolerate is on if (CensusDate.IsCensusCountry(FactDate, Location) || !Location.IsKnownCountry) { // this.FactErrorNumber = (int) FamilyTree.Dataerror.RESIDENCE_CENSUS_DATE; this.FactErrorLevel = Fact.FactError.WARNINGALLOW; this.FactErrorMessage = "Warning : Residence date " + FactDate + " is in a census year but doesn't overlap census date."; if (!Properties.GeneralSettings.Default.TolerateInaccurateCensusDate) { this.FactErrorMessage += " This would be accepted as a census fact with Tolerate slightly inaccurate census dates option."; } } } }
private void CheckCensusDate(string tag) { FactDate yearAdjusted = FactDate; // check if census fails to overlaps a census date if ((tag == "Census 1841" && !FactDate.Overlaps(CensusDate.UKCENSUS1841)) || (tag == "Census 1851" && !FactDate.Overlaps(CensusDate.UKCENSUS1851)) || (tag == "Census 1861" && !FactDate.Overlaps(CensusDate.UKCENSUS1861)) || (tag == "Census 1871" && !FactDate.Overlaps(CensusDate.UKCENSUS1871)) || (tag == "Census 1881" && !FactDate.Overlaps(CensusDate.UKCENSUS1881)) || (tag == "Census 1891" && !FactDate.Overlaps(CensusDate.UKCENSUS1891)) || (tag == "Census 1901" && !FactDate.Overlaps(CensusDate.UKCENSUS1901)) || (tag == "Census 1911" && !FactDate.Overlaps(CensusDate.UKCENSUS1911)) || (tag == "Census 1939" && !FactDate.Overlaps(CensusDate.UKCENSUS1939)) || (tag == "Census" && !CensusDate.IsUKCensusYear(FactDate, false)) || ((tag == "Lost Cousins" || tag == "LostCousins") && !CensusDate.IsLostCousinsCensusYear(FactDate, false)) && FactDate.DateString.Length >= 4) { // if not a census overlay then set date to year and try that instead string year = FactDate.DateString.Substring(FactDate.DateString.Length - 4); int result = 0; if (Int32.TryParse(year, out result)) { yearAdjusted = new FactDate(year); if (Properties.GeneralSettings.Default.TolerateInaccurateCensusDate) { // this.FactErrorNumber = (int)FamilyTree.Dataerror.RESIDENCE_CENSUS_DATE; this.FactErrorMessage = "Warning: Inaccurate Census date '" + FactDate + "' treated as '" + yearAdjusted + "'"; this.FactErrorLevel = Fact.FactError.WARNINGALLOW; } else { // this.FactErrorNumber = (int)FamilyTree.Dataerror.RESIDENCE_CENSUS_DATE; this.FactErrorLevel = Fact.FactError.WARNINGIGNORE; this.FactErrorMessage = "Inaccurate Census date '" + FactDate + "' fact ignored in strict mode. Check for incorrect date entered or try Tolerate slightly inaccurate census date option."; } } } if ((tag == "Census 1841" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1841)) || (tag == "Census 1851" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1851)) || (tag == "Census 1861" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1861)) || (tag == "Census 1871" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1871)) || (tag == "Census 1881" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1881)) || (tag == "Census 1891" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1891)) || (tag == "Census 1901" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1901)) || (tag == "Census 1911" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1911)) || (tag == "Census 1939" && !yearAdjusted.Overlaps(CensusDate.UKCENSUS1939))) { this.FactErrorMessage = "UK Census fact error date '" + FactDate + "' doesn't match '" + tag + "' tag. Check for incorrect date entered."; this.FactErrorLevel = FactError.ERROR; // this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE; return; } if (tag == "Census" || tag == "LostCousins" || tag == "Lost Cousins") { TimeSpan ts = FactDate.EndDate - FactDate.StartDate; if (ts.Days > 3650) { // this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE; this.FactErrorLevel = FactError.ERROR; this.FactErrorMessage = "Date covers more than one census."; return; } } if (tag == "Census") { if (!CensusDate.IsCensusYear(yearAdjusted, false)) { // this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE; this.FactErrorMessage = "Census fact error date '" + FactDate + "' isn't a supported census date. Check for incorrect date entered or try Tolerate slightly inaccurate census date option."; this.FactErrorLevel = FactError.ERROR; return; } if (Properties.GeneralSettings.Default.TolerateInaccurateCensusDate && yearAdjusted.IsKnown && !CensusDate.IsCensusYear(yearAdjusted, true)) { // this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE; this.FactErrorMessage = "Warning : Census fact error date '" + FactDate + "' overlaps census date but is vague. Check for incorrect date entered."; this.FactErrorLevel = FactError.WARNINGALLOW; } if (!FactDate.Equals(yearAdjusted)) { FactDate = yearAdjusted; } } if (tag == "Lost Cousins" || tag == "LostCousins") { if (Properties.GeneralSettings.Default.TolerateInaccurateCensusDate && yearAdjusted.IsKnown && !CensusDate.IsLostCousinsCensusYear(yearAdjusted, true)) { // this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE; this.FactErrorMessage = "Lost Cousins fact error date '" + FactDate + "' overlaps Lost Cousins census year but is vague. Check for incorrect date entered."; this.FactErrorLevel = Fact.FactError.WARNINGALLOW; } if (!CensusDate.IsLostCousinsCensusYear(yearAdjusted, false)) { // this.FactErrorNumber = (int)FamilyTree.Dataerror.CENSUS_COVERAGE; this.FactErrorMessage = "Lost Cousins fact error date '" + FactDate + "' isn't a supported Lost Cousins census year. Check for incorrect date entered or try Tolerate slightly inaccurate census date option."; this.FactErrorLevel = Fact.FactError.ERROR; } if (!FactDate.Equals(yearAdjusted)) { FactDate = yearAdjusted; } } }