Esempio n. 1
0
        public static SearchDescriptor GetSearchDescriptor(IndividualClass person)
        {
            SearchDescriptor searchDescriptor = new SearchDescriptor();

            searchDescriptor.FirstName = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.GivenName);
            searchDescriptor.LastName  = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname);
            searchDescriptor.BirthName = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname);
            if (searchDescriptor.BirthName.Length == 0)
            {
                searchDescriptor.BirthName = null;
            }
            IndividualEventClass birth = person.GetEvent(IndividualEventClass.EventType.Birth);

            if (!birth.badDate && birth.GetDate().ValidDate())
            {
                DateTime date = birth.GetDate().ToDateTime();
                searchDescriptor.BirthDate = date.ToString("yyyyMMdd");
            }
            IndividualEventClass death = person.GetEvent(IndividualEventClass.EventType.Death);

            if (!death.badDate && death.GetDate().ValidDate())
            {
                DateTime date = death.GetDate().ToDateTime();
                searchDescriptor.DeathDate = date.ToString("yyyyMMdd");
            }

            return(searchDescriptor);
        }
Esempio n. 2
0
        public bool UpdateIndividual(IndividualClass tempIndividual, PersonUpdateType updateType)
        {
            if (individualList.ContainsKey(tempIndividual.GetXrefName()))
            {
                IndividualClass updatePerson = individualList[tempIndividual.GetXrefName()];

                if ((updateType & PersonUpdateType.ChildFamily) != 0)
                {
                    updatePerson.SetFamilyChildList(tempIndividual.GetFamilyChildList());
                }
                if ((updateType & PersonUpdateType.SpouseFamily) != 0)
                {
                    updatePerson.SetFamilySpouseList(tempIndividual.GetFamilySpouseList());
                }
                if ((updateType & PersonUpdateType.Name) != 0)
                {
                    updatePerson.SetPersonalName(tempIndividual.GetPersonalName());
                }
                if ((updateType & PersonUpdateType.Events) != 0)
                {
                    updatePerson.SetEventList(tempIndividual.GetEventList());
                }

                individualList[tempIndividual.GetXrefName()] = updatePerson;
                return(true);
            }
            else
            {
                trace.TraceEvent(TraceEventType.Error, 0, "Error: Can't update {0} as it is not in the database!", tempIndividual.GetXrefName());
            }
            return(false);
        }
Esempio n. 3
0
        private void SaveButtonClick(object sender, EventArgs e)
        {
            PersonalNameClass personalName = new PersonalNameClass();

            personalName = tempIndividual.GetPersonalName();

            foreach (Control tempControl in this.nameControlPanel.Controls)
            {
                if (tempControl is TextBox)
                {
                    String controlName = tempControl.AccessibleName;

                    trace.TraceInformation("control name = " + controlName);

                    /*if (controlName.Contains(controlNamePrefix))
                     * {
                     * String subString = controlName.Substring(controlNamePrefix.Length);
                     * trace.TraceInformation("control substr = " + subString);
                     *
                     * personalName.SetName(subString, tempControl.Text);
                     *
                     * }*/
                }
            }

            tempIndividual.SetPersonalName(personalName);
            result = true;
            this.Close();
        }
        private void SetPersonProperties(ref IndividualClass person)
        {
            if (propertyList != null)
            {
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.GivenName, propertyList[0].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.MiddleName, propertyList[1].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.Surname, propertyList[2].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.BirthSurname, propertyList[3].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.NameString, propertyList[4].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.PublicName, propertyList[5].Value.ToString());

                switch ((PersonPropertySex)propertyList[SexIndex].Value)
                {
                case PersonPropertySex.Female:
                    person.SetSex(IndividualClass.IndividualSexType.Female);
                    break;

                case PersonPropertySex.Male:
                    person.SetSex(IndividualClass.IndividualSexType.Male);
                    break;

                case PersonPropertySex.Unknown:
                    person.SetSex(IndividualClass.IndividualSexType.Unknown);
                    break;
                }

                IList <IndividualEventClass> eventList = person.GetEventList();

                familyTree.UpdateIndividual(person, PersonUpdateType.ChildFamily | PersonUpdateType.Events | PersonUpdateType.Name | PersonUpdateType.SpouseFamily);
            }
            else
            {
                trace.TraceEvent(TraceEventType.Error, 0, "error no proplist");
            }
        }
