예제 #1
0
 private bool SetCertificatePresent()
 {
     return(Sources.Any(fs =>
     {
         return (FactType.Equals(Fact.BIRTH) && fs.isBirthCert()) ||
         (FactType.Equals(Fact.DEATH) && fs.isDeathCert()) ||
         (FactType.Equals(Fact.MARRIAGE) && fs.isMarriageCert()) ||
         (FactType.Equals(Fact.CENSUS) && fs.isCensusCert());
     }));
 }
예제 #2
0
    public List <WorkingMemoryFact> FindExistingFactOfType(FactType type)
    {
        List <WorkingMemoryFact> facts = new List <WorkingMemoryFact>();

        foreach (WorkingMemoryFact f in Facts)
        {
            if (type.Equals(f.FactType))
            {
                facts.Add(f);
            }
        }

        //Debug.Log("found existing facts of type " + type + " " + facts.Count);

        return(facts);
    }
예제 #3
0
	public List<WorkingMemoryFact> FindExistingFactOfType(FactType type)
	{
		List<WorkingMemoryFact> facts = new List<WorkingMemoryFact>();
		foreach(WorkingMemoryFact f in Facts)
		{
			if(type.Equals(f.FactType))
			{
				facts.Add(f);
			}
		}

		return facts;
	}
예제 #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");
                }
            }
        }