Пример #1
0
        /// <summary>
        /// 发布事件调用失败的结果
        /// </summary>
        internal static void PublishRaiseFailed(dynamic identity, EventKey key, string message)
        {
            var en  = EventUtil.GetRaiseResult(key.EventName, key.EventId);//消息队列的事件名称
            var arg = CreatePublishRaiseResultArg(identity, key, false, message, string.Empty);

            EventPortal.Publish(en, arg);
        }
Пример #2
0
        public static void NotifyDeleted(RemoteType remoteType, object id)
        {
            var arg       = CreateEventArg(remoteType, id);
            var eventName = RemoteObjectDeleted.GetEventName(remoteType);

            EventPortal.Publish(eventName, arg);
        }
Пример #3
0
        /// <summary>
        /// 发布事件调用成功的结果
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="eventId"></param>
        /// <param name="message"></param>
        internal static void PublishRaiseSucceeded(dynamic identity, string eventName, Guid eventId, string argsCode)
        {
            var en = EventUtil.GetRaiseResult(eventName, eventId); //消息队列的事件名称
            //返回事件成功被执行的结果
            var arg = CreatePublishRaiseResultArg(identity, new EventKey(eventId, eventName), true, string.Empty, argsCode);

            EventPortal.Publish(en, arg);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tip"></param>
        private static void CanceleReverse(EventAttribute tip)
        {
            if (!tip.IsEnabled)
            {
                return;
            }

            var reverseName = EventUtil.GetReverse(tip.Name);

            EventPortal.Cancel(reverseName);
        }
Пример #5
0
        /// <summary>
        /// 订阅回逆
        /// </summary>
        /// <param name="tip"></param>
        private static void SubscribeReverse(EventAttribute tip)
        {
            if (!tip.IsEnabled)
            {
                return;
            }

            var reverseName = EventUtil.GetReverse(tip.Name);

            EventPortal.Subscribe(reverseName, ReverseEventHandler.Instance);
        }
Пример #6
0
        /// <summary>
        /// 订阅触发
        /// </summary>
        /// <param name="tip"></param>
        private static void SubscribeRaise(EventAttribute tip)
        {
            if (!tip.IsEnabled)
            {
                return;
            }

            var raiseName = EventUtil.GetRaise(tip.Name);

            //作为事件的提供方,我们订阅了触发事件,这样当外界发布了“触发事件”后,这里就可以收到消息并且执行事件
            EventPortal.Subscribe(raiseName, RaiseEventHandler.Instance);
        }
Пример #7
0
        private static void ReverseRemoteEvent(EventEntry entry, dynamic identity, DTObject args)
        {
            entry.Status = EventStatus.Reversing;

            //调用远程事件时会创建一个接收结果的临时队列,有可能该临时队列没有被删除,所以需要在回逆的时候处理一次
            EventTrigger.CleanupRemoteEventResult(entry.EventName, entry.EventId);

            //发布“回逆事件”的事件
            var reverseEventName = EventUtil.GetReverse(entry.EventName);

            EventPortal.Publish(reverseEventName, entry.GetRemotable(identity, args));
            //注意,与“触发事件”不同,我们不需要等待回逆的结果,只用传递回逆的消息即可
            entry.Status = EventStatus.Reversed;
        }
Пример #8
0
        private static void RaiseRemoteEvent(EventEntry entry, dynamic identity, DTObject args)
        {
            entry.Status = EventStatus.Raising;

            //先订阅触发事件的返回结果的事件
            SubscribeRemoteEventResult(entry.EventName, entry.EventId);

            //再发布“触发事件”的事件
            var raiseEventName = EventUtil.GetRaise(entry.EventName);

            EventPortal.Publish(raiseEventName, entry.GetRemotable(identity, args)); //触发远程事件就是发布一个“触发事件”的事件 ,订阅者会收到消息后会执行触发操作

            TimeoutManager.Start(new EventKey(entry.EventId, entry.EventName));
        }
Пример #9
0
        public static void Cancel(RemoteType remoteType)
        {
            var eventName = GetEventName(remoteType);

            EventPortal.Cancel(eventName);
        }
Пример #10
0
        public static void Subscribe(RemoteType remoteType)
        {
            var eventName = GetEventName(remoteType);

            EventPortal.Subscribe(eventName, Handler);
        }
Пример #11
0
        /// <summary>
        /// 删除由于接受调用结果而创建的临时队列
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="eventId"></param>
        internal static void CleanupRemoteEventResult(string eventName, Guid eventId)
        {
            var raiseResultEventName = EventUtil.GetRaiseResult(eventName, eventId);

            EventPortal.Cleanup(raiseResultEventName);
        }
Пример #12
0
        /// <summary>
        /// 订阅远程事件的返回结果的事件
        /// </summary>
        internal static void SubscribeRemoteEventResult(string eventName, Guid eventId)
        {
            var raiseResultEventName = EventUtil.GetRaiseResult(eventName, eventId);

            EventPortal.Subscribe(raiseResultEventName, ReceiveResultEventHandler.Instance);
        }