EV.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.Util;
  7. using MECF.Framework.Common.Alarms;
  8. namespace Aitex.Core.RT.Event
  9. {
  10. public static class EV
  11. {
  12. public static ICommonEvent InnerEventManager { set; private get; }
  13. public static void PostMessage<T>(string module, T eventID, SerializableDictionary<string, string> dvid, params object[] args) where T : struct
  14. {
  15. if (InnerEventManager != null)
  16. InnerEventManager.WriteEvent(module, eventID.ToString(), dvid, args);
  17. }
  18. public static void PostMessage<T>(string module, T eventID, params object[] args) where T : struct
  19. {
  20. if (InnerEventManager != null)
  21. InnerEventManager.WriteEvent(module, eventID.ToString(), args);
  22. }
  23. public static void Notify(string eventName)
  24. {
  25. if (InnerEventManager != null)
  26. InnerEventManager.WriteEvent(eventName);
  27. }
  28. public static void Notify(string source, string eventName, string description)
  29. {
  30. if (InnerEventManager != null)
  31. InnerEventManager.WriteEvent(source, eventName, description);
  32. }
  33. public static void Notify(string eventName, SerializableDictionary<string, string> dvid)
  34. {
  35. if (InnerEventManager != null)
  36. InnerEventManager.WriteEvent(eventName, dvid);
  37. }
  38. public static void Notify(string eventName, SerializableDictionary<string, object> dvid)
  39. {
  40. if (InnerEventManager != null)
  41. InnerEventManager.WriteEvent(eventName, dvid);
  42. }
  43. //public static void PostMessage(string module, T eventID, params object[] args) where T : struct
  44. //{
  45. // if (InnerEventManager != null)
  46. // InnerEventManager.WriteEvent(module, eventID.ToString(), args);
  47. //}
  48. public static void PostNotificationMessage(string message)
  49. {
  50. if (InnerEventManager != null)
  51. InnerEventManager.PostNotificationMessage(message);
  52. }
  53. public static void PostPopDialogMessage(EventLevel level, string title, string message)
  54. {
  55. if (InnerEventManager != null)
  56. InnerEventManager.PostPopDialogMessage(level, title, message);
  57. }
  58. public static void PostKickoutMessage(string message)
  59. {
  60. if (InnerEventManager != null)
  61. InnerEventManager.PostKickoutMessage(message);
  62. }
  63. public static void PostSoundMessage(string message)
  64. {
  65. if (InnerEventManager != null)
  66. InnerEventManager.PostSoundMessage(message);
  67. }
  68. public static List<EventItem> GetAlarmEvent()
  69. {
  70. if (InnerEventManager != null)
  71. return InnerEventManager.GetAlarmEvent().OrderByDescending(p=>p.Level).ToList();
  72. return null;
  73. }
  74. public static void ClearAlarmEvent()
  75. {
  76. if (InnerEventManager != null)
  77. InnerEventManager.ClearAlarmEvent();
  78. }
  79. public static void ClearAlarmEvent(string name)
  80. {
  81. if (InnerEventManager != null)
  82. InnerEventManager.ClearAlarmEvent(name);
  83. }
  84. public static void ClearAlarmEvent(int id)
  85. {
  86. if (InnerEventManager != null)
  87. InnerEventManager.ClearAlarmEvent(id);
  88. }
  89. public static void ClearAlarmEvent(int id, int count)
  90. {
  91. if (InnerEventManager != null)
  92. InnerEventManager.ClearAlarmEvent(id, count);
  93. }
  94. public static List<EventItem> QueryDBEvent(string sql)
  95. {
  96. if (InnerEventManager != null)
  97. return InnerEventManager.QueryDBEvent(sql);
  98. return null;
  99. }
  100. public static void Subscribe(string evName)
  101. {
  102. if (InnerEventManager != null)
  103. InnerEventManager.Subscribe(new EventItem(evName));
  104. }
  105. public static void Subscribe(string evName, string description)
  106. {
  107. if (InnerEventManager != null)
  108. InnerEventManager.Subscribe(new EventItem(evName, description));
  109. }
  110. public static void Subscribe(EventItem item)
  111. {
  112. if (InnerEventManager != null)
  113. InnerEventManager.Subscribe(item);
  114. }
  115. public static void WriteEvent(string eventName)
  116. {
  117. if (InnerEventManager != null)
  118. InnerEventManager.WriteEvent(eventName);
  119. }
  120. public static void WriteEvent(string eventName, SerializableDictionary<string, string> dvid)
  121. {
  122. if (InnerEventManager != null)
  123. InnerEventManager.WriteEvent(eventName, dvid);
  124. }
  125. public static void PostInfoLog(string module, string description, int traceLevel = 2)
  126. {
  127. //LOG.Info(description, false, traceLevel+1);
  128. if (InnerEventManager != null)
  129. {
  130. InnerEventManager.PostInfoLog(module, description);
  131. }
  132. }
  133. public static void PostInfoLog(string module, string description, string roleName)
  134. {
  135. //LOG.Info(description, false, traceLevel+1);
  136. if (InnerEventManager != null)
  137. {
  138. InnerEventManager.PostInfoLog(module, description, roleName);
  139. }
  140. }
  141. public static void PostWarningLog(string module, string description, int traceLevel = 2)
  142. {
  143. //LOG.Warning(description, traceLevel + 1);
  144. if (InnerEventManager != null)
  145. {
  146. InnerEventManager.PostWarningLog(module, description);
  147. }
  148. }
  149. public static void PostAlarmLog(string module, string description, int traceLevel = 2)
  150. {
  151. //LOG.Error(description, traceLevel + 1);
  152. if (InnerEventManager != null)
  153. {
  154. InnerEventManager.PostAlarmLog(module, description);
  155. }
  156. }
  157. public static void PostAlarmLog(string module, EventItem item)
  158. {
  159. if (InnerEventManager != null)
  160. {
  161. InnerEventManager.PostAlarmDefineLog(module, item.EventEnum, item.AdditionalDescription, item.Action);
  162. }
  163. }
  164. public static void PostWarningLog(string module, EventItem item)
  165. {
  166. if (InnerEventManager != null)
  167. {
  168. InnerEventManager.PostAlarmDefineLog(module, item.EventEnum, item.AdditionalDescription, item.Action);
  169. }
  170. }
  171. public static void PostAlarmLog(string module, int eventID, string description = "")
  172. {
  173. if (InnerEventManager != null && Singleton<AlarmDefineFileManager>.Instance.AlarmTables.ContainsKey(Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable))
  174. {
  175. if (Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].IsUse)
  176. InnerEventManager.PostAlarmLog(module, eventID, $"{Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].Message}{description}");
  177. }
  178. }
  179. public static void PostWarningLog(string module, int eventID, string description = "")
  180. {
  181. if (InnerEventManager != null && Singleton<AlarmDefineFileManager>.Instance.AlarmTables.ContainsKey(Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable))
  182. {
  183. if (Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].IsUse)
  184. InnerEventManager.PostWarningLog(module, eventID, $"{Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].Message}{description}");
  185. }
  186. }
  187. }
  188. }