public void Stop() { try { OnInit("----------------------" + DateTime.Now + ":停止节点开始-----------------------------------------"); //1.停止所有监控扫描 GlobalNodeConfig.Monitors.ForEach(x => { x.CancelRun(); }); OnInit(DateTime.Now + ":监控停止完成"); //2.停止刷新命令队列 CommandQueueScanManger.StopScanCommandQueue(); OnInit(DateTime.Now + ":停止命令队列监听完成"); //刷新节点运行状态 var r2 = NodeProxy.PostToServer <EmptyResponse, UpdateNodeStatusRequest>(ProxyUrl.UpdateNodeStatus_Url, new UpdateNodeStatusRequest() { NodeId = GlobalNodeConfig.NodeID, Source = Source.Node, NodeStatus = Model.enums.NodeStatus.NoRun }); if (r2.Status != ResponesStatus.Success) { string msg = "更新节点运行状态失败,请求地址:" + ProxyUrl.UpdateNodeStatus_Url + ",服务器返回参数:" + JsonConvert.SerializeObject(r2); OnInit(msg); AlarmHelper.Alarm(GlobalNodeConfig.NodeInfo.isenablealarm, (AlarmType)GlobalNodeConfig.NodeInfo.alarmtype, GlobalNodeConfig.Alarm, "节点(" + GlobalNodeConfig.NodeID.ToString() + ")停止,更新运行状态失败", msg); } AlarmHelper.Alarm(GlobalNodeConfig.NodeInfo.isenablealarm, (AlarmType)GlobalNodeConfig.NodeInfo.alarmtype, GlobalNodeConfig.Alarm, "节点(" + GlobalNodeConfig.NodeID.ToString() + ")停止,请及时处理", DateTime.Now + ":当前节点(" + GlobalNodeConfig.NodeID.ToString() + ")已停止运行,如正常停止请忽略此预警"); OnInit("节点服务停止"); } catch (Exception ex) { string exemsg = "节点停止异常:" + JsonConvert.SerializeObject(ex); OnInit(exemsg); AlarmHelper.Alarm(GlobalNodeConfig.NodeInfo.isenablealarm, (AlarmType)GlobalNodeConfig.NodeInfo.alarmtype, GlobalNodeConfig.Alarm, "节点(" + GlobalNodeConfig.NodeID.ToString() + ")停止异常,请及时处理!", exemsg + ",节点停止日志:" + strLog.ToString()); } finally { OnInit("----------------------" + DateTime.Now + ":停止节点结束-----------------------------------------"); LogProxy.AddNodeLog(strLog.ToString(), LogType.NodeStopLog); strLog.Clear(); } }