Exemplo n.º 1
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.º 2
0
        private bool LoadRawWord()
        {
            SourceType = SourceType.stText;

            try
            {
                MSOWord.Application wordApp;
                try
                {
                    wordApp = new MSOWord.Application();
                }
                catch
                {
                    return(false);
                }

                IProgressController progress = AppHost.Progress;
                try
                {
                    wordApp.Visible     = DEBUG_WORD;
                    wordApp.WindowState = MSOWord.WdWindowState.wdWindowStateMaximize;

                    MSOWord.Document doc = wordApp.Documents.Open(fFileName);

                    progress.ProgressInit(fLangMan.LS(ILS.LSID_Loading), doc.Paragraphs.Count);

                    int lineNum = 0;
                    for (int i = 0; i < doc.Paragraphs.Count; i++)
                    {
                        string txt = doc.Paragraphs[i + 1].Range.Text;
                        txt = txt.Trim();

                        if (!string.IsNullOrEmpty(txt))
                        {
                            fRawContents.AddObject(txt, new RawLine(lineNum));
                        }

                        progress.ProgressStep(i + 1);
                        lineNum++;
                    }
                    fRawContents.AddObject("", new RawLine(lineNum));

                    return(AnalyseRaw());
                }
                finally
                {
                    progress.ProgressDone();

                    object saveOptionsObject = MSOWord.WdSaveOptions.wdDoNotSaveChanges;
                    wordApp.Quit(ref saveOptionsObject);
                    wordApp = null;
                }
            }
            catch (Exception ex)
            {
                fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_DataLoadError));
                Logger.LogWrite("Importer.LoadRawWord(): " + ex.Message);
                return(false);
            }
        }
