/// <summary>注销监听器 </summary> /// <param name="sender"></param> public static void LogOutListener(object sender) { if (_listenerList.ContainsKey(sender)) { _listenerList.Remove(sender); } else { object _sender = null; foreach (object item in _listenerList.Keys) { if (item.GetType().Equals(typeof(LibSqlExceptionEventSource))) { LibSqlExceptionEventSource a = (LibSqlExceptionEventSource)item; if (a.TouchObj == sender) { _sender = item; break; } } } if (_sender != null) { _listenerList.Remove(_sender); } } }
/// <summary> 触发事件 </summary> /// <param name="sender"></param> /// <param name="eventType"></param> /// <param name="avgs"></param> public static void TouchEvent(object sender, LibEventType eventType, params object[] avgs) { switch (eventType) { case LibEventType.FormCommunitation: Dictionary <object, object> param = null; string tag = string.Empty; if (avgs != null && avgs.Length > 1) { tag = avgs[0].ToString(); param = avgs[1] as Dictionary <object, object>; } GetListener(sender).eventSource.OnFormAcceptMsg(tag, param); break; case LibEventType.SqlException: foreach (object item in _listenerList.Keys) { if (item.GetType().Equals(typeof(LibSqlExceptionEventSource))) { LibSqlExceptionEventSource a = (LibSqlExceptionEventSource)item; if (a.TouchObj == sender) { if (avgs != null && avgs.Length > 0) { (_listenerList[item] as LibEventListener).eventSource.OnSqlException(avgs[0] as Exception); } } } } break; } }
void eventSource_DoSqlException(Exception ex) { LibSqlExceptionEventSource eventlistener = _obj as LibSqlExceptionEventSource; if (eventlistener != null) { ILibEventListener even = eventlistener.SubscribeObj as ILibEventListener; if (even != null) { LibSqlExceptionEventArgs fargs = new LibSqlExceptionEventArgs(); fargs.Exception = ex; fargs.EventSourse = eventlistener; even.DoEvents(LibEventType.SqlException, fargs); } } }
void eventSource_DoSqlException(Exception ex) { LibSqlExceptionEventSource eventlistener = _obj as LibSqlExceptionEventSource; }