123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Alarms;
- namespace Aitex.Core.RT.Event
- {
- public static class EV
- {
- public static ICommonEvent InnerEventManager { set; private get; }
- public static void PostMessage<T>(string module, T eventID, SerializableDictionary<string, string> dvid, params object[] args) where T : struct
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(module, eventID.ToString(), dvid, args);
- }
- public static void PostMessage<T>(string module, T eventID, params object[] args) where T : struct
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(module, eventID.ToString(), args);
- }
- public static void Notify(string eventName)
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(eventName);
- }
- public static void Notify(string source, string eventName, string description)
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(source, eventName, description);
- }
- public static void Notify(string eventName, SerializableDictionary<string, string> dvid)
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(eventName, dvid);
- }
- public static void Notify(string eventName, SerializableDictionary<string, object> dvid)
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(eventName, dvid);
- }
- //public static void PostMessage(string module, T eventID, params object[] args) where T : struct
- //{
- // if (InnerEventManager != null)
- // InnerEventManager.WriteEvent(module, eventID.ToString(), args);
- //}
- public static void PostNotificationMessage(string message)
- {
- if (InnerEventManager != null)
- InnerEventManager.PostNotificationMessage(message);
- }
- public static void PostPopDialogMessage(EventLevel level, string title, string message)
- {
- if (InnerEventManager != null)
- InnerEventManager.PostPopDialogMessage(level, title, message);
- }
- public static void PostKickoutMessage(string message)
- {
- if (InnerEventManager != null)
- InnerEventManager.PostKickoutMessage(message);
- }
- public static void PostSoundMessage(string message)
- {
- if (InnerEventManager != null)
- InnerEventManager.PostSoundMessage(message);
- }
- public static List<EventItem> GetAlarmEvent()
- {
- if (InnerEventManager != null)
- return InnerEventManager.GetAlarmEvent().OrderByDescending(p=>p.Level).ToList();
- return null;
- }
- public static void ClearAlarmEvent()
- {
- if (InnerEventManager != null)
- InnerEventManager.ClearAlarmEvent();
- }
- public static void ClearAlarmEvent(string name)
- {
- if (InnerEventManager != null)
- InnerEventManager.ClearAlarmEvent(name);
- }
- public static void ClearAlarmEvent(int id)
- {
- if (InnerEventManager != null)
- InnerEventManager.ClearAlarmEvent(id);
- }
- public static void ClearAlarmEvent(int id, int count)
- {
- if (InnerEventManager != null)
- InnerEventManager.ClearAlarmEvent(id, count);
- }
- public static List<EventItem> QueryDBEvent(string sql)
- {
- if (InnerEventManager != null)
- return InnerEventManager.QueryDBEvent(sql);
- return null;
- }
- public static void Subscribe(string evName)
- {
- if (InnerEventManager != null)
- InnerEventManager.Subscribe(new EventItem(evName));
- }
- public static void Subscribe(string evName, string description)
- {
- if (InnerEventManager != null)
- InnerEventManager.Subscribe(new EventItem(evName, description));
- }
- public static void Subscribe(EventItem item)
- {
- if (InnerEventManager != null)
- InnerEventManager.Subscribe(item);
- }
- public static void WriteEvent(string eventName)
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(eventName);
- }
- public static void WriteEvent(string eventName, SerializableDictionary<string, string> dvid)
- {
- if (InnerEventManager != null)
- InnerEventManager.WriteEvent(eventName, dvid);
- }
- public static void PostInfoLog(string module, string description, int traceLevel = 2)
- {
- //LOG.Info(description, false, traceLevel+1);
- if (InnerEventManager != null)
- {
- InnerEventManager.PostInfoLog(module, description);
- }
- }
- public static void PostInfoLog(string module, string description, string roleName)
- {
- //LOG.Info(description, false, traceLevel+1);
- if (InnerEventManager != null)
- {
- InnerEventManager.PostInfoLog(module, description, roleName);
- }
- }
- public static void PostWarningLog(string module, string description, int traceLevel = 2)
- {
- //LOG.Warning(description, traceLevel + 1);
- if (InnerEventManager != null)
- {
- InnerEventManager.PostWarningLog(module, description);
- }
- }
- public static void PostAlarmLog(string module, string description, int traceLevel = 2)
- {
- //LOG.Error(description, traceLevel + 1);
- if (InnerEventManager != null)
- {
- InnerEventManager.PostAlarmLog(module, description);
- }
- }
- public static void PostAlarmLog(string module, EventItem item)
- {
- if (InnerEventManager != null)
- {
- InnerEventManager.PostAlarmDefineLog(module, item.EventEnum, item.AdditionalDescription, item.Action);
- }
- }
- public static void PostWarningLog(string module, EventItem item)
- {
- if (InnerEventManager != null)
- {
- InnerEventManager.PostAlarmDefineLog(module, item.EventEnum, item.AdditionalDescription, item.Action);
- }
- }
- public static void PostAlarmLog(string module, int eventID, string description = "")
- {
- if (InnerEventManager != null && Singleton<AlarmDefineFileManager>.Instance.AlarmTables.ContainsKey(Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable))
- {
- if (Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].IsUse)
- InnerEventManager.PostAlarmLog(module, eventID, $"{Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].Message}{description}");
- }
- }
- public static void PostWarningLog(string module, int eventID, string description = "")
- {
- if (InnerEventManager != null && Singleton<AlarmDefineFileManager>.Instance.AlarmTables.ContainsKey(Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable))
- {
- if (Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].IsUse)
- InnerEventManager.PostWarningLog(module, eventID, $"{Singleton<AlarmDefineFileManager>.Instance.AlarmTables[Singleton<AlarmDefineFileManager>.Instance.CurrentAlarmTable][eventID].Message}{description}");
- }
- }
- }
- }
|