Esempio n. 5
0
        public bool GetPerson(ref IndividualClass person)
        {
            PersonalNameClass name = person.GetPersonalName();

            name.SetName(PersonalNameClass.PartialNameType.GivenName, propertyList[0].Value.ToString());
            name.SetName(PersonalNameClass.PartialNameType.MiddleName, propertyList[1].Value.ToString());
            name.SetName(PersonalNameClass.PartialNameType.Surname, propertyList[2].Value.ToString());
            name.SetName(PersonalNameClass.PartialNameType.BirthSurname, propertyList[3].Value.ToString());
            //name.SetName(PersonalNameClass.PartialNameType.GivenName, propertyList[4].Value.ToString());

            person.SetPersonalName(name);

            return(true);
        }
Esempio n. 6
0
        /*public void SetSelectedIndividual(String xrefName)
         * {
         * trace.TraceInformation("TreeViewPanel2::SetSelectedIndividual(" + xrefName + ")");
         * if (familyTree != null)
         * {
         *  selectedIndividual = (IndividualClass)familyTree.GetIndividual(xrefName);
         *
         *  ShowActiveFamily();
         * }
         * }*/
        public void ClickSelectedIndividual(IndividualClass individual)
        {
            trace.TraceInformation("TreeViewPanel2::ClickSelectedIndividual(" + individual.GetPersonalName().GetName() + ")");
            if (familyTree != null)
            {
                selectedIndividual = individual;

                ShowActiveFamily();

                if (parentForm != null)
                {
                    parentForm.SetSelectedIndividual(individual.GetXrefName());
                }
            }
        }
