陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
Method CreateScenario2 (
  String datasetname,
  String scenarioname
) as stream[Void]
{
  Description: 'Setup test data for Scenario2'
  TextBody:
  [*
    resource1 := "resource1";
    resource3 := "resource3";
    
    run := this.Run();
    mp2 := MDSMacroPlan::Create( DatasetCreateOptions::Construct( datasetname ).State( DatasetState::MemoryOnly() )
                                                                               .Path( GlobalParameters_MP::GetDatasetFolder() ) )
    mp2->( macroplan2 )
    {
      this->CreateScenarioAndLinkToMacroPlan( macroplan2, scenarioname )->( scenario2 )
      {
        // Hardcode start of planning year to ease the checking of capacity and csv file
        dto_periodparameter := DTO_PeriodParameter::Construct().StartOfPlanning( DateTime::Construct( 2022, 01, 01 ) );
        dto_periodspecification := DTO_PeriodSpecification::Construct().ID( "Monthly" ).NrOfHistoricalPeriod( 3 ).NrOfFuturePeriod( 2 );
        dto_resouce := DTO_Unit::Construct().CurrencyID( "EUR" ).UnitOfMeasurementName( "Ton" ).CapacityType( GlobalParameters_MP::GetCapacityTypeTime() ).EndDate( Date::MaxDate() );
                                                                                                          
        run->UI_PeriodParameter::MenuEdit( macroplan2, dto_periodparameter.ToNVT() )
        ->| run->UI_PeriodSpecification::MenuEdit( macroplan2, dto_periodspecification.ID(), dto_periodspecification.ToNVT() ) 
        ->| run->UI_Unit::MenuNew( macroplan2, dto_resouce.ID( resource1 ).Name( resource1 ).ToNVT() )
        ->| run->UI_Unit::MenuNew( macroplan2, dto_resouce.ID( resource3 ).Name( resource3 ).ToNVT() )  
      }
    }   
                                                                     
    return Transaction::GetCurrentTask().OnFinish();
  *]
  InterfaceProperties { Accessibility: 'Module' }
}