private async Task <string> GenerateLargeReportAsync(ReportSectionDisplayType reportPartType, int count) { // Create the objects collection that are going to be presented in the report /* 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 * */ // Demo purpose only. Wait for 10 seconds. await Task.Delay(10000); // Generate the report IReportBuilder reportGenerator = new HtmlReportBuilder(); reportGenerator.AppendReportSection( reportPartType, this.GetReportLargeData(count), "Employee list", "You are truely appreciated for all your effort in each day."); var htmlReport = reportGenerator.Build( "Employee list", "Below is the list of our employees.", "Copyright © MyCompany", currentToken); return(htmlReport); }
private void GenerateAndShowReport(ReportSectionDisplayType reportPartType) { // Create the objects collection that are going to be presented in the report /* 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 * */ // Generate the report IReportBuilder reportGenerator = new HtmlReportBuilder(); reportGenerator.AppendReportSection( reportPartType, this.GetReportData(), "Employee list", "You are truely appreciated for all your effort in each day."); var htmlReport = reportGenerator.Build( "Employee list", "Below is the list of our employees.", "Copyright © MyCompany"); this.ShowReport(htmlReport); this.SaveReport(htmlReport); }
private string GenerateReportUsingHtmlReportBuilder( ReportSectionDisplayType reportPartType, CancellationToken cancellationToken, IList <Employee> reportData, string xsltPath = null) { // Generate the report IReportBuilder reportGenerator; if (string.IsNullOrWhiteSpace(xsltPath)) { reportGenerator = new HtmlReportBuilder(); } else { reportGenerator = new HtmlReportBuilder(xsltPath); } reportGenerator.AppendReportSection( reportPartType, reportData, "Employee list", "You are truely appreciated for all your effort in each day.", cancellationToken); var htmlReport = reportGenerator.Build( "Employee list", "Below is the list of our employees.", "Copyright © MyCompany", cancellationToken); return(htmlReport); }
public ReportPart( ReportSectionDisplayType reportPartType, string groupHeader, string groupFooter) { this.ReportPartType = reportPartType; this.GroupHeader = groupHeader; this.GroupFooter = groupFooter; }
/// <summary> /// Appends the report section. /// </summary> /// <typeparam name="T">Data Type of the report content</typeparam> /// <param name="contentType">Report section content.</param> /// <param name="contents">The contents collection.</param> /// <param name="sectionHeader">The section header.</param> /// <param name="sectionFooter">The section footer.</param> public void AppendReportSection <T>(ReportSectionDisplayType contentType, IList <T> contents, string sectionHeader, string sectionFooter, CancellationToken cancellationToken) { var reportParts = this.GetReportPart(contentType, contents, sectionHeader, sectionFooter, cancellationToken); if (cancellationToken.IsCancellationRequested) { return; } this.ReportParts.Add(reportParts); }
private async Task <string> GenerateReportWithAutoGenDataAsync( ReportSectionDisplayType reportPartType, int count, CancellationToken cancellationToken, int delayToStart = 0) { // Wait for asked number of seconds. await Task.Delay(delayToStart); // get the asked number of report data in the collection var reportData = this.GetReportData(count); // Generate the report return(GenerateReportUsingHtmlReportBuilder(reportPartType, cancellationToken, reportData)); }
public virtual IObjectToXmlConverter GetObjectToXmlConverter(ReportSectionDisplayType targetContentType) { switch (targetContentType) { case ReportSectionDisplayType.Table: return(new ObjectToTableXmlConverter()); case ReportSectionDisplayType.Label: return(new ObjectToLabelXmlConverter()); case ReportSectionDisplayType.Paragraph: return(new ObjectToParagraphXmlConverter()); default: throw new Exception($"{targetContentType} - The content type is not supported."); } }
/// <summary> /// Gets the report part. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="contentType">Type of the content.</param> /// <param name="contents">The contents.</param> /// <param name="sectionHeader">The section header.</param> /// <param name="sectionFooter">The section footer.</param> /// <returns>IReport instance</returns> protected virtual IReportPart GetReportPart <T>( ReportSectionDisplayType contentType, IList <T> contents, string sectionHeader, string sectionFooter, CancellationToken cancellationToken) { var reportPartInstance = new ReportPart(contentType, sectionHeader, sectionFooter); foreach (var reportContent in contents) { if (cancellationToken.IsCancellationRequested) { return(reportPartInstance); } reportPartInstance.Parts.Add(reportContent); } return(reportPartInstance); }
/// <summary> /// Appends the report section. /// </summary> /// <typeparam name="T">Data Type of the report content</typeparam> /// <param name="contentType">Report section content.</param> /// <param name="contents">The contents collection.</param> /// <param name="sectionHeader">The section header.</param> /// <param name="sectionFooter">The section footer.</param> public void AppendReportSection <T>(ReportSectionDisplayType contentType, IList <T> contents, string sectionHeader, string sectionFooter) { this.AppendReportSection(contentType, contents, sectionHeader, sectionFooter, CancellationToken.None); }