Exemplo n.º 1
0
        private async Task <TResult> CallTerminalActivityAsync <TResult>(
            IUnitOfWork uow,
            string activityName,
            IEnumerable <KeyValuePair <string, string> > parameters,
            ActivityDO curActivityDO,
            Guid containerId,
            string curDocumentationSupport = null)
        {
            if (activityName == null)
            {
                throw new ArgumentNullException("activityName");
            }
            if (curActivityDO == null)
            {
                throw new ArgumentNullException("curActivityDO");
            }

            var dto = Mapper.Map <ActivityDO, ActivityDTO>(curActivityDO);

            var fr8DataDTO = new Fr8DataDTO
            {
                ContainerId = containerId,
                ActivityDTO = dto
            };

            if (curDocumentationSupport != null)
            {
                dto.Documentation = curDocumentationSupport;
            }

            _authorizationToken.PrepareAuthToken(uow, dto);

            EventManager.ActionDispatched(curActivityDO, containerId);

            if (containerId != Guid.Empty)
            {
                var containerDO = uow.ContainerRepository.GetByKey(containerId);
                EventManager.ContainerSent(containerDO, curActivityDO);

                var response = ObjectFactory.GetInstance <ITerminalTransmitter>().CallActivityAsync <TResult>(activityName, parameters, fr8DataDTO, containerId.ToString());

                EventManager.ContainerReceived(containerDO, curActivityDO);
                return(await response);
            }

            return(await ObjectFactory.GetInstance <ITerminalTransmitter>().CallActivityAsync <TResult>(activityName, parameters, fr8DataDTO, containerId.ToString()));
        }