示例#1
0
			public ImportImpl(StreamReader reader, string file, TaskModel taskModel, Action<string> output, IAsyncDatabaseCommands databaseCommands)
			{
				this.taskModel = taskModel;
				this.output = output;
				this.databaseCommands = databaseCommands;
				csvReader = new CsvReader(reader);
				header = csvReader.ReadHeaderRecord();
				entity = Path.GetFileNameWithoutExtension(file);
				sw = Stopwatch.StartNew();

				enumerator = csvReader.DataRecords.GetEnumerator();
			}
示例#2
0
			public ImportImpl(StreamReader reader, string file, TaskModel taskModel, Action<string> output, IAsyncDatabaseCommands databaseCommands)
			{
				this.taskModel = taskModel;
				this.output = output;
				this.databaseCommands = databaseCommands;
				csvReader = new CsvReader(reader);
				header = csvReader.ReadHeaderRecord();
				entity = Inflector.Pluralize(CSharpClassName.ConvertToValidClassName(Path.GetFileNameWithoutExtension(file)));
				if (entity.Length > 0 &&  char.IsLower(entity[0]))
					entity = char.ToUpper(entity[0]) + entity.Substring(1);
				sw = Stopwatch.StartNew();

				enumerator = csvReader.DataRecords.GetEnumerator();
			}
示例#3
0
 /// <summary>
 /// Constructs an instance of <c>DataRecord</c> with the header specified.
 /// </summary>
 /// <param name="headerRecord">
 /// The header record for this CSV record, or <see langword="null"/> if no header record applies.
 /// </param>
 public DataRecord(HeaderRecord headerRecord)
 {
     _headerRecord = headerRecord;
 }
示例#4
0
 /// <summary>
 /// Constructs an instance of <c>DataRecord</c> with the header and values specified, optionally making the values in this data record
 /// read-only.
 /// </summary>
 /// <param name="headerRecord">
 /// The header record for this CSV record, or <see langword="null"/> if no header record applies.
 /// </param>
 /// <param name="values">
 /// The values for this CSV record.
 /// </param>
 /// <param name="readOnly">
 /// If <see langword="true"/>, the values in this data record are read-only.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, string[] values, bool readOnly)
     : base(values, readOnly)
 {
     _headerRecord = headerRecord;
 }
示例#5
0
 /// <summary>
 /// Constructs an instance of <c>DataRecord</c> with the header and values specified.
 /// </summary>
 /// <param name="headerRecord">
 /// The header record for this CSV record, or <see langword="null"/> if no header record applies.
 /// </param>
 /// <param name="values">
 /// The values for this CSV record.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, string[] values)
     : this(headerRecord, values, false)
 {
 }
示例#6
0
        /// <summary>
        /// Reads the first record from the underlying CSV data and assigns it to <see cref="HeaderRecord"/>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If successful, all <see cref="DataRecord"/>s read by this <c>CsvReader</c> will have their <see cref="DataRecord.HeaderRecord"/> set accordingly.
        /// </para>
        /// <para>
        /// Any attempt to call this method when this <c>CsvReader</c> has already read a record will result in an exception.
        /// </para>
        /// </remarks>
        /// <returns>
        /// The <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> that was read, also available via the <see cref="HeaderRecord"/> property. If no records are left, this method returns <see langword="null"/>.
        /// </returns>
        public HeaderRecord ReadHeaderRecord()
        {
            this.EnsureNotDisposed();
            this.EnsureNotPassedFirstRecord();

            if (this.parser.ParseRecords(null, this.buffer, 0, 1) == 1)
            {
                ++this.recordNumber;
                this.headerRecord = new HeaderRecord(this.buffer[0]);
                return this.headerRecord;
            }

            return null;
        }
示例#7
0
 /// <summary>
 /// Constructs an instance of <c>DataRecord</c> with the header and values specified, optionally making the values in this data record
 /// read-only.
 /// </summary>
 /// <param name="headerRecord">
 /// The header record for this CSV record, or <see langword="null"/> if no header record applies.
 /// </param>
 /// <param name="values">
 /// The values for this CSV record.
 /// </param>
 /// <param name="readOnly">
 /// If <see langword="true"/>, the values in this data record are read-only.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, IEnumerable <string> values, bool readOnly)
     : base(values, readOnly)
 {
     _headerRecord = headerRecord;
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the DataRecord class.
 /// </summary>
 /// <remarks>
 /// The resultant data record will have the specified values, and may or may not be read-only. It will use the specified <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> (which will therefore
 /// be returned from <see cref="HeaderRecord"/>).
 /// </remarks>
 /// <param name="headerRecord">
 /// An optional <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> associated with this <c>DataRecord</c>.
 /// </param>
 /// <param name="readOnly">
 /// <see langword="true"/> to mark this <c>DataRecord</c> as read-only.
 /// </param>
 /// <param name="values">
 /// The values comprising this <c>DataRecord</c>.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, bool readOnly, params string[] values)
     : this(headerRecord, readOnly, (IEnumerable <string>)values)
 {
 }
示例#9
0
 /// <summary>
 /// Constructs an instance of <c>DataRecord</c> with the header and values specified.
 /// </summary>
 /// <param name="headerRecord">
 /// The header record for this CSV record, or <see langword="null"/> if no header record applies.
 /// </param>
 /// <param name="values">
 /// The values for this CSV record.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, IEnumerable <string> values)
     : this(headerRecord, values, false)
 {
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the DataRecord class.
 /// </summary>
 /// <remarks>
 /// The resultant data record will the specified values, and is not read-only. It will use the specified <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> (which will therefore
 /// be returned from <see cref="HeaderRecord"/>).
 /// </remarks>
 /// <param name="headerRecord">
 /// An optional <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> associated with this <c>DataRecord</c>.
 /// </param>
 /// <param name="values">
 /// The values comprising this <c>DataRecord</c>.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, params string[] values)
     : this(headerRecord, false, values)
 {
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the DataRecord class.
 /// </summary>
 /// <remarks>
 /// The resultant data record will have no values, but is not read-only. It will use the specified <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> (which will therefore
 /// be returned from <see cref="HeaderRecord"/>).
 /// </remarks>
 /// <param name="headerRecord">
 /// An optional <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> associated with this <c>DataRecord</c>.
 /// </param>
 public DataRecord(HeaderRecord headerRecord)
     : this(headerRecord, false)
 {
 }
示例#12
0
 // used internally by the parser to speed up the creation of parsed records
 internal DataRecord(HeaderRecord headerRecord, IList <string> values)
     : base(values)
 {
     this.headerRecord = headerRecord;
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the DataRecord class.
 /// </summary>
 /// <remarks>
 /// The resultant data record will have the specified values, and may or may not be read-only. It will use the specified <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> (which will therefore
 /// be returned from <see cref="HeaderRecord"/>).
 /// </remarks>
 /// <param name="headerRecord">
 /// An optional <see cref="Kent.Boogaart.KBCsv.HeaderRecord"/> associated with this <c>DataRecord</c>.
 /// </param>
 /// <param name="readOnly">
 /// <see langword="true"/> to mark this <c>DataRecord</c> as read-only.
 /// </param>
 /// <param name="values">
 /// The values comprising this <c>DataRecord</c>.
 /// </param>
 public DataRecord(HeaderRecord headerRecord, bool readOnly, IEnumerable <string> values)
     : base(readOnly, values)
 {
     this.headerRecord = headerRecord;
 }
示例#14
0
 private static bool IsHeaderMatch(ConstructFile constructFile, HeaderRecord fileHeader)
 {
     var titles = constructFile.GetColumnTitles();
     for (int i = 0; i < fileHeader.Count; ++i)
     {
         if (i < titles.Length)
         {
             if (titles[i] != fileHeader[i])
                 return false;
         }
         else
         {
             return false;
         }
     }
     return true;
 }