using HDLMonitorService.Helper;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HDLMonitorService.ServiceMonitor
{
public class DeviceCacheServiceMonitor
{
private static int DeviceCacheExCount = 0;
///
/// 监控Api服务
///
public static void monitorDeviceCacheServer()
{
new Thread(new ThreadStart(() =>
{
while (true)
{
try
{
HttpHp.Post>(ConfigurationManager.AppSettings["GetDeviceCacheUrl"], Newtonsoft.Json.JsonConvert.SerializeObject(new
{
MAC = "6BC7FEFFAAA04908",
DeviceType = "LightSwitch",
SubnetID = 1,
DeviceID = 1,
LoopID = 1
}));
DeviceCacheExCount = 0;
}
catch (Exception exc)
{
DeviceCacheExCount++;
if (DeviceCacheExCount == 3)
{
try
{
AlarmHp.ApplicationAlarm("LogicAndDataServer", "warn-system", exc.StackTrace, "115.29.191.136", exc.Message);
}
catch (Exception ex)
{
LogHp.WriteLog("设备状态缓存异常", Newtonsoft.Json.JsonConvert.SerializeObject(ex));
}
}
}
Thread.Sleep(1000 * 10);
}
}))
{ IsBackground = true }.Start();
}
}
}