Esempio n. 7
0
        private void ReadFile(ref FamilyTreeStoreBaseClass inFamilyTree, FamilyTreeStoreAnarkiv anarkivStore)
        {
            //IndividualClass person = anarkivStore.GetIndividual();

            IEnumerator <IndividualClass> people = anarkivStore.SearchPerson();

            AnarkivMappers mappers = new AnarkivMappers(inFamilyTree);
            IDictionary <string, XrefMapperClass> individualMapper = mappers.GetMapper(XrefType.Individual);
            IDictionary <string, XrefMapperClass> familyMapper     = mappers.GetMapper(XrefType.Family);

            int counter = 0;

            while (people.MoveNext())
            {
                IndividualClass person = people.Current;

                trace.TraceInformation("Person[" + counter++ + "]:" + person.GetPersonalName().ToString());

                IndividualXrefClass xref = new IndividualXrefClass(inFamilyTree.CreateNewXref(XrefType.Individual));

                individualMapper.Add(person.GetXrefName(), new XrefMapperClass(xref.GetXrefName(), true));
                person.SetXrefName(xref.GetXrefName());

                if (person.GetFamilyChildList() != null)
                {
                    IList <FamilyXrefClass> newChildFamilies = new List <FamilyXrefClass>();
                    foreach (FamilyXrefClass childFamily in person.GetFamilyChildList())
                    {
                        FamilyXrefClass newFamily = new FamilyXrefClass(mappers.GetLocalXRef(XrefType.Family, childFamily.GetXrefName()));
                        newChildFamilies.Add(newFamily);
                    }
                    person.SetFamilyChildList(newChildFamilies);
                }

                if (person.GetFamilySpouseList() != null)
                {
                    IList <FamilyXrefClass> newSpouseFamilies = new List <FamilyXrefClass>();
                    foreach (FamilyXrefClass spouseFamily in person.GetFamilySpouseList())
                    {
                        FamilyXrefClass newFamily = new FamilyXrefClass(mappers.GetLocalXRef(XrefType.Family, spouseFamily.GetXrefName()));
                        newSpouseFamilies.Add(newFamily);
                    }
                    person.SetFamilySpouseList(newSpouseFamilies);
                }


                inFamilyTree.AddIndividual(person);
            }

            IEnumerator <FamilyClass> familyEnumerator = anarkivStore.SearchFamily();

            counter = 0;
            while (familyEnumerator.MoveNext())
            {
                FamilyClass family    = familyEnumerator.Current;
                FamilyClass newFamily = new FamilyClass();

                trace.TraceInformation("Family[" + counter++ + "]:" + family.GetXrefName());
                newFamily.SetXrefName(mappers.GetLocalXRef(XrefType.Family, family.GetXrefName(), true));

                trace.TraceInformation("Family xref " + family.GetXrefName() + " ==> " + newFamily.GetXrefName());

                if (family.GetParentList() != null)
                {
                    //IList<IndividualXrefClass> newParentList = new List<IndividualXrefClass>();
                    foreach (IndividualXrefClass parent in family.GetParentList())
                    {
                        IndividualXrefClass newParent = new IndividualXrefClass(mappers.GetLocalXRef(XrefType.Individual, parent.GetXrefName()));
                        //newParentList.Add(newParent);
                        newFamily.AddRelation(newParent, FamilyClass.RelationType.Parent);
                        trace.TraceInformation(" add parent  " + parent.GetXrefName() + " => " + newParent.GetXrefName());
                    }
                }
                if (family.GetChildList() != null)
                {
                    //IList<IndividualXrefClass> newChildList = new List<IndividualXrefClass>();
                    foreach (IndividualXrefClass child in family.GetChildList())
                    {
                        IndividualXrefClass newChild = new IndividualXrefClass(mappers.GetLocalXRef(XrefType.Individual, child.GetXrefName()));
                        //newChildList.Add(newChild);
                        newFamily.AddRelation(newChild, FamilyClass.RelationType.Child);
                        trace.TraceInformation(" add child  " + child.GetXrefName() + " => " + newChild.GetXrefName());
                    }
                }
                //family.

                inFamilyTree.AddFamily(newFamily);
            }
        }
        public static void SearchDuplicates(IndividualClass person1, IFamilyTreeStoreBaseClass familyTree1, IFamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, IProgressReporterInterface reporter = null, NameEquivalenceDb nameEqDb = null)
        {
            IndividualEventClass birth = person1.GetEvent(IndividualEventClass.EventType.Birth);
            IndividualEventClass death = person1.GetEvent(IndividualEventClass.EventType.Death);

            if (reporter != null)
            {
                trace.TraceInformation(reporter.ToString());
            }
            if (((birth != null) && (birth.GetDate() != null) && (birth.GetDate().ValidDate())) ||
                ((death != null) && (death.GetDate() != null) && (death.GetDate().ValidDate())))
            {
                string searchString;

                if (familyTree2.GetCapabilities().jsonSearch)
                {
                    searchString = SearchDescriptor.ToJson(SearchDescriptor.GetSearchDescriptor(person1));
                }
                else
                {
                    searchString = person1.GetName().Replace("*", "");
                }

                IEnumerator <IndividualClass> iterator2 = familyTree2.SearchPerson(searchString);
                int cnt2 = 0;

                if (iterator2 != null)
                {
                    int cnt3 = 0;
                    do
                    {
                        IndividualClass person2 = iterator2.Current;

                        if (person2 != null)
                        {
                            cnt3++;
                            //trace.TraceInformation(reporter.ToString() + "   2:" + person2.GetName());
                            if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName()))
                            {
                                if (ComparePerson(person1, person2, nameEqDb))
                                {
                                    trace.TraceData(TraceEventType.Information, 0, "   2:" + person2.GetName() + " " + person1.GetXrefName() + " " + person2.GetXrefName());
                                    reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                }
                                cnt2++;
                            }
                        }
                    } while (iterator2.MoveNext());

                    iterator2.Dispose();
                    trace.TraceInformation(" " + searchString + " matched with " + cnt2 + "," + cnt3);
                }

                if (cnt2 == 0) // No matches found for full name
                {
                    if ((person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname).Length > 0) &&
                        (person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname).Length > 0) &&
                        !person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname).Equals(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname)))
                    {
                        String strippedName = person1.GetName().Replace("*", "");

                        if (strippedName.Contains(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname)))
                        {
                            String maidenName = strippedName.Replace(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname), "").Replace("  ", " ");
                            IEnumerator <IndividualClass> iterator3 = familyTree2.SearchPerson(maidenName);
                            //trace.TraceInformation(" Searching Maiden name " + maidenName);

                            if (iterator3 != null)
                            {
                                int cnt3 = 0;
                                do
                                {
                                    IndividualClass person2 = iterator3.Current;

                                    if (person2 != null)
                                    {
                                        if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName()))
                                        {
                                            cnt3++;
                                            if (ComparePerson(person1, person2, nameEqDb))
                                            {
                                                trace.TraceData(TraceEventType.Information, 0, "   2b:" + person2.GetName());
                                                reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                            }
                                        }
                                    }
                                } while (iterator3.MoveNext());
                                iterator3.Dispose();
                                trace.TraceInformation(" Maiden name " + maidenName + " mathched with " + cnt3);
                            }
                        }
                        if (strippedName.Contains(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname)))
                        {
                            String marriedName = strippedName.Replace(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname), "").Replace("  ", " ");
                            IEnumerator <IndividualClass> iterator3 = familyTree2.SearchPerson(marriedName);

                            //trace.TraceInformation(" Searching Married name " + marriedName);
                            if (iterator3 != null)
                            {
                                int cnt3 = 0;
                                do
                                {
                                    //IndividualClass person1 = iterator1.Current;
                                    IndividualClass person2 = iterator3.Current;

                                    if (person2 != null)
                                    {
                                        //trace.TraceInformation(reporter.ToString() + "   2:" + person2.GetName());
                                        if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName()))
                                        {
                                            cnt3++;
                                            if (ComparePerson(person1, person2, nameEqDb))
                                            {
                                                trace.TraceData(TraceEventType.Information, 0, "   2c:" + person2.GetName());
                                                reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                            }
                                        }
                                    }
                                } while (iterator3.MoveNext());
                                iterator3.Dispose();
                                trace.TraceInformation(" Married name " + marriedName + " matched to " + cnt3);
                            }
                        }
                    }
                }
            }
            else
            {
                trace.TraceData(TraceEventType.Information, 0, "No valid birth or death date for " + person1.GetName().ToString() + " skip duplicate search");
            }
        }
