Programmatic report export in background

1 Answer 45 Views
DataSources Rendering Report Designer - Web Report Parameters Rest Service
Steve
Top achievements
Rank 2
Iron
Steve asked on 15 Jun 2023, 07:54 PM

Hi,
 I am working on a ASP.NET Core (.NET 6) web application with the main report UI using the HTML 5 viewer, working from the REST service controller.

We also require automated report exporting to run at scheduled times with predefined parameters (to be stored and emailed). SQL datasource(s) and engine settings will be the same as used in the reports controller.

Please can you advise on the best approach to process and output export files from the server-side application code.

It looks like I need to use the ReportProcessor class, but not sure how to make use of "engine" config...

 

Further application detail and problem encountered:

I have implemented the EF Core based report storage example and have a custom function assembly, used in most reports.

The IReportSourceResolver is provided along with the engine configuration - connections strings and custom function assembly reference - in a ReportServiceConfiguration instance for the ReportsController.


I believe that ReportProcessor does not somehow obtain the IReportServiceConfiguration the REST controller has injected.

There is no issue running code in a background job (eg. Quartz.NET):

  • loading a report instance with the IReportSourceResolver implementation
  • using code based on this example to set SQL datasource connection strings
  • using ReportProcessor.RenderReport().

This has worked fine for a little while, but the ReportProcessor seems to no longer find and load the custom assembly - though I'm sure it is output to the build location (and has had no recent changes).

Thanks.



1 Answer, 1 is accepted

Sort by
1
Accepted
Dimitar
Telerik team
answered on 20 Jun 2023, 10:40 AM

Hi Steven,

Thank you for the provided information about your scenario!

The custom user functions assembly needs to be referenced in the configuration file of the running application that is used to create an IConfiguration instance. That is enough in the case where reporting service is used but when using the ReportProcessor class to render reports, the IConfiguration instance has to be manually passed to the constructor of the report processor.

Please refer to the How to pass configuration settings to ReportProcessor in ASP.NET Core application that does not use Telerik Reporting REST Service - Telerik Reporting KB article for details on how that may happen.

As long as the custom assembly is correctly added to the assemblyReferences section, that should be enough to get the assembly resolved. For example, this is how the telerikReporting property may look in the appsettings.json file:

  "telerikReporting": {
    "assemblyReferences": [
      {
        "name": "CustomFunctions"
      }
    ]
  }

For retrieving the reports from your database and creating the ReportSource object of it, you will need to write the code that does that but you may also use the example from the  5th step of the MSSQL Server database as Reports Storage for Web Report Designer - Telerik Reporting article.

I hope that the provided suggestions will help, please let me know if you have any additional questions.

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Steve
Top achievements
Rank 2
Iron
commented on 20 Jun 2023, 03:07 PM

Hi Dimitar,

Thanks, I totally missed that IConfiguration constructor overload for ReportProcessor.

One more question. If the IConfiguration contains datasource connnection strings, will ReportProcessor make use of any that match a shared connection alias in the report being processed - or will code still be required to set them in the Report object?

Dimitar
Telerik team
commented on 22 Jun 2023, 08:53 AM

Hi Steven,

Yes, as long as they are shared connections, the ReportProcessor should be able to resolve them from the given IConfiguration instance if the alias(nameof the connection is the same as the one in the report definition.

Tags
DataSources Rendering Report Designer - Web Report Parameters Rest Service
Asked by
Steve
Top achievements
Rank 2
Iron
Answers by
Dimitar
Telerik team
Share this question
or