The requested page is not available for the requested platform. You are viewing the content for Default platform.

Register Services in the Report Designer

  • 4 min to read

You can register custom and/or predefined services to provide specific functionality to the Web Report Designer and its built-in Document Preview.

Report Designer's Services

In the Startup.ConfigureServices method, use the ServiceCollectionServiceExtensions and ReportDesignerConfigurationBuilder classes' methods as shown below.

using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;
//... 

public class Startup {
//... 
    public void ConfigureServices(IServiceCollection services) {
        // ...

        services.ConfigureReportingServices(configurator => {
            configurator.ConfigureReportDesigner(designerConfigurator => {
                designerConfigurator.RegisterDataSourceWizardConnectionStringsProvider<customProvider>();
            });
        });        
        services.AddSingleton<IDataSourceWizardDBSchemaProviderExFactory, DBSchemaProviderExFactory>();
    }
//...    
}

See Introduction to Dependency Injection in ASP.NET Core for more information.

Custom Services

The following table lists the services you can implement and register in the Report Designer:

Service

Description

Registration Methods

IDataSourceWizardConnectionStringsProvider

Enables you to manage data connections for the Data Source Wizard.

RegisterDataSourceWizardConnectionStringsProvider<T>

RegisterDataSourceWizardConfigFileConnectionStringsProvider (to use the data source connections from the application's configuration file).

ISecureDataConverter

Allows you to provide a custom encryption mechanism to store data source connection strings on the client.

ServiceCollectionServiceExtensions class's methods

IDataSourceWizardDBSchemaProviderExFactory

Provides the capability to customize the database schema.

ServiceCollectionServiceExtensions class's methods

ISqlDataSourceWizardCustomizationService

Allows you to customize the Data Source Wizard.

RegisterSqlDataSourceWizardCustomizationService<T>

IReportDesignerExceptionHandler

Enables you to handle server-side errors in the Report Designer.

ServiceCollectionServiceExtensions class's methods

PreviewReportCustomizationService

Enables you to customize the current report and assign a CachedReportSourceWeb object when the Report Designer is about to be switched to the Preview tab.

ServiceCollectionServiceExtensions class's methods

Predefined Services

The table below lists the ReportDesignerConfigurationBuilder's methods to register the predefined services that override the default Report Designer behavior:

Method Description
AllowPassingDataSourceConnectionParametersToClient Allows the Web Report Designer to pass data source connection parameters from the application configuration file to the client.
EnableCustomSql Enables editing custom SQL strings in the Data Source Wizard.

Document Viewer's Services

You can also register services for the Report Designer's integrated Document Viewer.

In the Startup.ConfigureServices method, use the ServiceCollectionServiceExtensions and WebDocumentViewerConfigurationBuilder classes' methods as demonstrated below.

public void ConfigureServices(IServiceCollection services) {
    // ...
    services.ConfigureReportingServices(configurator => {
        configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
            viewerConfigurator.RegisterWebDocumentViewerDrillThroughProcessor<CustomDrillThroughProcessor>();
        });
    });

    services.AddSingleton<WebDocumentViewerOperationLogger, MyOperationLogger>();
}

Custom Services

The following table lists the services you can implement and register in the Report Designer's Preview:

Service

Description

Registration Methods

IWebDocumentViewerAuthorizationService

Enables you to implement a custom authorization mechanism.

ServiceCollectionServiceExtensions class's methods

IExportingAuthorizationService

Allows you to provide a custom authorization mechanism for exported documents.

ServiceCollectionServiceExtensions class's methods

WebDocumentViewerOperationLogger

Enables you to log events when the Web Document Viewer processes reports and generated documents.

ServiceCollectionServiceExtensions class's methods

IWebDocumentViewerDrillThroughProcessor

Provides drill-through functionality to web reports.

WebDocumentViewerConfigurationBuilder.RegisterWebDocumentViewerDrillThroughProcessor

IWebDocumentViewerReportResolver

Resolves reports to display in the Web Document Viewer.

ServiceCollectionServiceExtensions class's methods

DocumentOperationService

Enables you to perform custom operations with a Document Viewer's currently opened document.

ServiceCollectionServiceExtensions class's methods

IConnectionProviderFactory

Allows you to restore a data connection on a report's deserialization.

WebDocumentViewerConfigurationBuilder.RegisterConnectionProviderFactory

IWebDocumentViewerExceptionHandler

Enables you to handle server-side errors in the Web Document Viewer.

ServiceCollectionServiceExtensions class's methods

IWebDocumentViewerExportResultUriGenerator

Allows you to override the default URI that a browser uses to get an export result.

ServiceCollectionServiceExtensions class's methods

StorageCleanerSettings

Enables you to provide time settings to clean a storage to store documents and reports.

ServiceCollectionServiceExtensions class's methods

CacheCleanerSettings

Enables you to provide time settings to clean a cache to store documents and reports.

ServiceCollectionServiceExtensions class's methods

Predefined Services

The table below lists the WebDocumentViewerConfigurationBuilder's methods to register the predefined services that override the default Document Viewer behavior:

Method Description
UseFileReportStorage Specifies a path to the report's file storage.
UseFileDocumentStorage Specifies a path to the report document's file storage.
UseFileExportedDocumentStorage Specifies a path to the exported document's file storage.
UseEmptyStoragesCleaner Replaces a service that is used to clean the report and document storage with an empty service to avoide automatic cleaning of this storage.
EnablePassingExportOptionsPasswordsToClient Enables passing PDF/Excel passwords specified in the Report Designer to the Web Document Viewer.

Report Storage Extension

Create a descendant from the ReportStorageWebExtension class to define how reports should be stored on your application's server side. Use the static ReportStorageWebExtension.RegisterExtensionGlobal method in the Startup.Configure method to register your storage.

public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
    // ...
    DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension.RegisterExtensionGlobal(new MyReportStorageWebExtension());   
}

Logger Service

Use the LoggerService class to handle exceptions that occur on the server side and log other document-related operations and information messages. Use the LoggerService.Initialize method at the application startup to register a custom logger instance.

public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
    // ...
    DevExpress.XtraReports.Web.ClientControls.LoggerService.Initialize(new MyLoggerService());   
}