Пример #1
0
        public ResponseBase <PageInfoResponse <LoadNodePerformancelistResponse> > LoadNodePerformancelist(LoadNodePerformancelistRequest req)
        {
            try
            {
                int pageIndex  = (req.iDisplayStart / req.iDisplayLength) + 1;
                int totalCount = 0;
                LoadNodePerformancelistResponse performanceDetail = new LoadNodePerformancelistResponse();
                List <int> nodeidlist = noderep.Find(out totalCount, pageIndex, req.iDisplayLength, m => m.id.ToString(), x => x.nodestatus == (req.NodeRunStatus <= 0?x.nodestatus:req.NodeRunStatus) && x.id == (req.NodeId <= 0?x.id:req.NodeId)).Select(k => k.id).ToList();
                nodeidlist.ForEach(m =>
                {
                    var performancelist = nodeperformanceRep.Find(x => m == x.nodeid && x.nodeid == (req.NodeId <= 0?x.nodeid:req.NodeId)).OrderByDescending(x => x.lastupdatetime).Take(15).ToList().OrderBy(x => x.lastupdatetime).ToList();
                    performancelist.ForEach(x =>
                    {
                        if (performanceDetail.NodePerfomance.ContainsKey(x.nodeid.ToString()))
                        {
                            performanceDetail.NodePerfomance[x.nodeid.ToString()].Add(x);
                        }
                        else
                        {
                            performanceDetail.NodePerfomance.Add(x.nodeid.ToString(), new List <tb_nodeperformance>()
                            {
                                x
                            });
                        }
                    });
                });


                return(ResponseToClient <PageInfoResponse <LoadNodePerformancelistResponse> >(ResponesStatus.Success, "", new PageInfoResponse <LoadNodePerformancelistResponse>()
                {
                    aaData = performanceDetail, iTotalDisplayRecords = totalCount, iTotalRecords = totalCount, sEcho = req.sEcho
                }));
            }
            catch (Exception ex)
            {
                return(ResponseToClient <PageInfoResponse <LoadNodePerformancelistResponse> >(ResponesStatus.Exception, JsonConvert.SerializeObject(ex)));
            }
        }
Пример #2
0
 protected override void Run()
 {
     lock (lockObj)
     {
         List <tb_node> nodelist = nodeRep.Find(x => x.isdel == 0 && x.ifcheckstate == true).ToList();
         List <tb_user> userList = userRep.Find(x => x.isdel == 0).ToList();
         StringBuilder  strLog   = new StringBuilder();
         nodelist.ForEach(x =>
         {
             try
             {
                 List <int> uidlist      = x.alarmuserid.ConvertToList();
                 List <tb_user> userlist = userList.Where(m => uidlist.Contains(m.id)).ToList();
                 string alaramperson     = x.alarmtype == (int)AlarmType.Email ? string.Join(",", userlist.Select(m => m.useremail).ToArray()) : string.Join(",", userlist.Select(m => m.usermobile).ToArray());
                 if (x.nodestatus == (int)NodeStatus.Running)//运行中
                 {
                     #region 检测心跳
                     double totalsecond = Math.Abs(x.nodelastupdatetime.Subtract(DateTime.Now).TotalSeconds);
                     if (totalsecond > 20 || totalsecond < 0)//大于10s 说明心跳不正常
                     {
                         List <int> taskidlist = new List <int>();
                         taskVersionRep.Find(m => m.nodeid == x.id && m.isdel == 0).ToList().ForEach(m =>
                         {
                             taskidlist.Add(m.taskid);
                         });
                         nodeRep.UpdateNodeById(x.id, new Dictionary <string, string>()
                         {
                             { "nodestatus", ((int)NodeStatus.NoRun).ToString() }, { "refreshcommandqueuestatus", ((int)RefreshCommandQueueStatus.NoRefresh).ToString() }
                         });                                                                                                                                                                                                             //, { "refreshcommandqueuestatus", ((int)RefreshCommandQueueStatus.NoRefresh).ToString() }
                         taskRep.UpdateById(taskidlist, new Dictionary <string, string>()
                         {
                             { "taskschedulestatus", ((int)TaskScheduleStatus.StopSchedule).ToString() }
                         });
                         string title             = "节点(编号):" + x.nodename + "(" + x.id.ToString() + "),心跳异常,已自动更新为未运行状态,请及时处理该节点下的任务!";
                         StringBuilder strContent = new StringBuilder();
                         strContent.AppendLine("节点(编号):" + x.nodename + "(" + x.id.ToString() + ")<br/>");
                         strContent.AppendLine("节点最后一次心跳时间:" + x.nodelastupdatetime + "<br/>");
                         //当前节点心跳不正常,已修改节点状态为未运行
                         AlarmHelper.AlarmAsync(x.isenablealarm, (AlarmType)x.alarmtype, alaramperson, title, strContent.ToString());
                     }
                     else
                     {
                         if (x.refreshcommandqueuestatus == (int)RefreshCommandQueueStatus.Refreshing)
                         {
                             double totalsecond2 = Math.Abs(x.lastrefreshcommandqueuetime.Subtract(DateTime.Now).TotalSeconds);
                             if (totalsecond2 > 20 || totalsecond2 < 0)//大于10s 说明心跳不正常
                             {
                                 nodeRep.UpdateNodeById(x.id, new Dictionary <string, string>()
                                 {
                                     { "refreshcommandqueuestatus", ((int)RefreshCommandQueueStatus.NoRefresh).ToString() }
                                 });                                                                                                                                                       //,
                                 string title             = "节点(编号):" + x.nodename + "(" + x.id.ToString() + "),监听队列异常,已自动更新为未监听状态,请及时处理该节点!";
                                 StringBuilder strContent = new StringBuilder();
                                 strContent.AppendLine("节点(编号):" + x.nodename + "(" + x.id.ToString() + ")<br/>");
                                 strContent.AppendLine("节点最后一次监听队列时间:" + x.lastrefreshcommandqueuetime + "<br/>");
                                 //当前节点心跳不正常,已修改节点状态为未运行
                                 AlarmHelper.AlarmAsync(x.isenablealarm, (AlarmType)x.alarmtype, alaramperson, title, strContent.ToString());
                             }
                         }
                     }
                     #endregion
                 }
             }
             catch (Exception ex)
             {
                 strLog.AppendLine("检测节点心跳异常:" + JsonConvert.SerializeObject(ex));
             }
         });
         if (strLog.Length > 0)
         {
             log.Error(strLog.ToString());
         }
     }
 }