Ejemplo n.º 1
0
        /// <summary>
        /// 将事件向远程监听者播送。
        /// </summary>
        /// <param name="pEvent">事件数据契约。</param>
        public void CastRemoteEvent(EventDC pEvent)
        {
            List <RemoteEventListenEntity> EventListenList = new List <RemoteEventListenEntity>();

            lock (locker)
            {
                EventListenList = dataPers.GetQueryable <RemoteEventListenEntity>()
                                  .Where(ww => ww.SenderInterfaceName == pEvent.SenderInterfaceName &&
                                         ww.SenderTypeName == pEvent.SenderTypeName &&
                                         ww.EventName == pEvent.EventName).ToList();

                Action saveForCast = delegate()
                {
                    foreach (var EventListen in EventListenList)
                    {
                        RemoteEventEntity eventEt = new RemoteEventEntity();
                        eventEt.AppRuntimeName      = EventListen.AppRuntimeName;
                        eventEt.EventKey            = pEvent.EventKey;
                        eventEt.EventName           = pEvent.EventName;
                        eventEt.HandleState         = HandleState.Unstarted;
                        eventEt.MessageJsonValue    = pEvent.Message.JsonValue;
                        eventEt.MessageTypeQuaName  = pEvent.Message.TypeQualifiedName;
                        eventEt.SenderInterfaceName = pEvent.SenderInterfaceName;
                        eventEt.SenderTypeName      = pEvent.SenderTypeName;

                        if (!dataPers.GetQueryable <RemoteEventEntity>().Contains(eventEt))
                        {
                            dataPers.Add(eventEt);
                        }
                    }
                };
                dataPers.WorkUnitAct(saveForCast);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理某个事件出错。
        /// </summary>
        /// <param name="EventKey">事件键。</param>
        /// <param name="appRuntimeName">应用运行时名称。</param>
        public void ErredEvent(string EventKey, string appRuntimeName)
        {
            RemoteEventEntity eventEy = new RemoteEventEntity(EventKey, appRuntimeName);

            lock (locker)
            {
                dataPers.Update <RemoteEventEntity>(new { HandleState = HandleState.Erred }, ww => ww.EventEntityKey == eventEy.EventEntityKey);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 开始处理某个事件。
        /// </summary>
        /// <param name="EventKey">事件键。</param>
        /// <param name="appRuntimeName">应用运行时名称。</param>
        public bool StartEvent(string EventKey, string appRuntimeName)
        {
            bool isNotHandled = false;

            RemoteEventEntity pEventEt = new RemoteEventEntity(EventKey, appRuntimeName);

            lock (locker)
            {
                Action UpForStart = delegate()
                {
                    RemoteEventEntity theEventEt = dataPers.GetQueryable <RemoteEventEntity>()
                                                   .Where(ww => ww.EventEntityKey == pEventEt.EventEntityKey && ww.HandleState == HandleState.Unstarted).FirstOrDefault();

                    if (theEventEt != null)
                    {
                        theEventEt.HandleState = HandleState.Handling;
                        isNotHandled           = dataPers.Update(theEventEt);
                    }
                };
                dataPers.WorkUnitAct(UpForStart);
            }

            return(isNotHandled);
        }