public void Handle(RestartChannelMethodCommand request)
        {
            var handler = HandlerInfos.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            if (handler == null)
            {
                throw new HandlerNotFoundException();
            }

            var rawHandler = RawHandlers.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            Task.Run(() => { rawHandler.Restart(); });
            Thread.Sleep(1000);

            HandlerInfoCollection.UpdateHandlerState(GetType().Name, request.HandlerId, "Restarted");
        }
コード例 #2
0
        public void Handle(StopChannelMethodCommand request)
        {
            var handlerInfo = HandlerInfos.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            if (handlerInfo == null)
            {
                throw new HandlerNotFoundException();
            }

            if (handlerInfo.State.Equals("stopped", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var handler = RawHandlers.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            handler.Stop();
            HandlerInfoCollection.UpdateHandlerState(GetType().Name, request.HandlerId, "Stopped");
        }
コード例 #3
0
        public void Handle(StartChannelMethodCommand request)
        {
            var handler = HandlerInfos.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            if (handler == null)
            {
                throw new HandlerNotFoundException();
            }
            if (handler.State.Equals("started", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var rawHandler = RawHandlers.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            Task.Run(() => { rawHandler.Start(); });
            Thread.Sleep(1000);

            HandlerInfoCollection.UpdateHandlerState(GetType().Name, request.HandlerId, "Running");
        }
コード例 #4
0
 public IEnumerable <HandlerInformation> Handle(ListHandlerByStateQuery request)
 {
     return(HandlerInfos.Where(x => x.State.Equals(request.State, StringComparison.OrdinalIgnoreCase)));
 }
コード例 #5
0
        public List <string> Handle(HandlerHistoryQuery request)
        {
            var handler = HandlerInfos.FirstOrDefault(x => x.HandlerId == request.HandlerId);

            return(handler != null ? handler.History : null);
        }