EV.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. namespace Aitex.Core.RT.Event
  8. {
  9. public static class EV
  10. {
  11. public static ICommonEvent InnerEventManager { set; private get; }
  12. public static void PostMessage<T>(string module, T eventID, SerializableDictionary<string, string> dvid, params object[] args) where T : struct
  13. {
  14. if (InnerEventManager != null)
  15. InnerEventManager.WriteEvent(module, eventID.ToString(), dvid, args);
  16. }
  17. public static void PostMessage<T>(string module, T eventID, params object[] args) where T : struct
  18. {
  19. if (InnerEventManager != null)
  20. InnerEventManager.WriteEvent(module, eventID.ToString(), args);
  21. }
  22. public static void Notify(string eventName)
  23. {
  24. if (InnerEventManager != null)
  25. InnerEventManager.WriteEvent(eventName);
  26. }
  27. public static void Notify(string source, string eventName, string description)
  28. {
  29. if (InnerEventManager != null)
  30. InnerEventManager.WriteEvent(source, eventName, description);
  31. }
  32. public static void Notify(string eventName, SerializableDictionary<string, string> dvid)
  33. {
  34. if (InnerEventManager != null)
  35. InnerEventManager.WriteEvent(eventName,dvid);
  36. }
  37. public static void Notify(string eventName, SerializableDictionary<string, object> dvid)
  38. {
  39. if (InnerEventManager != null)
  40. InnerEventManager.WriteEvent(eventName, dvid);
  41. }
  42. //public static void PostMessage(string module, T eventID, params object[] args) where T : struct
  43. //{
  44. // if (InnerEventManager != null)
  45. // InnerEventManager.WriteEvent(module, eventID.ToString(), args);
  46. //}
  47. public static void PostNotificationMessage(string message)
  48. {
  49. if (InnerEventManager != null)
  50. InnerEventManager.PostNotificationMessage(message);
  51. }
  52. public static void PostPopDialogMessage(EventLevel level, string title, string message)
  53. {
  54. if (InnerEventManager != null)
  55. InnerEventManager.PostPopDialogMessage(level, title, message);
  56. }
  57. public static void PostKickoutMessage(string message)
  58. {
  59. if (InnerEventManager != null)
  60. InnerEventManager.PostKickoutMessage(message);
  61. }
  62. public static void PostSoundMessage(string message)
  63. {
  64. if (InnerEventManager != null)
  65. InnerEventManager.PostSoundMessage(message);
  66. }
  67. public static List<EventItem> GetAlarmEvent()
  68. {
  69. if (InnerEventManager != null)
  70. return InnerEventManager.GetAlarmEvent();
  71. return null;
  72. }
  73. public static void ClearAlarmEvent()
  74. {
  75. if (InnerEventManager != null)
  76. InnerEventManager.ClearAlarmEvent();
  77. }
  78. public static List<EventItem> QueryDBEvent(string sql)
  79. {
  80. if (InnerEventManager != null)
  81. return InnerEventManager.QueryDBEvent(sql);
  82. return null;
  83. }
  84. public static int GetCount(string sql)
  85. {
  86. if (InnerEventManager != null)
  87. return InnerEventManager.GetCount(sql);
  88. return 0;
  89. }
  90. public static void Subscribe(string evName)
  91. {
  92. if (InnerEventManager != null)
  93. InnerEventManager.Subscribe(new EventItem(evName));
  94. }
  95. public static void Subscribe(string evName, string description)
  96. {
  97. if (InnerEventManager != null)
  98. InnerEventManager.Subscribe(new EventItem(evName, description));
  99. }
  100. public static void Subscribe(EventItem item)
  101. {
  102. if (InnerEventManager != null)
  103. InnerEventManager.Subscribe(item);
  104. }
  105. public static void WriteEvent(string eventName)
  106. {
  107. if (InnerEventManager != null)
  108. InnerEventManager.WriteEvent(eventName);
  109. }
  110. public static void WriteEvent(string eventName, SerializableDictionary<string, string> dvid)
  111. {
  112. if (InnerEventManager != null)
  113. InnerEventManager.WriteEvent(eventName, dvid);
  114. }
  115. public static void PostInfoLog(string module, string description, int traceLevel=2)
  116. {
  117. //LOG.Info(description, false, traceLevel+1);
  118. if (InnerEventManager != null)
  119. {
  120. InnerEventManager.PostInfoLog(module, description);
  121. }
  122. }
  123. public static void PostWarningLog(string module, string description, int traceLevel = 2)
  124. {
  125. //LOG.Warning(description, traceLevel + 1);
  126. if (InnerEventManager != null)
  127. {
  128. InnerEventManager.PostWarningLog(module, description);
  129. }
  130. }
  131. public static void PostAlarmLog(string module, string description, int traceLevel = 2)
  132. {
  133. //LOG.Error(description, traceLevel + 1);
  134. if (InnerEventManager != null)
  135. {
  136. InnerEventManager.PostAlarmLog(module, description);
  137. }
  138. }
  139. }
  140. }