Example #1
0
        public int FindLogs(string mnemonic)
        {
            var directory = Directory.GetCurrentDirectory();
            // я блять в душе не ебу как читать LIS файл, по этому хрен с ним
            var lasFiles = Directory
                           .GetFiles(directory, "*.las", SearchOption.AllDirectories)
                           .Select(x => new FileInfo(x));

            if (!lasFiles.Any())
            {
                Console.WriteLine($"{":no_entry: ".Emoji()}Couldn't find a LAS files in '{directory}'..");
                return(1);
            }

            var box = new List <(FileInfo info, LASFile file)>();

            foreach (var file in lasFiles)
            {
                try
                {
                    // Да, я придумал мини-индексатор на коленке,
                    // А потом уже понял что Я ПРОСТО МОГУ НЕ ЧИТАТЬ кусок сектора с данными
                    // Но, без чтения сектора с данными - парсеру плохо, впринципе могу поправить:
                    // Но, мне впадлу ебаться с этим тухлым парсером - секс конечно круто, но нет
                    if (Indexer.HasIndexed(file))
                    {
                        box.Add((file, Indexer.ByFileName(file).las));
                    }
                    else
                    {
                        var las = LASFileReader.Open(file, true); // todo - fix parse file without '~A' sector
                        Indexer.Stage(file, las);
                        box.Add((file, las));
                    }
                }
                catch // todo trace-logging (and trace-flag)
                {
                    Console.WriteLine($"{":x: ".Emoji()}[fail] can't read '{file.Name}' in '{file.DirectoryName}'".Color(Color.DarkOrange));
                }
            }

            var result = box.Where(x => x.file.Data().logParameters.HasParameter(mnemonic));

            foreach (var(info, file) in result)
            {
                Console.WriteLine($"{":heavy_check_mark:".Emoji()} found '{mnemonic}' in '{info.FullName}'...".Color(Color.GreenYellow));
                var target = file.Data().logParameters[mnemonic];
                Console.WriteLine($"\t{target.Mnemonic} - {target.Description}, {target.Value}".Color(Color.Gray));
            }

            if (!result.Any())
            {
                Console.WriteLine($"{":no_entry: ".Emoji()}Log-type '{mnemonic}' not found in files which are located in '{directory}'..".Color(Color.DarkOrange));
                return(2);
            }

            return(0);
        }
Example #2
0
        public LASFile GetLASFile(string inputFilename, ModelImportStatus mis)
        {
            LASFile lf = null;

            try
            {
                LASFileReader lfr          = new LASFileReader();
                int           columnOffset = 0;
                int           errorCode    = 0;
                lf = lfr.ReadLASFile(inputFilename, columnOffset, out errorCode);

                if (errorCode == 0)
                {
                    mis.finalErrorCode = ModelImportStatus.OK;
                    string res = "";
                    foreach (string nc in lf.columnHeaders)
                    {
                        res += nc + ", ";
                    }
                    mis.linesReadFromSource = lf.dataRows.Count;

                    // Display error mesasges if required
                    if (lf.errorDetails != null && lf.errorDetails.Count > 0)
                    {
                        string messageBoxText = "The file (" + inputFilename + ") was loaded, but issues were noted as follows:";
                        mis.AddWarningMessage(messageBoxText);
                        foreach (string ed in lf.errorDetails)
                        {
                            string ss = "\n" + ed;
                            mis.AddWarningMessage(ss);
                        }
                    }
                }
                else
                {
                    string messageBoxText = "The file (" + inputFilename + ") could not be loaded.  Please check that the file is " +
                                            "accessible, is not open in another application and is in the correct format.";
                    mis.AddErrorMessage(messageBoxText);
                    string errorCodeDetails = LASErrorCodes.LookupCode(errorCode);
                    if (lf != null && lf.errorDetails != null)
                    {
                        foreach (string ed in lf.errorDetails)
                        {
                            string ss = "\n" + ed;
                            mis.AddErrorMessage(ss);
                        }
                    }

                    mis.finalErrorCode = ModelImportStatus.ERROR_LOADING_FILE;
                    string caption = "Error loading file " + inputFilename;
                }
            }
            catch (Exception ex)
            {
            }
            return(lf);
        }
