Exemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="isPreviewOnly"></param>
 /// <returns></returns>
 public List<RawDataRow> LoadRawDataForPreview(string inputDataFile, IOResults ares) {            
     // first read the raw lines
     List<string> dataLines = ReadDataLines(true, inputDataFile, ares);
     char delimiter = ',';
     if (inputDataFile.ToLower().EndsWith(".las"))
     {
         delimiter = '\t';
     }
     List<RawDataRow> data = ParseDataLines(dataLines, ares, delimiter);
     int maxCols = 0;
     foreach (RawDataRow r in data) {
         int ct = r.dataItems.Count;
         maxCols = Math.Max(ct, maxCols);
     }
     this.MaxCols = maxCols;
     previewLines = dataLines;
     return data;                 
 }
Exemplo n.º 2
0
        private void LoadLASTextDataForPreview(string inputFilename)
        {
            IOResults ares = new IOResults();

            List<ColumnMetaInfo> mandatoryColumns = new List<ColumnMetaInfo>();
            List<ColumnMetaInfo> optionalColumns = new List<ColumnMetaInfo>();

            List<ColumnMetaInfo> dbFields = GetGeophysicsFieldsFromXODB();
            foreach (ColumnMetaInfo s in dbFields)
            {
                mandatoryColumns.Add(s);
            }


            // talk to the database to get the column names 

            ImportDataPreview.SetMandatoryMappingColumns(mandatoryColumns);
            ImportDataPreview.SetOptionalMappingColumns(optionalColumns);
            ImportDataPreview.SetPreviewType("MODEL");

            bool firstLineIsHeader = true;
            List<RawDataRow> dt = blockRawFileReader.LoadRawDataForPreview(inputFilename, ares);
            ImportDataPreview.ResetTable(dt, firstLineIsHeader);
            
        }
Exemplo n.º 3
0
 private void LoadFileForPreview(string fileToLoad)
 {
     IOResults ares = new IOResults();
     
     bool firstLineIsHeader = true;// (bool)dataEntryForm.checkBoxModelFirstRowHeader.IsChecked;
     List<RawDataRow> dt = blockRawFileReader.LoadRawData(firstLineIsHeader, fileToLoad, ares);
     blockRawFileReader.PerformColumnLoad(fileToLoad, ares, blockRawFileReader.MaxCols, firstLineIsHeader, workerLoadData);
     string ss = blockRawFileReader.GetColumnStats();
     List<string> res = blockRawFileReader.DetermineColumnDataTypes();
     columnDefs = new ModelColumnDefinitions();
     // collect column assignments here
     blockRawFileReader.SetColumnDefinitions(columnDefs);
 }
Exemplo n.º 4
0
        private void LoadGeophysiscsTextDataForPreview(string inputFilename)
        {
            IOResults ares = new IOResults();

            List<ColumnMetaInfo> dbFields = GetGeophysicsFieldsFromXODB();
            // 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
            {
                List<RawDataRow> dt = blockRawFileReader.LoadRawDataForPreview(inputFilename, ares);
                ImportDataPreview.ResetTable(dt, firstLineIsHeader);
                
            }
        }
Exemplo n.º 5
0
        private void LoadTextDataForPreview(string inputFilename)
        {
            IOResults ares = new IOResults();
            // talk to the database to get the column names 
            List<ColumnMetaInfo> dbFields = null;
            if (SelectedImportType == GeneralParameters.BLOCKMODEL)
            {
                dbFields = bmDBFields;
            }
            else if (SelectedImportType == GeneralParameters.COLLAR)
            {
                dbFields = collarDBFields;
            }
            else if (SelectedImportType == GeneralParameters.ASSAY)
            {
                dbFields = assayDBFields;
            }
            else if (SelectedImportType == GeneralParameters.COAL_QUALITY)
            {
                dbFields = coalQualityDBFields;
            }
            else if (SelectedImportType == GeneralParameters.SURVEY)
            {
                dbFields = surveyDBFields;
            }
            else if (SelectedImportType == GeneralParameters.LITHO)
            {
                dbFields = lithoDBFields;
            }
            else
            { 
            
            }
            ImportDataPreview.SetMandatoryMappingColumns(dbFields);
            ImportDataPreview.SetPreviewType("MODEL");

            bool firstLineIsHeader = true;
            List<RawDataRow> dt = blockRawFileReader.LoadRawDataForPreview(inputFilename, ares);
            if (inputFilename.ToLower().EndsWith("las")) {
                ImportDataPreview.ResetTable(dt, false);
                
            }
            else
            {
                ImportDataPreview.ResetTable(dt, firstLineIsHeader);
                
            }
        }
