예제 #1
0
		public GedcomMultimediaRecord(GedcomDatabase database) : this()
		{
			Database = database;
			Level = 0;
						
			XRefID = database.GenerateXref("OBJE");
			database.Add(XRefID, this);
		}
예제 #2
0
		public GedcomSubmitterRecord(GedcomDatabase database) : this()
		{
			Database = database;

			Level = 0;
			XRefID = database.GenerateXref("S");
						
			database.Add(XRefID, this);
		}
예제 #3
0
		/// <summary>
		/// Create a new parse state object
		/// </summary>
		public GedcomParseState()
		{
			_Records = new Stack<GedcomRecord>();
			_Database = new GedcomDatabase();
			// max level of 99, pre alloc size of stack
			_PreviousTags = new Stack<Pair<string,int>>(100);
			
			_PairPool = new Pair<string,int>[100];
		}
예제 #4
0
		public GedcomNoteRecord(GedcomDatabase database) : this()
		{
			Level = 0;
			Database = database;
			XRefID = database.GenerateXref("NOTE");
			Text = string.Empty;
			
			database.Add(XRefID, this);
		}	
예제 #5
0
		public GedcomRepositoryRecord(GedcomDatabase database) : this()
		{		
			Database = database;
			Level = 0;
			
			Name = "New Repository";
			
			XRefID = database.GenerateXref("REPO");
			database.Add(XRefID, this);
		}
		private void Read(string file)
		{
			string dir = "/home/david/Projects/Gedcom.NET/Data/tests";
			string gedcomFile = Path.Combine(dir,file);
			
			_reader = new GedcomRecordReader();
			_reader.ReadGedcom(gedcomFile);
			_database = _reader.Database;
			
			NUnit.Framework.Assert.Greater(_reader.Database.Count,0,"No records read");

		}
예제 #7
0
		public GedcomFamilyRecord(GedcomDatabase database, GedcomIndividualRecord indi1, GedcomIndividualRecord indi2) : this()
		{
			Level = 0;
			Database = database;
			XRefID = database.GenerateXref("FAM");
			
			if (indi1 != null)
			{
				GedcomFamilyLink link = new GedcomFamilyLink();
				link.Database = database;
				link.Family = XRefID;
				link.Indi = indi1.XRefID;
				indi1.SpouseIn.Add(link);
				
				if (indi2 != null)
				{
					link = new GedcomFamilyLink();
					link.Database = database;
					link.Family = XRefID;
					link.Indi = indi2.XRefID;
					indi2.SpouseIn.Add(link);	
				}
				
				switch (indi1.Sex)
				{
					case GedcomSex.Female:
						Wife = indi1.XRefID;
						if (indi2 != null)
						{
							Husband = indi2.XRefID;
						}
						break;
					default:
						// got to put some where if not male or female,
						// go with same as male
						Husband = indi1.XRefID;
						if (indi2 != null)
						{
							Wife = indi2.XRefID;
						}
						break;
				}
			}
			
			database.Add(XRefID, this);
		}
예제 #8
0
		public static void FindDuplicates(GedcomDatabase databaseA, GedcomDatabase databaseB, float matchThreshold, DuplicateFoundFunc foundFunc)
		{		
			int total = databaseA.Individuals.Count;	
			int potential = 0;
						
			foreach (GedcomIndividualRecord indi in databaseA.Individuals)
			{
				List<GedcomIndividualRecord> matches = FindDuplicates(indi, databaseB, matchThreshold);
			
				if (matches.Count > 0)
				{
                    if (potential == 0)
                    Console.WriteLine("Match in " + databaseA.Name + " to " + databaseB.Name);
					foundFunc(indi, matches);		
					potential ++;
				}
			}
		}
예제 #9
0
		public GedcomSourceRecord (GedcomDatabase database) : this()
		{
			Database = database;
			Level = 0;
			
			Title = "New Source";
			
			// default to filer being current user
#if __MonoCS__
			// bug in mono code, doesn't correctly get the real name, need to strip off , chars
			FiledBy = UnixUserInfo.GetRealUser().RealName.Trim(new char[] { ',' });
#endif
			
			if (string.IsNullOrEmpty(FiledBy))
			{
				FiledBy = Environment.UserName;
			}
						
			XRefID = database.GenerateXref("SOURCE");
			database.Add(XRefID, this);
		}
