示例#1
0
        private void AddFacts(XmlNode node, string factType)
        {
            XmlNodeList list          = node.SelectNodes(factType);
            bool        preferredFact = true;

            foreach (XmlNode n in list)
            {
                Fact f = new Fact(n, this, preferredFact);
                if (f.FactType != Fact.CENSUS)
                {
                    Facts.Add(f);
                    if (!preferredFacts.ContainsKey(f.FactType))
                    {
                        preferredFacts.Add(f.FactType, f);
                    }
                }
                else
                {
                    // Handle a census fact on a family.
                    if (Properties.GeneralSettings.Default.OnlyCensusParents)
                    {
                        if (Husband != null && Husband.IsAlive(f.FactDate))
                        {
                            Husband.AddFact(f);
                        }
                        if (Wife != null && Wife.IsAlive(f.FactDate))
                        {
                            Wife.AddFact(f);
                        }
                    }
                    else
                    {  // all members of the family who are alive get the census fact
                        foreach (Individual person in Members)
                        {
                            if (person.IsAlive(f.FactDate))
                            {
                                person.AddFact(f);
                            }
                        }
                    }
                }
                preferredFact = false;
            }
        }
示例#2
0
        void AddFacts(XmlNode node, string factType, IProgress <string> outputText)
        {
            XmlNodeList list          = node.SelectNodes(factType);
            bool        preferredFact = true;

            foreach (XmlNode n in list)
            {
                try
                {
                    Fact f = new Fact(n, this, preferredFact, outputText);
                    f.Location.FTAnalyzerCreated = false;
                    if (!f.Location.IsValidLatLong)
                    {
                        outputText.Report($"Found problem with Lat/Long for Location '{f.Location}' in facts for {FamilyID}: {FamilyName}");
                    }
                    if (string.IsNullOrEmpty(f.Comment) && Husband != null && Wife != null && f.IsMarriageFact)
                    {
                        string description = Fact.GetFactTypeDescription(factType);
                        f.Comment = $"{description} of {Husband.Name} and {Wife.Name}";
                    }
                    if (f.FactType != Fact.CENSUS)
                    {
                        Facts.Add(f);
                        if (!_preferredFacts.ContainsKey(f.FactType))
                        {
                            _preferredFacts.Add(f.FactType, f);
                        }
                    }
                    else
                    {
                        // Handle a census fact on a family.
                        if (GeneralSettings.Default.OnlyCensusParents)
                        {
                            if (Husband != null && Husband.IsAlive(f.FactDate))
                            {
                                Husband.AddFact(f);
                            }
                            if (Wife != null && Wife.IsAlive(f.FactDate))
                            {
                                Wife.AddFact(f);
                            }
                        }
                        else
                        {
                            // all members of the family who are alive get the census fact
                            foreach (Individual person in Members.Where(p => p.IsAlive(f.FactDate)))
                            {
                                person.AddFact(f);
                            }
                        }
                    }
                }
                catch (InvalidXMLFactException ex)
                {
                    outputText.Report($"Error with Family : {FamilyID}\n       Invalid fact : {ex.Message}");
                }
                catch (TextFactDateException te)
                {
                    if (te.Message == "UNMARRIED" || te.Message == "NEVER MARRIED" || te.Message == "NOT MARRIED")
                    {
                        Fact f = new Fact(string.Empty, Fact.UNMARRIED, FactDate.UNKNOWN_DATE, FactLocation.UNKNOWN_LOCATION, string.Empty, true, true);
                        Husband?.AddFact(f);
                        Wife?.AddFact(f);
                        Facts.Add(f);
                    }
                }
                preferredFact = false;
            }
        }