Coder Social home page Coder Social logo

devexpress-examples / reporting-use-async-engine-in-aspnet-core Goto Github PK

View Code? Open in Web Editor NEW
3.0 56.0 0.0 361 KB

Asynchronous save, load, and export operations in Web Reporting

License: Other

C# 74.66% HTML 25.34%
async asynchronous reporting aspnet-core reporting-for-asp-net-core

reporting-use-async-engine-in-aspnet-core's Introduction

Reporting for ASP.NET Core - How to Use the Asynchronous Engine

Overview

This example demonstrates how to implement and use custom services, which allow you to save, load, and export reports asynchronously.

This application registers a service with the IReportProviderAsync interface. The latter allows you to perform the following tasks asynchronously:

  • open subreports from the master report;
  • resolve a unique identifier to a report (an operation that affects the Designer Preview and Document Viewer performance).

In general, asynchronous operation mode gives you the following advantages:

  • It handles threads in web applications more cautiously and returns threads to the thread pool while the operation is in progress.
  • You can write safe asynchronous code in a project with a third-party library that uses only asynchronous API.

You can use an asynchronous engine in the following scenarios:

  • Handle the End User Report Designer and Web Document Viewer events to load data or create a document asynchronously. The key point is that these actions can be performed in the context of the current HTTP request in the WebDocumentViewerOperationLogger and PreviewReportCustomizationService class methods.
  • Drill Through navigation in the Web Document Viewer. Use the IDrillThroughProcessorAsync interface.
  • If an application uses JWT-based Authentication, use the IWebDocumentViewerExportResultUriGeneratorAsync interface to load exported documents to the storage asynchronously.

Implementation Details

Perequisites

To get started, create a sample project with our ASP.NET Core Reporting Project Template.

Report Provider

The CustomReportProviderAsync.cs file contains a class that implements the DevExpress.XtraReports.Services.IReportProviderAsync interface and calls the report storage's ReportStorageWebExtension.GetDataAsync method.

Report Storage

The CustomReportStorageWebExtension.cs file contains a class that implements a custom report storage with asynchronous methods. The CustomReportStorageWebExtension class inherits from the ReportStorageWebExtension and overrides all its public methods. Note that methods, which cannot be used in asynchronous mode, throw exceptions.

Report Model and Controllers

The Home controller uses the GetModelAsync methods to generate report models and send them to the End User Report Designer and Document Viewer.
You cannot use asynchronous API if the Bind method receives a report instance or a string (ReportUrl) as a parameter. Bind report controls to the ReportDesignerModel or WebDocumentViewerModel objects originated from controllers. The controller-based model allows you to use asynchronous API and avoid obscure problems. Such problems may occur when a subreport fails to load and throws an exception, or when a dynamic list of parameter values fails to retrieve its data.

ExportToPdf Action

The export action takes advantage of the IReportProviderAsync service that resolves report ID to a report and expedites the load of subreports without the need for the web report controls. The DI container injects the IReportProviderAsync service into the XtraReport instance. Then, the asynchronous CreateDocumentAsync method creates a document and the asynchronous ExportToPdfAsync method exports the document to PDF.

Enable Asynchronous Services

Request handlers in ASP.NET Core applications are asynchronous. To enable asynchronous services, call the UseAsyncEngine method at application startup:

services.ConfigureReportingServices(configurator => { 
    configurator.ConfigureReportDesigner(designerConfigurator => { 
        //.. 
    }); 
    configurator.ConfigureWebDocumentViewer(viewerConfigurator => { 
        //.. 
    }); 
    configurator.UseAsyncEngine(); 
});

Files to Review

Documentation

More Examples

reporting-use-async-engine-in-aspnet-core's People

Contributors

andreylepikhov avatar devexpressexamplebot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.