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
41
42
43
44
45
46
47
48
49
Quintiq file version 2.0
#parent: #root
Method ExtendCombiwithNextElement
{
  Description: 'Determine if the combi needs to be extended with an element. This is the case if the first element type in the combi has reached the expected duration.'
  TextBody:
  [*
    lastelement := this.LastCombiElement();
    if(  lastelement.istype( OptCampaignCombiElementCampaign ) )
    {
      ///////////////////////////////////////////////////////////////////////////////////////////////////
      //Close of the campaign combi with all possible transition types
      ///////////////////////////////////////////////////////////////////////////////////////////////////
      transitiontypes := selectsortedset( lastelement.astype( OptCampaignCombiElementCampaign ), CampaignType_MP.AsFromOfTransitionType, tt, true, tt.Name() );
      if( transitiontypes.Size() = 0 )
      {
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        //Combi cannot be extended. 
        //In principle this should not happen but is possible if the campaigns/tranisitions are not complete
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        this.IsDeadEnd( true ) 
      }
      else
      {
        OptCampaignCombi::AddTransitionsTypeCombi( this, lastelement.OptCampaignUnitSubPeriod(), transitiontypes );
      }  
    }
    else
    {
      ///////////////////////////////////////////////////////////////////////////////////////////////////
      //Close of the transition combi with the following campaign
      ///////////////////////////////////////////////////////////////////////////////////////////////////
      campaigntype := guard( lastelement.astype( OptCampaignCombiElementTransition ).TransitionType_MP().ToCampaignType(), null( CampaignType_MP ) );
      if( isnull( campaigntype ) )
      {
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        //Combi cannot be extended. 
        //In principle this should not happen but is possible if the campaigns/tranisitions are not complete
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        this.IsDeadEnd( true )  
      }  
      else
      { 
        //Close of the transition combi with a campaign
        OptCampaignCombi::AddCampaignTypeToCombi( this, lastelement.OptCampaignUnitSubPeriod(), campaigntype );
      }
    }
  *]
}