Exemplo n.º 6
0
        private List<string> ReadDataLines(bool readPreview, string inputFile, IOResults ares)
        {
            //Pass the file path and file name to the StreamReader constructor
            readPreview = true;
            List<string> allLines = null;
            StreamReader sr = null;
            FileStream fs = null;

            try
            {
                fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 
                sr = new StreamReader(fs);
            }
            catch (FileNotFoundException fex)
            {
                ares.errorCondition = 1;
                ares.errorMessage = "Can't find the input file that was entered.  Please make sure the file exists and that you have permission to read the file.";
                ares.extendedErrorMessage = fex.ToString();
            }
            catch (Exception ex)
            {
                ares.errorCondition = 1;
                ares.errorMessage = "There has been a problem accessing the input data file.  Pleas emake sure the file is not being open in other applications and that you have permission to read the file.";
                ares.extendedErrorMessage = ex.ToString();
            }
            allLines = new List<string>();
            if (sr != null)
            {
                string line = null;
                
                //Continue to read until you reach end of file

                if (readPreview)
                {
                    int ct = 0;
                    while ((line = sr.ReadLine()) != null)
                    {
                        // bypass specified number of lines
                        if (ct >= SkipLines)
                        {

                            allLines.Add(line);
                            if (ct > this.previewCount)
                            {
                                break;
                            }
                        }
                        ct++;
                    }
                }
                else {
                    while ((line = sr.ReadLine()) != null)
                    {
                        allLines.Add(line);

                    }
                }
                sr.Dispose();
                sr.Close();
                if (fs != null) {
                    fs.Close();
                }
            }
            if(ares.errorCondition == 0){
                dataLoaded = true;
            }
            return allLines;

        }
Exemplo n.º 7
0
        public void PerformColumnLoad(string fileName, IOResults ares, int numColumns, bool firstLineIsHeader, BackgroundWorker bw)
        {
            columnManager = new ColumnManager(numColumns);
            int maxLoadCount = 5000;
            int ct = 0;
            StreamReader sr = null;
            FileStream fs = null;
            try
            {
                fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 
                sr = new StreamReader(fs);
            }
            catch (FileNotFoundException fex)
            {
                ares.errorCondition = 1;
                ares.extendedErrorMessage = fex.ToString();
            }
            catch (Exception ex)
            {
                ares.errorCondition = 1;                
                ares.extendedErrorMessage = ex.ToString();
            }
            
            if (sr != null)
            {
                
                    string line = null;
                    //Continue to read until you reach end of file
                    int recordNumber = 0;
                    if (firstLineIsHeader) {
                        string headers = sr.ReadLine();
                        this.SetColumnHeaders(headers, columnManager);
                    }
                    int progressIndicator = 0;
                    int reportProgressOn = 10000;
                
                    while ((line = sr.ReadLine()) != null)
                    {
                        ct++;
                        if (ct == maxLoadCount) {
                            break;
                        }
                        ParseLineIntoColumns(recordNumber, line, numColumns);
                        recordNumber++;
                        progressIndicator++;
                        if (progressIndicator == reportProgressOn) {
                            progressIndicator = 0;
                            bw.ReportProgress(recordNumber, fileName);
                        }
                    }
                
                sr.Dispose();
                sr.Close();
                if (fs != null) {
                    fs.Close();
                }
            }
           

        }
Exemplo n.º 8
0
        internal List<RawDataRow> LoadRawData(bool firstLineIsHeader, string fileName, IOResults ares)
        {

            List<string> rawStringData = ReadDataLines(false, fileName, ares);


            return null;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="allLines"></param>
        /// <param name="ares"></param>
        /// <returns></returns>
        private List<RawDataRow> ParseDataLines(List<string> allLines, IOResults ares, char delimiter)
        {
            List<RawDataRow> dt = new List<RawDataRow>();

         


            char[] splitArray = new char[3];
            // set up the delimiting characters
            splitArray[0] = delimiter;
            
            int fileLineNumber = 1;
            foreach (string ln in allLines)
            {
                try
                {

                    string[] items = splitQuoted(ln, ',');
                   // string[] items = ln.Split(splitArray, StringSplitOptions.None);
                    RawDataRow rdr = new RawDataRow();
                    rdr.dataItems = new List<string>(items);
                    dt.Add(rdr);
                }
                catch (Exception ex)
                {
                    // error parsing the line, or casting the objects
                    ares.errorMessage += ex.ToString();
                    
                }
                fileLineNumber++;
            }
            return dt;
        }