SetDateByLevel(Value: DateTime; Level: DimCalendarLevel);
SetDateByLevel(Value: System.DateTime; Level: Prognoz.Platform.Interop.Dimensions.DimCalendarLevel);
Value. The date, to which expression element value must be fixed.
Level. Calendar frequency, to which expression element value must be fixed.
The SetDateByLevel method fixes date and calendar frequency for expression element.
Date and calendar frequency can be fixed if expression element is a value for the specified date, that is the IMsFormulaTermInfo.Type property is set to MsFormulaTermType.Date.
Executing the example requires that the repository contains a modeling container with the MS identifier that contains the determinate equation model with the MODEL_DATEBYLEVEL identifier. This model must contain one or more factors.
Add links to the Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MSKey: Integer;
Model: IMsModel;
Transform: IMsFormulaTransform;
Determ: IMsDeterministicTransform;
Info: IMsFormulaTermInfo;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MSKey := mb.GetObjectKeyById("MS");
// Get the model
Model := mb.ItemByIdNamespace("MODEL_DATEBYLEVEL", MSKey).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get calculation parameters of determinate equation
Determ := Transform.FormulaItem(0).Method As IMsDeterministicTransform;
Info := Determ.Operands.Item(0).TermInfo;
// Set type of expression element: date-specific value
Info.Type := MsFormulaTermType.Date;
// Set date for expression element
Info.SetDateByLevel(DateTime.Parse("01.01.2015"), DimCalendarLevel.Year);
// Insert element to equation
Determ.Expression.AsString := Info.TermInnerText;
// Save changes
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the date 2015 year is fixed for model factor.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MSKey: uinteger;
Model: IMsModel;
Transform: IMsFormulaTransform;
Determ: IMsDeterministicTransform;
Info: IMsFormulaTermInfo;
Begin
// Get current repository
mb := Params.Metabase;
// Get modelling container key
MSKey := mb.GetObjectKeyById("MS");
// Get the model
Model := mb.ItemByIdNamespace["MODEL_DATEBYLEVEL", MSKey].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get calculation parameters of determinate equation
Determ := Transform.FormulaItem[0].Method As IMsDeterministicTransform;
Info := Determ.Operands.Item[0].TermInfo;
// Set type of expression element: date-specific value
Info.Type := MsFormulaTermType.mfttDate;
// Set date for expression element
Info.SetDateByLevel(DateTime.Parse("01.01.2015"), DimCalendarLevel.dclYear);
// Insert element to equation
Determ.Expression.AsString := Info.TermInnerText;
// Save changes
(Model As IMetabaseObject).Save();
End Sub;
See also: