Ejemplo n.º 1
0
        public int ArrangeInstantTask(string tid, uint dtuId, JObject[] cmdobjs, ATTaskResultConsumer consumer)
        {
            ATTask task = new ATTask(tid, dtuId, cmdobjs, TaskType.INSTANT, consumer);

            ATTaskPersistent.Init();
            ATTaskPersistent.SaveTaskImmedate(task);
            task.Consumer += OnAtInstantTaskFinished;
            DacTaskContext context = null;

            if (_workers.ContainsKey(dtuId))
            {
                if (!IsWorkerAvaliable(_workers[dtuId]))
                {
                    _workers[dtuId].Stop();
                }
                context = _workers[dtuId].GetContext();
            }
            else
            {
                context = CreateContext(dtuId);
            }
            var atworker = new AtCommandWorker(task, context);

            atworker.StartWork();
            return(task.ID);
        }
Ejemplo n.º 2
0
 public void Stop()
 {
     _schedule.Shutdown();
     foreach (DACWorker w in _workers.Values)
     {
         w.Stop();
     }
     _schedule.Clear();
     _workers.Clear();
     DACTaskPersistent.Stop();
     ATTaskPersistent.Stop();
 }
Ejemplo n.º 3
0
 //DTU 配置回调, 用于处理数据库任务记录
 private static void OnAtInstantTaskFinished(ExecuteResult result)
 {
     ATTaskPersistent.SaveTaskResult(result);
     Log.DebugFormat("OnInstaceTaskFinished :t={0}, r={1}, status={2}", result.Task.ID, result.ErrorCode, result.Task.Status);
 }