Example #1
0
        /// <summary>
        /// Write the record lines out where no errors.
        /// </summary>
        private FileOperationResult <TContent> WriteRecords(long lineNumber, FileOperationResult <TContent> result)
        {
            if (result != null && !result.HasErrors)
            {
                foreach (var rec in result.Records)
                {
                    _textWriter.WriteLine(rec.LineData);
                }
            }
            else
            {
                // Reset the line number as the data was never written.
                _lineNumber = lineNumber;
            }

            OnRecordWrite(result);

            return(result);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileReaderLoggerData"/> class.
 /// </summary>
 /// <param name="operationResult">The <see cref="FileOperationResult"/>.</param>
 /// <param name="fileRecord">The corresponding <see cref="Beef.FlatFile.FileRecord"/> to the logged message.</param>
 /// <param name="messageItem">The specific <see cref="Beef.Entities.MessageItem"/> from the <see cref="FileRecord"/> being logged.</param>
 public FileReaderLoggerData(FileOperationResult operationResult, FileRecord fileRecord = null, MessageItem messageItem = null)
 {
     OperationResult = operationResult ?? throw new ArgumentNullException(nameof(operationResult));
     FileRecord      = fileRecord;
     MessageItem     = messageItem;
 }
Example #3
0
 /// <summary>
 /// Raises the <see cref="RecordRead"/> event.
 /// </summary>
 /// <param name="result">The <see cref="FileOperationResult"/>.</param>
 protected void OnRecordRead(FileOperationResult result)
 {
     RecordRead?.Invoke(this, new FileOperationEventArgs {
         OperationResult = result
     });
 }