RefreshAttributesStructure;
RefreshAttributesStructure();
The RefreshAttributesStructure method refreshes the structure of attributes of the variable
The method is relevant if the variable is based on attributes.
Executing the example requires a time series database with the TSDB identifier, containing the model of the determinate equation with the MODEL_ATTR identifier in the internal modeling container.
To execute the example, add links to the Cubes, Metabase, Ms system assemblies.
Sub UserCalc;
Var
Mb: IMetabase;
RubrDescr: IMetabaseObjectDescriptor;
Rubr: IRubricator;
MsDescr: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
TransformVarables: IMsFormulaTransformVariables;
TransfVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
Period: IMsModelPeriod;
Formula: IMsFormula;
Begin
// Get time series database
Mb := MetabaseClass.Active;
RubrDescr := Mb.ItemById("TSDB");
Rubr := RubrDescr.Bind As IRubricator;
// Get the internal modeling container
MsDescr := Rubr.ModelSpace;
// Get the model
Model := Mb.ItemByIdNamespace("MODEL_ATTR", MsDescr.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Refresh output variable attributes structure
TransformVarables := Transform.Outputs;
TransfVar := TransformVarables.Item(0);
TransfVar.RefreshAttributesStructure;
// Set the parameters for calculation of the model
Coord := Transform.CreateCoord(TransfVar);
Calc := Transform.CreateCalculation;
Period := Calc.Period;
Period.IdentificationStartDate := Model.Period.IdentificationStartDate;
Period.IdentificationEndDate := Model.Period.IdentificationEndDate;
Period.ForecastStartDate := Model.Period.ForecastStartDate;
Period.ForecastEndDate := Model.Period.ForecastEndDate;
Calc.CurrentPoint := Model.Period.IdentificationStartDate;
// Perform calculation of the model
Formula := Transform.FormulaItem(0);
(Formula.Method As IMsDeterministicTransform).Execute(Calc, Coord);
// Save changes
(Model As IMetabaseObject).Save;
End Sub UserCalc;
Example execution result: the structure of attributes of the output variable in the MODEL_ATTR model is updated, the model is calculated.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
RubrDescr: IMetabaseObjectDescriptor;
Rubr: IRubricator;
MsDescr: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
TransformVarables: IMsFormulaTransformVariables;
TransfVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
Period: IMsModelPeriod;
Formula: IMsFormula;
Begin
// Get time series database
Mb := Params.Metabase;
RubrDescr := Mb.ItemById["TSDB"];
Rubr := RubrDescr.Bind() As IRubricator;
// Get the internal modeling container
MsDescr := Rubr.ModelSpace;
// Get the model
Model := Mb.ItemByIdNamespace["MODEL_ATTR", MsDescr.Key].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Refresh output variable attributes structure
TransformVarables := Transform.Outputs;
TransfVar := TransformVarables.Item[0];
TransfVar.RefreshAttributesStructure();
// Set the parameters for calculation of the model
Coord := Transform.CreateCoord(TransfVar);
Calc := Transform.CreateCalculation();
Period := Calc.Period;
Period.IdentificationStartDate := Model.Period.IdentificationStartDate;
Period.IdentificationEndDate := Model.Period.IdentificationEndDate;
Period.ForecastStartDate := Model.Period.ForecastStartDate;
Period.ForecastEndDate := Model.Period.ForecastEndDate;
Calc.CurrentPoint := Model.Period.IdentificationStartDate;
// Perform calculation of the model
Formula := Transform.FormulaItem[0];
(Formula.Method As IMsDeterministicTransform).Execute(Calc, Coord);
// Save changes
(Model As IMetabaseObject).Save();
End Sub;
See also: