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)
SyntaxExportContext ExportAsync(
ExportRequest request
)
Function ExportAsync (
request As ExportRequest
) As ExportContext
ExportContext^ ExportAsync(
ExportRequest^ request
)
abstract ExportAsync :
request : ExportRequest -> ExportContext
Parameters
- request
- Type: Dundas.BI.ExportExportRequest
The request.
Return Value
Type:
ExportContextAn
ExportContext corresponding to the request.
Exceptions| Exception | Condition |
|---|
| ArgumentNullException | request is . |
| InvalidSessionException | The caller context is not associated with a valid session. |
Remarks Note |
|---|
|
The provided ExportRequest object is automatically disposed when the export operation is complete.
|
ExamplesThis 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.
using Dundas.BI;
using Dundas.BI.AccountServices;
using Dundas.BI.Services;
using Dundas.BI.Export;
...
EngineManager.CreateEngine(
@"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data"
);
try
{
EngineManager.StartEngine();
Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null);
LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn(
"admin",
"1234",
true,
null
);
Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId(
logOnResult.Session.Id
);
Guid dashboardId = new Guid("5f83b776-7980-4049-bd7a-76c562eeb340");
Guid excelProviderId = new Guid("679e6337-48aa-4aa3-ad3d-db30ce943dc9");
IExportService exportService =
Engine.Current.GetService<IExportService>();
ExportRequest exportRequest =
new ExportRequest(
excelProviderId,
dashboardId
);
ExportContext exportContext =
exportService.ExportAsync(exportRequest);
exportContext.ExportTask.Wait();
string filePath =
Path.Combine(@"C:\temp", exportContext.Result.Name + "." + exportContext.Result.FileExtension );
using (var fileStream = File.Create(filePath))
{
exportContext.Result.Content.CopyTo(fileStream);
}
}
finally
{
EngineManager.ShutdownEngine();
}
See Also