예제 #1
0
		public GedcomHeader()
		{
            this.Test = false;
            this.Filename = "Unknown.ged";

            this.ApplicationName = "DNA Adoption By Rob Warthen";
            this.ApplicationSystemID = "645723";
            this.ApplicationVersion = "1.0";
            this.Corporation = "Warthen Services";
            GedcomAddress ga = new GedcomAddress();
            ga.AddressLine = "320 OBrien Ave";
            ga.City = "Taneytown";
            ga.State = "MD";
            ga.PostCode = "21787";
            this.CorporationAddress = ga;
		}
예제 #2
0
		private bool AddressParse(GedcomAddress address, string tag, string lineValue, GedcomLineValueType lineValueType)
		{
			bool done = false;
						
			//  FIXME: checking for ADDR is wrong, doesn't work properly, ok to just
			//  check address is not null?  Real solution is to use a stack for PreviousTag
			// like it should have been doing in the first place
			// PreviousTag is now using a stack so will return the parent tag, which should be ADDR
			if (address != null || _ParseState.PreviousTag == "ADDR")
			{
				switch (tag)
				{
					case "CONT":
						address.AddressLine += Environment.NewLine;
						address.AddressLine += lineValue;
						done = true;
						break;
					case "ADR1":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.AddressLine1 = lineValue;
						}
						done = true;
						break;
					case "ADR2":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.AddressLine2 = lineValue;
						}
						done = true;
						break;
					case "ADR3":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.AddressLine3 = lineValue;
						}
						done = true;
						break;
					case "CITY":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.City = lineValue;
						}
						done = true;
						break;
					case "STAE":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.State = lineValue;
						}
						done = true;
						break;
					case "POST":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.PostCode = lineValue;
						}
						done = true;
						break;
					case "CTRY":
						if (lineValueType == GedcomLineValueType.DataType)
						{
							address.Country = lineValue;
						}
						done = true;
						break;
				}
			}
			
			return done;
		}
