CopyScenarioData(DestScenarioKey: Integer;
SourceScenarioKey: Integer;
mvkTarget: MsVariableKind);
CopyScenarioData(DestScenarioKey: uinteger;
SourceScenarioKey: uinteger;
mvkTarget: Prognoz.Platform.Interop.Ms.MsVariableKind);
DestScenarioKey. Consumer scenario key.
SourceScenarioKey. Provider scenario key.
mvkTarget. Type of variables to be copied.
The CopyScenarioData method copies data by the modelling scenarios.
To copy data by the Fact scenario, use -1 key.
Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the PROBLEM identifier. The modeling problem must contain several modeling scenarios.
Add links to the Metabase, Ms system assemblies.
Sub ProblemScenarioData;
Var
MB: IMetabase;
MsObj: IMetabaseObject;
MObj: IMetabaseObject;
Problem: IMsProblem;
DestScen: IMsScenario;
DestScenKey: Integer;
ProbScen: IMsProblemScenarios;
Begin
MB := MetabaseClass.Active;
// Get modeling container
MsObj := MB.ItemById("MODEL_SPACE").Bind;
// Get modeling problem
MObj := MB.ItemByIdNamespace("PROBLEM", MsObj.Key).Edit;
Problem := MObj As IMsProblem;
// Get modeling problem scenarios
ProbScen := Problem.Scenarios;
// Get the first scenario in the modeling problem
DestScen := ProbScen.Item(0);
DestScenKey := (DestScen As IMetabaseObject).Key;
// Copy data by the input variables from the Fact scenario to the first scenario
ProbScen.CopyScenarioData(DestScenKey, -1, MsVariableKind.Input);
// Save modeling problem
MObj.Save;
End Sub ProblemScenarioData;
Example execution result: data of input variables is copied to the first scenario of the modeling problem by the Fact scenario.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MsObj: IMetabaseObject;
MObj: IMetabaseObject;
Problem: IMsProblem;
DestScen: IMsScenario;
DestScenKey: uinteger;
ProbScen: IMsProblemScenarios;
Begin
MB := Params.Metabase;
// Get modeling container
MsObj := MB.ItemById["MODEL_SPACE"].Bind();
// Get modeling problem
MObj := MB.ItemByIdNamespace["PROBLEM", MsObj.Key].Edit();
Problem := MObj As IMsProblem;
// Get modeling problem scenarios
ProbScen := Problem.Scenarios;
// Get the first scenario in the modeling problem
DestScen := ProbScen.Item[0];
DestScenKey := (DestScen As IMetabaseObject).Key;
// Copy data by the input variables from the Fact scenario to the first scenario
ProbScen.CopyScenarioData(DestScenKey, (-1) As uinteger, MsVariableKind.mvkInput);
// Save modeling problem
MObj.Save();
End Sub;
See also: