Example #1
0
 /// <summary>
 /// Create a container for generating a line-based report, defaults to CSV fields and file suffix
 /// </summary>
 /// <param name="loggers">the logger handle, lines are output to the logger as well as the output file</param>
 public TabularReport(LMLoggers loggers)
 {
     this.loggers = loggers;
     Separator    = ',';
     rows         = new Row[0]; // non-null to start
     f            = new ResultsOutputFile(loggers.Logger(LMLoggers.AppSection.App));
 }
Example #2
0
 /// <summary>
 /// Create a container for generating a line-based report, defaults to CSV fields and file suffix
 /// </summary>
 /// <param name="et">the column header type</param>
 /// <param name="loggers">the logger handle, lines are output to the logger as well as the output file</param>
 public TabularReport(System.Type et, LMLoggers loggers)
 {
     this.loggers = loggers;
     Separator    = ',';
     GenColumns(et);
     rows = new Row[0]; // non-null to start
     f    = new ResultsOutputFile(loggers.Logger(LMLoggers.AppSection.App));
 }
Example #3
0
        // assumes file is created and open, header and footer text is set and rows constructed.
        public virtual void CreateReport(UInt16 logResults)
        {
            lines = new List <string>(2 + rows.Length + 1);

            if (hf != null)
            {
                lines.Add(hf.header);
                lines.Add(hf.GetColumnHeader());
            }

            string s;

            for (int i = 0; i < rows.Length; i++)
            {
                Row r = rows[i];
                if (r != null)
                {
                    s = rows[i].ToLine(separator);
                }
                else
                {
                    s = sepAsString;
                }
                lines.Add(s);
            }

            if (hf != null)
            {
                lines.Add(hf.footer);
            }

            foreach (string ls in lines)
            {
                f.WriteLine(ls);
            }
            bool sendToLogFile = false, logToConsole = false;

            switch (logResults)
            {
            case 1:
                sendToLogFile = true;
                break;

            case 2:
                logToConsole = true;
                break;

            case 3:
                sendToLogFile = logToConsole = true;
                break;
            }

            if (sendToLogFile || logToConsole)
            {
                LMLoggers.LognLM log = loggers.Logger(LMLoggers.AppSection.App);
                TraceEventCache  tec = new TraceEventCache();
                foreach (string ls in lines)
                {
                    if (sendToLogFile && logToConsole)
                    {
                        log.TraceEvent(LogLevels.Verbose, 717, ls);
                    }
                    else if (logToConsole)
                    {
                        log.TraceEventConsole(LogLevels.Verbose, 717, ls, tec);
                    }
                    else
                    {
                        log.TraceEventFileOnly(LogLevels.Verbose, 717, ls, tec);
                    }
                }
            }
        }