コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     ///非admin用户,可查看所属业务组内的任务
     $svr_con = "";
     if (Yii::$app->user->getIdentity()->admin != 1) {
         $app_con = "svr_gid in (0";
         $query = DcmdUserGroup::find()->andWhere(['uid' => Yii::$app->user->getId()])->asArray()->all();
         if ($query) {
             foreach ($query as $item) {
                 $app_con .= "," . $item['gid'];
             }
         }
         $app_con .= ")";
         $query = DcmdApp::find()->where($app_con)->asArray()->all();
         $app_con = "app_id in (0";
         foreach ($query as $item) {
             $app_con .= "," . $item['app_id'];
         }
         $app_con .= ")";
         $query = DcmdService::find()->where($app_con)->asArray()->all();
         $svr_con = "svr_id in (0";
         foreach ($query as $item) {
             $svr_con .= "," . $item['svr_id'];
         }
         $svr_con .= ")";
     } else {
         ///管理员只能查看同一系统组的产品
         $app_con = "sa_gid in (0";
         $query = DcmdUserGroup::find()->andWhere(['uid' => Yii::$app->user->getId()])->asArray()->all();
         if ($query) {
             foreach ($query as $item) {
                 $app_con .= "," . $item['gid'];
             }
         }
         $app_con .= ")";
         $query = DcmdApp::find()->where($app_con)->asArray()->all();
         $app_con = "app_id in (0";
         foreach ($query as $item) {
             $app_con .= "," . $item['app_id'];
         }
         $app_con .= ")";
         $query = DcmdService::find()->where($app_con)->asArray()->all();
         $svr_con = "svr_id in (0";
         foreach ($query as $item) {
             $svr_con .= "," . $item['svr_id'];
         }
         $svr_con .= ")";
     }
     $query = DcmdTask::find()->where($svr_con)->orderBy('task_id desc');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['task_id' => $this->task_id, 'depend_task_id' => $this->depend_task_id, 'app_id' => $this->app_id, 'svr_id' => $this->svr_id, 'update_env' => $this->update_env, 'update_tag' => $this->update_tag, 'state' => $this->state, 'freeze' => $this->freeze, 'valid' => $this->valid, 'pause' => $this->pause, 'concurrent_rate' => $this->concurrent_rate, 'timeout' => $this->timeout, 'auto' => $this->auto, 'process' => $this->process, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'task_name', $this->task_name])->andFilterWhere(['like', 'task_cmd', $this->task_cmd])->andFilterWhere(['like', 'depend_task_name', $this->depend_task_name])->andFilterWhere(['like', 'app_name', $this->app_name])->andFilterWhere(['like', 'svr_name', $this->svr_name])->andFilterWhere(['like', 'svr_path', $this->svr_path])->andFilterWhere(['like', 'tag', $this->tag])->andFilterWhere(['like', 'err_msg', $this->err_msg])->andFilterWhere(['like', 'task_arg', $this->task_arg])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Creates a new DcmdTaskServicePool model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($task_id)
 {
     $task = DcmdTask::findOne($task_id);
     if (Yii::$app->request->post()) {
         $model = new DcmdTaskServicePool();
     } else {
         return $this->render('create', ['task' => $task, 'svr_pool' => $svr_pool]);
     }
     /*if ($model->load(Yii::$app->request->post()) && $model->save()) {
       } else {
           return $this->render('create', [
               'model' => NULL,
               'task' => $task,
           ]);
       }*/
 }
コード例 #3
0
 /**
  * Finds the DcmdTask model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DcmdTask the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DcmdTask::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
ファイル: DcmdTaskNode.php プロジェクト: shitfSign/ducter-web
 public function getTaskFreeze($task_id)
 {
     $query = DcmdTask::findOne($task_id);
     if ($query->freeze == 1) {
         return true;
     }
     return false;
 }
コード例 #5
0
 public function actionAgentSubtaskOut($task_id, $task_cmd, $subtask_id, $ip)
 {
     $task = DcmdTask::findOne($task_id);
     $task_name = $task->task_name;
     return $this->render('sub_task_output', ['task_id' => $task_id, 'task_cmd' => $task_cmd, 'task_name' => $task_name, 'subtask_id' => $subtask_id, 'ip' => $ip]);
 }
コード例 #6
0
 public function actionTaskList($ip)
 {
     $ret_msg = '<table class="table table-striped table-bordered"><tbody>';
     $ret_msg .= "<tr><td>任务名称</td><td>脚本名称</td><td>产品名称</td><td>创建时间</td>";
     ///获取任务列表
     $query = DcmdTaskNode::findAll(['ip' => $ip]);
     if ($query) {
         $task_id = "task_id in (0";
         foreach ($query as $item) {
             $task_id .= "," . $item->task_id;
         }
         $task_id .= ")";
         ///获取任务信息
         $query = DcmdTask::find()->andWhere($task_id)->orderBy('task_id desc')->all();
         if ($query) {
             foreach ($query as $task) {
                 $ret_msg .= "<tr><td><a href='index.php?r=dcmd-task-async/monitor-task&task_id=" . $task->task_id . "' target=_blank>" . $task->task_name . "</a></td>";
                 $ret_msg .= "<td>" . $task->task_cmd . "</td>";
                 $ret_msg .= "<td>" . $task->app_name . "</td>";
                 $ret_msg .= "<td>" . $task->ctime . "</td>";
                 $ret_msg .= "</tr>";
             }
         }
     }
     $ret_msg .= "</tbody></table>";
     echo $ret_msg;
 }