Esempio n. 1
0
        public static void CompareTrees(FamilyTreeStoreBaseClass familyTree1, FamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, ProgressReporterInterface reporter = null)
        {
            IEnumerator <IndividualClass> iterator1;
            int cnt1 = 0;

            iterator1 = familyTree1.SearchPerson(null, reporter);

            trace.TraceInformation("CompareTrees() started");

            if (iterator1 != null)
            {
                do
                {
                    IndividualClass person1 = iterator1.Current;

                    cnt1++;
                    if (person1 != null)
                    {
                        trace.TraceInformation(" 1:" + person1.GetName());
                        SearchDuplicates(person1, familyTree1, familyTree2, reportDuplicate, reporter);
                    }
                } while (iterator1.MoveNext());
                iterator1.Dispose();
            }
            else
            {
                trace.TraceInformation("iter=null");
            }
            trace.TraceInformation("CompareTrees() done");
        }
Esempio n. 2
0
        void SearchTree(FamilyTreeStoreBaseClass familyTree, String searchString)
        {
            IEnumerator <IndividualClass> iterator;


            iterator = familyTree.SearchPerson(searchString, progressReporter);

            if (iterator != null)
            {
                while (iterator.MoveNext())
                {
                    IndividualClass person = (IndividualClass)iterator.Current;

                    if (person != null)
                    {
                        AddToSearchResults(person);
                    }
                }
            }
        }
Esempio n. 3
0
        void StartSearch()
        {
            trace.TraceInformation("ComparePanel1::StartSearch()" + DateTime.Now);
            if (familyTree == null)
            {
                return;
            }

            //parentForm.
            //startButton.Enabled = false;
            //dateButton.Enabled = false;
            resultList.Items.Clear();

            trace.TraceInformation("search:" + searchTextBox.Text + " " + DateTime.Now);

            if (searchTextBox.Text.Length > 0)
            {
                IEnumerator <IndividualClass> iterator;
                searchTextBox.Items.Add(searchTextBox.Text);

                iterator = familyTree.SearchPerson(searchTextBox.Text);

                if (iterator != null)
                {
                    while (iterator.MoveNext())
                    {
                        IndividualClass person = (IndividualClass)iterator.Current;

                        if (person != null)
                        {
                            ListViewItem item = new ListViewItem(person.GetName());
                            item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), person.GetDate(IndividualEventClass.EventType.Death).ToString() });
                            item.Tag = person.GetXrefName();

                            resultList.Items.Add(item);
                        }
                    }
                }
            }
            trace.TraceInformation(" Database: " + familyTree.GetSourceFileName() + "  " + DateTime.Now);
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            String searchString = nameSearchTextBox.Text.ToUpper();

            //m_familyTree.SearchPerson("ekman");

            searchResultListBox.Items.Clear();

            if (m_familyTree != null)
            {
                IEnumerator <IndividualClass> iterator;
                iterator = m_familyTree.SearchPerson(searchString);

                trace.TraceInformation("dialog.ok");

                if (iterator != null)
                {
                    while (iterator.MoveNext())
                    {
                        IndividualClass indi = (IndividualClass)iterator.Current;

                        //trace.TraceInformation("iter:[" + indi.GetName() + "]");

                        searchResultListBox.Items.Add(indi.GetName());
                        //indi.Print();
                    }
                }
                else
                {
                    trace.TraceInformation("iter=null");
                }
                trace.TraceInformation("done");
            }

            //this.Close();
        }
Esempio n. 5
0
        public static void SearchDuplicates(IndividualClass person1, FamilyTreeStoreBaseClass familyTree1, FamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, ProgressReporterInterface reporter = 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 fullName = person1.GetName().Replace("*", "");
                IEnumerator <IndividualClass> iterator2 = familyTree2.SearchPerson(fullName);
                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))
                                {
                                    reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                }
                                cnt2++;
                            }
                        }
                    } while (iterator2.MoveNext());

                    iterator2.Dispose();
                    trace.TraceInformation(" " + fullName + " 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))
                                            {
                                                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))
                                            {
                                                reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                            }
                                        }
                                    }
                                } while (iterator3.MoveNext());
                                iterator3.Dispose();
                                trace.TraceInformation(" Married name " + marriedName + " matched to " + cnt3);
                            }
                        }
                    }
                }
            }
            else
            {
                trace.TraceInformation("No valid birth or death date for " + person1.GetName().ToString() + " skip duplicate search");
            }
        }
Esempio n. 6
0
        public bool DownloadImages2(FamilyTreeStoreBaseClass tree)
        {
            IEnumerator <IndividualClass> individualIterator = tree.SearchPerson();
            List <IndividualClass>        individualList     = new List <IndividualClass>();
            FamilyUtility utility = new FamilyUtility();

            String dirname = utility.GetCurrentDirectory() + "\\" + FamilyUtility.MakeFilename("ImageDownload_" + tree.GetSourceFileName() + "_" + DateTime.Now.ToString());

            Directory.CreateDirectory(dirname);

            List <String> endings = new List <string>();

            endings.Add("_large.jpg");
            endings.Add("_medium.jpg");
            endings.Add("_t.jpg");
            endings.Add("_t2.jpg");

            while (individualIterator.MoveNext())
            {
                individualList.Add(individualIterator.Current);
            }
            foreach (IndividualClass person in individualList)
            {
                IList <MultimediaLinkClass> links = person.GetMultimediaLinkList();

                IList <MultimediaLinkClass> newLinks = new List <MultimediaLinkClass>();
                IList <String> dlLinks     = new List <String>();
                IList <String> dlLinksBase = new List <String>();
                IList <String> dlLinksTrue = new List <String>();

                foreach (MultimediaLinkClass link in links)
                {
                    Boolean webimage = (link.GetLink().ToLower().IndexOf("http:") >= 0) || (link.GetLink().ToLower().IndexOf("https:") >= 0);

                    if (webimage)
                    {
                        dlLinks.Add(link.GetLink());
                    }
                }

                foreach (String link in dlLinks)
                {
                    String basename = link;

                    if (link.ToLower().IndexOf(".jpg") >= 0)
                    {
                        foreach (String ending in endings)
                        {
                            if (link.ToLower().IndexOf(ending) >= 0)
                            {
                                basename = link.Substring(0, link.ToLower().IndexOf(ending));

                                if (dlLinksBase.IndexOf(basename) < 0)
                                {
                                    dlLinksBase.Add(basename);
                                }
                            }
                        }
                    }
                }
                foreach (String link in dlLinksBase)
                {
                    int bestIndex = -1;
                    int index     = 0;
                    while ((bestIndex < 0) && (index < endings.Count))
                    {
                        String newLink = link + endings[index];
                        bestIndex = dlLinks.IndexOf(newLink);
                        dlLinksTrue.Add(newLink);
                        index++;
                    }
                }

                foreach (String link in dlLinksTrue)
                {
                    String filename = dirname + "\\" + FamilyUtility.MakeFilename(person.GetXrefName() + " " + person.GetName() + " " + GetLastPart(link));

                    if (filename.Length > 255)
                    {
                        filename = filename.Substring(0, 255);
                    }
                    filename = filename + ".jpg";
                    //trace.TraceInformation(filename);

                    if (SaveImageLocal(filename, link, ImageFormat.Jpeg))
                    {
                        newLinks.Add(new MultimediaLinkClass("image/jpeg", filename));
                    }
                }
                foreach (MultimediaLinkClass link in newLinks)
                {
                    person.AddMultimediaLink(link);
                }
            }

            return(true);
        }