ControlledObject: IEaxDataAreaSlice;
ControlledObject: Prognoz.Platform.Interop.Express.IEaxDataAreaSlice;
The ControlledObject property returns the analytical data area slice for which parameter control is set up.
To determine expression to bind report and slice parameters, use the IEaxDataAreaParamControl.Expression property.
To execute the example the repository must contain a regular report with the REPORT identifier. Parameters and slice on which the table is built are added to the report. The cube with a parameter containing name and the TERRITORIA identifier is used as data source for slice.
Add links to the Dal, Express, Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Area: IEaxDataArea;
Slices: IEaxDataAreaSlices;
Slice: IEaxDataAreaSlice;
Control: IEaxDataAreaParamControl;
Info: IEaxDataAreaControlInfo;
SliceCtrl: IEaxDataAreaControl;
Parameters: IEaxDataAreaParams;
Param: IEaxDataAreaParam;
ParamMB: IMetabaseObjectParamValue;
i: Integer;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get regular report
Report := MB.ItemById("REPORT").Edit As IPrxReport;
// Get analytical area of regular report
Area := Report.DataArea As IEaxDataArea;
// Get analytical area slices
Slices := Area.Slices;
// Get the first slice
Slice := Slices.Item(0);
// Display the number of slice parameters obtained on automatic generation
Parameters := Slice.Params;
Debug.WriteLine("Number of slice parameters: " + Parameters.Count.ToString);
//Disable automatic generation
Slice.GenerateSourceParams := False;
// Display the number of slice parameters after generation is disabled
Debug.WriteLine("Number of slice parameters after the generation is disabled: " + Parameters.Count.ToString);
// Add a slice parameter
Parameters.Clear;
Param := Parameters.AddNew;
Param.Id := "TERRITORIA";
Param.Name := "TERRITORIA";
Param.DataType := DbDataType.Integer;
// Get report parameters
ParamMB := Report.MetabaseObject.ParamValues.Item(0);
// Get object of slice parameter controlling setting
Info := Area.ControlInfo;
// Add a controlling setting object
SliceCtrl := Info.AddControl(Slice);
// Get slice to set up control
Slice := SliceCtrl.ControlledObject;
// Add a controlling setting for slice parameter
Control := SliceCtrl.AddControl(Param.Id);
Debug.WriteLine("Slice parameter: " + Param.Name + '(' + Param.Id + ").");
For i := 0 To SliceCtrl.Count - 1 Do
Control := SliceCtrl.Item(i);
// Get parameter to bind to report parameter
Param := Control.ControlledParam;
// Set expression determining parameter binding
Control.Expression.AsString := "{@" + (ParamMB.Id) + "}";
End For;
//Check whether slice parameter control is set up
Debug.WriteLine("Control is not specified: " + SliceCtrl.IsEmpty.ToString);
// Save report
Report.MetabaseObject.Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Report;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Area: IEaxDataArea;
Slices: IEaxDataAreaSlices;
Slice: IEaxDataAreaSlice;
Control: IEaxDataAreaParamControl;
Info: IEaxDataAreaControlInfo;
SliceCtrl: IEaxDataAreaControl;
Parameters: IEaxDataAreaParams;
Param: IEaxDataAreaParam;
ParamMB, ParamMB1: IMetabaseObjectParamValue;
Expression: String;
i: Integer;
Begin
// Get repository
MB := Params.Metabase;
// Get regular report
Report := MB.ItemById["REPORT"].Edit() As IPrxReport;
// Get analytical area of regular report
Area := Report.DataArea As IEaxDataArea;
// Get analytical area slices
Slices := Area.Slices;
// Get the first slice
Slice := Slices.Item[0];
// Display the number of slice parameters obtained on automatic generation
Parameters := Slice.Params;
System.Diagnostics.Debug.WriteLine("Number of slice parameters: " + Parameters.Count.ToString());
//Disable automatic generation
Slice.GenerateSourceParams := False;
// Display the number of slice parameters after generation is disabled
System.Diagnostics.Debug.WriteLine("Number of slice parameters after the generation is disabled: " + Parameters.Count.ToString());
// Add a slice parameter
Parameters.Clear();
Param := Parameters.AddNew();
Param.Id := "TERRITORIA";
Param.Name := "TERRITORIA";
Param.DataType := DbDataType.ddtInteger;
// Get report parameters
ParamMB := Report.MetabaseObject.ParamValues.Item[0];
// Get object of slice parameter controlling setting
Info := Area.ControlInfo;
// Add a controlling setting object
SliceCtrl := Info.AddControl(Slice);
// Get slice to set up control
Slice := SliceCtrl.ControlledObject;
// Add a controlling setting for slice parameter
Control := SliceCtrl.AddControl(Param.Id);
System.Diagnostics.Debug.WriteLine("Slice parameter: " + Param.Name + '(' + Param.Id + ").");
For i := 0 To SliceCtrl.Count - 1 Do
Control := SliceCtrl.Item[i];
// Get parameter to bind to report parameter
Param := Control.ControlledParam;
// Set expression determining parameter binding
Control.Expression.AsString := "{@" + (ParamMB.Id) + "}";
End For;
//Check whether slice parameter control is set up
System.Diagnostics.Debug.WriteLine("Control is not specified: " + SliceCtrl.IsEmpty.ToString());
// Save report
Report.MetabaseObject.Save();
End Sub;
After executing the example the console window displays:
The number of slice parameters before and after automatic generation is disabled.
Whether slice parameters control is set up.
The slice parameter will be linked to report parameter.
See also: