Esempio n. 1
0
 private void ReadFile()
 {
     if (File.Exists(this.pathFile))
     {
         if (this.dataTable == null)
         {
             InitializeDataTable();
         }
         else
         {
             this.dataTable.Clear();
         }
         csvAdapter = new CsvAdapter(this.pathFile, this.dataTable, constantProgramName);
         csvAdapter.ReadFile();
     }
     else
     {
         if (this.dataTable != null)
         {
             this.dataTable.Clear();
         }
         //this.csvAdapter = null;
         //this.dataTable = null;
     }
 }
Esempio n. 2
0
        public string ReadFile()
        {
            if (!csvAdapter.ReadFile())
            {
                return("Unable to read file.  Connection must already exist.");
            }
// TODO I don't think this is necessary anymore since we fixed the CsvAdapter to not allow rows with only blanks in them
// This probably isn't hurting anything
            // Handle blank rows in the DataTable.  This is necessary since the CsvAdapter will allow a valid row if
            // it contains a blank value.  We want a blank to mean the end of the data, even if there are some additional
            // rows that follow, since we use a blank line to stop processing while testing a file with many lines.  In
            // this case, if a line has all blanks/nulls, then delete it and any remaining lines.
            // Problem also arises with leftover ElementId values when we are saving them but switch to a shorter output.
            int  blankRowNumber = 0;
            bool blankRowFound  = false;

            for (int i = 0; i < this.DataTable.Rows.Count; i++)
            {
                DataRow dataRow = this.DataTable.Rows[i];
                if (dataRow[2] is DBNull || dataRow[2].ToString() == "")    // Looking at Action column
                {
                    blankRowNumber = i;
                    blankRowFound  = true;
                    break;
                }
            }
            if (blankRowFound)
            {
                int rowIndexMax = DataTable.Rows.Count - 1;
                for (int i = rowIndexMax; i >= blankRowNumber; i--)
                {
                    DataTable.Rows[i].Delete();
                }
            }

            // Fix all of the lower/upper case issues
            FixKeyWordCase();

            return("");
        }
Esempio n. 3
0
 private void buttonRefresh_Click(object sender, EventArgs e)
 {
     this.dataTable.Clear();
     csvAdapter.ReadFile();
 }