Esempio n. 9
0
        private void UpdateIndividual(IndividualClass person, TreeViewLayout layout, ref IndividualButton personButton, FamilyButton parentButton = null)
        {
            trace.TraceInformation("UpdateIndividual(" + person.GetXrefName() + "),gen:" + personButton.bLayout.generation + ",name:" + person.GetPersonalName().GetName());
            if (personButton.individual == null)
            {
                personButton.individual = person;
                personButton.Refresh();
            }
            if (!personButton.Visible)
            {
                if (!personButton.SetLayout(layout, parentButton))
                {
                    trace.TraceInformation("UpdateIndividual(" + person.GetXrefName() + "),gen:" + personButton.bLayout.generation + ")-aborted,hidden");
                    return;
                }
            }

            if (layout.VisibleButton(personButton.bLayout))
            {
                if (layout.SearchChildren())
                {
                    UpdateFamilyList(person.GetFamilySpouseList(), personButton);
                }
                if (layout.SearchParents())
                {
                    UpdateFamilyList(person.GetFamilyChildList(), personButton);
                }
                trace.TraceInformation("UpdateIndividual(" + person.GetXrefName() + ", " + personButton.bLayout.generation + ")-done");
            }
            else
            {
                trace.TraceInformation("UpdateIndividual(" + person.GetXrefName() + ", " + personButton.bLayout.generation + ") not visible generation => stop!");
            }
        }
