예제 #1
0
 /**
  * Execute given job
  * @param SchedulersJob $job
  */
 public function executeJob($job)
 {
     if (!$this->job->runJob()) {
         // if some job fails, change run status
         $this->jobFailed($this->job);
     }
 }
예제 #2
0
 /**
  * Execute given job
  * @param SchedulersJob $job
  */
 public function executeJob($job)
 {
     if (!$this->job->runJob()) {
         // if some job fails, change run status
         $this->jobFailed($this->job);
     }
     // If the job produced a session, destroy it - we won't need it anymore
     if (session_id()) {
         session_destroy();
     }
 }
예제 #3
0
 /**
  * Execute given job
  * @param SchedulersJob $job
  */
 public function executeJob($job)
 {
     $this->setTimeLimit($this->max_runtime);
     $res = $this->job->runJob();
     $this->clearTimeLimit();
     if (!$res) {
         // if some job fails, change run status
         $this->jobFailed($this->job);
     }
     // If the job produced a session, destroy it - we won't need it anymore
     if (session_id()) {
         session_destroy();
     }
 }
예제 #4
0
 public function testrunJob()
 {
     //test without a valid user
     $schedulersJob = new SchedulersJob();
     $schedulersJob->target = 'function::processAOW_Workflow';
     $result = $schedulersJob->runJob();
     $this->assertEquals(false, $result);
     $schedulersJob->mark_deleted($schedulersJob->id);
     //test with valid user
     $schedulersJob = new SchedulersJob();
     $schedulersJob->assigned_user_id = 1;
     $schedulersJob->target = 'function::processAOW_Workflow';
     $result = $schedulersJob->runJob();
     $this->assertEquals(true, $result);
     $schedulersJob->mark_deleted($schedulersJob->id);
     //test with valid user
     $schedulersJob = new SchedulersJob();
     $schedulersJob->assigned_user_id = 1;
     $schedulersJob->target = 'url::https://suitecrm.com/';
     $result = $schedulersJob->runJob();
     $this->assertEquals(true, $result);
     $schedulersJob->mark_deleted($schedulersJob->id);
 }
 /**
  * Create a job queue FTS consumer for a specific module
  *
  * @param string $module
  * @param bool   $runNow Run job immediately instead of placing in job queue
  * @return string Id of newly created job
  */
 public function createJobQueueConsumerForModule($module, $runNow = false)
 {
     $jobBean = BeanFactory::getBean('SchedulersJobs');
     $q = sprintf("SELECT name FROM %s\n             WHERE name = 'FTSConsumer %s' AND deleted = 0 AND status != '%s'", $jobBean->table_name, $module, SchedulersJob::JOB_STATUS_DONE);
     $res = $jobBean->db->query($q);
     if ($row = $GLOBALS['db']->fetchByAssoc($res)) {
         $GLOBALS['log']->info("Job queue already exists for: FTSConsumer {$module}");
         return;
     }
     $GLOBALS['log']->info("Creating FTS Job queue consumer for: {$module} ");
     $job = new SchedulersJob();
     $job->data = $module;
     $job->name = "FTSConsumer {$module}";
     $job->target = "class::SugarSearchEngineFullIndexer";
     $job->assigned_user_id = 1;
     if ($runNow) {
         $job->runJob();
     } else {
         $queue = new SugarJobQueue();
         $queue->submitJob($job);
     }
     return $job->id;
 }