This is a migrated thread and some comments may be shown as answers.

While automating rendering of multiple PDF reports, seemingly intermittent failure to render sub reports occurs.

5 Answers 131 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
GeneralMac
Top achievements
Rank 1
GeneralMac asked on 15 May 2020, 02:31 PM

The company I work for generates multiple PDF reports everyday on a schedule. We loop through a list that we generate reports for. The reports have multiple sub reports that have datasources that connect to our databases. The sub reports have sub reports as well. We have run into an issue that we have been wrestling with and need some assistance.

Every now and then a report is generated, without throwing errors, that is mostly blank. All it has on it is some text, a logo and a page number; none of which are sub reports. We have error handling all around the code in which does the actual rendering, yet we don't see an exception being thrown. We also check to see if there isn't data for the report before and if there isn't we don't ask the Telerik Reporting library to render anything.

I've attached three images, the first is "blank" report and the second that is populated report. The blank report was generated through our automated process along with other reports. The populated report is one that I generated using the same code but manually outside of the scheduled time in which we "batch" generate reports. These would be considered the same report, because the same parameters were used in the query for the same database.

The third image is the report designer view of the same report -- the top most report.

Thank you for any help you can give us.

5 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 20 May 2020, 08:38 AM

Hi GeneralMac,

From the screenshots, I infer that the detail section of the report is not generated when the report comes out blank. The Page Header with the logo, the Report Footer with the static text, and the Page Footer with the page numbers seem to be generated in both cases.

Generally, the detail section will be generated for each data record in the Report DataSource. If the DataSource is empty, there will be no detail section. If there is no data source associated with the Report DataSource property, the detail section will be generated once.

Based on the available information, my only assumption is that when the report was generated blank, the Report DataSource returned no data. The fact that when the report was blank in the Page Header the top TextBoxes that were supposed to display fields from the data source were missing supported this. Note that in the blank report above 'Daily Report' text there are no TextBoxes, whereas in the correct report there are two lines that are also present in the design screenshot - "=Fields...Name".

You may test whether the detail section is generated, for example, by setting it a background color so that it can be distinguished from the other sections.

You may also enable the Trace Listener for the project that renders the reports to check whether our code will log some useful information, for example concerning the subreport rendering.

If you sent us a runnable sample that demonstrates the issue we would be glad to investigate it.

Regards,
Todor
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
GeneralMac
Top achievements
Rank 1
answered on 21 May 2020, 03:42 PM

Todor,

Thank you for your observations. I don't think I realized that if the Report DataSource was empty that the detail sections wouldn't be rendered. This makes sense now. Before we ask the Telerik Reporting library to generate the report for us we insert data into a table that is read initially by the top most level Report. We also do clean up as well by deleting out of this table. At this point I think there may be some concurrent processes happening that may be wiping this data out before we get to rendering the Report. We have implemented more checks around this code to see if this is the case. I appreciate the help!

0
GeneralMac
Top achievements
Rank 1
answered on 25 Jun 2020, 12:33 PM
Also, for anyone else struggling with things just not rendering I ran on to reporting doc (https://docs.telerik.com/reporting/report-structure-dataitem-set-no-data-message#-no-data-message-for-reports).
If the dataSource for the top level report (i.e. not a sub-report), nothing that has to do with the datasource (including the length of the datasource) renders, only static text and parameters.
0
GeneralMac
Top achievements
Rank 1
answered on 06 Jul 2020, 03:28 PM

Todor,
I have placed a check in our code immediately before and immediately after rendering of the Report. And the result of a "blank" is still being intermittently generated. Here is a small snippet of the code:

01.var result = await _reportRepository.GetBaseReportDataCount();
02.if (result < 1)
03.{
04.    var msg = $"A Report with a date range of {report.ReportDateStart} - {report.ReportDateEnd} (UTC) has no baseReportData and can't be rendered.";
05.    _logger.LogCritical(msg);
06.    throw new NoBaseReportDataException(msg);
07.}
08. 
09.//This method will invoke the <class>_ItemDataBinding method
10.var renderingResult = reportProcessor.RenderReport(format: "PDF", reportSource: reportSource, deviceInfo: new Hashtable());
11.if (renderingResult.HasErrors) {
12.    var msg = $"Errors have occured for {reportName} with a date range of {report.ReportDateStart} - {report.ReportDateEnd} (UTC).";
13.    throw new Exception(msg);
14.}
15. 
16.// Check BaseReportData table again after generation.
17.result = await _reportRepository.GetBaseReportDataCount();
18.if (result < 1)
19.{
20.    var msg = $"A Report with a date range of {report.ReportDateStart} - {report.ReportDateEnd} (UTC) has no baseReportData and can't be rendered.";
21.    _logger.LogCritical(msg);
22.    throw new NoBaseReportDataException(msg);
23.}

We can't seem to catch when this happens. The report generates just fine when it is the only report being generated. But when our service generates reports on a schedule there is a chance that a blank report is created. Again, its not all of the time that this happens -- seemingly intermittent. Thanks for the help.

 

0
Todor
Telerik team
answered on 09 Jul 2020, 12:30 PM

Hello GeneralMac,

Based on one of the comments in the code snippet, I assume that you use the ItemDataBinding event of the report or report item. Can you specify whether this is correct, and if so how do you use the event handler? Do you use other report events to modify the report run time in the code behind?

You may try to serialize the report definition just before it gets passed to the ReportProcessor. This way you will see how the final report definition looks like and may find something useful for troubleshooting the issue. For example, you may compare the report definition when the same report is rendered alone, and when from the scheduled service. Note that the serialization process ignores some information like events.

You may still send us a runnable project that demonstrates the problem for local investigation.

Regards,


Todor
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
GeneralMac
Top achievements
Rank 1
Answers by
Todor
Telerik team
GeneralMac
Top achievements
Rank 1
Share this question
or