Beispiel #1
0
        private void Process(String[] filePaths, IStreamReaderFactory streamReaderFactory, IRecordReader recordReader, IRecordMatchExpression expression, Action<IStreamReader, Record> writeMatchedRecordMethod, Action<IStreamReader, Record> writeUnmatchedRecordMethod)
        {
            var messageBuilder = new StringBuilder();

              foreach (String filePath in filePaths)
              {
            this.logManager.WriteImportantMessageToJobLog("Processing '" + filePath + "'.");
            var fileReader = streamReaderFactory.CreateStreamReader(filePath);

            this.OnFileOpened(fileReader.Length);

            Record record;
            while (!expression.HasReachedMatchQuota && (record = recordReader.ReadRecord(fileReader)) != null)
            {
              this.OnFileRead(fileReader.Position);

              messageBuilder.Append("Record found at position " + record.Start + " with Term '" + record.Term + "'");
              if (expression.IsMatch(record))
              {
            this.statisticsCollector.RecordIsMatched(filePath);
            messageBuilder.Append(" matches with List Term '" + record.Term + "'");
            writeMatchedRecordMethod(fileReader, record);
              }
              else
              {
            this.statisticsCollector.RecordIsUnmatched(filePath);
            writeUnmatchedRecordMethod(fileReader, record);
              }

              messageBuilder.Append(".");
              this.logManager.WriteMessageToJobLog(messageBuilder.ToString());
              messageBuilder.Clear();

              if (this.IsCancelled())
              {
            break;
              }
            }

            fileReader.Close();
              }
        }