Exemplo n.º 1
0
 void _invoke(CmdHander handler, ApiSdk.CmdDetail arg)
 {
     ThreadPool.QueueUserWorkItem((x) =>
     {
         try
         {
             var result = ApiSdk.CommandApi.BeginExecute(arg.CmdId);
             if (result.code <= 0)
             {
                 RLib.WatchLog.Loger.Error("开始命令执行失败", result.msg);
                 return;
             }
             if (handler == null)
             {
                 throw new Exception("该命令没有执行程序!");
             }
             handler.Invoke(arg);
             ApiSdk.CommandApi.EndExecute(arg.CmdId, true, "");
         }
         catch (Exception ex)
         {
             RLib.WatchLog.Loger.Error("命令执行失败", ex);
             ApiSdk.CommandApi.EndExecute(arg.CmdId, false, ex.Message);
         }
         finally
         {
             cmdQueue.TryEnd(arg);
             TryOut();
         }
     });
 }
Exemplo n.º 2
0
        private void RouterCmd(ApiSdk.CmdDetail arg)
        {
            CmdHander handler = null;

            switch (arg.CmdType)
            {
            case ConfigConst.CmdType_StartTask:
                arg.TaskArg = RLib.Utils.DataSerialize.DeserializeObject <Ruanal.Core.CmdTaskArg>(arg.CmdArgs);
                handler     = OnStartTask;
                break;

            case ConfigConst.CmdType_StopTask:
                arg.TaskArg = RLib.Utils.DataSerialize.DeserializeObject <Ruanal.Core.CmdTaskArg>(arg.CmdArgs);
                handler     = OnStopTask;
                break;

            case ConfigConst.CmdType_DeleteTask:
                arg.TaskArg = RLib.Utils.DataSerialize.DeserializeObject <Ruanal.Core.CmdTaskArg>(arg.CmdArgs);
                handler     = OnDeleteTask;
                break;

            //case ConfigConst.CmdType_DispatchJob:
            //    arg.DispatchArg = RLib.Utils.DataSerialize.DeserializeObject<Ruanal.Core.CmdDispatchArg>(arg.CmdArgs);
            //    handler = OnDispatchJob;
            //    break;
            case ConfigConst.CmdType_StopDispatchJob:
                arg.DispatchArg = RLib.Utils.DataSerialize.DeserializeObject <Ruanal.Core.CmdDispatchArg>(arg.CmdArgs);
                handler         = OnStopDispatchJob;
                break;

            case ConfigConst.CmdType_ConfigUpdate:
                handler = OnConfigUpdate;
                break;

            case ConfigConst.CmdType_RestartNode:
                handler = OnRestartNode;
                break;
            }
            _invoke(handler, arg);
        }