Exemplo n.º 1
0
 public function saveTaskInfo($taskName, $addInfo)
 {
     Yii::import('site.common.components.cron.*');
     /** @var CActiveRecord $owner  */
     $owner = $this->getOwner();
     $modelName = get_class($owner);
     $cronTask = CronTask::model()->findByAttributes(array('ownerModel' => $modelName, 'ownerId' => $owner->primaryKey, 'taskName' => $taskName));
     if (!$cronTask) {
         $cronTask = new CronTask();
         $cronTask->ownerModel = $modelName;
         $cronTask->ownerId = $owner->primaryKey;
         $cronTask->taskName = $taskName;
     } else {
         Yii::app()->cron->delete($cronTask->taskId);
     }
     $cronTask->taskId = $addInfo['atId'];
     $cronTask->uniqKey = $addInfo['uniqKey'];
     $res = $cronTask->save();
     if (!$res) {
         Yii::log($cronTask->getErrors(), CLogger::LEVEL_ERROR);
     }
 }