Exemplo n.º 3
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.º 4
0
        public static ExtList <PatriarchObj> GetPatriarchsLinks(IBaseContext context,
                                                                int gensMin, bool datesCheck,
                                                                bool loneSuppress)
        {
            ExtList <PatriarchObj> patList = GetPatriarchsList(context, gensMin, datesCheck);

            IProgressController progress = AppHost.Progress;

            progress.ProgressInit(LangMan.LS(LSID.LSID_LinksSearch), patList.Count);
            try
            {
                int num2 = patList.Count;
                for (int i = 0; i < num2; i++)
                {
                    PatriarchObj patr = patList[i];

                    for (int j = i + 1; j < num2; j++)
                    {
                        PatriarchObj patr2 = patList[j];

                        GEDCOMIndividualRecord cross = TreeTools.PL_SearchDesc(patr.IRec, patr2.IRec);
                        if (cross != null)
                        {
                            patr.HasLinks  = true;
                            patr2.HasLinks = true;

                            if (cross.Sex == GEDCOMSex.svFemale)
                            {
                                patr.Links.Add(patr2);
                            }
                            else
                            {
                                patr2.Links.Add(patr);
                            }
                        }
                    }

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

            if (loneSuppress)
            {
                for (int i = patList.Count - 1; i >= 0; i--)
                {
                    PatriarchObj patr = patList[i];
                    if (!patr.HasLinks)
                    {
                        patList.Delete(i);
                    }
                }
                patList.Pack();
            }

            return(patList);
        }
Exemplo n.º 5
0
        // TODO: localize filter?
        public void WriteStatsReport(string title, string cap1, string cap2, List <StatsItem> vals)
        {
#if !NETSTANDARD
            if (vals == null)
            {
                return;
            }

            string fileName = AppHost.StdDialogs.GetSaveFile("", "", "Excel files (*.xls)|*.xls", 1, "xls", "");
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            IProgressController progress = AppHost.Progress;
            try
            {
                int rowsCount = vals.Count;
                progress.ProgressInit(LangMan.LS(LSID.LSID_MIExport) + "...", rowsCount);

                try
                {
                    Workbook  workbook  = new Workbook();
                    Worksheet worksheet = new Worksheet(title);

                    worksheet.Cells[0, 1] = new Cell(cap1);
                    worksheet.Cells[0, 2] = new Cell(cap2);

                    int row = 1;
                    for (int i = 0; i < rowsCount; i++)
                    {
                        StatsItem item = vals[i];
                        worksheet.Cells[row, 1] = new Cell(item.Caption);
                        worksheet.Cells[row, 2] = new Cell(item.GetDisplayString());

                        row++;
                        progress.ProgressStep();
                    }

                    workbook.Worksheets.Add(worksheet);
                    workbook.Save(fileName);

                    if (File.Exists(fileName))
                    {
                        Process.Start(fileName);
                    }
                }
                finally
                {
                    progress.ProgressDone();
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreeStats.WriteStatsReport(): " + ex.Message);
                AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_UploadErrorInExcel));
            }
#endif
        }
Exemplo n.º 6
0
        public static ExtList <PatriarchObj> GetPatriarchsList(IBaseContext context,
                                                               int gensMin, bool datesCheck)
        {
            ExtList <PatriarchObj> patList = new ExtList <PatriarchObj>(true);

            IProgressController progress = AppHost.Progress;

            progress.ProgressInit(LangMan.LS(LSID.LSID_PatSearch), context.Tree.RecordsCount);

            GKUtils.InitExtCounts(context.Tree, -1);
            try
            {
                int num = context.Tree.RecordsCount;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMRecord rec = context.Tree[i];

                    if (rec is GEDCOMIndividualRecord)
                    {
                        GEDCOMIndividualRecord iRec = rec as GEDCOMIndividualRecord;

                        var parts = GKUtils.GetNameParts(iRec);

                        int birthDate = context.FindBirthYear(iRec);
                        int descGens  = GKUtils.GetDescGenerations(iRec);

                        bool res = (iRec.ChildToFamilyLinks.Count == 0);
                        res = (res && iRec.Sex == GEDCOMSex.svMale);
                        res = (res && /*nf != "" && nf != "?" &&*/ parts.Name != "" && parts.Name != "?");
                        res = (res && descGens >= gensMin);

                        if (datesCheck)
                        {
                            res = (res && birthDate != 0);
                        }

                        if (res)
                        {
                            PatriarchObj pObj = new PatriarchObj();
                            pObj.IRec             = iRec;
                            pObj.BirthYear        = birthDate;
                            pObj.DescendantsCount = GKUtils.GetDescendantsCount(iRec) - 1;
                            pObj.DescGenerations  = descGens;
                            patList.Add(pObj);
                        }
                    }

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

            return(patList);
        }
Exemplo n.º 7
0
        private bool LoadRawText()
        {
            SourceType = SourceType.stText;

            try
            {
                using (StreamReader strd = new StreamReader(fFileName, Encoding.GetEncoding(1251)))
                {
                    IProgressController progress = AppHost.Progress;
                    try
                    {
                        progress.ProgressInit(fLangMan.LS(ILS.LSID_Loading), (int)strd.BaseStream.Length);

                        int lineNum = 0;
                        while (strd.Peek() != -1)
                        {
                            string txt = strd.ReadLine().Trim();

                            if (!string.IsNullOrEmpty(txt))
                            {
                                fRawContents.AddObject(txt, new RawLine(lineNum));
                            }

                            progress.ProgressStep((int)strd.BaseStream.Position);
                            lineNum++;
                        }
                        fRawContents.AddObject("", new RawLine(lineNum));
                    }
                    finally
                    {
                        progress.ProgressDone();
                    }
                }

                return(AnalyseRaw());
            }
            catch (Exception ex)
            {
                fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_DataLoadError));
                Logger.LogWrite("Importer.LoadRawText(): " + ex.Message);
                return(false);
            }
        }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
0
        private void CheckGroups()
        {
            IProgressController progress = AppHost.Progress;

            gkLogChart1.Clear();
            tvGroups.DataStore = null;

            progress.ProgressInit(LangMan.LS(LSID.LSID_CheckFamiliesConnection), fTree.RecordsCount);
            List <GEDCOMIndividualRecord> prepared     = new List <GEDCOMIndividualRecord>();
            List <GEDCOMRecord>           groupRecords = new List <GEDCOMRecord>();

            try
            {
                var rootItem = new TreeItem();

                int groupNum = 0;

                int num = fTree.RecordsCount;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMRecord rec = fTree[i];

                    if (rec.RecordType == GEDCOMRecordType.rtIndividual)
                    {
                        GEDCOMIndividualRecord iRec = rec as GEDCOMIndividualRecord;
                        if (prepared.IndexOf(iRec) < 0)
                        {
                            groupNum++;
                            groupRecords.Clear();

                            TreeTools.WalkTree(iRec, TreeTools.TreeWalkMode.twmAll, groupRecords);

                            int cnt = groupRecords.Count;

                            TreeItem groupItem = new TreeItem();
                            groupItem.Text = groupNum.ToString() + " " + LangMan.LS(LSID.LSID_Group).ToLower() + " (" + cnt.ToString() + ")";
                            rootItem.Children.Add(groupItem);

                            for (int j = 0; j < cnt; j++)
                            {
                                iRec = (GEDCOMIndividualRecord)groupRecords[j];
                                prepared.Add(iRec);

                                string pn = GKUtils.GetNameString(iRec, true, false);
                                if (iRec.Patriarch)
                                {
                                    pn = "(*) " + pn;
                                }

                                groupItem.Children.Add(new GKTreeNode(pn, iRec));
                            }
                            groupItem.Expanded = true;

                            gkLogChart1.AddFragment(cnt);
                        }
                    }

                    progress.ProgressStep();
                }

                tvGroups.DataStore = rootItem;
                tvGroups.RefreshData();
            }
            finally
            {
                groupRecords.Clear();
                //prepared.Dispose();
                progress.ProgressDone();
            }
        }
