| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetNewStartAndEndAfterResequence ( | 
|   Campaign_MP_DELETED_Q320 targetcampaign, | 
|   output DateTime newcampaignstart, | 
|   output DateTime newcampaignend, | 
|   output DateTime newtargetcampaignstart, | 
|   output DateTime newtargetcampaignend | 
| ) declarative remote | 
| { | 
|   Description: 'Return the new start and end for selected campaign and target campaign.' | 
|   TextBody: | 
|   [* | 
|     if( not isnull( targetcampaign ) ) | 
|     { | 
|       campaignduration := this.End() -  this.Start(); | 
|       previoustarget := guard( targetcampaign.Previous(), null(  Campaign_MP_DELETED_Q320 ) ); | 
|       previoustargetcampaigntype := guard( previoustarget.CampaignType_MP(), null( CampaignType_MP ) ); | 
|       targetcampaigntype := guard( targetcampaign.CampaignType_MP(), null( CampaignType_MP ) ); | 
|       sourcecampaigntype := this.CampaignType_MP(); | 
|       transitionduration := ifexpr( not isnull( previoustarget ) and  | 
|                                     previoustarget <> this and | 
|                                     targetcampaign.Start() - previoustarget.End() <= Campaign_MP_DELETED_Q320::GetMinTransitionDuration( previoustargetcampaigntype, targetcampaigntype ), | 
|                                     Campaign_MP_DELETED_Q320::GetTransitionDurationDifference( previoustargetcampaigntype, | 
|                                                                                   targetcampaigntype, | 
|                                                                                   previoustargetcampaigntype, | 
|                                                                                   sourcecampaigntype ), | 
|                                     Duration::Zero() ); | 
|        | 
|       newcampaignstart := targetcampaign.Start() + transitionduration;  | 
|        | 
|       newcampaignend := newcampaignstart + campaignduration; | 
|        | 
|       targetcampaignduration := targetcampaign.End() - targetcampaign.Start(); | 
|       newtargetcampaignstart := newcampaignend + Campaign_MP_DELETED_Q320::GetMinTransitionDuration( sourcecampaigntype, targetcampaigntype ); | 
|       newtargetcampaignend := newtargetcampaignstart + targetcampaignduration;   | 
|     } | 
|   *] | 
| } |