IExportServiceExportAsync Method (ExportRequest)

Performs an export according to the specified request.

Namespace:  Dundas.BI.Export
Assembly:  Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (8.0.2.1001)
Syntax
ExportContext ExportAsync(
	ExportRequest request
)

Parameters

request
Type: Dundas.BI.ExportExportRequest
The request.

Return Value

Type: ExportContext
An ExportContext corresponding to the request.
Exceptions
ExceptionCondition
ArgumentNullExceptionrequest is .
InvalidSessionExceptionThe caller context is not associated with a valid session.
Remarks
Note Note
The provided ExportRequest object is automatically disposed when the export operation is complete.
Examples

This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, export a dashboard to an Excel file, and then shutdown the Dundas BI engine.

C#
using Dundas.BI;
using Dundas.BI.AccountServices;
using Dundas.BI.Services;
using Dundas.BI.Export;
   ...

// Create the engine.
EngineManager.CreateEngine(
    // Path to the application's data folder. Type: System.String
    @"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data"
);

try
{
    // Start the Dundas BI Engine.
    EngineManager.StartEngine();

    Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null);

    LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn(
        // The account name. Type: System.String
        "admin",
        // The password. Type: System.String
        "1234",
        // Delete other sessions for the logon to succeed. Type: System.Boolean
        true,
        // Culture to associate with the session, or null. Type: System.Globalization.CultureInfo
        null
    );

    // Set the session ID to the connection context.
    Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId(
        logOnResult.Session.Id
    );

    // The dashboard to export.
    Guid dashboardId = new Guid("5f83b776-7980-4049-bd7a-76c562eeb340");

    // The provider id for the export.
    Guid excelProviderId = new Guid("679e6337-48aa-4aa3-ad3d-db30ce943dc9");

    // Get the export Service.
    IExportService exportService =
        Engine.Current.GetService<IExportService>();

    // Create an Export Request.
    ExportRequest exportRequest = 
        new ExportRequest(
            excelProviderId, 
            dashboardId
            );

    // Get the Export Context.
    ExportContext exportContext = 
        exportService.ExportAsync(exportRequest);

    // Wait for the export to finish.
    exportContext.ExportTask.Wait();

    // Define the place to save the file.
    string filePath = 
        Path.Combine(@"C:\temp", exportContext.Result.Name + "." + exportContext.Result.FileExtension );

    // Save the result to the file path.
    using (var fileStream = File.Create(filePath))
    {
        exportContext.Result.Content.CopyTo(fileStream);
    }

}
finally
{
    EngineManager.ShutdownEngine();
}
See Also