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);
        }
        IndividualEventClass DecodeEventType(string eventString, IndividualEventClass.EventType evType, bool note)
        {
            IndividualEventClass ev = new IndividualEventClass(evType);
            FamilyDateTimeClass  date;
            string tempString = eventString;

            date = ParseDateString(ref tempString);
            if (date != null)
            {
                ev.SetDate(date);
            }
            if (tempString.Length > 0)
            {
                if (note)
                {
                    ev.AddNote(new NoteClass(tempString));
                }
                else
                {
                    AddressClass address = new AddressClass();
                    address.AddAddressPart(AddressPartClass.AddressPartType.StreetAddress, tempString);
                    ev.AddAddress(address);
                }
            }
            trace.TraceInformation(evType + ":" + eventString + " => " + tempString + " " + ev);
            return(ev);
        }
Example #3
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 #4
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);
        }
Example #5
0
        private string CreateToolString()
        {
            string str = xref + "\n";

            if (family != null)
            {
                IndividualEventClass ev = family.GetEvent(IndividualEventClass.EventType.FamMarriage);

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

                    FamilyDateTimeClass date = ev.GetDate();

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

                        if (place != null)
                        {
                            str += " in " + place.ToString();
                        }
                    }
                    str += "\n";
                }
                IList <IndividualXrefClass> childList = family.GetChildList();
                int children = 0;

                if (childList != null)
                {
                    children = childList.Count;
                }
                IList <IndividualXrefClass> parentList = family.GetParentList();
                int parents = 0;

                if (parentList != null)
                {
                    parents = parentList.Count;
                }
                str += parents + " parents and " + children + " children";
            }

            return(str);
        }
        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("");
        }
        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");
            }
        }