예제 #3
0
        private GedcomIndividualRecord GetGedIndi(string indi, string family, string nKitNbr, string pre, string sex, GedcomIndividualRecord sindi=null,GedcomIndividualRecord schild=null)
        {
            if (htIndi.Contains(indi))
            {
                foreach (GedcomIndividualRecord ggir in _gd1.Individuals)
                {
                    try
                    {
                        if (ggir.XRefID.Equals(indi))
                            return ggir;
                    }
                    catch { }
                }
                return null;
            }
            else
                htIndi.Add(indi, indi);

            string fatherid = String.Empty;
            string motherid = String.Empty;
            string npre = "http://www.gedmatch.com/individual_detail.php?id_family=" + family + "&id_ged=" + indi;
            foreach (char ichar in Path.GetInvalidFileNameChars())
                indi.Replace(ichar, '_');
            GetHTML(npre, WorkIndiDir + family + "\\GM_INDI_" + nKitNbr + "_" + indi + ".html", pre);
            StreamReader reader = new StreamReader(WorkIndiDir + family + "\\GM_INDI_" + nKitNbr + "_" + indi + ".html");
            string line = reader.ReadLine();
            GedcomIndividualRecord record=null;
            GedcomFamilyRecord ngfr = null;

            bool union = false;
            while (line != null)
            {

                //Check for Name
                if (line.StartsWith("<br><font size=+3><b>"))
                {
                    int ine = line.IndexOf("</b>");
                    int ige = line.IndexOf("'>");
                    int iborn = line.IndexOf("Born:");
                    int ib = line.IndexOf("</b>");
                    int ideath = line.IndexOf("Died:");
                    string name = line.Substring(21, ine - 21).Replace("&nbsp;", " ").Trim();

                    record = new GedcomIndividualRecord(_gd1);
                    GedcomName gn = new GedcomName();
                    gn.Database = _gd1;
                    gn.Split(name);
                    gn.Level = 1;
                    gn.PreferedName = true; 
                    record.Names.Add(gn);
                    record.XRefID = indi;
                    record.Sex = GedcomSex.Undetermined;
                    if (sex.Equals("M"))
                    {
                        record.Sex = GedcomSex.Male;
                    }
                    if (sex.Equals("F"))
                    {
                        record.Sex = GedcomSex.Female;
                    }
                    try
                    {
                        string born = line.Substring(iborn + 11).Replace("<br>", "").Replace("&nbsp;", " ").Trim();
                        string death = string.Empty;
                        if (ideath > 0)
                        {
                            born = line.Substring(iborn + 11, ideath - iborn - 11).Replace("<br>", "").Replace("&nbsp;", " ").Trim();
                            death = line.Substring(ideath);
                        }

                        try
                        {
                            GedcomDate bd = new GedcomDate(born);
                            bd.Database = _gd1;
                            bd.Date1 = born.Substring(0, born.IndexOf(","));
                            bd.Level = record.Level + 2;
                            GedcomIndividualEvent gieb = new GedcomIndividualEvent();
                            gieb.Database = _gd1;
                            gieb.Date = bd;
                            //record.Birth.Date = bd;
                            GedcomAddress gab = new GedcomAddress();
                            gab.Database = _gd1;
                            gab.AddressLine = born.Substring(born.IndexOf(",") + 1);
                            gieb.Address = gab;
                            //record.Birth.Address = gab;
                            gieb.EventType = GedcomEvent.GedcomEventType.BIRT;
                            gieb.IndiRecord = record;
                            gieb.Level = record.Level + 1;
                            record.Events.Add(gieb);
                        }
                        catch
                        {
                        }

                        if (death.Equals(string.Empty))
                        {
                            GedcomDate dd = new GedcomDate(death);
                            dd.Database = _gd1;
                            dd.Date1 = death.Substring(0, death.IndexOf(","));
                            dd.Level = record.Level + 2;
                            GedcomIndividualEvent gieb = new GedcomIndividualEvent();
                            gieb.Database = _gd1;
                            gieb.Date = dd;
                            //record.Birth.Date = bd;
                            GedcomAddress gab = new GedcomAddress();
                            gab.Database = _gd1;
                            gab.AddressLine = born.Substring(death.IndexOf(",") + 1);
                            gieb.Address = gab;
                            //record.Birth.Address = gab;
                            gieb.EventType = GedcomEvent.GedcomEventType.DEAT;
                            gieb.IndiRecord = record;
                            gieb.Level = record.Level+1;
                            record.Events.Add(gieb);
                        }
                    }
                    catch {}
                    //GedcomFamilyRecord ngfr=null;
                    //if (sindi != null)
                    //{
                    //    ngfr = new GedcomFamilyRecord(_gd1, record, sindi);
                    //    //sindi.SpouseIn.Add(
                    //}
                    //if (schild != null)
                    //{
                    //    //GedcomFamilyLink gfl = new GedcomFamilyLink();
                    //    //gfl.Database = _gd1;
                    //    if (ngfr != null)
                    //    {
                    //        //gfl.XRefID = ngfr.XRefID;
                    //        ngfr.AddChild(schild);
                    //    }
                    //    else
                    //    {
                    //        ngfr = new GedcomFamilyRecord(_gd1, record, null);
                    //        ngfr.AddChild(schild);
                    //    }
                    //}
                }

                //Check for
                if (line.StartsWith("<br>Father: "))
                {
                    try
                    {
                        int ifam = line.IndexOf("id_family=");
                        int ig = line.IndexOf("&id_ged");
                        int ige = line.IndexOf("'>");
                        if (ifam > 0 && ig > 0)
                        {
                            string nfamily = line.Substring(ifam + 10, ig - ifam - 10);
                            string nindi = line.Substring(ig + 8, ige - ig - 8);
                            GetGedIndi(nindi, nfamily, nKitNbr, npre, "M", null, record);
                        }
                    }
                    catch { }
                }
                if (line.StartsWith("<br>Mother: "))
                {
                    try
                    {
                        int ifam = line.IndexOf("id_family=");
                        int ig = line.IndexOf("&id_ged");
                        int ige = line.IndexOf("'>");
                        if (ifam > 0 && ig > 0)
                        {
                            string nfamily = line.Substring(ifam + 10, ig - ifam - 10);
                            string nindi = line.Substring(ig + 8, ige - ig - 8);
                            GetGedIndi(nindi, nfamily, nKitNbr, npre, "F", null, record);
                        }
                        int iss = line.IndexOf("<br>Union with:");
                        if (iss > 0)
                            line = line.Substring(iss);
                    }
                    catch { }
                }

                //Check for Spouse
                if (line.StartsWith("<br>Union with:") || line.StartsWith("<br><br>Union with: ") || union)
                {
                    int ifam = line.IndexOf("id_family=");
                    int ig = line.IndexOf("&id_ged");
                    int ige = line.IndexOf("'>");
                    if (ifam > 0 && ig > 0)
                    {
                        string nfamily = line.Substring(ifam + 10, ig - ifam - 10);
                        string nindi = line.Substring(ig + 8, ige - ig - 8);
                        string nsex = "U";
                        if (sex.Equals("M"))
                        {
                            nsex = "F";
                        }
                        if (sex.Equals("F"))
                        {
                            nsex = "M";
                        }
                        GedcomIndividualRecord spouse = GetGedIndi(nindi, nfamily, nKitNbr, npre, nsex);
                        //ToDo Figure out if we already created the family with OTHER spouse
                        ngfr = new GedcomFamilyRecord(_gd1, record, spouse);
                        union = false;
                    }
                    else
                        union = true;
                }

                bool gotchild = false;
                while (line.StartsWith("<br>Children: ") || (gotchild && (line.StartsWith("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./individual")||line.StartsWith("&nbsp;&nbsp;&nbsp;&nbsp;+<a href='./individual"))))
                {
                    union = false;
                    int ifam = line.IndexOf("id_family=");
                    int ig = line.IndexOf("&id_ged");
                    int ige = line.IndexOf("'>");
                    if (ifam > 0 && ig > 0)
                    {
                        string nfamily = line.Substring(ifam + 10, ig - ifam - 10);
                        string nindi = line.Substring(ig + 8, ige - ig - 8);
                        string nsex = "U";
                        GedcomIndividualRecord child = GetGedIndi(nindi, nfamily, nKitNbr, npre, nsex);
                        if (ngfr == null)
                        {
                            //Add child to Group
                        }
                        else
                        {
                            ngfr.AddChild(child);
                        }
                        line = reader.ReadLine();
                    }
                    gotchild = true;
                }
                //Add Children
                line = reader.ReadLine();
            }
            reader.Close();

            return record;
        }