Quintiq file version 2.0
#parent: ActionBarGroupGeneral/ButtonOptimizer
Response OnClick () id:Response_ActionBarGroupGeneral_ButtonOptimizer_OnClick_715
{
  #keys: '[137862.0.1933627432]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebButton_OnClick'
  Precondition:
  [*
    activescenario := DataHolderActiveScenario.Data();
    
    return ScenarioManager::HasScenarioManager( ScenarioManager, feedback )
           and ScenarioManager::HasStrategy( ScenarioManager, feedback )
           and MacroPlan::HasMacroPlan( activescenario, feedback )
           and Period_MP::HasPeriod( feedback, MacroPlan )       
           and ScenarioManager::HasCapacityForMaximumNumberofConcurrentRuns( ScenarioManager, activescenario, false, feedback ) 
           and MacroPlan.CanPlan( feedback );
  *]
  QuillAction
  {
    Body:
    [*
      //Select strategy and run optimizer or abort optimizer
      
      if( MacroPlan.IsOptimizerRunning() ) // 1. Call abort if optimizer is currently running
      {                                  // 2. Only call dialog if optimizer is not currently running
        ApplicationMacroPlanner.AbortOptimizer();
      }
      else
      {
        run := MacroPlan.Optimization().GetLastRegularAlgorithmRun();
        strategy := AlgorithmRun::GetLastStrategyUsed( MacroPlan.GlobalParameters_MP(), run, ScenarioManager, true, false );
        
        dialog := construct(  DialogRunOptimizer );
        dialog.InitializeDialog( strategy );
      }
    *]
    GroupServerCalls: false
  }
}
