Exemple #1
0
 public function testFactoryByIdMethod()
 {
     $job = new TestAction();
     $job->insert();
     $newJob = Job::factoryById($job->id->getValue());
     $this->AssertEquals(get_class($job), get_class($newJob));
 }
Exemple #2
0
 public function getLastJob()
 {
     $jobData = DBSimple::get(Job::TableName, array('status' => Job::NewStatus, 'actionDate <= NOW() '), 'order by `id` asc');
     if (!empty($jobData)) {
         return Job::factory($jobData);
     }
 }
Exemple #3
0
 protected function action()
 {
     $job = Job::factoryById($this->getParam('id'));
     if ($job->status->getValue() != Job::NewStatus) {
         return;
     }
     $job->status = Job::CanceledStatus;
     $job->update();
 }
Exemple #4
0
 public function testAdd()
 {
     $fixture = 'hello world!';
     $api = new Add(['class' => TestAction::ModelName, 'actionDate' => '', 'hash' => $fixture]);
     $id = $api->exec();
     $new = Job::factoryById($id);
     $this->assertEquals($new->status->getValue(), TestAction::NewStatus);
     $this->assertEquals($new->class->getValue(), TestAction::ModelName);
     $this->assertEquals($new->hash->getValue(), $fixture);
 }
Exemple #5
0
 protected function action()
 {
     $orderCond = sprintf('id desc limit 0,%d', $this->limit);
     $data = DBSimple::select(Job::TableName, [], $orderCond);
     foreach ($data as $key => $row) {
         $job = Job::factory($row);
         $data[$key] = $job->getPreviewParseData();
     }
     return $data;
 }
Exemple #6
0
 public function main()
 {
     $fieldInfo = \Extasy\Schedule\Job::getFieldsInfo();
     $begin = [self::Title => '#'];
     $this->outputHeader($begin, self::Title);
     $view = new \Faid\View\View(__DIR__ . '/dashboard.tpl');
     $view->set('statuses', $fieldInfo['fields']['status']['values']);
     print $view->render();
     $this->outputFooter();
     $this->output();
 }
Exemple #7
0
 protected function action()
 {
     $originalJob = \Extasy\Schedule\Job::factoryById($this->getParam('id'));
     if (Job::NewStatus == $originalJob->status->getValue()) {
         return $originalJob->id->getValue();
     }
     $className = get_class($originalJob);
     $job = new $className();
     $job->hash = $originalJob->hash->getValue();
     $job->actionDate->setTime($this->getParam('actionDate'));
     $job->data = $originalJob->data->getValue();
     $job->insert();
     return $job->id->getValue();
 }
Exemple #8
0
 public static function cleanSchedule()
 {
     self::dbFixture(Job::getTableName(), array());
 }