DataType: DbDataType;
DataType: Prognoz.Platform.Interop.Dal.DbDataType;
The DataType property returns a data type of parameter.
To get parameter type, use the ITsModelParamValue.ParamType property.
Executing the example requires a modeling container with the MODEL_SPACE identifier in the repository. The modeling container must include modeling problem with the PROBLEM identifier calculating metamodel with parameters.
Add links to the Metabase, Ms, Dal system assemblies.
Sub ParamVals;
Var
mb: IMetabase;
Ms: IMetabaseObjectDescriptor;
Problem: IMsProblem;
CalcSett: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
ParamsVals: ITsModelParamValues;
ParVal: ITsModelParamValue;
i: Integer;
Begin
mb := MetabaseClass.Active;
// Get modeling container
Ms := mb.ItemById("MODEL_SPACE");
// Get modeling problem
Problem := mb.ItemByIdNamespace("PROBLEM", Ms.Key).Bind As IMsProblem;
// Create parameters or problem calculation
CalcSett := Problem.CreateCalculationSettings;
CalcSett.FactIncluded := True;
// Get parameter values
ParamsVals := CalcSett.ParamValues As ITsModelParamValues;
// Show information about parameters in the console window
For i := 0 To ParamsVals.Count - 1 Do
ParVal := ParamsVals.Item(i);
Debug.WriteLine("Parameter " + i.ToString + ":");
Debug.WriteLine(" parameter identifier: " + ParVal.Id);
Debug.WriteLine(" parameter key: " + ParVal.Key.ToString);
Debug.WriteLine(" parameter name: " + ParVal.Name);
Debug.WriteLine(" default value: " + ParVal.DefaultValue);
Debug.WriteLine(" parameter is hidden: " + ParVal.Hidden.ToString);
Debug.WriteLine(" parameter data type (value of enumeration DbDataType): " + ParVal.DataType.ToString);
Debug.WriteLine(" parameter type (value of enumeration TsParamType): " + ParVal.ParamType.ToString);
If ParVal.LinkedObject <> Null Then
Debug.WriteLine(" the dictionary, to which parameter refers: " + ParVal.LinkedObject.Name);
End If;
End For;
// Calculate
Calc := Problem.Calculate(CalcSett);
Calc.Run;
End Sub ParamVals;
After executing the example modeling problem is calculated, the console window displays values of parameters of the metamodel calculated by the problem.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Transform;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Ms: IMetabaseObjectDescriptor;
Problem: IMsProblem;
CalcSett: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
ParamsVals: ITsModelParamValues;
ParVal: ITsModelParamValue;
i: Integer;
Begin
mb := Params.Metabase;
// Get modeling container
Ms := mb.ItemById["MODEL_SPACE"];
// Get modeling problem
Problem := mb.ItemByIdNamespace["PROBLEM", Ms.Key].Bind() As IMsProblem;
// Create parameters or problem calculation
CalcSett := Problem.CreateCalculationSettings();
CalcSett.FactIncluded := True;
// Get parameter values
ParamsVals := CalcSett.ParamValues As ITsModelParamValues;
// Show information about parameters in the console window
For i := 0 To ParamsVals.Count - 1 Do
ParVal := ParamsVals.Item[i];
System.Diagnostics.Debug.WriteLine
("Parameter " + i.ToString() + ":");
System.Diagnostics.Debug.WriteLine
(" parameter identifier: " + ParVal.Id);
System.Diagnostics.Debug.WriteLine
(" parameter key: " + ParVal.Key.ToString());
System.Diagnostics.Debug.WriteLine
(" parameter name: " + ParVal.Name);
System.Diagnostics.Debug.WriteLine
(" default value: " + ParVal.DefaultValue);
System.Diagnostics.Debug.WriteLine
(" parameter is hidden: " + ParVal.Hidden.ToString());
System.Diagnostics.Debug.WriteLine
(" parameter data type (value of enumeration DbDataType): " + ParVal.DataType.ToString());
System.Diagnostics.Debug.WriteLine
(" parameter type (value of enumeration TsParamType): " + ParVal.ParamType.ToString());
If ParVal.LinkedObject <> Null Then
System.Diagnostics.Debug.WriteLine
(" the dictionary, to which parameter refers: " + ParVal.LinkedObject.Name);
End If;
End For;
// Calculate
Calc := Problem.Calculate(CalcSett);
Calc.Run();
End Sub;
See also: