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
35
36
37
38
39
40
41
42
43
44
45
  | Quintiq file version 2.0 
 |  #parent: #root 
 |  MethodOverride Copy ( 
 |    ScenarioNode scenarionode, 
 |    String scenarioname, 
 |    String newassumption, 
 |    String comment, 
 |    String storagestate 
 |  ) as Scenario 
 |  { 
 |    TextBody: 
 |    [* 
 |      fromscenario := scenarionode.astype( ScenarioMP ); 
 |      kbname := fromscenario.KBName(); 
 |      kbdescription := fromscenario.KBDescription(); 
 |      kbbranch := fromscenario.KBBranch(); 
 |      kbchangenr := fromscenario.KBChangeNr(); 
 |       
 |      // Get current user's name 
 |      currentusername := GlobalParameters_MP::GetUserName(); 
 |       
 |      //create a new scenario 
 |      scenario := construct( ScenarioMP, 
 |                             Name                    := scenarioname, 
 |                             CreatedBy               := currentusername, 
 |                             CreatedOn               := DateTime::Now(), 
 |                             Comment                 := comment, 
 |                             State                   := storagestate, 
 |                             KBName                  := kbname, 
 |                             KBDescription           := kbdescription,  
 |                             KBBranch                := kbbranch, 
 |                             KBChangeNr              := kbchangenr  
 |                           ); 
 |       
 |       
 |      //Copy authorization 
 |      groupnames := selectvalues( this, ScenarioAuthorization, sa, true, sa.Name() ) 
 |      scenario.Authorize( groupnames, true ); 
 |      // use another thread to copy the dataset, so that UI wouldn't blocked 
 |      scenario->Copy( scenarionode, newassumption ); 
 |       
 |      // Add the new scenario into scenario manager 
 |      return this.ScenarioManager().AddLeaf( scenarionode, &scenario ).astype( Scenario ); 
 |    *] 
 |  } 
 |  
  |