Esempio n. 1
0
        public void CheckChangedRecord(GDMRecord record, bool active)
        {
            int idx = fChangedRecords.IndexOf(record);

            if (active)
            {
                if (idx < 0)
                {
                    fChangedRecords.Add(record);
                }
            }
            else
            {
                if (idx >= 0)
                {
                    fChangedRecords.RemoveAt(idx);
                }
            }
        }
Esempio n. 2
0
        private void CollectData()
        {
            int num = fBase.Context.Tree.RecordsCount;

            for (int i = 0; i < num; i++)
            {
                GDMRecord rec = fBase.Context.Tree[i];
                if (rec.RecordType != GDMRecordType.rtIndividual)
                {
                    continue;
                }

                GDMIndividualRecord iRec = (GDMIndividualRecord)rec;
                if (!iRec.HasEvents)
                {
                    continue;
                }

                for (int k = 0, evNum = iRec.Events.Count; k < evNum; k++)
                {
                    GDMCustomEvent ev      = iRec.Events[k];
                    var            evtType = ev.GetTagType();

                    if (evtType == GEDCOMTagType.BIRT || evtType == GEDCOMTagType.DEAT)
                    {
                        int year = ev.GetChronologicalYear();
                        if (year != 0)
                        {
                            if (fYearMin > year)
                            {
                                fYearMin = year;
                            }
                            if (fYearMax < year)
                            {
                                fYearMax = year;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void ReindexBase(IBaseWindow baseWin)
        {
            if (baseWin == null)
            {
                return;
            }

            try
            {
                lock (fLock)
                {
                    using (WritableDatabase database = new WritableDatabase(GetXDBFolder(), Xapian.Xapian.DB_CREATE_OR_OPEN))
                        using (TermGenerator indexer = new TermGenerator())
                            using (Stem stemmer = new Stem("russian"))
                            {
                                indexer.SetStemmer(stemmer);

                                IProgressController progress = AppHost.Progress;
                                progress.ProgressInit(fPlugin.LangMan.LS(TLS.LSID_SearchIndexRefreshing), baseWin.Context.Tree.RecordsCount);
                                int num = baseWin.Context.Tree.RecordsCount;
                                for (int i = 0; i < num; i++)
                                {
                                    GDMRecord record = baseWin.Context.Tree[i];
                                    if (IsIndexedRecord(record))
                                    {
                                        ReindexRecord(baseWin, database, indexer, record);
                                    }

                                    progress.ProgressStep();
                                }
                                progress.ProgressDone();

                                SetDBLastChange(baseWin, database);
                            }
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("SearchManager.ReindexBase(): " + ex.Message);
            }
        }
Esempio n. 4
0
        private static void CheckFamilyRecord(IBaseContext baseContext, GDMTree tree, GEDCOMFormat format,
                                              GDMFamilyRecord fam)
        {
            if (format == GEDCOMFormat.gf_Native)
            {
                int num = fam.Events.Count;
                for (int i = 0; i < num; i++)
                {
                    CheckEventPlace(fam.Events[i]);
                }
            }
            else
            {
                int num2 = fam.Events.Count;
                for (int i = 0; i < num2; i++)
                {
                    CheckTagWithLists(tree, format, fam.Events[i]);
                }
            }

            for (int i = fam.Children.Count - 1; i >= 0; i--)
            {
                if (fam.Children[i].Value == null)
                {
                    fam.Children.DeleteAt(i);
                }
            }

            GDMRecord val = fam.Husband.Value;

            if (!string.IsNullOrEmpty(fam.Husband.XRef) && val == null)
            {
                fam.Husband.Value = null;
            }

            val = fam.Wife.Value;
            if (!string.IsNullOrEmpty(fam.Wife.XRef) && val == null)
            {
                fam.Wife.Value = null;
            }
        }
Esempio n. 5
0
        private static void CheckPointerWithNotes(GDMTree tree, GEDCOMFormat format, GDMPointerWithNotes ptr)
        {
            // TODO: checkit!
            GDMRecord val = ptr.Value;

            if (!string.IsNullOrEmpty(ptr.XRef) && val == null)
            {
                ptr.Value = null;
            }

            int num = ptr.Notes.Count;

            for (int i = 0; i < num; i++)
            {
                GDMNotes note = ptr.Notes[i];
                if (!note.IsPointer)
                {
                    TransformNote(tree, note);
                }
            }
        }
Esempio n. 6
0
        public IList <ISearchResult> FindAll(string searchPattern)
        {
            List <ISearchResult> result = new List <ISearchResult>();

            Regex regex = GKUtils.InitMaskRegex(searchPattern);

            int num = fContentList.Count;

            for (int i = 0; i < num; i++)
            {
                GDMRecord rec = fContentList[i].Record;

                string recName = GKUtils.GetRecordName(fBaseContext.Tree, rec, false);
                if (GKUtils.MatchesRegex(recName, regex))
                {
                    result.Add(new SearchResult(rec));
                }
            }

            return(result);
        }
        public override bool Accept()
        {
            try {
                fFilter.BranchCut = (ChartFilter.BranchCutType)fView.GetCutModeRadio();
                if (fFilter.BranchCut == ChartFilter.BranchCutType.Years)
                {
                    fFilter.BranchYear = (int)fView.YearNum.Value;
                }
                else if (fFilter.BranchCut == ChartFilter.BranchCutType.Persons)
                {
                    fFilter.BranchPersons = fTemp;
                }

                int selectedIndex = fView.SourceCombo.SelectedIndex;
                if (selectedIndex >= 0 && selectedIndex < 3)
                {
                    fFilter.SourceMode = (FilterGroupMode)fView.SourceCombo.SelectedIndex;
                    fFilter.SourceRef  = "";
                }
                else
                {
                    GDMRecord rec = fView.SourceCombo.SelectedTag as GDMRecord;
                    if (rec != null)
                    {
                        fFilter.SourceMode = FilterGroupMode.Selected;
                        fFilter.SourceRef  = rec.XRef;
                    }
                    else
                    {
                        fFilter.SourceMode = FilterGroupMode.All;
                        fFilter.SourceRef  = "";
                    }
                }

                return(true);
            } catch (Exception ex) {
                Logger.LogWrite("TreeFilterDlgController.Accept(): " + ex.Message);
                return(false);
            }
        }
Esempio n. 8
0
        private void CheckRecord(GDMRecord rec, int fileVer)
        {
            CheckStructWL(rec);

            if (rec.HasUserReferences)
            {
                for (int i = 0, num = rec.UserReferences.Count; i < num; i++)
                {
                    CheckUserRef(rec, rec.UserReferences[i]);
                }
            }

            // TODO
            // INDI: remove AFN, RFN - discuss???
            // INDI,FAM: remove SUBM - discuss???

            switch (rec.RecordType)
            {
            case GDMRecordType.rtIndividual:
                CheckIndividualRecord(rec as GDMIndividualRecord);
                break;

            case GDMRecordType.rtFamily:
                CheckFamilyRecord(rec as GDMFamilyRecord);
                break;

            case GDMRecordType.rtGroup:
                CheckGroupRecord(rec as GDMGroupRecord);
                break;

            case GDMRecordType.rtSource:
                CheckSourceRecord(rec as GDMSourceRecord);
                break;

            case GDMRecordType.rtMultimedia:
                CheckMultimediaRecord(rec as GDMMultimediaRecord, fileVer);
                break;
            }
        }
Esempio n. 9
0
        private static void GetBackReferences(GDMRecord inRecord, GDMRecord subject, List <BackReference> list)
        {
            try {
                if (subject is GDMSourceRecord)
                {
                    int num = inRecord.SourceCitations.Count;
                    for (int i = 0; i < num; i++)
                    {
                        if (inRecord.SourceCitations[i].XRef == subject.XRef)
                        {
                            list.Add(new BackReference(inRecord.RecordType, inRecord.XRef, ""));
                        }
                    }

                    var recordWithEvents = inRecord as GDMRecordWithEvents;
                    if (recordWithEvents != null)
                    {
                        GDMRecordWithEvents evsRec = recordWithEvents;

                        num = evsRec.Events.Count;
                        for (int i = 0; i < num; i++)
                        {
                            var evt = evsRec.Events[i];

                            int num2 = evt.SourceCitations.Count;
                            for (int k = 0; k < num2; k++)
                            {
                                if (evt.SourceCitations[k].XRef == subject.XRef)
                                {
                                    list.Add(new BackReference(inRecord.RecordType, inRecord.XRef, evt.GetTagName()));
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.WriteError("GMHelper.GetBackReferences()", ex);
            }
        }
Esempio n. 10
0
        public override void UpdateView()
        {
            if (fTask == null)
            {
                fView.Priority.SelectedIndex = -1;
                fView.StartDate.Text         = "";
                fView.StopDate.Text          = "";
                fView.GoalType.SelectedIndex = 0;
                fView.Goal.Text = "";
            }
            else
            {
                fView.Priority.SelectedIndex = (sbyte)fTask.Priority;
                fView.StartDate.Text         = fTask.StartDate.GetDisplayString(DateFormat.dfDD_MM_YYYY);
                fView.StopDate.Text          = fTask.StopDate.GetDisplayString(DateFormat.dfDD_MM_YYYY);

                var goal = fTask.GetTaskGoal();
                fTempRec = goal.GoalRec;
                fView.GoalType.SelectedIndex = (sbyte)goal.GoalType;

                switch (goal.GoalType)
                {
                case GDMGoalType.gtIndividual:
                case GDMGoalType.gtFamily:
                case GDMGoalType.gtSource:
                    fView.Goal.Text = GKUtils.GetGoalStr(goal.GoalType, fTempRec);
                    break;

                case GDMGoalType.gtOther:
                    fView.Goal.Text = fTask.Goal;
                    break;
                }
            }

            fView.NotesList.ListModel.DataOwner = fTask;

            ChangeGoalType();
        }
Esempio n. 11
0
        public void SelectLink(string linkName)
        {
            if (linkName.StartsWith("http"))
            {
                GKUtils.LoadExtFile(linkName);
                return;
            }

            if (linkName.StartsWith("view_"))
            {
                string xref = linkName.Remove(0, 5);
                GDMMultimediaRecord mmRec = fBase.Context.Tree.XRefIndex_Find(xref) as GDMMultimediaRecord;
                if (mmRec != null)
                {
                    fBase.ShowMedia(mmRec, false);
                }
            }
            else
            {
                GDMRecord record = Base.Context.Tree.XRefIndex_Find(linkName);
                fView.HyperView.Lines.Assign(fBase.GetRecordContent(record));
            }
        }
Esempio n. 12
0
        public void Test_GetRecordName()
        {
            GDMRecord rec = fContext.Tree.XRefIndex_Find("I1");

            Assert.AreEqual("Ivanov Ivan Ivanovich", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("F1");
            Assert.AreEqual("Ivanov Ivan Ivanovich - Ivanova Maria Petrovna", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("G1");
            Assert.AreEqual("GroupTest", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("L1");
            Assert.AreEqual("Test Location", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("R1");
            Assert.AreEqual("Test repository", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("RS1");
            Assert.AreEqual("Test research", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("S1");
            Assert.AreEqual("Test source", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("N1");
            Assert.AreEqual("Test note", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("TK1");
            Assert.AreEqual("Test task", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("O1");
            Assert.AreEqual("Test multimedia", GKUtils.GetRecordName(rec, false));

            rec = fContext.Tree.XRefIndex_Find("CM1");
            Assert.AreEqual("Test communication", GKUtils.GetRecordName(rec, false));
        }
Esempio n. 13
0
        private void btnSetAll_Click(object sender, EventArgs e)
        {
            string folder = cmbSelectFolder.Text;

            if (fBase != null)
            {
                var tree = fBase.Context.Tree;

                int changed = 0;
                int num     = tree.RecordsCount;
                for (int i = 0; i < num; i++)
                {
                    GDMRecord rec = tree[i];
                    if (SetRecordFolder(rec, folder))
                    {
                        changed += 1;
                    }
                }
                AppHost.StdDialogs.ShowMessage(string.Format("Processed {0} record(s)", changed));

                ModifyBase();
                cmbSelectFolder.Text = "";
            }
        }
Esempio n. 14
0
        private static bool ChildSelectorHandler(GDMRecord record)
        {
            GDMIndividualRecord iRec = record as GDMIndividualRecord;

            return(iRec != null && iRec.ChildToFamilyLinks.Count == 0);
        }
Esempio n. 15
0
 public override void Fetch(GDMRecord aRec)
 {
     fRec = (aRec as GDMResearchRecord);
 }
Esempio n. 16
0
        public static void TreeSync(GDMTree mainTree, string fileName, TextBox logText)
        {
            logText.Clear();

            GDMTree              extTree  = new GDMTree();
            GDMXRefReplacer      repMap   = new GDMXRefReplacer();
            ExtList <SyncRecord> syncList = new ExtList <SyncRecord>(true);

            try {
                var gedcomProvider = new GEDCOMProvider(extTree);
                gedcomProvider.LoadFromFile(fileName);

                extTree.Header.Clear();

                for (int i = 0, num = extTree.RecordsCount; i < num; i++)
                {
                    GDMRecord rec = extTree[i];
                    syncList.Add(new SyncRecord {
                        MasterRecord  = null,
                        UpdateRecord  = rec,
                        State         = SyncState.ssUndefined,
                        UpdateOldXRef = "",
                        UpdateNewXRef = ""
                    });
                }

                for (int i = 0, num = syncList.Count; i < num; i++)
                {
                    SyncRecord syncRec = syncList[i];

                    GDMRecord rec = mainTree.FindUID(syncRec.UpdateRecord.UID);

                    if (rec != null)
                    {
                        syncRec.MasterRecord = rec;
                        syncRec.State        = SyncState.ssHasMaster;
                    }
                    else
                    {
                        syncRec.State = SyncState.ssNoMaster;
                        rec           = extTree.Extract(extTree.IndexOf(syncRec.UpdateRecord));
                        string newXRef = mainTree.XRefIndex_NewXRef(rec);
                        repMap.AddXRef(rec, rec.XRef, newXRef);
                        rec.XRef = newXRef;
                        rec.ResetOwner(mainTree);
                        mainTree.AddRecord(rec);
                    }
                }

                for (int i = 0, num = repMap.Count; i < num; i++)
                {
                    GDMRecord rec = repMap[i].Rec;
                    rec.ReplaceXRefs(repMap);
                }

                for (int i = 0, num = extTree.RecordsCount; i < num; i++)
                {
                    GDMRecord rec = extTree[i];
                    rec.ReplaceXRefs(repMap);
                }

                for (int i = 0, num = syncList.Count; i < num; i++)
                {
                    SyncRecord syncRec = syncList[i];
                    if (syncRec.State == SyncState.ssHasMaster)
                    {
                        GDMRecord rec = extTree.Extract(extTree.IndexOf(syncRec.UpdateRecord));
                        rec.XRef = mainTree.XRefIndex_NewXRef(rec);
                        rec.ResetOwner(mainTree);
                        mainTree.AddRecord(rec);
                        string backUID = syncRec.MasterRecord.UID;
                        syncRec.UpdateRecord.MoveTo(syncRec.MasterRecord, true);
                        syncRec.MasterRecord.UID = backUID;
                        mainTree.DeleteRecord(rec);
                    }
                }

                logText.AppendText("Sync finished\r\n");
            } finally {
                syncList.Dispose();
                repMap.Dispose();
                extTree.Dispose();
            }
        }
Esempio n. 17
0
        private static void ReindexRecord(IBaseWindow baseWin, WritableDatabase database, TermGenerator indexer, GDMRecord record)
        {
            uint docid = FindDocId(baseWin, database, record.XRef);

            if (docid != 0)
            {
                // checking for needed updates
                string recLastchange = record.ChangeDate.ToString();
                string docLastchange;

                using (Document curDoc = database.GetDocument(docid)) {
                    docLastchange = curDoc.GetValue(0);
                }

                // updating a record
                if (!string.Equals(recLastchange, docLastchange))
                {
                    using (Document doc = new Document())
                    {
                        if (SetDocumentContext(baseWin, doc, indexer, record))
                        {
                            database.ReplaceDocument(docid, doc);
                        }
                    }
                }
            }
            else
            {
                // only adding
                using (Document doc = new Document())
                {
                    if (SetDocumentContext(baseWin, doc, indexer, record))
                    {
                        database.AddDocument(doc);
                    }
                }
            }
        }
Esempio n. 18
0
 public string GetRecordName(GDMRecord record, bool signed)
 {
     return(string.Empty);
 }
Esempio n. 19
0
 public bool RecordIsFiltered(GDMRecord record)
 {
     return(false);
 }
Esempio n. 20
0
        public static bool CheckGEDCOMFormat(GDMTree tree, IBaseContext baseContext, IProgressController pc)
        {
            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            if (baseContext == null)
            {
                throw new ArgumentNullException("baseContext");
            }

            if (pc == null)
            {
                throw new ArgumentNullException("pc");
            }

            bool result = false;

            try {
                GEDCOMFormat format = GEDCOMProvider.GetGEDCOMFormat(tree);
                int          fileVer;
                // remove a deprecated features
                if (format == GEDCOMFormat.gf_Native)
                {
                    GDMHeader header = tree.Header;
                    GDMTag    tag;

                    tag = header.FindTag("_ADVANCED", 0);
                    if (tag != null)
                    {
                        header.DeleteTag("_ADVANCED");
                    }

                    tag = header.FindTag("_EXT_NAME", 0);
                    if (tag != null)
                    {
                        header.DeleteTag("_EXT_NAME");
                    }

                    fileVer = ConvertHelper.ParseInt(header.Source.Version, GKData.APP_FORMAT_DEFVER);
                }
                else
                {
                    fileVer = -1;
                }

                pc.ProgressInit(LangMan.LS(LSID.LSID_FormatCheck), 100);
                try {
                    bool xrefValid    = true;
                    bool isExtraneous = (format != GEDCOMFormat.gf_Native);

                    int progress = 0;
                    int num      = tree.RecordsCount;
                    for (int i = 0; i < num; i++)
                    {
                        GDMRecord rec = tree[i];
                        CheckRecord(baseContext, tree, rec, format, fileVer);

                        if (isExtraneous && xrefValid && !CheckRecordXRef(rec))
                        {
                            xrefValid = false;
                        }

                        int newProgress = (int)Math.Min(100, ((i + 1) * 100.0f) / num);
                        if (progress != newProgress)
                        {
                            progress = newProgress;
                            pc.ProgressStep(progress);
                        }
                    }

                    // obsolete: AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_IDsCorrectNeed))
                    if (!xrefValid)
                    {
                        ConvertIdentifiers(tree, pc);
                    }

                    result = true;
                } finally {
                    pc.ProgressDone();
                }
            } catch (Exception ex) {
                Logger.LogWrite("GEDCOMChecker.CheckGEDCOMFormat(): " + ex.Message);
                AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_CheckGedComFailed));
            }

            return(result);
        }
Esempio n. 21
0
        private static bool SetDocumentContext(IBaseWindow baseWin, Document doc, TermGenerator indexer, GDMRecord rec)
        {
            StringList ctx = baseWin.GetRecordContent(rec);

            if (ctx == null)
            {
                return(false);
            }

            string recLastchange = rec.ChangeDate.ToString();
            string baseSign      = GetSign(baseWin);

            doc.SetData(rec.XRef);                              // not edit: for link from search results to gedcom-base
            doc.AddTerm("Q" + baseSign + "_" + rec.XRef);       // not edit: specific db_rec_id - for FindDocId()
            doc.AddValue(0, recLastchange);                     // not edit: for update check
            doc.AddBooleanTerm("GDB" + baseSign);               // not edit: for filtering by database in Search()

            indexer.SetDocument(doc);
            indexer.IndexText(ctx.Text);

            return(true);
        }
Esempio n. 22
0
 private static bool IsIndexedRecord(GDMRecord rec)
 {
     return(!((rec is GDMLocationRecord || rec is GDMGroupRecord)));
 }
Esempio n. 23
0
 public StringList GetRecordContent(GDMRecord record)
 {
     return(fController.GetRecordContent(record));
 }
Esempio n. 24
0
 public void ChangeRecord(GDMRecord record)
 {
 }
Esempio n. 25
0
 public void NotifyRecord(GDMRecord record, RecordAction action)
 {
 }
Esempio n. 26
0
 private bool TestExternalFilterHandler(GDMRecord record)
 {
     return(false);
 }
Esempio n. 27
0
 public StringList GetRecordContent(GDMRecord record)
 {
     return(null);
 }
Esempio n. 28
0
 private bool ExtFilterHandler(GDMRecord record)
 {
     return(true);
 }
Esempio n. 29
0
 public void SelectByRec(GDMRecord record)
 {
 }
Esempio n. 30
0
 public bool RecordIsFiltered(GDMRecord record)
 {
     return(fController.RecordIsFiltered(record));
 }