Exemplo n.º 10
0
        private bool ImportTableContent()
        {
            try
            {
                fLog.Clear();

                MSOExcel.Application excel;
                try
                {
                    excel = new MSOExcel.Application();
                }
                catch (Exception)
                {
                    return(false);
                }

                excel.Visible       = DEBUG_EXCEL;
                excel.DisplayAlerts = false;
                excel.WindowState   = MSOExcel.XlWindowState.xlMaximized;
                excel.Workbooks.Open(fFileName);
                MSOExcel.Worksheet sheet = excel.Worksheets[1] as MSOExcel.Worksheet;
                //sheet.Activate();

                IProgressController progress = AppHost.Progress;
                StringList          buffer   = new StringList();
                try
                {
                    int rowsCount = sheet.UsedRange.Rows.Count;
                    //int colsCount = sheet.UsedRange.Columns.Count;

                    progress.ProgressInit(fLangMan.LS(ILS.LSID_Loading), rowsCount);

                    MSOExcel.Range excelRange = sheet.UsedRange;
                    object[,] valueArray = (object[, ])excelRange.get_Value(MSOExcel.XlRangeValueDataType.xlRangeValueDefault);

                    int prevId = 0;

                    for (int row = 1; row <= rowsCount; row++)
                    {
                        string c1 = GetCell(valueArray, row, 1).Trim(); // position number
                        string c2 = GetCell(valueArray, row, 2).Trim(); // ancestor number
                        string c3 = GetCell(valueArray, row, 3).Trim(); // name, maybe start with the number of marriage
                        string c4 = GetCell(valueArray, row, 4).Trim(); // birth date
                        string c5 = GetCell(valueArray, row, 5).Trim(); // death date
                        string c6 = GetCell(valueArray, row, 6).Trim(); // birth or residence place

                        string s123 = c1 + c2;
                        if (s123 != "" && !string.IsNullOrEmpty(c3) && c3[0] != '/')
                        {
                            s123 += ". " + c3;
                        }
                        else
                        {
                            s123 += c3;
                        }

                        if (s123 == "")
                        {
                            continue;
                        }

                        string      line, p_id = "";
                        RawLineType lineType = RawLineType.rltComment;

                        if (IsGenerationLine(s123))
                        {
                            line     = s123;
                            lineType = RawLineType.rltRomeGeneration;
                        }
                        else
                        {
                            line = s123 + " " + c4 + " " + c5;
                            if (c6 != "")
                            {
                                line = line + ". " + c6 + ".";
                            }

                            line = line.Trim();

                            p_id = IsPersonLine(line);
                            if (!string.IsNullOrEmpty(p_id))
                            {
                                lineType = RawLineType.rltPerson;
                            }
                        }

                        switch (lineType)
                        {
                        case RawLineType.rltComment:
                            buffer.Add(line);
                            break;

                        case RawLineType.rltPerson:
                        case RawLineType.rltRomeGeneration:
                        case RawLineType.rltEOF:
                        {
                            prevId = ParseBuffer(buffer);
                            buffer.Clear();

                            switch (lineType)
                            {
                            case RawLineType.rltPerson:
                                buffer.Add(line);
                                break;

                            case RawLineType.rltRomeGeneration:
                                fLog.Add("> " + fLangMan.LS(ILS.LSID_Generation) + " \"" + line + "\"");
                                break;

                            case RawLineType.rltEOF:
                                fLog.Add("> EOF.");
                                break;
                            }
                        }
                        break;
                        }

                        progress.ProgressStep(row);
                    }

                    // hack: processing last items before end
                    prevId = ParseBuffer(buffer);

                    return(true);
                }
                finally
                {
                    progress.ProgressDone();

                    buffer.Dispose();

                    excel.Quit();
                    excel = null;
                }
            }
            catch (Exception ex)
            {
                fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_DataLoadError));
                Logger.LogWrite("Importer.ImportTableContent(): " + ex.Message);
                return(false);
            }
        }