예제 #10
0
		public static List<GedcomIndividualRecord> FindDuplicates(GedcomIndividualRecord indi, GedcomDatabase databaseB, float matchThreshold)
		{
			List<GedcomIndividualRecord> matches = new List<GedcomIndividualRecord>();
			
			foreach (GedcomIndividualRecord matchIndi in databaseB.Individuals)
			{
				// can't match self, databaseB could be the same database as indi.Database
				// so we can check this
				//if (matchIndi != indi)
				{
					float match = indi.IsMatch(matchIndi);
					
					if (match > matchThreshold)
					{
						matches.Add(matchIndi);	
						//System.Console.WriteLine(indi.Names[0].Name + " matches " + matchIndi.Names[0].Name + " at " + match + "%");
					}
				}
			}

			return matches;		
		}
예제 #11
0
		public GedcomChangeDate(GedcomDatabase database) : base(database)
		{
		}
예제 #12
0
 public GedcomDate(GedcomDatabase database)
     : this()
 {
     _database = database;
 }
예제 #13
0
		public GedcomIndividualRecord(GedcomDatabase database, string surname) : this()
		{
			Database = database;
			Level = 0;
			Sex = GedcomSex.Undetermined;
			XRefID = database.GenerateXref("I");

            if (!surname.Equals("unknown"))
            {
                GedcomName name = new GedcomName();
                name.Level = 1;
                name.Database = database;
                name.Name = "unknown /" + surname + "/";
                name.PreferedName = true;

                Names.Add(name);
            }
			
			database.Add(XRefID, this);
		}
예제 #14
0
		public GedcomIndividualRecord(GedcomDatabase database) : this(database, "unknown")
		{
		}
예제 #15
0
		/// <summary>
		/// Combines the given database with this one.
		/// This is literally what it says, no duplicate removal is performed
		/// combine will not take place if there are duplicate xrefs.
		/// </summary>
		/// <param name="database">
		/// A <see cref="GedcomDatabase"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.Boolean"/>
		/// </returns>
		public virtual bool Combine(GedcomDatabase database)
		{
			// check the databases can be combined, i.e. unique xrefs
			bool canCombine = true;
			foreach (GedcomRecord record in database.Table.Values)
			{
				if (Contains(record.XRefID))
				{
					canCombine = false;
					break;
				}
			}
			
			if (canCombine)
			{
				foreach (GedcomRecord record in database.Table.Values)
				{
					Add(record.XRefID, record);
				}
			}

			return canCombine;
		}
예제 #16
0
		public static GedcomAge Parse(string str, GedcomDatabase database)
		{
			GedcomAge age = null; 
			
			if (string.Compare(str, "INFANT", true) == 0)
			{
				age = new GedcomAge();
				age.Database = database;
				age.Equality = -1;
				age.Years = 1;
			}
			else if (string.Compare(str, "CHILD", true) == 0)
			{
				age = new GedcomAge();
				age.Database = database;
				age.Equality = -1;
				age.Years = 8;
			}
			else if (string.Compare(str, "STILLBORN", true) == 0)
			{
				age = new GedcomAge();
				age.Database = database;
				age.Equality = 0;
				age.Years = 0;
				age.Months = 0;
				age.Days = 0;
			}
			else
			{
				int equality = 0;
				int off = 0;
				if (str[0] == '<')
				{
					equality = -1;
					off = 1;
				}
				else if (str[0] == '>')
				{
					equality = 1;
					off = 1;
				}
		
				int val = -1;
				bool isAge = true;
				int year = -1;
				int month = -1;
				int day = -1;
				while ((isAge) && (off < str.Length))
				{
					char c = str[off];
					
					if (!char.IsWhiteSpace(c))
					{
						bool isDigit = char.IsDigit(c);
						
						if (val == -1 && !isDigit)
						{
							isAge  = false;
						}
						else if (isDigit)
						{
							int thisVal = val = (((int)c) - ((int)'0'));
							if (val == -1)
							{
								val = thisVal;
							}
							else
							{
								val *= 10;
								val += thisVal;
							}
						}
						else if (c == 'Y' || c == 'y')
						{
							if (year != -1)
							{
								isAge  = false;
							}
							else
							{
								year = val;
								val = -1;
							}
						}
						else if (c == 'M' || c == 'm')
						{
							if (month != -1)
							{
								isAge  = false;
							}
							else
							{
								month = val;
								val = -1;
							}
						}
						else if (c == 'D' || c == 'd')
						{
							if (day != -1)
							{
								isAge  = false;
							}
							else
							{
								day = val;
								val = -1;
							}
						}
						else
						{
							isAge  = false;
						}
					}
					off ++;
				}
				
				isAge &= (year != -1 || month != -1 || day != -1);
				
				if (isAge)
				{
					age = new GedcomAge();
					age.Database = database;
					age.Equality = equality;
					age.Years = year;
					age.Months = month;
					age.Days = day;
				}
			}
			
			return age;
		}