Esempio n. 10
0
        private void GetPersonProperties(IndividualClass person)
        {
            if (propertyList != null)
            {
                propertyList[0].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.GivenName);
                propertyList[1].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.MiddleName);
                propertyList[2].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname);
                propertyList[3].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname);
                propertyList[4].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.NameString);
                propertyList[5].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.PublicName);

                switch (person.GetSex())
                {
                case IndividualClass.IndividualSexType.Female:
                    propertyList[SexIndex].Value = PersonPropertySex.Female;
                    break;

                case IndividualClass.IndividualSexType.Male:
                    propertyList[SexIndex].Value = PersonPropertySex.Male;
                    break;

                case IndividualClass.IndividualSexType.Unknown:
                    propertyList[SexIndex].Value = PersonPropertySex.Unknown;
                    break;
                }

                IList <IndividualEventClass> eventList = person.GetEventList();

                if (eventList != null)
                {
                    foreach (IndividualEventClass ev in eventList)
                    {
                        switch (ev.GetEventType())
                        {
                        case IndividualEventClass.EventType.Birth:
                            propertyList[BirthIndex].Value     = ev.GetDate().ToDateTime();
                            propertyList[BirthIndex + 1].Value = ev.GetAddress();
                            trace.TraceInformation("Birth: " + ev.GetAddress() + " " + ev.GetPlace() + " " + ev.ToString());
                            break;

                        case IndividualEventClass.EventType.Death:
                            propertyList[DeathIndex].Value     = ev.GetDate().ToDateTime();
                            propertyList[DeathIndex + 1].Value = ev.GetAddress();
                            trace.TraceInformation("Death: " + ev.GetAddress() + " " + ev.GetPlace() + " " + ev.ToString());
                            break;
                        }
                    }
                }
                if (propertyList[BirthIndex].Value == null)
                {
                    propertyList[BirthIndex].Value = DateTime.MinValue;
                }
                if (propertyList[DeathIndex].Value == null)
                {
                    propertyList[DeathIndex].Value = DateTime.MinValue;
                }
            }
            else
            {
                trace.TraceEvent(TraceEventType.Error, 0, "error no proplist");
            }
        }
Esempio n. 11
0
        public void SetSelectedPerson(IndividualClass person)
        {
            trace.TraceInformation("SetSelectedPerson");
            if (person != null)
            {
                selectedPerson = person;

                if (propertyList != null)
                {
                    propertyList[0].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.GivenName);
                    propertyList[1].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.MiddleName);
                    propertyList[2].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname);
                    propertyList[3].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname);
                    propertyList[4].Value = person.GetPersonalName().GetName(PersonalNameClass.PartialNameType.NameString);

                    switch (person.GetSex())
                    {
                    case IndividualClass.IndividualSexType.Female:
                        propertyList[5].Value = PersonPropertySex.Female;
                        break;

                    case IndividualClass.IndividualSexType.Male:
                        propertyList[5].Value = PersonPropertySex.Male;
                        break;

                    case IndividualClass.IndividualSexType.Unknown:
                        propertyList[5].Value = PersonPropertySex.Unknown;
                        break;
                    }

                    IList <IndividualEventClass> eventList = person.GetEventList();

                    if (eventList != null)
                    {
                        foreach (IndividualEventClass ev in eventList)
                        {
                            switch (ev.GetEventType())
                            {
                            case IndividualEventClass.EventType.Birth:
                                propertyList[6].Value = ev.GetDate().ToDateTime();
                                break;

                            case IndividualEventClass.EventType.Death:
                                propertyList[7].Value = ev.GetDate().ToDateTime();
                                break;
                            }
                        }
                    }
                    if (propertyList[6].Value == null)
                    {
                        propertyList[6].Value = DateTime.MinValue;
                    }
                    if (propertyList[7].Value == null)
                    {
                        propertyList[7].Value = DateTime.MinValue;
                    }
                }
                else
                {
                    trace.TraceEvent(TraceEventType.Error, 0, "error no proplist");
                }
            }
            else
            {
                trace.TraceEvent(TraceEventType.Error, 0, "error no selected person");
            }
        }