Exemplo n.º 11
0
        private bool AnalyseRaw()
        {
            if (SourceType == SourceType.stTable)
            {
                return(false);
            }

            try
            {
                IProgressController progress = AppHost.Progress;

                try
                {
                    int[] numberStats = new int[3];

                    int num = fRawContents.Count;
                    progress.ProgressInit(fLangMan.LS(ILS.LSID_Analysis), num);

                    for (int i = 0; i < num; i++)
                    {
                        string  txt     = fRawContents[i].Trim();
                        RawLine rawLine = (RawLine)fRawContents.GetObject(i);

                        if (!string.IsNullOrEmpty(txt))
                        {
                            if (IsGenerationLine(txt))
                            {
                                rawLine.Type = RawLineType.rltRomeGeneration;
                            }
                            else
                            {
                                PersonNumbersType numbType = PersonNumbersType.pnUndefined;

                                if (!string.IsNullOrEmpty(ImportUtils.IsPersonLine_DAboville(txt)))
                                {
                                    rawLine.Type = RawLineType.rltPerson;
                                    numbType     = PersonNumbersType.pnDAboville;
                                    numberStats[1]++;
                                }
                                else if (!string.IsNullOrEmpty(ImportUtils.IsPersonLine_Konovalov(txt)))
                                {
                                    rawLine.Type = RawLineType.rltPerson;
                                    numbType     = PersonNumbersType.pnKonovalov;
                                    numberStats[2]++;
                                }

                                rawLine.NumbersType = numbType;
                            }
                        }
                        else
                        {
                            rawLine.Type = RawLineType.rltEOF;
                        }

                        progress.ProgressStep(i + 1);
                    }

                    if (numberStats[1] > numberStats[2])
                    {
                        CanNumbersType = PersonNumbersType.pnDAboville;
                    }
                    else
                    {
                        CanNumbersType = PersonNumbersType.pnKonovalov;
                    }

                    return(true);
                }
                finally
                {
                    progress.ProgressDone();
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("Importer.AnalyseRaw(): " + ex.Message);
                return(false);
            }
        }
Exemplo n.º 12
0
        private void PlacesLoad()
        {
            try
            {
                IProgressController progress = AppHost.Progress;

                fMapBrowser.InitMap();

                //cmbPersons.BeginUpdate();
                //tvPlaces.BeginUpdate();
                tvPlaces.DataStore = null;
                progress.ProgressInit(LangMan.LS(LSID.LSID_LoadingLocations), fTree.RecordsCount);
                try
                {
                    fPlaces.Clear();
                    cmbPersons.Items.Clear();
                    //cmbPersons.Sorted = false;
                    cmbPersons.Items.Add(new GKComboItem(LangMan.LS(LSID.LSID_NotSelected), null));

                    int num = fTree.RecordsCount;
                    for (int i = 0; i < num; i++)
                    {
                        GEDCOMRecord rec = fTree[i];
                        bool         res = rec is GEDCOMIndividualRecord && IsSelected(rec);

                        if (res)
                        {
                            GEDCOMIndividualRecord ind = rec as GEDCOMIndividualRecord;
                            int pCnt = 0;

                            int num2 = ind.Events.Count;
                            for (int j = 0; j < num2; j++)
                            {
                                GEDCOMCustomEvent ev = ind.Events[j];
                                if (ev.Place.StringValue != "")
                                {
                                    AddPlace(ev.Place, ev);
                                    pCnt++;
                                }
                            }

                            if (pCnt > 0)
                            {
                                cmbPersons.Items.Add(new GKComboItem(GKUtils.GetNameString(ind, true, false) + " [" + pCnt.ToString() + "]", ind));
                            }
                        }

                        progress.ProgressStep();
                    }

                    fBaseRoot.Expanded = true; //ExpandAll();
                    //cmbPersons.Sorted = true;

                    btnSelectPlaces.Enabled = true;
                }
                finally
                {
                    progress.ProgressDone();
                    //tvPlaces.EndUpdate();
                    //cmbPersons.EndUpdate();
                    tvPlaces.DataStore = fBaseRoot;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("MapsViewerWin.PlacesLoad(): " + ex.Message);
            }
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public override void Generate(bool show)
        {
#if !NETSTANDARD
            fPath = AppHost.StdDialogs.GetSaveFile("Excel files (*.xls)|*.xls");
            if (string.IsNullOrEmpty(fPath))
            {
                return;
            }

            Workbook  workbook  = new Workbook();
            Worksheet worksheet = new Worksheet("First Sheet");

            IProgressController progress = AppHost.Progress;
            progress.ProgressInit(LangMan.LS(LSID.LSID_MIExport) + "...", fTree.RecordsCount);

            var dateFormat = GlobalOptions.Instance.DefDateFormat;
            try
            {
                worksheet.Cells[1, 1]  = new Cell("№");
                worksheet.Cells[1, 2]  = new Cell(LangMan.LS(LSID.LSID_Surname));
                worksheet.Cells[1, 3]  = new Cell(LangMan.LS(LSID.LSID_Name));
                worksheet.Cells[1, 4]  = new Cell(LangMan.LS(LSID.LSID_Patronymic));
                worksheet.Cells[1, 5]  = new Cell(LangMan.LS(LSID.LSID_Sex));
                worksheet.Cells[1, 6]  = new Cell(LangMan.LS(LSID.LSID_BirthDate));
                worksheet.Cells[1, 7]  = new Cell(LangMan.LS(LSID.LSID_DeathDate));
                worksheet.Cells[1, 8]  = new Cell(LangMan.LS(LSID.LSID_BirthPlace));
                worksheet.Cells[1, 9]  = new Cell(LangMan.LS(LSID.LSID_DeathPlace));
                worksheet.Cells[1, 10] = new Cell(LangMan.LS(LSID.LSID_Residence));
                worksheet.Cells[1, 11] = new Cell(LangMan.LS(LSID.LSID_Age));
                worksheet.Cells[1, 12] = new Cell(LangMan.LS(LSID.LSID_LifeExpectancy));

                ushort row = 1;
                int    num = fTree.RecordsCount;
                for (int i = 0; i < num; i++)
                {
                    GDMRecord rec = fTree[i];
                    if (rec.RecordType == GDMRecordType.rtIndividual)
                    {
                        GDMIndividualRecord ind = (GDMIndividualRecord)rec;

                        if (fSelectedRecords == null || fSelectedRecords.IndexOf(rec) >= 0)
                        {
                            var parts = GKUtils.GetNameParts(ind);

                            string sx = "" + GKUtils.SexStr(ind.Sex)[0];
                            row++;

                            worksheet.Cells[row, 1]  = new Cell(ind.GetXRefNum());
                            worksheet.Cells[row, 2]  = new Cell(parts.Surname);
                            worksheet.Cells[row, 3]  = new Cell(parts.Name);
                            worksheet.Cells[row, 4]  = new Cell(parts.Patronymic);
                            worksheet.Cells[row, 5]  = new Cell(sx);
                            worksheet.Cells[row, 6]  = new Cell(GKUtils.GetBirthDate(ind, dateFormat, false));
                            worksheet.Cells[row, 7]  = new Cell(GKUtils.GetDeathDate(ind, dateFormat, false));
                            worksheet.Cells[row, 8]  = new Cell(GKUtils.GetBirthPlace(ind));
                            worksheet.Cells[row, 9]  = new Cell(GKUtils.GetDeathPlace(ind));
                            worksheet.Cells[row, 10] = new Cell(GKUtils.GetResidencePlace(ind, fOptions.PlacesWithAddress));
                            worksheet.Cells[row, 11] = new Cell(GKUtils.GetAge(ind, -1));
                            worksheet.Cells[row, 12] = new Cell(GKUtils.GetLifeExpectancy(ind));
                        }
                    }

                    progress.ProgressStep();
                }

                workbook.Worksheets.Add(worksheet);
                workbook.Save(fPath);

                #if !CI_MODE
                if (show)
                {
                    ShowResult();
                }
                #endif
            }
            finally
            {
                progress.ProgressDone();
            }
#endif
        }
Exemplo n.º 15
0
        public static Graph GetPatriarchsGraph(IBaseContext context, int gensMin,
                                               bool datesCheck, bool loneSuppress)
        {
            Graph graph = new Graph();

            try
            {
                using (ExtList <PatriarchObj> patList = GetPatriarchsList(context, gensMin, datesCheck))
                {
                    // init
                    GKUtils.InitExtData(context.Tree);

                    // prepare
                    int count = patList.Count;
                    for (int i = 0; i < count; i++)
                    {
                        PatriarchObj           patNode = patList[i];
                        GEDCOMIndividualRecord iRec    = patNode.IRec;

                        int count2 = iRec.SpouseToFamilyLinks.Count;
                        for (int k = 0; k < count2; k++)
                        {
                            GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[k].Family;
                            family.ExtData = new PGNode(family.XRef, PGNodeType.Patriarch, patNode.DescGenerations);
                        }
                    }

                    IProgressController progress = AppHost.Progress;
                    try
                    {
                        int patCount = patList.Count;
                        progress.ProgressInit(LangMan.LS(LSID.LSID_LinksSearch), patCount);

                        for (int i = 0; i < patCount; i++)
                        {
                            PatriarchObj patr = patList[i];

                            for (int j = i + 1; j < patCount; j++)
                            {
                                PatriarchObj patr2 = patList[j];

                                GEDCOMFamilyRecord cross = TreeTools.PL_SearchIntersection(patr.IRec, patr2.IRec);

                                if (cross != null)
                                {
                                    PGNode node = (PGNode)cross.ExtData;

                                    if (node != null && node.Type == PGNodeType.Patriarch)
                                    {
                                        // dummy
                                    }
                                    else
                                    {
                                        int size = GKUtils.GetDescGenerations(cross.GetHusband());
                                        if (size == 0)
                                        {
                                            size = 1;
                                        }
                                        cross.ExtData = new PGNode(cross.XRef, PGNodeType.Intersection, size);
                                    }
                                }
                            }

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

                    // create graph
                    int count3 = patList.Count;
                    for (int i = 0; i < count3; i++)
                    {
                        PatriarchObj patNode = patList[i];
                        PL_WalkDescLinks(graph, null, patNode.IRec);
                    }

                    // clear
                    GKUtils.InitExtData(context.Tree);

                    /*if (gpl_params.aLoneSuppress) {
                     *          for (int i = aList.Count - 1; i >= 0; i--) {
                     *                  PatriarchObj patr = aList[i] as PatriarchObj;
                     *                  if (patr.ILinks.Count == 0) aList.Delete(i);
                     *          }
                     *          aList.Pack();*/
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("PatriarchsMan.GetPatriarchsGraph(): " + ex.Message);
            }

            return(graph);
        }
Exemplo n.º 16
0
        public void LoadPlaces()
        {
            try {
                PlacesCache.Instance.Load();

                IProgressController progress = AppHost.Progress;
                GDMTree             tree     = fBase.Context.Tree;

                fView.MapBrowser.InitMap();

                fView.PersonsCombo.BeginUpdate();
                fView.PlacesTree.BeginUpdate();
                progress.ProgressInit(LangMan.LS(LSID.LSID_LoadingLocations), tree.RecordsCount);
                try {
                    fBaseRoot = fView.PlacesTree.AddNode(null, LangMan.LS(LSID.LSID_RPLocations), null);

                    fPlaces.Clear();
                    var personValues = new StringList();

                    int num = tree.RecordsCount;
                    for (int i = 0; i < num; i++)
                    {
                        GDMRecord rec = tree[i];
                        bool      res = rec is GDMIndividualRecord && IsSelected(rec);

                        if (res)
                        {
                            GDMIndividualRecord ind = rec as GDMIndividualRecord;
                            int pCnt = 0;

                            int num2 = ind.Events.Count;
                            for (int j = 0; j < num2; j++)
                            {
                                GDMCustomEvent ev = ind.Events[j];
                                if (ev.Place.StringValue != "")
                                {
                                    AddPlace(ev.Place, ev);
                                    pCnt++;
                                }
                            }

                            if (pCnt > 0)
                            {
                                personValues.AddObject(GKUtils.GetNameString(ind, true, false) + " [" + pCnt.ToString() + "]", ind);
                            }
                        }

                        progress.ProgressStep();
                    }

                    fView.PlacesTree.Expand(fBaseRoot);

                    personValues.Sort();
                    fView.PersonsCombo.Clear();
                    fView.PersonsCombo.AddItem(LangMan.LS(LSID.LSID_NotSelected), null);
                    fView.PersonsCombo.AddStrings(personValues);

                    fView.SelectPlacesBtn.Enabled = true;
                } finally {
                    progress.ProgressDone();
                    fView.PlacesTree.EndUpdate();
                    fView.PersonsCombo.EndUpdate();

                    PlacesCache.Instance.Save();
                }
            } catch (Exception ex) {
                Logger.LogWrite("MapsViewerWin.PlacesLoad(): " + ex.Message);
            }
        }