public static bool ComparePerson(IndividualClass person1, IndividualClass person2, NameEquivalenceDb nameEqDb)
        {
            if (IsNamesEqual(person1.GetName(), person2.GetName(), nameEqDb))
            {
                IndividualEventClass birth1 = person1.GetEvent(IndividualEventClass.EventType.Birth);
                IndividualEventClass birth2 = person2.GetEvent(IndividualEventClass.EventType.Birth);
                IndividualEventClass death1 = person1.GetEvent(IndividualEventClass.EventType.Death);
                IndividualEventClass death2 = person2.GetEvent(IndividualEventClass.EventType.Death);

                DateMatch birthMatch = DateMatch.Unknown, deathMatch = DateMatch.Unknown;

                if ((birth1 != null) && (birth2 != null))
                {
                    birthMatch = MatchDates(birth1.GetDate(), birth2.GetDate());
                }
                if ((death1 != null) && (death2 != null))
                {
                    deathMatch = MatchDates(death1.GetDate(), death2.GetDate());
                }
                if ((birthMatch == DateMatch.Unknown) && (deathMatch == DateMatch.Unknown))
                {
                    return(false);
                }
                if ((birthMatch == DateMatch.Bad) || (deathMatch == DateMatch.Bad))
                {
                    return(false);
                }
                return((birthMatch == DateMatch.Good) || (deathMatch == DateMatch.Good));
            }
            return(false);
        }
Example #2
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);
        }
Example #3
0
        void AddPersonToListView(IndividualClass person)
        {
            string birthAddress          = "";
            string deathAddress          = "";
            IndividualEventClass birthEv = person.GetEvent(IndividualEventClass.EventType.Birth);

            if (birthEv != null)
            {
                AddressClass address = birthEv.GetAddress();
                if (address != null)
                {
                    birthAddress = address.ToString();
                }
            }
            IndividualEventClass deathEv = person.GetEvent(IndividualEventClass.EventType.Death);

            if (deathEv != null)
            {
                AddressClass address = deathEv.GetAddress();
                if (address != null)
                {
                    deathAddress = address.ToString();
                }
            }

            ListViewItem item = new ListViewItem(person.GetName());

            item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), birthAddress, person.GetDate(IndividualEventClass.EventType.Death).ToString(), deathAddress });
            item.Tag = person.GetXrefName();

            resultList.Items.Add(item);
        }
        string GetEventDateString(IndividualClass person, IndividualEventClass.EventType evType)
        {
            if (person != null)
            {
                IndividualEventClass ev = person.GetEvent(IndividualEventClass.EventType.Birth);

                if (ev != null)
                {
                    FamilyDateTimeClass date = ev.GetDate();

                    if (date != null)
                    {
                        return(date.ToString());
                    }
                }
            }
            return("");
        }
        private string CreateToolString()
        {
            IndividualEventClass ev;
            FamilyDateTimeClass  date;
            AddressClass         address;
            string str = "";

            str = individual.GetName() + "\n";

            ev = individual.GetEvent(IndividualEventClass.EventType.Birth);

            if (ev != null)
            {
                str += "Born ";

                date = ev.GetDate();

                if (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown)
                {
                    str += date.ToString();
                }
                address = ev.GetAddress();
                if (address != null)
                {
                    str += " in " + address.ToString();
                }
                else
                {
                    PlaceStructureClass place = ev.GetPlace();

                    if (place != null)
                    {
                        str += " in " + place.ToString();
                    }
                }
            }
            str += "\n";// Environment.NewLine;
            ev   = individual.GetEvent(IndividualEventClass.EventType.Death);

            if (ev != null)
            {
                str += "Died ";

                date = ev.GetDate();

                if (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown)
                {
                    str += date.ToString();
                }
                address = ev.GetAddress();
                if (address != null)
                {
                    str += " in " + address.ToString();
                }
                else
                {
                    PlaceStructureClass place = ev.GetPlace();

                    if (place != null)
                    {
                        str += " in " + place.ToString();
                    }
                }
            }
            {
                IList <NoteClass> noteList = individual.GetNoteList();

                if (noteList != null)
                {
                    foreach (NoteClass note in noteList)
                    {
                        if (note.note != null)
                        {
                            str += "\n";//Environment.NewLine;
                            str += note.note.Replace("\r\n", "\n").Replace("\n\n", "\n");
                            //trace.TraceInformation("ShowNote:" + note.note);
                        }
                    }
                }
            }

            //str = str.Replace("\r\n", "\n");
            //str = str.Replace("\n\r", "\n");
            return(str);
        }
        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");
            }
        }
Example #7
0
        private string CreateToolString()
        {
            IndividualEventClass ev;
            FamilyDateTimeClass  date;
            AddressClass         address;
            string str = "";

            if (individual == null)
            {
                return("Updating..." + xref);
            }
            str = individual.GetName() + " (" + xref + ")\n";

            ev = individual.GetEvent(IndividualEventClass.EventType.Birth);

            if (ev != null)
            {
                str += "Born ";

                date = ev.GetDate();

                if (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown)
                {
                    str += date.ToString();
                }
                address = ev.GetAddress();
                if (address != null)
                {
                    str += " in " + address.ToString();
                }
                else
                {
                    PlaceStructureClass place = ev.GetPlace();

                    if (place != null)
                    {
                        str += " in " + place.ToString();
                    }
                }
            }
            str += "\n";// Environment.NewLine;
            ev   = individual.GetEvent(IndividualEventClass.EventType.Death);

            if (ev != null)
            {
                str += "Died ";

                date = ev.GetDate();

                if (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown)
                {
                    str += date.ToString();
                }
                address = ev.GetAddress();
                if (address != null)
                {
                    str += " in " + address.ToString();
                }
                else
                {
                    PlaceStructureClass place = ev.GetPlace();

                    if (place != null)
                    {
                        str += " in " + place.ToString();
                    }
                }
            }
            {
                IList <FamilyXrefClass> childList = individual.GetFamilyChildList();
                int childFamilies = 0;

                if (childList != null)
                {
                    childFamilies = childList.Count;
                }
                IList <FamilyXrefClass> spouseList = individual.GetFamilySpouseList();
                int spouseFamilies = 0;

                if (spouseList != null)
                {
                    spouseFamilies = spouseList.Count;
                }
                str += "\nChild in " + childFamilies + " families and spouse in " + spouseFamilies + " families";
            }
            {
                IList <NoteClass> noteList = individual.GetNoteList();

                if (noteList != null)
                {
                    foreach (NoteClass note in noteList)
                    {
                        if (note.note != null)
                        {
                            str += "\n";//Environment.NewLine;
                            str += note.note.Replace("\r\n", "\n").Replace("\n\n", "\n");
                            //trace.TraceInformation("ShowNote:" + note.note);
                        }
                    }
                }
            }

            //str = str.Replace("\r\n", "\n");
            //str = str.Replace("\n\r", "\n");
            return(str);
        }