Esempio n. 1
0
        /// <summary>
        /// Display basic information from selected log file using UI components
        /// </summary>
        /// <param name="fileString"></param>
        private void initReportDisplay(string fileString)
        {
            fileInputBox.Text = fileString;
            Report            = new ReportGenerator(new Log(fileString, ProgramFileHandler.ReadFile(fileString)).LogList);

            string   entries     = Report.Entries;
            DateTime startTime   = Report.StartTime;
            DateTime endTime     = Report.EndTime;
            TimeSpan logDuration = Report.LogDuration;

            string[] splitpath  = fileString.Split('.');
            string   reportPath = String.Join("_report.", splitpath);

            entriesTextBox.Text     = entries;
            startTimeTextBox.Text   = startTime.ToString("MMMM dd, yyyy HH:mm:ss.fff");
            endTimeTextBox.Text     = endTime.ToString("MMMM dd, yyyy HH:mm:ss.fff");
            logDurationTextBox.Text = logDuration.ToString("%d") + " days " +
                                      logDuration.ToString("%h") + " hours " +
                                      logDuration.ToString("%m") + " minutes " +
                                      logDuration.ToString("%s") + " seconds " +
                                      logDuration.ToString("%f") + " milliseconds";

            saveReportTextBox.Text   = reportPath;
            saveReportButton.Enabled = true;
        }
 /// <summary>
 /// Write report into a log file. Report Contains the following:
 /// 1. No. of log entries
 /// 2. Start time
 /// 3. End time
 /// 4. Duration from log start time to end time
 /// 5. All tags and count of how many times they are found on the log
 /// 6. All categories and count of how many times they are found on the log
 /// </summary>
 /// <param name="writePath"></param>
 public void WriteReportFile(string writePath)
 {
     string[] report =
     {
         "No. of Log Entries: " + this.Entries,
         "Start Time: " + this.StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff",CultureInfo.InvariantCulture),
         "End Time: " + this.EndTime.ToString("yyyy-MM-dd HH:mm:ss.fff",    CultureInfo.InvariantCulture),
         "Log Duration: " + this.LogDuration,
         "Tags: " + string.Join(", ",                                       this.GetTag.Select(t => $"['{t.Item1}', '{t.Item2}']")),
         "Categories: " + string.Join(", ",                                 this.GetCategory.Select(t => $"['{t.Item1}', '{t.Item2}']")),
     };
     ProgramFileHandler.WriteFile(writePath, report);
 }