yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
MethodOverride Copy (
  ScenarioNode fromscenario,
  String newassumption
)
{
  Description: 'Copy more details from fromscenario'
  TextBody:
  [*
    // Copy all assumptions over from the source scenario
    source := fromscenario.astype( ScenarioMP );
    
    traverse( source, Assumption, assumption )
    {
      assumption.Copy( this );
    }
    //delete the kpivalue that created during oncreate of scenario, and copy from source scenario
    this.KPIValue( relflush );
    traverse( source, KPIValue, kpi )
    {
      newkpi := kpi.DeepCopy( true, true ).astype( KPIValue ) ;
      this.KPIValue( relinsert, &newkpi );  
    }
    
    // Create new assumption for the new scenario
    this.CreateNewAssumption( newassumption );
    
    // Update last changed status of the new scenario
    this.UpdateLastChanged();
    
    datasetname := ScenarioManager::GetUniqueCompanyDatasetName( ScenarioManager::ScenarioMP() );
    
    opt := DatasetCreateOptions::Construct( datasetname ).AsCopy( fromscenario.astype( ScenarioMP ).DatasetMDSID() )
                                                         .State( DatasetState::FromString( this.State() ) )
                                                         .Path( GlobalParameters_MP::GetDatasetFolder() );
    
    MDSMacroPlan::Create( opt  )->UpdateScenario( this )
  *]
}