private void BtnMultiPartReport_Click(object sender, EventArgs e) { IObjectToXmlConverterFactory factory = new ObjectToXmlConverterFactory(); IReportBuilder reportGenerator = new HtmlReportBuilder(factory); // Create the objects collection that are going to be presented in the report IList <Blogger> bloggersCollection = new List <Blogger> { new Blogger(1, "Satheesh Krishnasamy."), new Blogger(2, "Martin Fowler") }; /* Create the report contents with the type of display. * * Table: to display the collection as a HTML table in the report * Label: to display the collection as a HTML label in the report * Paragraph: to display the collection as a HTML paragraph in the report * */ reportGenerator.AppendReportSection( ReportSectionDisplayType.Table, bloggersCollection, "Bloggers list", "You are truely appreciated for all your effort in each day. Wish you all thebest !!!!!", currentToken); // Create the objects collection that are going to be presented in the report IList <Article> articleCollection = new List <Article> { new Article("How safe is the anti-forgery token?", "This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token.This is a wonderful article about the anit-forgery token."), new Article("How safe is the viewstate field?", "This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. This is a wonderful article about the viewstate field in asp.net web forms. ") }; // Generate the report reportGenerator.AppendReportSection(ReportSectionDisplayType.Paragraph, articleCollection, "Article published today", DateTime.Now.ToLongTimeString()); reportGenerator.AppendReportSection(ReportSectionDisplayType.Label, articleCollection, "Article published today", DateTime.Now.ToLongTimeString()); var htmlReport = txtXmlReport.Text = reportGenerator.Build("My blog", "Articles published today.", "Copyright © MyCompany"); // save the file var reportFilePath = $"Reports\\HTMLReport_{DateTime.Now.ToString("yyyyMMddhhmmss")}.html"; IReportSaver saver = new ReportFileSaver(); saver.SaveReport(Path.Combine(Environment.CurrentDirectory, reportFilePath), htmlReport, true); OpenFolderInWindowsExplorer(reportFilePath, ""); }
private void SaveReport(string reportContent) { // save the file var reportFilePath = $"Reports\\HTMLReport_{DateTime.Now.ToString("yyyyMMddhhmmss")}.html"; IReportSaver saver = new ReportFileSaver(); saver.SaveReport(Path.Combine(Environment.CurrentDirectory, reportFilePath), reportContent, true); OpenFolderInWindowsExplorer(reportFilePath, ""); }
private void ExportReport() { var resultsCollection = this.GetResults(chkGroupResults.Checked); IReportBuilder reportGenerator = new HtmlReportBuilder(); var errors = this.FilterBySeverity(resultsCollection, SeverityType.Error); if (errors.Count > 0) { reportGenerator.AppendReportSection( ReportSectionDisplayType.Table, errors, "Severity: Error", string.Empty); } var warnings = this.FilterBySeverity(resultsCollection, SeverityType.Warning); if (warnings.Count > 0) { reportGenerator.AppendReportSection( ReportSectionDisplayType.Table, warnings, "Severity: warning", string.Empty); } var infos = this.FilterBySeverity(resultsCollection, SeverityType.Info); if (infos.Count > 0) { reportGenerator.AppendReportSection( ReportSectionDisplayType.Table, infos, "Severity: information", string.Empty); } var appreciations = this.FilterBySeverity(resultsCollection, SeverityType.Appreciation); if (appreciations.Count > 0) { reportGenerator.AppendReportSection( ReportSectionDisplayType.Table, appreciations, "Other good things", string.Empty); } var htmlReport = reportGenerator.Build( "Analysis result", string.Empty, "Copyright © MyCompany"); // save the file var reportFilePath = $"Reports\\HTMLReport_{DateTime.Now.ToString("yyyyMMddhhmmss")}.html"; IReportSaver saver = new ReportFileSaver(); saver.SaveReport(Path.Combine(Environment.CurrentDirectory, reportFilePath), htmlReport, true); openFolderInWindowsExplorer(reportFilePath, ""); }