AddScenario([External: Boolean = False;][Save: Boolean = True]): IMsScenarioTreeElement;
AddScenario(External: boolean; Save: boolean]): Prognoz.Platform.Interop.Ms.IMsScenarioTreeElement;
External. Indicates whether the scenario is external.
Save. Indicates whether the scenario is saved.
The AddScenario method adds a new scenario.
Available values of the External parameter:
True. Scenario is external.
False. The default value in Fore. Scenario is internal.
Available values of the Save parameter:
True. The default value in Fore. Scenario is saved after creation. For further scenario changes, it is should be opened for edit.
False. Scenario is opened for edit. All further changes in scenario should be saved.
Executing the example requires that the repository contains a modeling container with the MS identifier.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
ModelSpace: IMsModelSpace;
Tree: IMsScenarioTreeEntries;
Folder: IMsScenarioTreeFolder;
Scen: IMsScenarioTreeElement;
Scenario: IMsScenario;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Get modeling container
MObj := MB.ItemById("MS").Edit;
ModelSpace := MObj As IMsModelSpace;
// Get scenario tree
Tree := ModelSpace.ScenarioTree;
// Add folder
Folder := Tree.AddFolder("Additional scenario");
// Create a new scenario
Scen := Folder.Contents.AddScenario(False, False);
// Set scenario name
Scen.Name := "Base scenario";
// Specify that scenario is protected
Scenario := Scen.Scenario;
Scenario.Protected_ := True;
// Save changes to scenario
(Scenario As IMetabaseObject).Save;
// Save changes in modeling container
MObj.Save;
End Sub UserProc;
After executing the example a new folder is added into the scenarios tree of modeling container. One protected scenario will be created in this folder.
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;
MObj: IMetabaseObject;
ModelSpace: IMsModelSpace;
Tree: IMsScenarioTreeEntries;
Folder: IMsScenarioTreeFolder;
Scen: IMsScenarioTreeElement;
Scenario: IMsScenario;
Begin
// Get current repository
MB := Params.Metabase;
// Get modeling container
MObj := MB.ItemById["MS"].Edit();
ModelSpace := MObj As IMsModelSpace;
// Get scenario tree
Tree := ModelSpace.ScenarioTree;
// Add folder
Folder := Tree.AddFolder("Additional scenario");
// Create a new scenario
Scen := Folder.Contents.AddScenario(False, False);
// Set scenario name
Scen.Name := "Base scenario";
// Specify that scenario is protected
Scenario := Scen.Scenario;
Scenario.@Protected := True;
// Save changes to scenario
(Scenario As IMetabaseObject).Save();
// Save changes in modeling container
MObj.Save();
End Sub;
See also: