当前位置: 首页>>代码示例>>PHP>>正文


PHP Job::setStatus方法代码示例

本文整理汇总了PHP中Job::setStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::setStatus方法的具体用法?PHP Job::setStatus怎么用?PHP Job::setStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Job的用法示例。


在下文中一共展示了Job::setStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetSetStatus

 /**
  * Test getter/setter status
  */
 public function testGetSetStatus()
 {
     $this->assertNull($this->getStatus());
     $expectedStatus = 1;
     $this->assertEntity($this->jobInstance->setStatus($expectedStatus));
     $this->assertEquals($expectedStatus, $this->jobInstance->getStatus());
 }
开发者ID:xleliberty,项目名称:BatchBundle,代码行数:10,代码来源:JobInstanceTest.php

示例2: testToString

 public function testToString()
 {
     $startTime = new \DateTime('2013-02-01 12:34:56');
     $updatedTime = new \DateTime('2013-02-03 23:45:01');
     $status = BatchStatus::STOPPED;
     $exitStatus = ExitStatus::FAILED;
     $jobInstance = new JobInstance('test_connector', JobInstance::TYPE_IMPORT, 'test_job_instance');
     $jobInstance->setCode('job instance code');
     $endTime = new \DateTime('2013-03-04 21:43:05');
     $this->jobExecution->setStartTime($startTime);
     $this->jobExecution->setUpdatedTime($updatedTime);
     $this->jobExecution->setStatus(new BatchStatus($status));
     $this->jobExecution->setExitStatus(new ExitStatus($exitStatus, 'Test description'));
     $this->jobExecution->setJobInstance($jobInstance);
     $this->jobExecution->setEndTime($endTime);
     $timezone = $startTime->format('P');
     $expectedOutput = 'startTime=2013-02-01T12:34:56' . $timezone . ', endTime=2013-03-04T21:43:05' . $timezone . ', ' . 'updatedTime=2013-02-03T23:45:01' . $timezone . ', status=5, exitStatus=[FAILED] Test description, ' . 'exitDescription=[Test description], job=[job instance code]';
     $this->assertEquals($expectedOutput, (string) $this->jobExecution);
 }
开发者ID:xleliberty,项目名称:BatchBundle,代码行数:19,代码来源:JobExecutionTest.php

示例3: api_downloadedjob

 public function api_downloadedjob()
 {
     $job = new Job($this->args('job_id'));
     if (!$job->isHydrated()) {
         throw new Exception("Job does not exist.");
     }
     $bot = $job->getBot();
     if (!$bot->isHydrated()) {
         throw new Exception("Bot does not exist.");
     }
     if (!$bot->isMine()) {
         throw new Exception("This is not your bot.");
     }
     if (!$job->getQueue()->isMine()) {
         throw new Exception("This job is not in your queue.");
     }
     $job->setStatus('taken');
     $job->set('downloaded_time', date("Y-m-d H:i:s"));
     $job->set('progress', 0);
     // clear our download progress meter.
     $job->save();
     // This returns the new bot, but it's currently not needed
     $this->_markBotAsSeen($bot);
     return $job->getAPIData();
 }
开发者ID:eric116,项目名称:BotQueue,代码行数:25,代码来源:apiv1.php

示例4: grabJob

 /**
  * @param $job Job
  * @param $can_slice bool
  * @return Job
  * @throws Exception
  */
 public function grabJob($job, $can_slice = true)
 {
     $grabAttemptSQL = "\n            UPDATE jobs\n            SET bot_id =\n              CASE\n                WHEN bot_id=0\n                THEN\n                  ?\n                ELSE\n                  bot_id\n              END\n            WHERE id = ?\n        ";
     // Attempt to grab the job unless another bot already has
     db()->execute($grabAttemptSQL, array($this->id, $job->id));
     $job = new Job($job->id);
     // Reload the job
     if ($job->get('bot_id') != $this->id) {
         // We didn't grab it in time.
         throw new Exception("Unable to lock job #{$job->id}");
     }
     $job->setStatus('taken');
     $job->set('taken_time', date('Y-m-d H:i:s'));
     $job->save();
     //do we need to slice this job?
     if (!$job->getFile()->isHydrated() && $can_slice) {
         //pull in our config and make sure it's legit.
         $config = $this->getSliceConfig();
         if (!$config->isHydrated()) {
             $job->setStatus('available');
             $job->set('bot_id', 0);
             $job->set('taken_time', 0);
             $job->save();
             throw new Exception("This bot does not have a slice engine + configuration set.");
         }
         //is there an existing slice job w/ this exact file and config?
         $sj = SliceJob::byConfigAndSource($config->id, $job->get('source_file_id'));
         if ($sj->isHydrated()) {
             //update our job status.
             $job->set('slice_job_id', $sj->id);
             $job->set('slice_complete_time', $job->get('taken_time'));
             $job->set('file_id', $sj->get('output_id'));
             $job->save();
         } else {
             //nope, create our slice job for processing.
             $sj->set('user_id', User::$me->id);
             $sj->set('job_id', $job->id);
             $sj->set('input_id', $job->get('source_file_id'));
             $sj->set('slice_config_id', $config->id);
             $sj->set('slice_config_snapshot', $config->getSnapshot());
             $sj->set('add_date', date("Y-m-d H:i:s"));
             $sj->setStatus('available');
             $sj->save();
             //update our job status.
             $job->setStatus('slicing');
             $job->set('slice_job_id', $sj->id);
             $job->save();
         }
     }
     $log = new JobClockEntry();
     $log->set('job_id', $job->id);
     $log->set('user_id', User::$me->id);
     $log->set('bot_id', $this->id);
     $log->set('queue_id', $job->get('queue_id'));
     $log->set('start_date', date("Y-m-d H:i:s"));
     $log->setStatus('working');
     $log->save();
     $this->set('job_id', $job->id);
     $this->setStatus(BotState::Working);
     $this->set('last_seen', date("Y-m-d H:i:s"));
     $this->save();
     return $job;
 }
开发者ID:JoonasMelin,项目名称:BotQueue,代码行数:69,代码来源:bot.php

示例5: addFileToQueue

 /**
  * @param $queue_id int
  * @param $file StorageInterface
  * @return Job
  */
 public static function addFileToQueue($queue_id, $file)
 {
     $sortSQL = "SELECT max(id)+1 FROM jobs WHERE user_id = ?";
     $sort = db()->getValue($sortSQL, array(User::$me->id));
     // Special case for first sort value
     if ($sort == "") {
         $sort = 1;
     }
     $job = new Job();
     $job->set('user_id', User::$me->id);
     $job->set('queue_id', $queue_id);
     $job->set('source_file_id', $file->id);
     if ($file->isGCode()) {
         $job->set('file_id', $file->id);
     }
     if ($file->isMakerbot()) {
         $job->set('file_id', $file->id);
     }
     $job->setName($file->get('path'));
     $job->setStatus('available');
     $job->set('created_time', date("Y-m-d H:i:s"));
     $job->set('user_sort', $sort);
     $job->save();
     return $job;
 }
开发者ID:eric116,项目名称:BotQueue,代码行数:30,代码来源:job.php


注:本文中的Job::setStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。