private void OnUnSubscribeForSubscriptionType(SubscribeEventArgs e) { if (UnSubscribeForSubscriptionType != null) { UnSubscribeForSubscriptionType(this, e); } }
//Passes subscription to service session for subscription. public void OPCSubscribe(object sender, SubscribeEventArgs e) { try { client.OPCSubscribe(e.subscription); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
public void Invoke(SubscribeEventArgs <Message> routemsg, Message message, Result result) { object[] data = new object[] { routemsg, message, result }; if (UseThreads) { System.Threading.ThreadPool.QueueUserWorkItem(OnInvoke, data); } else { OnInvoke(data); } }
protected void OnInvoke(object state) { object[] data = (object[])state; SubscribeEventArgs <Message> routemsg = (SubscribeEventArgs <Message>)data[0]; Message message = (Message)data[1]; Result result = (Result)data[2]; try { ControllerContext context = new ControllerContext(); Controller.Context = context; if (message.Body != null && (mToObjectMethod == null || mSelectTokenMethod == null)) { mToObjectMethod = message.Body.GetType().GetMethod(ToObjectMethodName, new Type[] { typeof(Type) }); mSelectTokenMethod = message.Body.GetType().GetMethod(SelectTokenMethodName, new Type[] { typeof(String) }); } object[] objs = new Object[Parameters.Count]; if (Parameters.Count == 1 && Parameters[0].ParameterType.IsClass) { objs[0] = mToObjectMethod.Invoke(message.Body, new object[] { Parameters[0].ParameterType }); } else { for (int i = 0; i < Parameters.Count; i++) { System.Reflection.ParameterInfo p = Parameters[i]; object pobject = mSelectTokenMethod.Invoke(message.Body, new object[] { p.Name }); if (pobject != null) { objs[i] = mToObjectMethod.Invoke(pobject, new object[] { p.ParameterType }); } else { objs[i] = GetTypeDefault(p.ParameterType); } } } result.Data = Method.Invoke(Controller, objs); result.Headers = context.ResultHeaders; } catch (Exception e_) { result.ErrorCode = 500; result.Error = e_.Message; result.ErrorStackTrace = e_.StackTrace; } finally { routemsg.Reply(result); } }
private void OnReceive(object sender, SubscribeEventArgs <Message> e) { Result result = new Result(); ActioHandler handler; if (mHandlers.TryGetValue(e.Data.Api, out handler)) { handler.Invoke(e, e.Data, result); } else { result.ErrorCode = 404; result.Error = string.Format("{0} api action not found!", e.Data.Api); e.Reply(result); } }
/// <summary> /// 关注帖吧事件处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void SubscribeBarSectionEventModule_After(long sender, SubscribeEventArgs eventArgs) { if (eventArgs.TenantTypeId != TenantTypeIds.Instance().BarSection()) { return; } ActivityService activityService = new ActivityService(); if (EventOperationType.Instance().Create() == eventArgs.EventOperationType) { activityService.TraceBackInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection()); //用户内容计数 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), 1); } else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType) { activityService.RemoveInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection()); //用户内容计数 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), -1); } }
protected virtual void OnSubscribedTopic(SubscribeEventArgs e) { SubscribededTopic?.Invoke(this, e); }