예제 #1
0
        public void FileLoadProgress(int progressPercent, string text = null)
        {
            trace.TraceInformation("FamilyForm2::FileLoadProgress(" + progressPercent + ")");

            if (progressPercent < 0)
            {
                familyTree = readFileWorker.GetFamilyTree();
                if (familyTree != null)
                {
                    if (trace.Switch.Level.HasFlag(SourceLevels.Information))
                    {
                        familyTree.Print();
                    }

                    toolStripProgressBar1.Visible = false;
                    toolStripStatusLabel1.Text    = familyTree.GetShortTreeInfo();//"I:" + familyTree.individualList.Count + " F:" + familyTree.familyList.Count + " N:" + familyTree.noteList.Count;

                    //PopulatePersonList();

                    ConnectPanelsToTree(familyTree);
                }
                else
                {
                    trace.TraceEvent(TraceEventType.Error, 0, "  Error: tree == null! " + DateTime.Now);
                }
                progressReporter = null;
                readFileWorker   = null;
            }
            else
            {
                TextCallback(progressPercent, text);
            }
        }
예제 #2
0
        private bool ReadFile(String fileName, ref FamilyTreeStoreBaseClass inFamilyTree)
        {
            printMemory = false;// true;

            GedcomImportResult importResult = new GedcomImportResult();

            DebugStringAdd(ref importResult, "GedcomDecoder::Readfile(" + fileName + ") Start " + DateTime.Now);

            familyTree = inFamilyTree;

            familyTree.Print();

            if (printMemory)
            {
                memory = new MemoryClass();

                memory.PrintMemory();
            }


            fileBuffer = new FileBufferClass();

            fileBuffer.ReadFile(fileName);

            DebugStringAdd(ref importResult, "GedcomDecoder::Readfile() size " + fileBuffer.GetSize());
            if (printMemory)
            {
                memory.PrintMemory();
            }

            String HeadString = "";

            parsedLines = 0;

            if (fileBuffer.GetSize() < 12)
            {
                importResult = line.GetDebugString();
                DebugStringAdd(ref importResult, "gedcom file too small!: " + fileName + ", size:" + fileBuffer.GetSize());
                importResult.WriteToFile(fileName);
                return(false);
            }

            Byte[] fileDataBuffer = fileBuffer.GetBuffer();

            //DebugStringAdd(ref importResult, "");

            string hdrStrText    = "";
            string linefeed      = "";
            bool   linefeedFound = false;

            for (int i = 0; i < 20; i++)
            {
                char ch = (char)fileDataBuffer[i];
                //DebugStringAdd(ref importResult, fileDataBuffer[i].ToString());
                HeadString += ch;
                hdrStrText += ch.ToString() + " ";
                if (!linefeedFound)
                {
                    if ((ch == '\n') || (ch == '\r'))
                    {
                        linefeed += ch;
                    }
                    else if (linefeed.Length > 0)
                    {
                        linefeedFound = true;
                    }
                }
            }
            //DebugStringAdd(ref importResult, "");

            DebugStringAdd(ref importResult, "Header bytes: " + hdrStrText);

            if (!linefeedFound)
            {
                DebugStringAdd(ref importResult, " Did not find proper linefeed!: " + fileName + ", size:" + fileBuffer.GetSize() + ":" + HeadString);
                importResult.WriteToFile(fileName);
                return(false);
            }

            line = new GedcomLineStatus(ref importResult, linefeed);

            if (HeadString.IndexOf("HEAD") < 0)
            {
                importResult = line.GetDebugString();
                DebugStringAdd(ref importResult, "gedcom file header missing!: " + fileName + ", size:" + fileBuffer.GetSize() + ":" + HeadString);
                importResult.WriteToFile(fileName);
                return(false);
            }

            familyTree.SetSourceFileType("GEDCOM");

            if (printMemory)
            {
                memory.PrintMemory();
            }

            Parse(ref importResult);

            if (printMemory)
            {
                memory.PrintMemory();
            }
            familyTree.Print();
            DebugStringAdd(ref importResult, "GedcomDecoder::Readfile() Done " + DateTime.Now);

            importResult.WriteToFile(fileName);

            return(true);
        }
예제 #3
0
        public bool ReadFile(String fileName, ref FamilyTreeStoreBaseClass inFamilyTree)
        {
            printMemory = false;// true;

            trace.TraceInformation("TextDecoder::Readfile(" + fileName + ") Start " + DateTime.Now);

            familyTree = inFamilyTree;

            familyTree.Print();

            if (printMemory)
            {
                memory = new MemoryClass();

                memory.PrintMemory();
            }

            xrefMapLists = new XrefMapLists(inFamilyTree);

            fileBuffer = new FileBufferClass();

            fileBuffer.ReadFile(fileName);

            trace.TraceInformation("TextDecoder::Readfile() size " + fileBuffer.GetSize());
            if (printMemory)
            {
                memory.PrintMemory();
            }

            String HeadString = "";

            trace.TraceInformation("Text file " + fileName + " read ok, size " + fileBuffer.GetSize());

            if (fileBuffer.GetSize() < 12)
            {
                trace.TraceInformation("Text file too small!: " + fileName + ", size:" + fileBuffer.GetSize());
                return(false);
            }

            Byte[] fileDataBuffer = fileBuffer.GetBuffer();

            for (int i = 0; i < 12; i++)
            {
                trace.TraceInformation(" data:" + (int)fileDataBuffer[i]);
                HeadString += (char)fileDataBuffer[i];
            }
            trace.TraceInformation("");

            familyTree.SetSourceFileType("Text");

            if (printMemory)
            {
                memory.PrintMemory();
            }

            if (printMemory)
            {
                memory.PrintMemory();
            }
            familyTree.Print();
            trace.TraceInformation("TextDecoder::Readfile() Done " + DateTime.Now);

            Parse(FamilyUtility.MakeFilename(fileName + "_parsed_" + DateTime.Now.ToString() + ".txt"));

            xrefMapLists.Analyze(trace);
            return(true);
        }