StubLoadSelections: IMsStubLoadSelectionValues;
StubLoadSelections: Prognoz.Platform.Interop.Ms.IMsStubLoadSelectionValues;
The StubLoadSelections property returns the collection of selections in data sources used to load data on model calculation.
The use of this property enables the user to avoid loading of data that are not used in calculations. Thus, it reduces calculation time.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the PROBLEM_FILTER identifier. Metamodel calculated by this problem must contain several elements in calculation chain.
Add links to the Cubes, Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Problem: IMsProblem;
CalcSettings: IMsProblemCalculationSettings;
StubLoadSel: IMsStubLoadSelectionValues;
StubLoadSelVal: IMsStubLoadSelectionValue;
Stub: IVariableStub;
SelSet: IDimSelectionSet;
i: Integer;
DimInst: IDimInstance;
Sel: IDimSelection;
Calculation: IMsProblemCalculation;
Begin
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace("PROBLEM_FILTER", MsKey).Edit As IMsProblem;
// Get problem calculation parameters
CalcSettings := Problem.CreateCalculationSettings;
// Get selection parameters in data sources for loading on problem calculation
StubLoadSel := CalcSettings.StubLoadSelections;
// Clear selection
StubLoadSel.Clear;
// Get the first data source used by modeling problem
Stub := Problem.VariableStubs(MsVariableKind.All).Item(0);
// Set selection in data source for loading on model calculation
StubLoadSelVal := StubLoadSel.Add(Stub.Key);
// Output data source name
Debug.WriteLine("Data source name: " + mb.Item(StubLoadSelVal.StubKey).Name);
SelSet := StubLoadSelVal.SelectionSet;
SelSet.Clear;
For i := 0 To Stub.DimensionCount - 1 Do
DimInst := (Stub.Dimension(i) As IMetabaseObject).Open(Null) As IDimInstance;
Sel := SelSet.Add(DimInst);
Sel.SelectElement(1, True);
Sel.SelectElement(3, True);
End For;
// Calculate problem
Calculation := Problem.Calculate(CalcSettings);
Calculation.Run;
End Sub UserProc;
After executing the example the modeling problem is calculated considering set selection for loading in data sources.
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.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
Problem: IMsProblem;
CalcSettings: IMsProblemCalculationSettings;
StubLoadSel: IMsStubLoadSelectionValues;
StubLoadSelVal: IMsStubLoadSelectionValue;
Stub: IVariableStub;
SelSet: IDimSelectionSet;
i: Integer;
DimInst: IDimInstance;
Sel: IDimSelection;
Calculation: IMsProblemCalculation;
Begin
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace["PROBLEM_FILTER", MsKey].Edit() As IMsProblem;
// Get problem calculation parameters
CalcSettings := Problem.CreateCalculationSettings();
// Get selection parameters in data sources for loading on problem calculation
StubLoadSel := CalcSettings.StubLoadSelections;
// Clear selection
StubLoadSel.Clear();
// Get the first data source used by modeling problem
Stub := Problem.VariableStubs[MsVariableKind.mvkAll].Item[0];
// Set selection in data source for loading on model calculation
StubLoadSelVal := StubLoadSel.Add(Stub.Key);
// Output data source name
System.Diagnostics.Debug.WriteLine("Data source name: " + mb.Item[StubLoadSelVal.StubKey].Name);
SelSet := StubLoadSelVal.SelectionSet;
SelSet.Clear();
For i := 0 To Stub.DimensionCount - 1 Do
DimInst := (Stub.Dimension[i] As IMetabaseObject).Open(Null) As IDimInstance;
Sel := SelSet.Add(DimInst);
Sel.SelectElement(1, True);
Sel.SelectElement(3, True);
End For;
// Calculate problem
Calculation := Problem.Calculate(CalcSettings);
Calculation.Run();
End Sub;
See also: