예제 #1
0
 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";
     }
 }
예제 #2
0
 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');
     }
 }
예제 #3
0
 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]);
 }
예제 #4
0
 public static function apiReset($uid)
 {
     $url = Yii::app()->createurl('api/reset');
     $task = Queue::createTask($url, $uid, 'api/close');
     Queue::enqueue($task);
 }
예제 #5
0
 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);
     }
 }