public function actionView() { $services = Service::model()->findAllByAttributes(['status' => 0]); $task = []; $url = $this->app->createUrl('api/view'); foreach ($services as $service) { $task[] = Queue::createTask($url, $service->uid); } if (Queue::enqueue($task, true)) { echo "Success"; } else { echo "Failed"; } }
public function run() { $uid = $this->request->getQuery('id', 0); $service = Service::model()->findByPk($uid); if (!empty($service)) { if (in_array($service->status, [1, 2])) { // 不可用状态 $task = Queue::createTask($this->app->createUrl('api/open'), $uid); } else { $task = Queue::createTask($this->app->createUrl('api/close'), $uid); } if (Queue::enqueue($task)) { $this->response(200, ':) success'); } else { $this->response(200, ':( failure'); } } else { $this->response(404, 'Not Found'); } }
public function actionDashboard() { $service = Service::model()->with('user')->findByPk($this->user->getId()); if (($post = $this->request->getPost('Service', false)) != false) { $service->rules = $post['rules']; if ($service->save()) { $task = Queue::createTask($this->createUrl('api/pac'), $service->uid); Queue::enqueue($task); } } $this->render('dashboard', ['service' => $service]); }
public static function apiReset($uid) { $url = Yii::app()->createurl('api/reset'); $task = Queue::createTask($url, $uid, 'api/close'); Queue::enqueue($task); }
private function postAction($uid, $currentAction, $postAction = false) { $action = $this->request->getPost('postAction', false); if ($action == $currentAction) { $url = Yii::app()->createUrl($action); $task = Queue::createTask($url, $uid, $postAction); Queue::enqueue($task); } }