public async Task <bool> Handle(LaunchCaseInstanceCommand launchCaseInstanceCommand, CancellationToken token)
        {
            var caseInstance = await _casePlanInstanceCommandRepository.Get(launchCaseInstanceCommand.CasePlanInstanceId, token);

            if (caseInstance == null || string.IsNullOrWhiteSpace(caseInstance.AggregateId))
            {
                throw new UnknownCasePlanInstanceException(launchCaseInstanceCommand.CasePlanInstanceId);
            }

            await _casePlanInstanceProcessor.Execute(caseInstance, token);

            await _casePlanInstanceCommandRepository.Update(caseInstance, token);

            await _casePlanInstanceCommandRepository.SaveChanges(token);

            return(true);
        }
예제 #2
0
        public async Task <bool> Execute(string casePlanInstanceId, string casePlanElementInstanceId, Dictionary <string, string> parameters, CancellationToken token)
        {
            var casePlanInstance = await _casePlanInstanceCommandRepository.Get(casePlanInstanceId, token);

            if (casePlanInstance == null)
            {
                throw new UnknownCasePlanInstanceException(casePlanInstanceId);
            }

            if (!string.IsNullOrWhiteSpace(casePlanElementInstanceId))
            {
                var elt = casePlanInstance.GetChild(casePlanElementInstanceId);
                if (elt == null)
                {
                    throw new UnknownCasePlanElementInstanceException(casePlanInstanceId, casePlanElementInstanceId);
                }
            }

            var subscriber = await _subscriberRepository.Get(casePlanInstanceId, casePlanElementInstanceId, EvtName, token);

            if (subscriber == null)
            {
                throw new InvalidOperationException("subscriber doesn't exist");
            }

            subscriber.IsCaptured = true;
            subscriber.Parameters = parameters;
            await _subscriberRepository.Update(subscriber, token);

            await _casePlanInstanceProcessor.Execute(casePlanInstance, token);

            await _casePlanInstanceCommandRepository.Update(casePlanInstance, token);

            await _casePlanInstanceCommandRepository.SaveChanges(token);

            return(true);
        }