Ejemplo n.º 1
0
        private bool ImportTextContent()
        {
            try {
                fLog.Clear();

                GDMLines buffer = new GDMLines();
                try {
                    int prev_id = 0;

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

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

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

                            switch (rawLine.Type)
                            {
                            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;
                        }
                    }

                    return(true);
                } finally {
                }
            } catch (Exception ex) {
                Logger.WriteError("Importer.ImportTextContent()", ex);
                throw;
            }
        }
Ejemplo n.º 2
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);
            }
        }