Пример #1
0
        private bool _StopWork(int taskId)
        {
            if (!this.diswork.ToList().Exists(x => x.TaskId == taskId))
            {
                return(true);
            }
            try
            {
                DispatchItem task = null;
                lock (dislocker)
                {
                    task = diswork.FirstOrDefault(x => x.TaskId == taskId);
                    if (task == null)
                    {
                        return(true);
                    }
                    Schedule.StopJob(task.JobContext.JobName);
                    diswork.Remove(task);

                    task.Dispose();
                }


                DoPingSign();
                return(true);
            }
            finally
            {
                _synCacheTask();
            }
        }
Пример #2
0
        private bool _innerStart(Ruanal.Core.ApiSdk.TaskDetail taskdetail)
        {
            if (taskdetail.TaskType != 1)
            {
                throw new Exception("非调度任务,启动失败!");
            }
            lock (dislocker)
            {
                if (diswork.Exists(x => x.TaskId == taskdetail.TaskId))
                {
                    return(true);
                }

                DispatchItem dw    = new DispatchItem(taskdetail);
                bool         setOk = this.Schedule.StartJob(taskdetail.TaskId.ToString(), dw, taskdetail.RunCron);
                if (setOk)
                {
                    var JobContext = this.Schedule.GetJobContext(taskdetail.TaskId.ToString());
                    dw.JobContext = JobContext;
                    diswork.Add(dw);
                    return(true);
                }
                return(false);
            }
        }