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"); }
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"); }
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"); }
public IEnumerable <HandlerInformation> Handle(ListHandlerByStateQuery request) { return(HandlerInfos.Where(x => x.State.Equals(request.State, StringComparison.OrdinalIgnoreCase))); }
public List <string> Handle(HandlerHistoryQuery request) { var handler = HandlerInfos.FirstOrDefault(x => x.HandlerId == request.HandlerId); return(handler != null ? handler.History : null); }