DataProviders
BiExcellence.OpenBi.Api.DataProviders is the client for the reporting engine. A dataprovider is not a stored object but state in the caller's session on the server: it is opened from a connection template, changed, executed and read, and its id is the name it has in that session.
DataProviderView holds an open dataprovider together with its definition, so most work goes through it:
using BiExcellence.OpenBi.Api.ConnectionTemplates;
using BiExcellence.OpenBi.Api.DataProviders;
// 1. validate a connection template - this puts a dataprovider into the session
var validated = await client.ValidateConnectionTemplateAsync(templateId, cancellationToken: cancellationToken);
var name = validated.DataproviderName!;
// 2. open the cube, query or stored view to read
var opened = await client.OpenDataProviderAsync(name, new OpenDataProviderRequest { InfoCube = "SALES" }, cancellationToken);
// every further connection it turned out to need has to be validated too
foreach (var used in opened.UsedConnections)
{
await client.ValidateConnectionTemplateAsync(
used.ConnectionTemplateId!, new() { DataproviderId = used.DataProviderName }, cancellationToken);
}
// 3. read the definition
await using var view = await client.GetDataProviderViewAsync(name, cancellationToken);
// 4. change it in memory
view.Dimensions["COUNTRY"]!.Axis = DataProviderAxis.Rows;
view.Dimensions["COUNTRY"]!.Filters.Add(new DataProviderFilter("DE"));
view.KeyFigures["REVENUE"]!.Visible = false;
// 5. execute, then read
var result = await view.ExecuteAsync(cancellationToken);
var grid = await view.GetGridDataAsync(withTuples: true, cancellationToken: cancellationToken);
Disposing the view closes the dataprovider on the server.
The definition
Unlike every other resource type of this client, the definition (DataProviderDefinition) is mutable: it is read, edited and sent back.
ExecuteAsyncsends the whole definition. What is left out of it is removed from the dataprovider.- Where executing changed the definition on the server, the view reads it again before
ExecuteAsyncreturns, so it never works on an outdated definition. Dimensions,KeyFigures,Variablesand a dimension'sAttributesare lists that can also be indexed by id. The indexer returnsnullwhere there is no element with that id.- Positions are 1-based per axis and are applied as sent, so setting one dimension's
Positionalone leaves two dimensions on the same position. DataProviderElementExtensions hasMoveandSwap, which renumber the others.
Reading the result
| Call | Returns |
|---|---|
GetGridDataAsync, GetGridDataSliceAsync |
The grid, cell by cell - see DataProviderGridCell for what each cell holds |
GetChartDataAsync |
The data as series and categories for a chart |
GetF4ValuesAsync |
The values a dimension or variable can take (value help) |
ExportAsync |
The grid as an Excel or CSV document (DataProviderExportFormat) |
SaveAsync |
Stores the current state as a view that can be opened again later |