Exemplo n.º 1
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.º 2
0
        private void SetColumnHeaders(string headers, ColumnManager columnManager)
        {

            string[] items = headers.Split(splitArray, StringSplitOptions.None);
            int columnIndex = 0;
            foreach (string s in items)
            {
                columnManager.SetColumnName(s, columnIndex);
                columnIndex++;
            }
            //columnManager.SetColumnName(s, idx);
        }
Exemplo n.º 3
0
 internal string QueryRow(int rowNum, ColumnManager columnManager)
 {
     string ss = columnManager.GetRowAsStringAt(rowNum);
     return ss;
 }