Id:String;
Id:string;
The Id property determines data source identifier.
To get data source as a repository object, use the IAdhocDataSourceObject.SourceObjectDescriptor property.
Executing the example requires that the repository contains a dashboard with the DASHBOARD_ID identifier and an express report with the EXP_DSOID identifier.
Add links to the Adhoc, Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Dashboard: IAdhocReport;
DsObjs, DOD: IAdhocDataSourceObjects;
i: Integer;
DsObj: IAdhocDataSourceObject;
mbo, mbos: IMetabaseObject;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get dashboard
mbo := mb.ItemById("DASHBOARD_ID").Edit;
Dashboard := mbo As IAdhocReport;
// Get dashboard data sources
DsObjs := Dashboard.DataSourceObjects;
DsObjs.RemoveById("EXP_DSOID");
DsObjs.RemoveById("EXP_DSO");
//Add a data source
mbos := mb.ItemById("EXP_DSOID") As IMetabaseObject;
DsObj := Dashboard.AddDataSourceObject("EXP_DSOID", mbos);
// Copy data source
DsObj := Dashboard.CopyDataSourceObjectEx(DsObj, "EXP_DSO");
// Remove the first data source
DsObjs.Remove(0);
For i := 0 To DsObjs.Count - 1 Do
// Get data source name
DsObj := DsObjs.Item(i);
Debug.WriteLine("Data source name " + (i + 1).ToString + " - " + DsObj.SourceObjectDescriptor.Name);
// Get data source identifier
Debug.WriteLine("Data source identifier " + (i + 1).ToString + " - " + DsObj.Id);
End For;
// Get the number of sources
DOD := DsObj.DataSourceObjects;
Debug.WriteLine("Number of sources = " + DOD.Count.ToString);
mbo.Save;
End Sub UserProc;
After executing the example a data source is copied to the dashboard, and the EXP_DSO identifier is assigned to it, the console window displays the number of active slides, data source names, data source identifiers, the number of data sources.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Adhoc;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Dashboard: IAdhocReport;
DsObjs, DOD: IAdhocDataSourceObjects;
i: Integer;
DsObj: IAdhocDataSourceObject;
mbo, mbos: IMetabaseObject;
slides: IAdhocSlides;
Begin
// Get current repository
mb := Params.Metabase;
// Get dashboard
mbo := mb.ItemById["DASHBOARD_ID"].Edit();
Dashboard := mbo As IAdhocReport;
// Get dashboard data sources
DsObjs := Dashboard.DataSourceObjects;
DsObjs.RemoveById("EXP_DSOID");
DsObjs.RemoveById("EXP_DSO");
//Adding data source
mbos := mb.ItemById["EXP_DSOID"] As IMetabaseObject;
DsObj := Dashboard.AddDataSourceObject("EXP_DSOID", mbos);
// Copy data source
DsObj := Dashboard.CopyDataSourceObjectEx(DsObj, "EXP_DSO");
// Remove the first data source
DsObjs.Remove(0);
For i := 0 To DsObjs.Count - 1 Do
// Get data source name
DsObj := DsObjs.Item[i];
System.Diagnostics.Debug.WriteLine("data source name " + (i + 1).ToString() + " - " + DsObj.SourceObjectDescriptor.Name);
// Get data source identifier
System.Diagnostics.Debug.WriteLine("data source identifier " + (i + 1).ToString() + " - " + DsObj.Id);
End For;
// Get the number of sources
DOD := DsObj.DataSourceObjects;
System.Diagnostics.Debug.WriteLine("Number of sources - " + DOD.Count.ToString());
mbo.Save();
End Sub;
See also: