Example #1
0
        private void ParseFileContent(FileStringUnit fileContent)
        {
            var targetDate = TargetDate;
            var result     = new ParseResultUnit(fileContent.Filepath);

            using (StringReader sr = new StringReader(fileContent.Content))
            {
                int lineNumber = 0;
                while (sr.Peek() != -1)
                {
                    lineNumber++;

                    var line  = sr.ReadLine().Trim();
                    var match = TimestampCaptureRegex.Match(line);
                    if (!match.Success)
                    {
                        continue;
                    }
                    DateTime parsedDate;
                    if (!DateTime.TryParse(match.Value, out parsedDate) || targetDate.Date != parsedDate.Date)
                    {
                        continue;
                    }

                    var messageValue = line.Remove(0, match.Value.Length).Trim(':');
                    var messageKey   = OnMessageKeyRequested(messageValue);
                    result.AddLine(parsedDate, lineNumber, messageKey);
                }
            }
            fileContent.Clear();
            if (result.Count == 0)
            {
                FileSet.Remove(fileContent.Filepath);
            }
            AddResult(result);
        }
 public FileParseInstruction(FileStringUnit fileContent, DateTime targetDate)
 {
     FileContent = fileContent;
     TargetDate  = targetDate;
 }