admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 ) );
  *]
}