Exemplo n.º 1
0
        private static void ConvertIdentifiers(GDMTree tree, IProgressController pc)
        {
            pc.ProgressInit(LangMan.LS(LSID.LSID_IDsCorrect), tree.RecordsCount * 2);
            GDMXRefReplacer repMap = new GDMXRefReplacer();

            try {
                int recsCount = tree.RecordsCount;
                for (int i = 0; i < recsCount; i++)
                {
                    GDMRecord rec = tree[i];
                    if (!CheckRecordXRef(rec))
                    {
                        string newXRef = tree.XRefIndex_NewXRef(rec);
                        repMap.AddXRef(rec, rec.XRef, newXRef);
                        rec.XRef = newXRef;
                    }
                    pc.ProgressStep();
                }

                tree.Header.ReplaceXRefs(repMap);
                for (int i = 0; i < recsCount; i++)
                {
                    GDMRecord rec = tree[i];
                    rec.ReplaceXRefs(repMap);
                    pc.ProgressStep();
                }
            } finally {
                repMap.Dispose();
                pc.ProgressDone();
            }
        }
Exemplo n.º 2
0
        private void ConvertIdentifiers()
        {
            fProgress.ProgressInit(LangMan.LS(LSID.LSID_IDsCorrect), fTree.RecordsCount * 2);
            GDMXRefReplacer repMap = new GDMXRefReplacer();

            try {
                int recsCount = fTree.RecordsCount;
                for (int i = 0; i < recsCount; i++)
                {
                    GDMRecord rec = fTree[i];
                    if (!CheckRecordXRef(rec))
                    {
                        string oldXRef = rec.XRef;
                        string newXRef = fTree.NewXRef(rec, true);
                        repMap.AddXRef(rec, oldXRef, newXRef);
                    }
                    fProgress.ProgressStep();
                }

                fTree.Header.ReplaceXRefs(repMap);
                for (int i = 0; i < recsCount; i++)
                {
                    GDMRecord rec = fTree[i];
                    rec.ReplaceXRefs(repMap);
                    fProgress.ProgressStep();
                }
            } finally {
                repMap.Dispose();
                fProgress.ProgressDone();
            }
        }
Exemplo n.º 3
0
        public override void ReplaceXRefs(GDMXRefReplacer map)
        {
            base.ReplaceXRefs(map);

            fNotes.ReplaceXRefs(map);
            fSourceCitations.ReplaceXRefs(map);
            fMultimediaLinks.ReplaceXRefs(map);
        }
Exemplo n.º 4
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();
            }
        }