Exemplo n.º 1
0
        public async Task CreateWorkflowActionsAsync(ICommandCQRS command, ICollection <IWorkflowAction> workflowActions)
        {
            string subscriptionName;
            IWorkflowActionExecutor aggregatorExecutor = _workflowActionExecutors.Single(x => x.Key == typeof(WorkflowActionAggregationExecutor)).Value;

            foreach (IWorkflowAction workflowAction in workflowActions)
            {
                foreach (IWorkflowActionExecutor workflowExecutor in _workflowActionExecutors.Where(x => workflowAction.GetType() == x.Key).Select(s => s.Value))
                {
                    if (workflowAction.WorkflowActions != null && workflowAction.WorkflowActions.Count > 0)
                    {
                        subscriptionName = $"{workflowAction.WorkflowActions.Count}_{workflowAction.UniqueId}";
                        await _serviceBusClient.CreateSubscriptionAsync(ServiceBusClient.WorkflowAggregationTopicName, subscriptionName,
                                                                        string.Format(ServiceBusClient.SERVICE_BUS_CORRELATIONID_FILTER, workflowAction.UniqueId), true);

                        await aggregatorExecutor.CreateActionEventAsync(command, workflowAction);
                        await CreateWorkflowActionsAsync(command, workflowAction.WorkflowActions);

                        continue;
                    }
                    await workflowExecutor.CreateActionEventAsync(command, workflowAction);
                }
            }
        }