예제 #17
0
		/// <summary>
		/// Outputs a GedcomDatabase to the given file
		/// </summary>
		/// <param name="database">The GedcomDatabase to write</param>
		/// <param name="file">The filename to write to</param>
		public void WriteGedcom(GedcomDatabase database, string file)
		{
            lock (database)
            {
                Encoding enc = new UTF8Encoding();
                using (GedcomStreamWriter w = new GedcomStreamWriter(file, false, enc))
                {
                    w.AllowInformationSeparatorOneSave = AllowInformationSeparatorOneSave;
                    w.AllowLineTabsSave = AllowLineTabsSave;
                    w.AllowTabsSave = AllowTabsSave;

                    // write header

                    GedcomHeader header = database.Header;
                    header.Test = Test;
                    header.Filename = file;

                    header.ApplicationName = ApplicationName;
                    header.ApplicationSystemID = ApplicationSystemID;
                    header.ApplicationVersion = ApplicationVersion;
                    header.Corporation = Corporation;
                    header.CorporationAddress = CorporationAddress;

                    header.Output(w);

                    // write records

                    foreach (DictionaryEntry entry in database)
                    {
                        GedcomRecord record = entry.Value as GedcomRecord;

                        record.Output(w);
                        //w.Write(Environment.NewLine);
                    }

                    w.WriteLine();
                    w.WriteLine("0 TRLR");
                    //w.Write(Environment.NewLine);
                }
            }
		}
예제 #18
0
	protected virtual void OnNewDatabase_Activated(object sender, System.EventArgs e)
	{
		GedcomDatabase database;
		
		database = new GedcomDatabase();
		
		// create an initial person as we need one to work properly
		GedcomIndividualRecord indi = new GedcomIndividualRecord(database);
		
		database.Name = "Unsaved";
		
		SetGedcomDatabase(database);
	}
