示例#1
0
 /**
  * @param string $jobIdentifier
  * @return JobConfigurationInterface
  */
 protected function loadJobConfiguration($jobIdentifier)
 {
     $jobConfiguration = $this->jobConfigurationRepository->findOneByIdentifier($jobIdentifier);
     if ($jobConfiguration === null) {
         $this->addFlashMessage(sprintf('Unable to find a Job Configuration with identifier "%s"', $jobIdentifier), '', Message::SEVERITY_ERROR);
         $this->redirect('index');
     }
     return $jobConfiguration;
 }
 /**
  * @param string $jobIdentifier
  * @param array $options
  */
 protected function executeJob($jobIdentifier, array $options = [])
 {
     $jobConfiguration = $this->jobConfigurationRepository->findOneByIdentifier($jobIdentifier);
     try {
         $startTime = microtime(true);
         $options = new JobConfigurationOptions($options);
         if ($this->jobRunnerService->execute($jobConfiguration, $options)) {
             if ($jobConfiguration->isAsynchronous()) {
                 $this->flashMessageContainer->addMessage(new Message(sprintf('Job "%s" queued with success', $jobConfiguration->getName())));
             } else {
                 $duration = round(microtime(true) - $startTime, 2);
                 $this->flashMessageContainer->addMessage(new Message(sprintf('Job "%s" exectued with success in %s sec.', $jobConfiguration->getName(), $duration)));
             }
         }
     } catch (\Exception $exception) {
         $this->systemLogger->logException($exception);
         $this->flashMessageContainer->addMessage(new Error(sprintf('Failed to execute job "%s" with message: %s', $jobConfiguration->getName(), $exception->getMessage())));
     }
 }