using HDLMonitorService.Entity; using HDLMonitorService.Helper; using System; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace HDLMonitorService.ServiceMonitor { public class AlexaMonitor { private static int DeviceCacheExCount = 0; public static void monitor() { new Thread(new ThreadStart(() => { while (true) { try { var reqPack = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "Json//AlexaReqPack.json"); var result = HttpHp.Post(ConfigurationManager.AppSettings["AelxaApi"], reqPack); if (result == null) { throw new Exception("响应数据异常"); } DeviceCacheExCount = 0; } catch (Exception exc) { DeviceCacheExCount++; if (DeviceCacheExCount == 3) { try { AlarmHp.ApplicationAlarm("AlexaApi", "warn-system", exc.StackTrace, "118.31.3.103", exc.Message); } catch (Exception ex) { LogHp.WriteLog("Alexa异常", Newtonsoft.Json.JsonConvert.SerializeObject(ex)); } } } Thread.Sleep(1000 * 10); } })) { IsBackground = true }.Start(); } } }