示例#1
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}";
                    }
                    Facts.Add(f);
                    if (f.FactType != Fact.CENSUS)
                    {
                        if (Husband != null)
                        {
                            Husband.AddFact(f);
                        }
                        if (Wife != null)
                        {
                            Wife.AddFact(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;
            }
        }
示例#2
0
 public DisplayFact(Individual ind, Fact fact) : this(ind, ind.Surname, ind.Forenames, fact)
 {
 }
示例#3
0
 public override string ToString()
 {
     return(Ind == null ? Fact.FactTypeDescription + ": " + Fact.FactDate + " " + Fact.Comment
                        : IndividualID + ": " + Forenames + " " + Surname + ", " + Fact.ToString());
 }
示例#4
0
 public ExportFact(Individual ind, Fact f)
 {
     Ind = ind;
     F   = f;
 }
示例#5
0
        /**
         * @return Returns the first fact of the given type.
         */
        public FactDate GetPreferredFactDate(string factType)
        {
            Fact f = GetPreferredFact(factType);

            return((f == null) ? FactDate.UNKNOWN_DATE : f.FactDate);
        }
示例#6
0
 public ExportFact(Individual ind, Fact f)
 {
     this.ind = ind;
     this.f   = f;
 }