/// <summary> /// Saves the report to a given file, with some extra data provided. /// </summary> /// <param name="pathToFolder">Path to folder to save the report in</param> /// <param name="data">The extra result data that should be in the report.</param> public String SaveReport(string pathToFolder, ResultData data) { string additionalHeader = @" <script type=""text/javascript""> function toggleNext(elm){ var next = elm.parentNode.nextElementSibling; if(next.style.display == ""none""){ next.style.display = ""block""; } else { next.style.display = ""none""; } } function toggle(id){ var next = document.getElementById(id); if(next.style.display == ""none""){ next.style.display = ""block""; } else { next.style.display = ""none""; } } function mark(elm){ var clsses = elm.className; if(clsses.indexOf(""mark"") > -1){ elm.className = clsses.replace("" mark"",""""); } else { elm.className += "" mark""; } } </script> <style type=""text/css""> .green { background-color: #00ff00; } .red { background-color: #ff0000; } .mark { background-color: #0000ff; } </style>" ; String table = String.Format(@"<table><tr><th>Sample</th><th>Command</th><th>Runtime</th><th>Result file</th><th>Changes (click to show)</th></tr>{0}</table>", Builder.ToString()); String first = String.Format(@"<p>Report generated for CCExtractor version {0}</p>", data.CCExtractorVersion); BuilderDiff.Close(); String reportName = GetReportFileName(data); using (StreamWriter sw = new StreamWriter(Path.Combine(pathToFolder, reportName))) { sw.WriteLine(String.Format(@" <html> <head> <title>{0}</title> <style type=""text/css"">{1}</style> {2} </head> <body>" , "Report " + DateTime.Now.ToShortDateString(), SideBySideModel.GetCSS(), additionalHeader)); sw.WriteLine(first); sw.WriteLine(table); string[] lines = File.ReadAllLines(TempFileName); foreach (string line in lines) { sw.WriteLine(line); } sw.WriteLine("</body></html>"); // Delete temporary html. File.Delete(TempFileName); } return(reportName); }
/// <summary> /// Gets the name of the report file. /// </summary> /// <returns>The report file name.</returns> /// <param name="data">Data.</param> public string GetReportFileName(ResultData data) { return("Report_" + data.FileName + "_" + data.StartTime.ToString("yyyy-MM-dd_HHmmss") + ".html"); }
/// <summary> /// Saves the report to a given file, with some extra data provided. /// </summary> /// <param name="pathToFolder">Path to folder to save the report in</param> /// <param name="data">The extra result data that should be in the report.</param> public string SaveReport(string pathToFolder, ResultData data) { // Do nothing return(""); }