Example #3
0
        private void LoadGeophysiscsTextDataForPreview(string inputFilename)
        {
            IOResults ares = new IOResults();

            List<ColumnMetaInfo> dbFields = GetGeophysicsFieldsFromNKD();
            // talk to the database to get the column names 

            ImportDataPreview.SetMandatoryMappingColumns(dbFields);
            ImportDataPreview.SetPreviewType("GEOPHYISCS");

            bool firstLineIsHeader = true;

            if (inputFilename.ToLower().EndsWith("las"))
            {
                LASFileReader lfr = new LASFileReader();
                int errCode = 0;
                LASFile fl = lfr.ReadLASFile(inputFilename, 0, out errCode);

                List<RawDataRow> dt = new List<RawDataRow>();
                RawDataRow rdh = new RawDataRow();
                rdh.dataItems = new List<string>();
                rdh.dataItems.Add("Depth");
                foreach (string ss in fl.columnHeaders)
                {
                    rdh.dataItems.Add(ss);
                }

                dt.Add(rdh);
                foreach (LASDataRow ldr in fl.dataRows)
                {
                    RawDataRow rd = new RawDataRow();
                    rd.dataItems.Add("" + ldr.depth);
                    foreach (double d in ldr.rowData)
                    {
                        rd.dataItems.Add("" + d);
                    }
                    dt.Add(rd);
                }

                ImportDataPreview.ResetTable(dt, true);

            }
            else
            {
                var rawFileReader = new RawFileReader(',');
                List<RawDataRow> dt = rawFileReader.LoadRawDataForPreview(inputFilename, ares);
                ImportDataPreview.ResetTable(dt, firstLineIsHeader);

            }
        }
Example #4
0
        public LASFile GetLASFile(string inputFilename,ModelImportStatus mis ) {
            LASFile lf = null;
            try
            {
                LASFileReader lfr = new LASFileReader();
                int columnOffset = 0;
                int errorCode = 0;
                 lf = lfr.ReadLASFile(inputFilename, columnOffset, out errorCode);
                
                if (errorCode == 0)
                {
                    mis.finalErrorCode = ModelImportStatus.OK;
                    string res = "";
                    foreach (string nc in lf.columnHeaders)
                    {
                        res += nc + ", ";
                    }
                    mis.linesReadFromSource = lf.dataRows.Count;
  
                    // Display error mesasges if required
                    if (lf.errorDetails != null && lf.errorDetails.Count > 0)
                    {
                        string messageBoxText = "The file (" + inputFilename + ") was loaded, but issues were noted as follows:";
                        mis.AddWarningMessage(messageBoxText);
                        foreach (string ed in lf.errorDetails)
                        {
                            string ss = "\n" + ed;
                            mis.AddWarningMessage(ss);
                        }
                        
                        
                       

                    }

                }
                else
                {

                    string messageBoxText = "The file (" + inputFilename + ") could not be loaded.  Please check that the file is " +
                                            "accessible, is not open in another application and is in the correct format.";
                    mis.AddErrorMessage(messageBoxText);
                    string errorCodeDetails = LASErrorCodes.LookupCode(errorCode);
                    if (lf != null && lf.errorDetails != null)
                    {
                        foreach (string ed in lf.errorDetails)
                        {
                            string ss = "\n" + ed;
                            mis.AddErrorMessage(ss);
                        }
                    }
                    
                    mis.finalErrorCode = ModelImportStatus.ERROR_LOADING_FILE;
                    string caption = "Error loading file " + inputFilename;
                    
                }

            }
            catch (Exception ex)
            {

            }
            return lf;
        }