예제 #1
0
        void SaveListConents()
        {
            SaveFileDialog fileDlg = new SaveFileDialog();

            fileDlg.Filter           = "Compare List|*.fsc";
            fileDlg.InitialDirectory = utility.GetCurrentDirectory();

            if (fileDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                FileStream saveList = new FileStream(fileDlg.FileName, FileMode.Create);

                SavedMatches           savedMatches = new SavedMatches();
                DataContractSerializer serializer   = new DataContractSerializer(typeof(SavedMatches));

                savedMatches.database1 = selectedForm1.Text;
                savedMatches.database2 = selectedForm2.Text;
                foreach (ListViewItem item in matchListView1.Items)
                {
                    DuplicateTreeItems matchingPersons = (DuplicateTreeItems)item.Tag;

                    savedMatches.itemList.Add(matchingPersons);
                }

                serializer.WriteObject(saveList, savedMatches);
                saveList.Close();
            }
        }
예제 #2
0
            public CompareTreeWorker(
                object sender,
                SavedMatches matches,
                AsyncWorkerProgress progress,
                FamilyTreeStoreBaseClass familyTree1,
                FamilyTreeStoreBaseClass familyTree2,
                ReportCompareResult resultReporter)
            {
                trace = new TraceSource("CompareTreeWorker", SourceLevels.All);

                resultReporterFunction = resultReporter;

                progressReporter = progress;
                this.matches     = matches;

                backgroundWorker = new BackgroundWorker();

                backgroundWorker.WorkerReportsProgress = true;
                if (matches == null)
                {
                    backgroundWorker.DoWork += new DoWorkEventHandler(DoWork);
                }
                else
                {
                    backgroundWorker.DoWork += new DoWorkEventHandler(DoWorkLoadFile);
                }

                backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Completed);
                backgroundWorker.ProgressChanged    += new ProgressChangedEventHandler(ProgressChanged);

                WorkerInterface workerInterface = new WorkerInterface();

                workerInterface.familyTree1 = familyTree1;
                workerInterface.familyTree2 = familyTree2;
                backgroundWorker.RunWorkerAsync(workerInterface);
            }
예제 #3
0
        void ExportListConents(bool html)
        {
            SaveFileDialog fileDlg = new SaveFileDialog();

            if (html)
            {
                fileDlg.Filter = "Compare List|*.html";
            }
            else
            {
                fileDlg.Filter = "Compare List|*.txt";
            }
            fileDlg.InitialDirectory = utility.GetCurrentDirectory();

            if (fileDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                //FileStream saveList = new FileStream(fileDlg.FileName, FileMode.Create);
                StreamWriter exportFile = new StreamWriter(fileDlg.FileName);

                bool found1 = false;
                bool found2 = false;
                FamilyTreeStoreBaseClass familyTree1 = null;
                FamilyTreeStoreBaseClass familyTree2 = null;

                SavedMatches matches = new SavedMatches();
                matches.database1 = selectedForm1.Text;
                matches.database2 = selectedForm2.Text;
                int i = 0;
                foreach (FamilyForm2 form in formList)
                {
                    if (matches.database1 == form.Text)
                    {
                        found1                 = true;
                        selectedForm1          = form;
                        familyTree1            = form.GetTree();
                        listBox1.SelectedIndex = i;
                    }
                    if (matches.database2 == form.Text)
                    {
                        found2                 = true;
                        selectedForm2          = form;
                        familyTree2            = form.GetTree();
                        listBox2.SelectedIndex = i;
                    }
                    i++;
                }

                if (found1 && found2)
                {
                    if (html)
                    {
                        exportFile.WriteLine("<!DOCTYPE html><html><head><title>List of possible duplicate people</title></head><body><table><tr><th>Name1 (Birth - Death)</th><th>Name2 (Birth - Death)</th></tr>\n");
                    }
                    else
                    {
                        exportFile.WriteLine("Url\tName\tBirth\tDeath\tUrl\tName\tBirth\tDeath");
                    }

                    foreach (ListViewItem item in matchListView1.Items)
                    {
                        DuplicateTreeItems matchingPersons = (DuplicateTreeItems)item.Tag;
                        IndividualClass    person1 = null, person2 = null;

                        person1 = familyTree1.GetIndividual(matchingPersons.item1);
                        person2 = familyTree2.GetIndividual(matchingPersons.item2);
                        if ((person1 != null) && (person2 != null))
                        {
                            if (html)
                            {
                                exportFile.WriteLine("\n<tr>\n");
                            }
                            FormatPerson(person1, html, exportFile);
                            FormatPerson(person2, html, exportFile);
                            if (html)
                            {
                                exportFile.WriteLine("\n</tr>\n");
                            }
                        }
                    }
                }

                if (html)
                {
                    exportFile.WriteLine("\n</table></body></html>");
                }
                exportFile.Close();
            }
        }