AlarmQueueTimeJob.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Quartz;
  2. using System;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using ToolLibrary.LogHelper;
  6. using Yunda.ISAS.DataMonitoringServer.WebSocket.Model;
  7. using YunDa.ISAS.Redis.Entities.AlarmCategory;
  8. namespace Yunda.ISAS.DataMonitoringServer.TimeWorkers
  9. {
  10. /// <summary>
  11. /// 报警队列推送
  12. /// </summary>
  13. [DisallowConcurrentExecution]
  14. public class AlarmQueueTimeJob : IJob
  15. {
  16. public async Task Execute(IJobExecutionContext context)
  17. {
  18. try
  19. {
  20. var list =await TimeWorkService._redisDataRepository.AlarmListRedis.HashSetGetAllAsync(nameof(AlarmListRedis));
  21. if (list != null && list.Count > 0)
  22. {
  23. var orders = list.OrderByDescending(t => DateTime.Parse(t.AlarmDateTime));
  24. //.OrderBy(t => t.IsClear)
  25. //.ThenBy(t => t.DMAlarmCategory.Level);
  26. var msg = new DataMonitorMessageModel()
  27. {
  28. MessageType = MessgeTypeEnum.AlarmQueue,
  29. Content = orders,
  30. GroupType = GroupTypeEnum.All
  31. };
  32. TimeWorkService._webSocketServer.SendMsg(msg);
  33. }
  34. }
  35. catch (System.Exception ex)
  36. {
  37. Log4Helper.Error(this.GetType(), "报警队列推送", ex);
  38. }
  39. }
  40. }
  41. }