예제 #19
0
        public void controller(string[] args)
        {
            if (args.Length >= 2 && args[0].Equals("-FTDNA"))
            {
                FamilyTreeDNA.FamilyTreeDNA ftd = new FamilyTreeDNA.FamilyTreeDNA();
                ftd.Login("169551", "D3742");
            }
            if (args.Length >= 2 && args[0].Equals("-compare"))
            {
                GedcomDatabase gd1 = new GedcomDatabase();
                GedcomIndividualRecord record = new GedcomIndividualRecord(gd1, "Robert Warthen");
                record.Sex = GedcomSex.Male;
                //record.Birth = new GedcomIndividualEvent().Date.;

                GedcomParser.GedcomRecordWriter grw = new GedcomParser.GedcomRecordWriter();
                grw.WriteGedcom(gd1, "C:\\Temp\\Rob.ged");

            }
            if (args.Length >= 2 && args[0].Equals("-compdir"))
            {
                sw = new StreamWriter(args[1] + "\\match.csv");
                sw.WriteLine("File1,File2,Exact Match,Given1,Surname1,Birth Date1,Birth Place1,Death Date1,Death Place1,Given2,Surname2,Birth Date2,Birth Place2,Death Date2,Death Place2");
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                string[] files2 = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);

                if (args.Length >= 3 && args[2].Equals("-file"))
                {
                    files = new string[1];
                    files[0] = args[3];
                }

                if (args.Length >= 3 && args[2].Equals("-dir"))
                {
                    files2 = Directory.GetFiles(args[3], "*.*", SearchOption.TopDirectoryOnly);
                }

                foreach (string gdf1 in files)
                {
                    string gedcomFile1 = gdf1.ToUpper();
                    if (!gedcomFile1.EndsWith(".GED"))
                        continue;

                    swFile1 = Path.GetFileName(gedcomFile1);
                    //Console.WriteLine("Loading " + );
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    try { grr1.ReadGedcom(); }
                    catch { continue; }
                    GedcomDatabase gd1 = grr1.Database;
                    foreach (string gdf2 in files2)
                    {
                        string gedcomFile2 = gdf2.ToUpper();
                        if (!gedcomFile2.EndsWith(".GED"))
                            continue;
                        if (gedcomFile2.Equals(gedcomFile1))
                            continue;
                        swFile2 = Path.GetFileName(gedcomFile2);
                        //Console.WriteLine("Comparing " + gedcomFile1 + " and " + gedcomFile2);
                        GedcomParser.GedcomRecordReader grr2 = new GedcomParser.GedcomRecordReader();
                        grr2.GedcomFile = gedcomFile2;
                        try { grr2.ReadGedcom(); }
                        catch { continue; }
                        GedcomDatabase gd2 = grr2.Database;

                        GedcomDuplicate.DuplicateFoundFunc found = new GedcomDuplicate.DuplicateFoundFunc(FoundDuplicate);
                        float matchThreshold = 95;

                        GedcomDuplicate.FindDuplicates(gd1, gd2, matchThreshold, found);
                    }
                    sw.Flush();
                }
                sw.Close();
            }
            if (args.Length >= 2 && args[0].Equals("-surname"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;
                    bool foundfile = false;

                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            if (rec.Names.Count > 0 &&  rec.Names[0].Surname.ToUpper().Equals(surname))
                            {
                                if (!foundfile)
                                {
                                    Console.WriteLine("File " + gedcomFile1);
                                    foundfile = true;
                                }
                                Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                                try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                                catch { }
                                try { Console.Write(" in " + rec.Birth.Place.Name); }
                                catch { }
                                try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                                catch { }
                                try { Console.Write(" at " + rec.Death.Place.Name); }
                                catch { }
                                Console.WriteLine();
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Can't read");
                        }
                    }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-soundex"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();
                string sunameSoundex = Util.GenerateSoundex(surname);

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;
                    bool foundfile = false;

                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        if (rec.Names[0].SurnameSoundex.Equals(sunameSoundex))
                        {
                            if (!foundfile)
                            {
                                Console.WriteLine("File " + gedcomFile1);
                                foundfile = true;
                            }
                            Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                            try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                            catch { }
                            try { Console.Write(" in " + rec.Birth.Place.Name); }
                            catch { }
                            try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                            catch { }
                            try { Console.Write(" at " + rec.Death.Place.Name); }
                            catch { }
                            Console.WriteLine();
                        }
                    }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-loaddir"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);

                foreach (string gedcomFile1 in files)
                {
                    Console.WriteLine("Loading " + gedcomFile1);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;

                    foreach (GedcomIndividualRecord matchIndi in gd1.Individuals)
                    {
                        SaveDatabase(matchIndi);
                    }
                }
            }

            if (args.Length >= 2 && args[0].ToUpper().Equals("-GEDMATCH"))
            {
                GedMatch.GedMatch gm = new GedMatch.GedMatch();
                gm.WorkDir = args[1];
                gm.DoMatch = true;
                gm.DoGed = true;

                gm.loadGedMatch(args[2],true);
            }
            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-GETGEDMATCH"))
            {
                GedMatch.GedMatch gm = new GedMatch.GedMatch();
                gm.WorkDir = args[1];
                gm.DoGed = true;

                gm.loadGedMatch(args[2], true);
            }
        }
예제 #20
0
        private void GetGedMatch(string nKitNbr, string html, string pre, string sex, int attempt = 0)
        {
            if (!html.Equals("&nbsp;") && !html.Equals(String.Empty) && (html.IndexOf("<a href") >= 0))
            {
                Console.WriteLine("Loading GED Kit number " + nKitNbr);
                _gd1 = new GedcomDatabase();
                GedcomHeader gh = new GedcomHeader();
                string GedName = String.Empty;
                gh.Filename = "GM_" + nKitNbr + ".ged";
                _gd1.Header = gh;

                htIndi = new System.Collections.Hashtable(50);

                html = html.Replace("&nbsp;", " ");
                html = html.Replace("<a href='", "");
                string geds = String.Empty;
                try { geds = html.Trim().Substring(0, html.IndexOf(" title") - 2); }
                catch { }

                int ifam = html.IndexOf("id_family=");
                int ifame = html.IndexOf("' title");
                string nfamily = html.Substring(ifam + 10,ifame-ifam-10);
                GetHTML(geds, WorkDir + "\\GM_SURNAME" + nKitNbr + ".html", pre);

                StreamReader reader = new StreamReader(WorkDir + "\\GM_SURNAME" + nKitNbr + ".html");
                string line = reader.ReadLine();
                bool found = false;
                while (line != null)
                {
                    if (line.StartsWith("ANCESTORS OF: "))
                    {
                        int ig = line.IndexOf("&id_ged");
                        int ige = line.IndexOf("'>");
                        int ine = line.IndexOf("</a>");
                        try
                        {
                            GedName = line.Substring(ige + 2, ine - ige - 2).Replace("&nbsp;", " ").Replace("<b>", "").Replace("</b>", "");
                        }
                        catch { }
                        try
                        {
                            string nindi = line.Substring(ig + 8, ige - ig - 8);

                            if (!Directory.Exists(WorkIndiDir + nfamily))
                                Directory.CreateDirectory(WorkIndiDir + nfamily);

                            GedcomIndividualRecord gir = GetGedIndi(nindi, nfamily, nKitNbr, geds, sex);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message + " - " + ex.StackTrace);
                        }
                        found = true;
                        break;
                    }
                    line = reader.ReadLine();
                }
                reader.Close();

                if (!found && attempt++ < 2)
                {
                    GetHTML("http://www.gedmatch.com/surname.php?id_family=" + nfamily, WorkDir + "\\GM_SURNAME_LIST_" + nKitNbr + ".html", geds);
                    StreamReader freader = new StreamReader(WorkDir + "\\GM_SURNAME_LIST_" + nKitNbr + ".html");
                    string fline = freader.ReadLine();
                    {
                        //Try http://www.gedmatch.com/surname_detail.php?id_familyname=243182&id_family=5884506
                        try
                        {
                            GetHTML("http://www.gedmatch.com/surname.php?initial=A&id_family=" + nfamily, WorkDir + "\\GM_SURNAME_LIST_A_" + nKitNbr + ".html", geds);

                            StreamReader f1reader = new StreamReader(WorkDir + "\\GM_SURNAME_LIST_A_" + nKitNbr + ".html");
                            string f1line = f1reader.ReadLine();
                            while (f1line != null)
                            {
                                if (f1line.IndexOf("id_familyname=") > 0)
                                {
                                    int ifamname = f1line.IndexOf("id_familyname=");
                                    int ige = f1line.IndexOf("&");
                                    string nfamilyname = f1line.Substring(ifamname + 14, ige - ifamname - 14);
                                    //Get http://www.gedmatch.com/surname_detail.php?id_familyname=243182&id_family=5884506
                                    GetHTML("http://www.gedmatch.com/surname_detail.php?id_familyname=" + nfamilyname + "&id_family=" + nfamily, WorkDir + "\\GM_SURNAME_DETAIL_" + nKitNbr + ".html", geds);

                                    StreamReader dreader = new StreamReader(WorkDir + "\\GM_SURNAME_DETAIL_" + nKitNbr + ".html");
                                    string dline = dreader.ReadLine();
                                    while (dline != null)
                                    {
                                        if (dline.IndexOf("id_ged=") > 0)
                                        {
                                            int iged = dline.IndexOf("id_ged=");
                                            int ie = dline.IndexOf("'>");
                                            string nindi = dline.Substring(iged + 7,ie-7-iged);
                                            html = dline.Substring(iged, ie + 4 - iged);
                                            //Call 
                                            if (!Directory.Exists(WorkIndiDir + nfamily))
                                                Directory.CreateDirectory(WorkIndiDir + nfamily);
                                            GetGedIndi(nindi, nfamily, nKitNbr, geds, sex);
                                            found = true;
                                        }
                                        dline = dreader.ReadLine();
                                    }
                                }
                                f1line = f1reader.ReadLine();
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message + " - " + ex.StackTrace);
                        }

                    }
                    reader.Close();

                }

                if (found)
                lock (gedfile)
                {
                    gedfile = WorkDir + "\\GM_" + GedName + nKitNbr + ".ged";
                    Console.WriteLine("Writting " + gedfile);
                    GedcomParser.GedcomRecordWriter grw = new GedcomParser.GedcomRecordWriter();
                    try
                    {
                        grw.WriteGedcom(_gd1, gedfile);
                    }
                    catch
                    {   
                        try
                        {
                            gedfile = WorkDir + "\\GM_" + nKitNbr + ".ged";
                            grw.WriteGedcom(_gd1, gedfile);
                        }
                        catch (Exception ex) { Console.WriteLine("Couldn't write out " + gedfile + ": " + ex.Message + " - " + ex.StackTrace); }
                    }
                    gedfile = string.Empty;
                }

            }
        }
