Quintiq file version 2.0
|
#parent: #root
|
Method CreateDemoScenariosAndImport (
|
String democategory,
|
String demoscenario,
|
MPSync mpsync,
|
MPDomainHandler mpdomainhandler,
|
SWF_WorkflowDataset workflow,
|
String snopusername
|
) as ScenarioMP
|
{
|
TextBody:
|
[*
|
// Load Sales demo workflow data from binary string
|
this.SynchronizeDemoWorkflowDataset( democategory, workflow );
|
|
// Retrive DemoScenario kt
|
table := DemoScenarioTable::Table();
|
scenarios := construct( Strings );
|
scenarioMP := null( ScenarioMP );
|
datapath := GlobalParameters_MP::GetDefinitonsDir() + "/" + GlobalParameters_MP::GetSalesDemoPath() + "/" + democategory;
|
i := 0;
|
|
|
scenarios := selectvalues( table, Rows, r, r.Demo() = democategory and ( demoscenario = Translations::Scenario_DemoScenario_All() or r.Scenario() = demoscenario ), r.Scenario() );
|
|
// To make sure Transaction in domainhandler is completed
|
Transaction::Transaction().Propagate();
|
|
// Go through every row in DemoScenario and create scenario and import data respectively
|
traverse( scenarios, Elements, e , e <> Translations::Scenario_DemoScenario_All() )
|
{
|
base := null( ScenarioMP );
|
|
foldername := ifexpr( e = '-', democategory, democategory + '/' + e );
|
datasetname := ScenarioManager::GetUniqueCompanyDatasetName( ScenarioManager::ScenarioMP() );
|
|
rootfolder := select( this, RootScenarioFolder, root, true, true );
|
folder := select( rootfolder, Children, child, child.Name() = democategory );
|
|
if( isnull( folder ) )
|
{
|
folder := this.CreateFolder( rootfolder, democategory, democategory, snopusername );
|
}
|
|
// We do not use the CreateScenarioMP because we need specific dataset name.
|
base := ScenarioMP::Create( this,
|
folder,
|
datasetname,
|
ifexpr( e = '-', foldername, e ),
|
'',
|
GlobalParameters_MP::GetStorageState(),
|
'',
|
snopusername );
|
|
// We will return the first created demo dataset to be selected in App.
|
// All strategies, account and bookmarks for a Demo type is the same, we only need to import it once
|
if( i = 0 )
|
{
|
scenarioMP := base; // We will return the first created demo dataset to be selected in App.
|
|
accounts := ScenarioManager::ReadAccountFile( datapath );
|
this.SynchronizeAccounts( accounts );
|
|
strategies := ScenarioManager::ReadStrategiesFile( datapath );
|
this.ImportStrategies( strategies );
|
|
bookmarks := ScenarioManager::ReadBookmarksFile( datapath );
|
this.ImportBookmarks( bookmarks );
|
|
kpisettings := ScenarioManager::ReadKPISettingsFile( datapath );
|
this.ImportKPISettings( kpisettings );
|
|
importprofiles := MPSync::ReadImportProfilesFile( datapath );
|
mpsync.ImportUserGroupProfiles( importprofiles );
|
mpsync.SynchronizeDemoImportProfiles( datapath );
|
}
|
|
i := i + 1;
|
|
// Add authorization to all user groups to scenario
|
base.AuthorizeAll();
|
|
kb := select( this.MDSScenarioManager(), MDSKBs, kb, kb.Name().ToUpper() = this.CompanyKBName().ToUpper() );
|
this.UpdateScenarioKBInfo( base, kb.Name(), kb.Branch(), kb.ChangeNr(), base.State(), kb.Description() );
|
|
mdsid := MDSID::Create( base.DatasetMDSID() );
|
row := select( table, Rows, r, r.Demo() = democategory and r.Scenario() = base.Name() );
|
|
strategy := ifexpr( row.StrategyIsWildcard(), Strategy::DefaultStrategyName(), row.Strategy() )
|
|
MacroPlan::JobSynchronizeDemoDataAndRunOptimizer( mdsid, base, foldername, democategory, strategy );
|
}
|
|
return scenarioMP;
|
*]
|
}
|