Пример #1
0
        public bool ReadFile(String filename, ref IFamilyTreeStoreBaseClass inFamilyTree)
        {
            printMemory = false;// true;

            trace.TraceInformation("TextDecoder::Readfile(" + filename + ") Start " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            familyTree = inFamilyTree;

            trace.TraceInformation(familyTree.GetShortTreeInfo());
            //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.TraceData(TraceEventType.Verbose, 0, familyTree.GetShortTreeInfo());
            trace.TraceInformation("TextDecoder::Readfile() Done " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            string directory = "/tmp/";

            if (!Directory.Exists(directory))
            {
                //Directory.CreateDirectory(directory);
                directory = "";
            }

            if ((directory.Length > 0) && filename.Contains(directory))
            {
                filename = filename.Substring(directory.Length);
            }
            Parse(directory + FamilyUtility.MakeFilename(filename + "_text_parsed_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".txt"));

            xrefMapLists.Analyze(trace);
            return(true);
        }
Пример #2
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);
        }