예제 #21
0
	private void SetGedcomDatabase(GedcomDatabase database)
	{
		_database = null;
		_record = null;
	
		_database = database;
			
		_record = _database.Individuals[0];
				
		if (_currentView != null)
		{
			_currentView.Database = _database;
					
			_currentView.Record = _record;
		}
		
		ViewNotebook.Sensitive = true;
		Merge.Sensitive = true;
		Save.Sensitive = true;
		SaveAs.Sensitive = true;
		PropertiesAction.Sensitive = true;
		
		// get all report related actions, make sensitive
		foreach (Gtk.Action action in _reportsGroup.ListActions())
		{
			action.Sensitive = true;
		}
		
		// get all tools related actions, make sensitive
		foreach (Gtk.Action action in _toolsGroup.ListActions())
		{
			action.Sensitive = true;
		}
		
		// get all view related actions, make sensitive
		foreach (Gtk.Action action in _viewGroup.ListActions())
		{
			action.Sensitive = true;	
		}		
		
		NewIndividual.Sensitive = true;
		NewMedia.Sensitive = true;
		NewRepository.Sensitive = true;
		NewSource.Sensitive = true;
		NewNote.Sensitive = true;
	}
예제 #22
0
        public void controller(string[] args)
        {
            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-FTDNA"))
            {
                FamilyTreeDNA.FamilyTreeDNA ftd = new FamilyTreeDNA.FamilyTreeDNA();
                if (args.Length >= 3)
                    ftd.Login(args[1], args[2]);
                else
                    ftd.Login("169551", "D3742");
            }
            if (args.Length >= 2 && args[0].ToUpper().Equals("-23"))
            {
                MeAnd23.MeAnd23 m23 = new MeAnd23.MeAnd23();
                if (args.Length >= 3)
                    m23.Login(args[1], args[2]);
                else
                    m23.Login("*****@*****.**", "nurse1");
            }
            if (args.Length >= 2 && args[0].ToUpper().Equals("-CSV"))
            {

            }
             
            if (args.Length >= 2 && args[0].Equals("-compare"))
            {
                GedcomDatabase gd1 = new GedcomDatabase();
                GedcomIndividualRecord record = new GedcomIndividualRecord(gd1, "Robert Warthen");
                record.Sex = GedcomSex.Male;
                //record.Birth = new GedcomIndividualEvent().Date.;

                GedcomParser.GedcomRecordWriter grw = new GedcomParser.GedcomRecordWriter();
                grw.WriteGedcom(gd1, "C:\\Temp\\Rob.ged");

            }
            if (args.Length >= 2 && args[0].Equals("-surlist"))
            {
                swsn = new StreamWriter(args[1] + "\\surname.csv", false);

                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                string[] files2 = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);

                if (args.Length >= 3 && args[2].Equals("-file"))
                {
                    files = new string[1];
                    files[0] = args[3];
                }

                if (args.Length >= 3 && args[2].Equals("-dir"))
                {
                    files2 = Directory.GetFiles(args[3], "*.*", SearchOption.TopDirectoryOnly);
                }

                foreach (string gdf1 in files)
                {
                    string gedcomFile1 = gdf1.ToUpper();
                    if (!gedcomFile1.EndsWith(".GED"))
                        continue;

                    swFile1 = Path.GetFileName(gedcomFile1);
                    //Console.WriteLine("Loading " + );
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    try { grr1.ReadGedcom(); }
                    catch { Console.WriteLine("Couldn't read file " + gedcomFile1);  continue; }
                    GedcomDatabase gd1 = grr1.Database;
                    System.Collections.Generic.List<string> sv = new System.Collections.Generic.List<string>();
                    sv.Clear();
                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            foreach (GedcomName sname in rec.Names)
                            {
                                string sn = sname.Surname.ToUpper();
                                if (sn.Length == 0)
                                    continue;
                                if (!sv.Contains(sname.Surname.ToUpper()))
                                {
                                    sv.Add(sname.Surname.ToUpper());
                                    swsn.WriteLine(gedcomFile1 + ",\"" + sname.Surname.ToUpper().Replace("\"", "_") + "\"");
                                }
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Can't read");
                        }
                    }
                }
                swsn.Close();
            }
            if (args.Length >= 2 && args[0].Equals("-compdir"))
            {
                sw = new StreamWriter(args[1] + "\\match.csv");
                sw.WriteLine("File1,File2,Exact Match,Given1,Surname1,Birth Date1,Birth Place1,Death Date1,Death Place1,Given2,Surname2,Birth Date2,Birth Place2,Death Date2,Death Place2");
                
                swsn = new StreamWriter(args[1] + "\\surname.csv",false);
                
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                string[] files2 = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);

                if (args.Length >= 3 && args[2].Equals("-file"))
                {
                    files = new string[1];
                    files[0] = args[3];
                }

                if (args.Length >= 3 && args[2].Equals("-dir"))
                {
                    files2 = Directory.GetFiles(args[3], "*.*", SearchOption.TopDirectoryOnly);
                }

                foreach (string gdf1 in files)
                {
                    string gedcomFile1 = gdf1.ToUpper();
                    if (!gedcomFile1.EndsWith(".GED"))
                        continue;

                    swFile1 = Path.GetFileName(gedcomFile1);
                    //Console.WriteLine("Loading " + );
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    try { grr1.ReadGedcom(); }
                    catch { continue; }
                    GedcomDatabase gd1 = grr1.Database;
                    System.Collections.Generic.List<string> sv = new System.Collections.Generic.List<string>();
                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            foreach (GedcomName sname in rec.Names)
                            {
                                if (!sv.Contains(sname.Surname.ToUpper()))
                                {
                                    sv.Add(sname.Surname.ToUpper());
                                    swsn.WriteLine(gedcomFile1 + ",\"" + sname.Surname.ToUpper().Replace("\"","_") + "\"");
                                }
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Can't read");
                        }
                    }
                    foreach (string gdf2 in files2)
                    {
                        string gedcomFile2 = gdf2.ToUpper();
                        if (!gedcomFile2.EndsWith(".GED"))
                            continue;
                        if (gedcomFile2.Equals(gedcomFile1))
                            continue;
                        swFile2 = Path.GetFileName(gedcomFile2);
                        //Console.WriteLine("Comparing " + gedcomFile1 + " and " + gedcomFile2);
                        GedcomParser.GedcomRecordReader grr2 = new GedcomParser.GedcomRecordReader();
                        grr2.GedcomFile = gedcomFile2;
                        try { grr2.ReadGedcom(); }
                        catch { continue; }
                        GedcomDatabase gd2 = grr2.Database;

                        GedcomDuplicate.DuplicateFoundFunc found = new GedcomDuplicate.DuplicateFoundFunc(FoundDuplicate);
                        float matchThreshold = 95;

                        GedcomDuplicate.FindDuplicates(gd1, gd2, matchThreshold, found);
                    }
                    sw.Flush();
                    swsn.Flush();
                }
                sw.Close();
                swsn.Close();
            }
            if (args.Length >= 2 && args[0].Equals("-surname"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    try
                    {
                        grr1.GedcomFile = gedcomFile1;
                        grr1.ReadGedcom();
                        GedcomDatabase gd1 = grr1.Database;
                        bool foundfile = false;

                        foreach (GedcomIndividualRecord rec in gd1.Individuals)
                        {
                            try
                            {
                                if (rec.Names.Count > 0 && rec.Names[0].Surname.ToUpper().Equals(surname))
                                {
                                    if (!foundfile)
                                    {
                                        Console.WriteLine("File " + gedcomFile1);
                                        foundfile = true;
                                    }
                                    Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                                    try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                                    catch { }
                                    try { Console.Write(" in " + rec.Birth.Place.Name); }
                                    catch { }
                                    try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                                    catch { }
                                    try { Console.Write(" at " + rec.Death.Place.Name); }
                                    catch { }
                                    Console.WriteLine();
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Can't read");
                            }
                        }
                    }
                    catch { }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-surfile"))
            {
                List<string> lstSurname = new List<string>();
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                //string surname = args[2].ToUpper();
                
                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    try
                    {
                        grr1.GedcomFile = gedcomFile1;
                        grr1.ReadGedcom();
                        GedcomDatabase gd1 = grr1.Database;
                        bool foundfile = false;

                        if (!Directory.Exists(args[1] + "\\Surname"))
                            Directory.CreateDirectory(args[1] + "\\Surname");

                        foreach (GedcomIndividualRecord rec in gd1.Individuals)
                        {
                            try
                            {
                                StreamWriter sw;
                                if (rec.Names.Count > 0)
                                {
                                    string surname = rec.Names[0].Surname.Replace("(", "").Replace(")", "").Replace("_", "").Replace("?", "").Replace("[", "").Replace("]", "").Replace("\'", "").Replace("\\", "").Replace("/", "");
                                    if (!lstSurname.Contains(surname))
                                    {
                                        sw = new StreamWriter(args[1] + "\\Surname\\Surname_" + surname + ".csv", false);
                                        sw.WriteLine("File,Given,Surname,Birth Date,Birth Place,Death Date,Death Place");
                                        lstSurname.Add(surname);
                                    }
                                    else
                                        sw = new StreamWriter(args[1] + "\\Surname\\Surname_" + surname + ".csv", true);

                                    sw.Write("\"" + gedcomFile1 + "\"," + "\"" + rec.Names[0].Given + "\"," + "\"" + rec.Names[0].Surname + "\",");
                                    try { sw.Write("\"" + rec.Birth.Date.DateString + "\"," + "\"" + rec.Birth.Place.Name + "\","); }
                                    catch { sw.Write(",,"); }
                                    try { sw.WriteLine( "\"" + rec.Death.Date.DateString + "\"," + "\"" + rec.Death.Place.Name + "\"");}
                                    catch { sw.WriteLine(","); }
                                    sw.Close();
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Can't read: " + ex.Message + "-" + ex.StackTrace);
                            }
                            finally
                            {
                                if (sw != null)
                                    sw.Close();
                            }
                        }
                    }
                    catch { }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-birth"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;
                    bool foundfile = false;

                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            if (rec.Birth != null && rec.Birth.Place != null && rec.Birth.Place.Name != null && rec.Birth.Place.Name.ToUpper().Contains(surname))
                            {
                                if (!foundfile)
                                {
                                    Console.WriteLine("File " + gedcomFile1);
                                    foundfile = true;
                                }
                                Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                                try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                                catch { }
                                try { Console.Write(" in " + rec.Birth.Place.Name); }
                                catch { }
                                try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                                catch { }
                                try { Console.Write(" at " + rec.Death.Place.Name); }
                                catch { }
                                Console.WriteLine();
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Can't read:" + ex.Message + " : " + ex.StackTrace);
                        }
                    }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-soundex"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();
                string sunameSoundex = Util.GenerateSoundex(surname);

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;
                    bool foundfile = false;

                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        if (rec.Names[0].SurnameSoundex.Equals(sunameSoundex))
                        {
                            if (!foundfile)
                            {
                                Console.WriteLine("File " + gedcomFile1);
                                foundfile = true;
                            }
                            Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                            try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                            catch { }
                            try { Console.Write(" in " + rec.Birth.Place.Name); }
                            catch { }
                            try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                            catch { }
                            try { Console.Write(" at " + rec.Death.Place.Name); }
                            catch { }
                            Console.WriteLine();
                        }
                    }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-loaddir"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);

                foreach (string gedcomFile1 in files)
                {
                    Console.WriteLine("Loading " + gedcomFile1);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;

                    foreach (GedcomIndividualRecord matchIndi in gd1.Individuals)
                    {
                        SaveDatabase(matchIndi);
                    }
                }
            }

            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-GEDMATCH"))
            {
                GedMatch.GedMatch gm = new GedMatch.GedMatch();
                gm.WorkDir = args[1];
                gm.DoMatch = true;
                gm.DoGed = true;

                gm.loadGedMatch(args[2],true);
            }
            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-GETGEDMATCH"))
            {
                GedMatch.GedMatch gm = new GedMatch.GedMatch();
                gm.WorkDir = args[1];
                gm.DoGed = true;

                gm.loadGedMatch(args[2], true);
            }
             
        }