Quintiq file version 2.0
|
#parent: #root
|
Method CreateScenarioMPFromDataset (
|
ScenarioNode scenarionode,
|
String scenarioname,
|
String assumption,
|
String comment,
|
String scenariodescription,
|
String datasetname,
|
Key datasetmdsid,
|
String datasetstoragestate
|
) as ScenarioMP
|
{
|
Description: 'Create a scenario only, do not create dataset'
|
TextBody:
|
[*
|
// Get current user's name
|
currentusername := GlobalParameters_MP::GetUserName();
|
|
//create a new scenario
|
scenario := construct( ScenarioMP,
|
AsScenarioMP := this,
|
Name := scenarioname,
|
CreatedBy := currentusername,
|
CreatedOn := DateTime::Now(),
|
DatasetMDSID := datasetmdsid,
|
DatasetName := datasetname,
|
Comment := comment,
|
IsLoaded := true,
|
State := datasetstoragestate,
|
KBDescription := scenariodescription
|
);
|
|
// Update last changed info of this scenario, which is the current user in this case
|
scenario.UpdateLastChanged();
|
|
// Get mds info of the selected dataset
|
mdsinfo := MDSEditor::Editor().ObjectInfo( datasetmdsid );
|
|
// Check if the selected dataset can be found or is it online
|
if( not isnull( mdsinfo )
|
// Just an extra guard to make sure dataset is loaded [ UI also block where unloaded dataset without scenario can not be created as scenario ]
|
and mdsinfo.IsLoaded() )
|
{
|
MacroPlan::JobUpdateCompany( mdsinfo.MDSID(), scenario );
|
}
|
else
|
{
|
debuginfo( '#### mds isnull: ID = ', datasetmdsid );
|
}
|
|
// Add scenario to scenario manager
|
scn := this.AddLeaf( scenarionode, &scenario ).astype( ScenarioMP );
|
// Create assumption for the new scenario
|
scn.CreateNewAssumption( assumption );
|
|
return scn;
|
*]
|
}
|