| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CopyScenario ( | 
|   ScenarioManager scenariomanager, | 
|   MacroPlan macroplancopy | 
| ) | 
| { | 
|   Description: 'Makes a copy of the scenario and links it to the copy of macroplan' | 
|   TextBody: | 
|   [* | 
|     // Martijn Apr-14-2016 (created) | 
|     // Create a copy of the scenario (and relate this to the copy of the macroplan) | 
|     scenario := select( scenariomanager, ScenarioMP, sc, sc.DatasetMDSID() = this.MDSID() ); | 
|     newscenarioname := scenariomanager.GetUniqueScenarioName( scenario.Name() + Translations::MP_JobRunOptimizerWithParallelTuning_CopySuffix() ); | 
|     newscenario := scenario.Copy( scenario, newscenarioname, '', scenario.Comment(), | 
|                                   scenario.State(), scenario.KBDescription(), scenario.KBName(), | 
|                                   macroplancopy.MDSID(), macroplancopy.MDSMacroPlan().Name() ); | 
|     newscenario.KBBranch( scenario.KBBranch() ); | 
|     newscenario.IsHidden( true ); | 
|      | 
|      | 
|     // Move the copy to the autotunefolder | 
|     rootfolder := select( scenariomanager, RootScenarioFolder, root, true, true ); | 
|     foldername := Translations::MP_JobRunOptimizerWithParallelTuning_FolderName(); | 
|     autotunefolder := select( rootfolder, Children, child, child.Name() = foldername ); | 
|      | 
|     if( isnull( autotunefolder ) ) | 
|     { | 
|       autotunefolder := scenariomanager.CreateFolder( rootfolder, foldername, Translations::MP_JobRunOptimizerWithParallelTuning_FolderDescription(), '' ); | 
|       autotunefolder.IsHidden( true ); | 
|     } | 
|     autotunefolder.MoveAfter( newscenario, null( ScenarioNode ) ); | 
|   *] | 
| } |