|
@@ -965,6 +965,7 @@ namespace PMS.BusinessService.CloudMonitorManage
|
|
|
{
|
|
|
//如果这个客户端ID没有启动,直接退出
|
|
|
if (!GetProjectMonitor().Any(m => m.客户端ID == clientId)) return;
|
|
|
+ if (!WorkTimeCheckContinue(clientId + "ReceiveServerInfo")) return;
|
|
|
foreach (var item in serverInfos)
|
|
|
{
|
|
|
if (!item.Success)
|
|
@@ -1440,6 +1441,7 @@ namespace PMS.BusinessService.CloudMonitorManage
|
|
|
{
|
|
|
//如果这个客户端ID没有启动,直接退出
|
|
|
if (!GetProjectMonitor().Any(m => m.客户端ID == clientId)) return;
|
|
|
+ if (!WorkTimeCheckContinue(clientId + "ReceiveDbConnectInfo")) return;
|
|
|
var config = GetCloudMonitorConfig().AlertConfig;
|
|
|
foreach (var item in dbConnectInfos)
|
|
|
{
|
|
@@ -1526,6 +1528,7 @@ namespace PMS.BusinessService.CloudMonitorManage
|
|
|
{
|
|
|
//如果这个客户端ID没有启动,直接退出
|
|
|
if (!GetProjectMonitor().Any(m => m.客户端ID == clientId)) return;
|
|
|
+ if (!WorkTimeCheckContinue(clientId + "ReceiveDbLockedInfo")) return;
|
|
|
foreach (var item in dbLockedInfos)
|
|
|
{
|
|
|
if (!item.Success)
|
|
@@ -1591,6 +1594,7 @@ namespace PMS.BusinessService.CloudMonitorManage
|
|
|
{
|
|
|
//如果这个客户端ID没有启动,直接退出
|
|
|
if (!GetProjectMonitor().Any(m => m.客户端ID == clientId)) return;
|
|
|
+ if (!WorkTimeCheckContinue(clientId + "ReceiveServiceWorkStateInfo")) return;
|
|
|
foreach (var item in serviceWorkStateInfos)
|
|
|
{
|
|
|
if (!item.Success)
|
|
@@ -2293,6 +2297,67 @@ namespace PMS.BusinessService.CloudMonitorManage
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 工作时间
|
|
|
+ /// <summary>
|
|
|
+ /// 表示非工作时间的采集频率
|
|
|
+ /// </summary>
|
|
|
+ private const int workFrequency = 15;
|
|
|
+ private static Dictionary<string, int> _cacheWorkTime = new Dictionary<string, int>();
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 判断工作时间,是否继续
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool WorkTimeCheckContinue(string id)
|
|
|
+ {
|
|
|
+ //不是工作时间直接继续
|
|
|
+ if (!IsWorkTime()) return true;
|
|
|
+ if(_cacheWorkTime.TryGetValue(id, out var num))
|
|
|
+ {
|
|
|
+ num++;
|
|
|
+ if (num >= workFrequency)
|
|
|
+ {
|
|
|
+ _cacheWorkTime[id] = 0;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _cacheWorkTime[id] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 判断当前时间是否工作时间
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool IsWorkTime()
|
|
|
+ {
|
|
|
+ var config = GetCloudMonitorConfig();
|
|
|
+ AlertConfig alertConfig = config.AlertConfig;
|
|
|
+
|
|
|
+ // 当前时间的小时和分钟
|
|
|
+ var currentTime = DateTime.Now.TimeOfDay;
|
|
|
+
|
|
|
+ // 将字符串时间转换为 TimeSpan
|
|
|
+ var startTime = TimeSpan.Parse(alertConfig.工作开始时间);
|
|
|
+ var endTime = TimeSpan.Parse(alertConfig.工作结束时间);
|
|
|
+
|
|
|
+ // 检查当前时间是否在时间区间内
|
|
|
+ if (currentTime >= startTime && currentTime <= endTime)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|
|
|
;
|