예제 #1
0
 public ResponseBase <LoadCommandListResponse> LoadCommandList(LoadCommandListRequest req)
 {
     try
     {
         tb_node node = null;
         if (!string.IsNullOrEmpty(req.NodeId))
         {
             int nodeId = int.Parse(req.NodeId);
             if (nodeId > 0)
             {
                 node = noderepository.FindSingle(x => x.id == nodeId);
                 if (node == null)
                 {
                     return(ResponseToClient <LoadCommandListResponse>(ResponesStatus.Failed, "当前节点" + req.NodeId + "不存在库中!"));
                 }
             }
         }
         List <tb_commandlibdetail> lib = cmdlibdetailrepository.Find(x => x.isdel == 0).OrderByDescending(x => x.createtime).Take(node.maxrefreshcommandqueuecount).ToList();
         if (lib.Count <= 0)
         {
             return(ResponseToClient <LoadCommandListResponse>(ResponesStatus.Failed, "当前暂无命令列表"));
         }
         LoadCommandListResponse data = new LoadCommandListResponse()
         {
             NodeId = req.NodeId,
             CommandLibDetailList = lib
         };
         return(ResponseToClient <LoadCommandListResponse>(ResponesStatus.Success, "", data));
     }
     catch (Exception ex)
     {
         return(ResponseToClient <LoadCommandListResponse>(ResponesStatus.Exception, JsonConvert.SerializeObject(ex)));
     }
 }
예제 #2
0
        public ResponseBase <PlatformStatisResponse> PlatformStatis(PlatformStatisRequest req)
        {
            try
            {
                PlatformStatisResponse platformrep = new PlatformStatisResponse();
                #region 统计节点
                List <tb_node> node = noderepository.Find(x => x.isdel == 0).ToList();
                platformrep.NodeInfo.TotalNodeCount = node.Count;
                int RunningNodeCount = node.Where(x => x.nodestatus == (int)NodeStatus.Running).Count();
                int NoRunNodeCount   = node.Where(x => x.nodestatus == (int)NodeStatus.NoRun).Count();
                platformrep.NodeInfo.NodeDic.Add(NodeStatus.NoRun.description(), NoRunNodeCount);
                platformrep.NodeInfo.NodeDic.Add(NodeStatus.Running.description(), RunningNodeCount);
                #endregion

                #region 统计任务
                List <tb_task> task = taskrep.Find(x => x.isdel == 0).ToList();
                platformrep.TaskInfo.TotalTaskCount = task.Count;
                int TotalScheduleTaskCount = task.Where(x => x.tasktype == (int)TaskType.SchedulingTask).Count();
                int TotalOnceTaskCount     = task.Where(x => x.tasktype == (int)TaskType.OnceTask).Count();

                platformrep.TaskInfo.TaskTypeDic.Add(TaskType.SchedulingTask.description() + "_#3c8dbc", TotalScheduleTaskCount);
                platformrep.TaskInfo.TaskTypeDic.Add(TaskType.OnceTask.description() + "_#f39c12", TotalOnceTaskCount);

                int WaitScheduleCount      = task.Where(x => x.taskschedulestatus == (int)TaskScheduleStatus.WaitSchedule).Count();
                int NoScheduleCount        = task.Where(x => x.taskschedulestatus == (int)TaskScheduleStatus.NoSchedule).Count();
                int PauseScheduleTaskCount = task.Where(x => x.taskschedulestatus == (int)TaskScheduleStatus.PauseSchedule).Count();
                int SchedulingTaskCount    = task.Where(x => x.taskschedulestatus == (int)TaskScheduleStatus.Scheduling).Count();
                int StopScheduleTaskCount  = task.Where(x => x.taskschedulestatus == (int)TaskScheduleStatus.StopSchedule).Count();

                platformrep.TaskInfo.ScheduleDic.Add(TaskScheduleStatus.NoSchedule.description() + "_#f39c12", NoScheduleCount);
                platformrep.TaskInfo.ScheduleDic.Add(TaskScheduleStatus.WaitSchedule.description() + "_#3c8dbc", WaitScheduleCount);
                platformrep.TaskInfo.ScheduleDic.Add(TaskScheduleStatus.Scheduling.description() + "_#00c0ef", SchedulingTaskCount);
                platformrep.TaskInfo.ScheduleDic.Add(TaskScheduleStatus.PauseSchedule.description() + "_#ff3bd9", PauseScheduleTaskCount);
                platformrep.TaskInfo.ScheduleDic.Add(TaskScheduleStatus.StopSchedule.description() + "_#dd4b39", StopScheduleTaskCount);

                #endregion

                #region 命令队列统计
                List <tb_commandqueue> cmdqueue = cmdqueuerespository.Find(x => x.isdel == 0).ToList();
                platformrep.CommandQueueInfo.TotalCommandQueueCount = cmdqueue.Count;
                int NoExecuteCommandQueueCount        = cmdqueue.Where(x => x.commandstate == (int)(ExecuteStatus.NoExecute)).Count();
                int ExecuteExceptionCommandQueueCount = cmdqueue.Where(x => x.commandstate == (int)(ExecuteStatus.ExecuteException)).Count();
                int ExecuteFailedCommandQueueCount    = cmdqueue.Where(x => x.commandstate == (int)(ExecuteStatus.ExecuteFailed)).Count();
                int ExecuteSucessCommandQueueCount    = cmdqueue.Where(x => x.commandstate == (int)(ExecuteStatus.ExecuteSucess)).Count();
                int ExecutingCommandQueueCount        = cmdqueue.Where(x => x.commandstate == (int)(ExecuteStatus.Executing)).Count();

                platformrep.CommandQueueInfo.CommandQueueDic.Add(ExecuteStatus.NoExecute.description() + "_#f39c12", NoExecuteCommandQueueCount);
                platformrep.CommandQueueInfo.CommandQueueDic.Add(ExecuteStatus.Executing.description() + "_#00c0ef", ExecutingCommandQueueCount);
                platformrep.CommandQueueInfo.CommandQueueDic.Add(ExecuteStatus.ExecuteSucess.description() + "_#00a65a", ExecuteSucessCommandQueueCount);
                platformrep.CommandQueueInfo.CommandQueueDic.Add(ExecuteStatus.ExecuteFailed.description() + "_#dd4b39", ExecuteFailedCommandQueueCount);
                platformrep.CommandQueueInfo.CommandQueueDic.Add(ExecuteStatus.ExecuteException.description() + "_#ff3bd9", ExecuteExceptionCommandQueueCount);

                #endregion

                #region 用户统计

                List <tb_user> user = userrepository.Find(x => x.isdel == 0).ToList();
                platformrep.UserInfo.TotalUserCount = user.Count;
                #endregion

                #region 命令统计
                List <tb_commandlibdetail> cmd = cmdrespository.Find(x => x.isdel == 0).ToList();
                platformrep.CommandInfo.CommandCount = cmd.Count;
                #endregion
                return(ResponseToClient <PlatformStatisResponse>(ResponesStatus.Success, "", platformrep));
            }
            catch (Exception ex)
            {
                return(ResponseToClient <PlatformStatisResponse>(ResponesStatus.Exception, ex.Message));
            }
        }