Params: IMsModelParams;
The Params property returns the collection of parameters.
To get the collection of parameter values, use the IMsModelParamValues interface.
Executing the example requires a form containing the LanerBox component and the UiErAnalayzer component with the UiErAnalayzer1 identifier which is a data source for LanerBox. UiErAnalayzer1 must contain the workbook of the time series database containing the calculated series.
Add links to the Cubes, Dal, Metabase, Ms, Transform system assemblies.
Sub MsParamProv;
Var
Eax: IEaxAnalyzer;
ParamsProv: IMsParamProvider;
Params: IMsModelParams;
Param: IMsModelParam;
ParamVals: IMsModelParamValues;
pVal: IMsModelParamValue;
Laner: ILaner;
i: Integer;
Serie: ILanerSerie;
CalcSerie: ILanerCalculateSerie;
TransfPeriod: ILanerTransformPeriod;
Begin
Eax := UiErAnalyzer1.ErAnalyzer;
// Get the object for working with parameters
ParamsProv := Eax.ParamProvider As IMsParamProvider;
ParamsProv.Params.Clear;
Params := ParamsProv.Params;
// Create new parameters and specify their values
Param := Params.Add;
Param.ParamType := TsParamType.Date;
Param.DataType := DbDataType.DateTime;
Param.Id := "IDENT_START";
Param.Name := "Sample start";
Param := Params.Add;
Param.ParamType := TsParamType.Date;
Param.DataType := DbDataType.DateTime;
Param.Id := "IDENT_END";
Param.Name := "Sample end";
Param := Params.Add;
Param.ParamType := TsParamType.Date;
Param.DataType := DbDataType.DateTime;
Param.Id := "FORECAST_END";
Param.Name := "Forecast end";
// Set parameter values
ParamVals := ParamsProv.ParamValues;
// Sample start
pVal := ParamVals.FindById("IDENT_START");
pVal.Value := "01.01.2003";
// Sample end
pVal := ParamVals.FindById("IDENT_END");
pVal.Value := "01.01.2007";
// Forecast end
pVal := ParamVals.FindById("FORECAST_END");
pVal.Value := "01.01.2015";
// Use the parameters in the workbook
Laner := Eax.Laner;
Laner.BeginUpdate;
// Get the calculated series
For i := 0 To Laner.Series.Count - 1 Do
Serie := Laner.Series.Item(i);
If Serie.Kind = LnSerieKind.Calculate Then
CalcSerie := Serie As ILanerCalculateSerie;
TransfPeriod := CalcSerie.TransformPeriod;
TransfPeriod.AutoPeriod := TransformModelAutoPeriodOptions.None;
TransfPeriod.PeriodSet := LnTransformPeriodSet.All;
// Specify parameters for the calculation period of the series
TransfPeriod.StartDateParamId := "IDENT_START";
TransfPeriod.IdentificationEndDateParamId := "IDENT_END";
TransfPeriod.EndDateParamId := "FORECAST_END";
End If;
End For;
// Update parametric values in the workbook
Laner.Refresh;
Laner.EndUpdate;
End Sub MsParamProv;
Example execution result: the parameters determining the period of calculation of calculated series are created in the workbook. The values of parameters are set, the calculated series are calculated again according to the values of parameters.
See also: