private void LogToOrigin(ParserEventRecord record) { DynamicResult dr = record.SourceData as DynamicResult; if (dr != null) { if (dr.ContainsKey("$origin")) { string origin = dr["$origin"]; int id = origin.LastIndexOf("::", StringComparison.Ordinal); if (id != -1) { string sheetName = origin.Substring(0, id); int line = int.Parse(origin.Substring(id + 2)); var sheet = GetSheet(sheetName, false); try { sheet.AddMessage(line, record.Message); } catch (Exception ex) { LogEnvironment.LogEvent(ex.OutlineException(), LogSeverity.Error); } } } } }
/// <summary> /// Dumps a single event the target of this dumper /// </summary> /// <param name="record">The Event-Record representing the Parser-Event that must be logged to this dumpers Target</param> public void DumpEvent(ParserEventRecord record) { string msg; if ((DumpDecider.Decide(record, DecisionMethod.Simple, out msg) & (DecisionResult.Success | DecisionResult.Acceptable)) != DecisionResult.None) { DumpEventRecord(record); } }
/// <summary> /// Adds a new row to this excel sheet /// </summary> /// <param name="record">the parser-event that must be added to this sheetWrapper</param> public void AddRow(ParserEventRecord record) { var source = record.SourceData as DynamicResult; CheckIndexColumns(source); var row = NextLine(); (from t in columns.Select((s, i) => new { Index = i, Name = s }) select new { Column = t.Index, Value = t.Name == "Message" ? record.Message : source?[t.Name] }).ForEach( u => SetValue(row.CreateCell(u.Column), $"{u.Value}")); }
/// <summary> /// Dumps a single event the target of this dumper /// </summary> /// <param name="record">The Event-Record representing the Parser-Event that must be logged to this dumpers Target</param> protected override void DumpEventRecord(ParserEventRecord record) { if (record.Severity == ParserEventSeverity.Report && reportSheet != null) { GetSheet(reportSheet).AddRow(record); } else if (record.Severity == ParserEventSeverity.Warning && warningSheet != null) { GetSheet(warningSheet).AddRow(record); } else if (record.Severity == ParserEventSeverity.Error && errorSheet != null) { GetSheet(errorSheet).AddRow(record); } LogToOrigin(record); }
/// <summary> /// Dumps a required event to the target of this dumper /// </summary> /// <param name="record">the record that has passed the dump-decider</param> protected abstract void DumpEventRecord(ParserEventRecord record);