Exemplo n.º 1
0
        public int StopBatchTask(string strName,
                                 BatchTaskInfo param,
                                 out BatchTaskInfo info,
                                 out string strError)
        {
            strError = "";
            info     = null;

            if (strName == "!pause")
            {
                this.PauseBatchTask = true;
                info = GetTaskInfo("全部批处理任务已经被暂停");
                return(1);
            }

            BatchTask task = this.BatchTasks.GetBatchTask(strName);

            // 任务本来就不存在
            if (task == null)
            {
                strError = "任务 '" + strName + "' 不存在";
                return(-1);
            }

            task.Stop();

            info = task.GetCurrentInfo(param.ResultOffset,
                                       param.MaxResultBytes);

            return(1);
        }
Exemplo n.º 2
0
        public int AbortBatchTask(string strName,
                                  BatchTaskInfo param,
                                  out BatchTaskInfo info,
                                  out string strError)
        {
            strError = "";
            info     = null;

            if (this.BatchTasks == null)
            {
                strError = "this.BatchTasks == null";
                return(-1);
            }

            BatchTask task = this.BatchTasks.GetBatchTask(strName);

            // 任务本来就不存在
            if (task == null)
            {
                strError = "任务 '" + strName + "' 不存在";
                return(-1);
            }

            task._pendingCommands.Add("abort");
            task.Stop();

            info = task.GetCurrentInfo(param.ResultOffset,
                                       param.MaxResultBytes);

            return(1);
        }
Exemplo n.º 3
0
        public int AbortBatchTask(string strName,
                                  BatchTaskInfo param,
                                  out BatchTaskInfo info,
                                  out string strError)
        {
            strError = "";
            info     = null;

            if (this.BatchTasks == null)
            {
                strError = "this.BatchTasks == null";
                return(-1);
            }

            BatchTask task = this.BatchTasks.GetBatchTask(strName);

            // 任务本来就不存在
            if (task == null)
            {
                strError = "任务 '" + strName + "' 不存在";
                return(-1);
            }

            // TODO: 如果任务已经是停止状态,那么添加 "abort" 会不会影响下一个新开始的启动?
            if (task._pendingCommands.IndexOf("abort") == -1)
            {
                task._pendingCommands.Add("abort");
            }
            task.Stop();

            info = task.GetCurrentInfo(param.ResultOffset,
                                       param.MaxResultBytes);
            return(1);
        }
Exemplo n.º 4
0
 public void StopAllBatchTasks()
 {
     for (int i = 0; i < this.BatchTasks.Count; i++)
     {
         BatchTask task = this.BatchTasks[i];
         task.Stop();
     }
 }