コード例 #1
0
 public FactSource(XmlNode node)
 {
     this.SourceID     = node.Attributes["ID"].Value;
     this.SourceTitle  = FamilyTree.GetText(node, "TITL", true);
     this.Publication  = FamilyTree.GetText(node, "PUBL", true);
     this.Author       = FamilyTree.GetText(node, "AUTH", true);
     this.SourceText   = FamilyTree.GetText(node, "TEXT", true);
     this.SourceMedium = FamilyTree.GetText(node, "REPO/CALN/MEDI", true);
     if (this.SourceMedium.Length == 0)
     {
         this.SourceMedium = FamilyTree.GetText(node, "NOTE/CONC", true);
     }
     this.Facts = new List <Fact>();
 }
コード例 #2
0
        private void CheckForSharedFacts(XmlNode node)
        {
            XmlNodeList list = node.SelectNodes("_SHAR");

            foreach (XmlNode n in list)
            {
                string indref = n.Attributes["REF"].Value;
                string role   = FamilyTree.GetText(n, "ROLE", false);
                if (role.Equals("Household Member"))
                {
                    FamilyTree.Instance.AddSharedFact(indref, this);
                }
            }
        }
コード例 #3
0
        public FactSource(XmlNode node)
        {
            bool noteRead = false;

            SourceID    = node.Attributes["ID"].Value;
            SourceTitle = FamilyTree.GetText(node, "TITL", true);
            Publication = FamilyTree.GetText(node, "PUBL", true);
            Author      = FamilyTree.GetText(node, "AUTH", true);
            SourceText  = FamilyTree.GetText(node, "TEXT", true);
            if (string.IsNullOrEmpty(SourceText))
            {
                SourceText = FamilyTree.GetText(node, "NOTE", true);
                noteRead   = true;
            }
            SourceMedium = FamilyTree.GetText(node, "REPO/CALN/MEDI", true);
            if (!noteRead && SourceMedium.Length == 0)
            {
                SourceMedium = FamilyTree.GetText(node, "NOTE/CONC", true);
            }
            Facts = new List <Fact>();
        }
コード例 #4
0
        private void CreateFact(XmlNode node, string reference, bool preferred)
        {
            if (node != null)
            {
                FamilyTree ft = FamilyTree.Instance;
                try
                {
                    FactType = FixFactTypes(node.Name);
                    string factDate = FamilyTree.GetText(node, "DATE", false);
                    this.FactDate  = new FactDate(factDate, reference);
                    this.Preferred = preferred;
                    if (FactType.Equals(CUSTOM_EVENT) || FactType.Equals(CUSTOM_FACT))
                    {
                        string tag = FamilyTree.GetText(node, "TYPE", false).ToUpper();
                        string factType;
                        if (CUSTOM_TAGS.TryGetValue(tag, out factType))
                        {
                            FactType = factType;
                            CheckCensusDate(tag);
                        }
                        else
                        {
                            FactType = Fact.UNKNOWN;
                            FamilyTree.Instance.CheckUnknownFactTypes(tag);
                            Tag = tag;
                        }
                    }
                    SetCommentAndLocation(FactType, FamilyTree.GetText(node, false), FamilyTree.GetText(node, "PLAC", false),
                                          FamilyTree.GetText(node, "PLAC/MAP/LATI", false), FamilyTree.GetText(node, "PLAC/MAP/LONG", false));
                    if (Location.IsBlank)
                    {
                        SetAddress(FactType, node);
                    }

                    // only check UK census dates for errors as those are used for colour census
                    if (FactType.Equals(CENSUS) && Location.IsUnitedKingdom)
                    {
                        CheckCensusDate("Census");
                    }

                    // need to check residence after setting location
                    if (FactType.Equals(RESIDENCE) && Properties.GeneralSettings.Default.UseResidenceAsCensus)
                    {
                        CheckResidenceCensusDate();
                    }

                    // check Children Status is valid
                    if (FactType.Equals(CHILDREN1911))
                    {
                        CheckValidChildrenStatus(node);
                    }

                    // now iterate through source elements of the fact finding all sources
                    XmlNodeList list = node.SelectNodes("SOUR");
                    foreach (XmlNode n in list)
                    {
                        if (n.Attributes["REF"] != null)
                        {   // only process sources with a reference
                            string     srcref = n.Attributes["REF"].Value;
                            FactSource source = ft.GetSourceID(srcref);
                            if (source != null)
                            {
                                Sources.Add(source);
                                source.AddFact(this);
                            }
                            else
                            {
                                ft.XmlErrorBox.AppendText("Source " + srcref + " not found." + "\n");
                            }
                        }
                        if (IsCensusFact)
                        {
                            this.CensusReference = new CensusReference(this, n);
                        }
                    }
                    // if we have checked the sources and no census ref see if its been added as a comment to this fact
                    if (FactType.Equals(CENSUS) || FactType.Equals(CENSUS_FTA) || FactType.Equals(RESIDENCE))
                    {
                        CheckForSharedFacts(node);
                        if (this.CensusReference == CensusReference.UNKNOWN)
                        {
                            this.CensusReference = new CensusReference(this, node);
                        }
                        else if (!this.CensusReference.IsKnownStatus)
                        {
                            CensusReference pageRef = this.CensusReference;
                            this.CensusReference = new CensusReference(this, node, pageRef);
                        }
                    }
                    if (FactType == DEATH)
                    {
                        Comment = FamilyTree.GetText(node, "CAUS", true);
                        if (node.FirstChild != null && node.FirstChild.Value == "Y" && !FactDate.IsKnown)
                        {
                            FactDate = new FactDate(FactDate.MINDATE, DateTime.Now); // if death flag set as Y then death before today.
                        }
                    }
                    string age = FamilyTree.GetText(node, "AGE", false);
                    if (age.Length > 0)
                    {
                        this.GedcomAge = new Age(age, FactDate);
                    }
                    this.CertificatePresent = SetCertificatePresent();
                }
                catch (Exception ex)
                {
                    string message = (node == null) ? string.Empty : node.InnerText + ". ";
                    throw new InvalidXMLFactException(message + "\n            Error " + ex.Message + "\n");
                }
            }
        }