public OABDownloadLogLine(List <string> header, LogSourceLine line) : base(line) { this.data = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); IList <string> columns = line.GetColumns(); if (columns.Count < header.Count) { base.RaiseException(string.Format("Headers collection provided does not match the schema. Header count: {0}, Columns count: {1}", header.Count, columns.Count), new object[0]); } if (line.Timestamp != null) { this.timestamp = line.Timestamp.Value; } else { base.RaiseException("First column of line should be a well-formatted DateTime, column-value: {0}", new object[] { columns[0] }); } for (int i = 0; i < header.Count; i++) { this.data[header[i]] = columns[i]; } }
public override void ProcessLine(LogSourceLine line, List <LogLine> logLinesProcessed) { if (line.LogSource.Schema.IsHeader(line)) { List <string> list; if (!StringUtils.TryGetColumns(line.Text, ',', ref list)) { Log.LogErrorMessage(string.Format("Format Exception: Unable to parse OABDownload log header from line - '{0}'", line.Text), new object[0]); return; } if (string.IsNullOrEmpty(list[0]) || !list[0].Equals("DateTime", StringComparison.OrdinalIgnoreCase)) { Log.LogErrorMessage(string.Format("Format Exception: OABDownload log Header is in an incorrect format. The first parsed column is not equal to DateTime: - '{0}'", line.Text), new object[0]); return; } this.logHeader = list; return; } else { if (line.LogSource.Schema.IsComment(line)) { return; } if (this.logHeader == null || this.logHeader.Count == 0) { Log.LogErrorMessage("Format Exception: OABDownload log line processing skipped since we have not yet parsed a valid header.", new object[0]); return; } try { OABDownloadLogLine item = new OABDownloadLogLine(this.logHeader, line); logLinesProcessed.Add(item); } catch (InvalidDataException ex) { Log.LogErrorMessage("Skipped corrupted log line. Exception - {0}", new object[] { ex }); } return; } }
public override bool IsHeader(LogSourceLine line) { return(line.Text.StartsWith("DateTime", StringComparison.InvariantCultureIgnoreCase)); }