/// <summary> /// Load html report from file. /// </summary> /// <param name="reportFilePath"> The html file report.</param> /// <param name="htmlReponseContentFiles"> The html response content files.</param> private void LoadHtmlReportFromFile(string reportFilePath,string[] htmlReponseContentFiles) { printForm = new HtmlPrintForm(); printForm.PluginMenus = this.mnFile; printForm.HtmlResponseViewEvent += new HtmlResponseViewEventHandler(Report_HtmlResponseViewEvent); printForm.ApplyToolbarSettingsEvent += new ApplyToolbarSettingsEventHandler(Report_ApplyToolbarSettingsEvent); printForm.ApplyMenuSettingsEvent += new ApplyMenuSettingsEventHandler(Report_ApplyMenuSettingsEvent); try { StreamReader reader = new StreamReader(reportFilePath, Encoding.UTF8); string data = reader.ReadToEnd(); reader.Close(); printForm.UpdateSavePrintReportMenu(true); printForm.HtmlContentResults = htmlReponseContentFiles; printForm.LoadData(data, "html"); AddDocument(printForm, "Report Preview - HTML", true); } catch (Exception ex) { printForm.UpdateSavePrintReportMenu(false); MessageBox.Show(ex.Message,AppLocation.ApplicationName,MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Loads the html report viewer. /// </summary> /// <param name="reportType"> The report type.</param> private void LoadHtmlReportViewer(string reportType) { ReportCommand reportCmd = new ReportCommand(); printForm = new HtmlPrintForm(); printForm.PluginMenus = this.mnFile; printForm.HtmlResponseViewEvent += new HtmlResponseViewEventHandler(Report_HtmlResponseViewEvent); printForm.ApplyToolbarSettingsEvent += new ApplyToolbarSettingsEventHandler(Report_ApplyToolbarSettingsEvent); printForm.ApplyMenuSettingsEvent += new ApplyMenuSettingsEventHandler(Report_ApplyMenuSettingsEvent); try { string logo = "<div class='ReportName'><img src='../gb logo.gif' align='middle'></img>Ecyware GreenBlue Inspector Report</div><br /><br /><br />"; // merge reports StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.Append("<head><link rel='stylesheet' type='text/css' href='../report.css'></head>"); sb.Append("<body topmargin='40' leftmargin='10'>"); sb.Append(logo); ArrayList htmlFiles = new ArrayList(); for (int i=0;i<this.CurrentReportList.Count;i++) { HtmlUnitTestReport report = (HtmlUnitTestReport)this.CurrentReportList[i]; string html = string.Empty; if ( reportType == "basic" ) { html = reportCmd.CreateHtmlReport(report, InspectorConfig.BasicReportTemplate, InspectorConfig.SolutionDataFile, InspectorConfig.ReferenceDataFile); } else { html = reportCmd.CreateHtmlReport(report, InspectorConfig.AdvancedReportTemplate, InspectorConfig.SolutionDataFile, InspectorConfig.ReferenceDataFile); } sb.Append(html); // Add Html Response Content to array if ( report.ResponseDocument[0].IsHtmlResponseFile ) { htmlFiles.Add(System.Windows.Forms.Application.UserAppDataPath + "\\temphtml\\" + report.ResponseDocument[0].HtmlResponse); } } sb.Append("</body>"); sb.Append("</html>"); printForm.UpdateSavePrintReportMenu(true); printForm.HtmlContentResults = (string[])htmlFiles.ToArray(typeof(string)); printForm.LoadData(sb.ToString(), "html"); AddDocument(printForm, "Report Preview - HTML", true); } catch (Exception ex) { printForm.UpdateSavePrintReportMenu(false); MessageBox.Show(ex.Message,AppLocation.ApplicationName,MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void HtmlBrowserInvoker(object sender, EventArgs e) { HtmlTextResultEventArgs args = (HtmlTextResultEventArgs)e; printForm = new HtmlPrintForm(); printForm.PluginMenus = this.mnFile; printForm.HtmlResponseViewEvent += new HtmlResponseViewEventHandler(Report_HtmlResponseViewEvent); printForm.ApplyToolbarSettingsEvent += new ApplyToolbarSettingsEventHandler(Report_ApplyToolbarSettingsEvent); printForm.ApplyMenuSettingsEvent += new ApplyMenuSettingsEventHandler(Report_ApplyMenuSettingsEvent); try { if ( args.Append ) { printForm.AppendData(args.HtmlText, false); } else { printForm.AppendData(args.HtmlText, true); } printForm.UpdateSavePrintReportMenu(true); AddDocument(printForm, "Display Results", true); } catch (Exception ex) { printForm.UpdateSavePrintReportMenu(false); MessageBox.Show(ex.Message,AppLocation.ApplicationName,MessageBoxButtons.OK, MessageBoxIcon.Error); } }