Beispiel #1
0
        private void OnRecoveryRequest(RecoveryRequest request)
        {
            var pendingRequests = _requirements.RequestPersistence.GetPendingRequests();

            foreach (IActionRequest pendingRequest in pendingRequests)
            {
                if (pendingRequest is IRequestWithContext)
                {
                    var contextRequest = pendingRequest as IRequestWithContext;
                    var user           = new ActionProcessorUser(_requirements.Authorisation, _requirements.Authorisation?.SystemUserName);
                    var context        = new ActionRequestContext(user, Self, pendingRequest as IActionRequest, null, null);

                    contextRequest.InitialiseContext(context);
                }

                Self.Tell(pendingRequest.FlagForRecovery());
            }
        }
Beispiel #2
0
        public Task <IResponse> ProcessAction <TRequest>(TRequest request, string userName = null)
            where TRequest : class, IRequestWithContext
        {
            if (State != ActionProcessorState.Started)
            {
                throw new ActionProcessorException("ProcessAction requests cannot be submitted before the processor has been started");
            }

            var user             = new ActionProcessorUser(_requirements.Authorisation, userName);
            var completionSource = new TaskCompletionSource <IResponse>();
            var context          = new ActionRequestContext(user, _actionProcessorManager, request as IActionRequest, null, completionSource);

            request.InitialiseContext(context);

            _actionProcessorManager.Tell(request);

            return(completionSource.Task);
        }