예제 #1
0
        private void GedcomImportForm_Activated(object sender, EventArgs e)
        {
            if (loaded == false)
            {
                loaded          = true;
                lblParsing.Text = "Parsing Gedcom...";
                Application.DoEvents();
                GedcomParser gedcomParser = new GedcomParser();
                gedcomParser.Parse(Filename);
                lblParsing.Text     = "Parsing Gedcom complete.";
                lblIndividuals.Text = "Parsed " + gedcomParser.gedcomIndividuals.Count.ToString() + " individuals...";
                lblFamilies.Text    = "Parsed " + gedcomParser.gedcomFamilies.Count.ToString() + " families...";
                Application.DoEvents();
                GedcomImporter.Import(gedcomParser);

                Individual a = null;
                using (var ctx = new FamilyTracesContext())
                {
                    a = ctx.Individuals.First();
                }

                /*
                 * //Test code: TODO remove
                 * AncestorList ancestorList = new AncestorList();
                 * ancestorList.MaxDepth = 200;
                 * ancestorList.CalcAncestorList("@I7952@", gedcomParser.gedcomIndividuals, gedcomParser.gedcomFamilies, true, @"C:\Users\Serge.Meunier\Downloads\mine\ancestry.txt");
                 * lblIndividuals.Text = "Exporting completed";
                 */
                butClose.Enabled = true;
            }
        }
예제 #2
0
        public static void Import(GedcomParser gedcomParser)
        {
            Hashtable individualIdMapper = new Hashtable();

            using (var ctx = new FamilyTracesContext())
            {
                ctx.Families.RemoveRange(ctx.Families);
                ctx.Individuals.RemoveRange(ctx.Individuals);
                ctx.Sources.RemoveRange(ctx.Sources);
                ctx.Notes.RemoveRange(ctx.Notes);
                ctx.SaveChanges();

                foreach (GedcomNote gedcomNote in gedcomParser.gedcomNotes.Values)
                {
                    ctx.Notes.Add(new Note()
                    {
                        Id   = gedcomNote.Id,
                        Text = gedcomNote.Text
                    });
                }

                foreach (GedcomSource gedcomSource in gedcomParser.gedcomSources.Values)
                {
                    ctx.Sources.Add(new Source()
                    {
                        Id   = gedcomSource.Id,
                        Text = gedcomSource.Text
                    });
                }

                foreach (GedcomIndividual gedcomIndividual in gedcomParser.gedcomIndividuals.Values.Take(20))
                {
                    ctx.Individuals.Add(new Individual()
                    {
                        Id          = gedcomIndividual.Id,
                        GivenName   = gedcomIndividual.GivenName,
                        BirthDate   = gedcomIndividual.BirthDate,
                        BirthPlace  = gedcomIndividual.BirthPlace,
                        Description = gedcomIndividual.Description,
                        DiedCause   = gedcomIndividual.DiedCause,
                        DiedDate    = gedcomIndividual.DiedDate,
                        DiedPlace   = gedcomIndividual.DiedPlace,
                        Gender      = Enums.Gender.Male,
                        Nationality = gedcomIndividual.Nationality,
                        Occupation  = gedcomIndividual.Occupation,
                        Prefix      = gedcomIndividual.Prefix,
                        Suffix      = gedcomIndividual.Suffix,
                        Surname     = gedcomIndividual.Surname
                    });
                }
                ctx.SaveChanges();
            }
        }