예제 #1
0
        public ImportResult ReadAll()
        {
            var result = new ImportResult();

            using (this.s = File.Open(this.pathAndFileName, FileMode.Open, FileAccess.Read))
            {
                this.r = CreateDataReader(s, this.importDefinition.FileType);

                this.fieldCount = this.r.FieldCount;

                if (this.importDefinition.HeaderRow)
                {
                    this.r.Read();
                }

                ImportedRow row = this.ReadRow();
                do
                {
                    result.Rows.Add(row);
                    row = this.ReadRow();
                } while (row != null);
            }

            return(result);
        }
예제 #2
0
        public ImportedRow ReadRow()
        {
            var r = new ImportedRow();

            if (this.r.Read())
            {
                this.currentRow++;
                var o = new string[this.fieldCount];
                for (var i = 0; i < this.fieldCount; i++)
                {
                    if (!this.r.IsDBNull(i))
                    {
                        o[i] = this.r.GetValue(i).ToString();
                    }
                }

                return(new ImportedRow(this.currentRow, o, this.importDefinition));
            }
            else
            {
                return(null);
            }
        }