Exemplo n.º 1
0
        public override IEvent BuildEvent(ICommandCQRS command, WorkflowActionShareDocumentUnitModel workflowAction)
        {
            DocumentUnitModel documentUnitModel = workflowAction.GetReferenced();
            DocumentUnit      documentUnit      = _webAPIClient.GetDocumentUnitAsync(new DocumentUnit(documentUnitModel.UniqueId)).Result;

            documentUnit.WorkflowName       = workflowAction.WorkflowName;
            documentUnit.IdWorkflowActivity = workflowAction.IdWorkflowActivity;

            EventShareDocumentUnit @event = new EventShareDocumentUnit(Guid.NewGuid(), workflowAction.CorrelationId, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity, documentUnit, null);

            return(@event);
        }
Exemplo n.º 2
0
        public IEvent CreateEvent(ICommandCQRS command, bool isUpdate, DocumentUnit documentUnit = null)
        {
            IEvent evt = null;

            if (!isUpdate)
            {
                ICommandCQRSCreate cQRSCreate = (ICommandCQRSCreate)command;
                evt = CreateInsertEvent(cQRSCreate, documentUnit);
            }
            if (isUpdate)
            {
                ICommandCQRSUpdate cQRSUpdate = (ICommandCQRSUpdate)command;
                evt = CreateUpdateEvent(cQRSUpdate, documentUnit);
            }
            return(evt);
        }
Exemplo n.º 3
0
        public override IEvent BuildEvent(ICommandCQRS command, WorkflowActionModel workflowAction)
        {
            IEvent @event = null;

            foreach (IWorkflowActionExecutor workflowExecutor in _workflowExecutorsFunc().Where(x => workflowAction.GetType() == x.Key).Select(s => s.Value))
            {
                @event = workflowExecutor.BuildEvent(command, workflowAction);
                if (workflowAction.CorrelationId != Guid.Empty)
                {
                    @event.ReplyTo = ServiceBus.ServiceBusClient.WorkflowAggregationTopicName;
                }
            }
            EventWorkflowActionAggregation aggregationEvent = new EventWorkflowActionAggregation(Guid.NewGuid(), workflowAction.UniqueId, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity, workflowAction, null);

            aggregationEvent.CorrelatedMessages.Add(@event);
            return(aggregationEvent);
        }
        public async Task CreateActionEventAsync(ICommandCQRS command, TWFAction workflowAction)
        {
            try
            {
                IEvent @event = BuildEvent(command, workflowAction);
                if (workflowAction.CorrelationId != Guid.Empty)
                {
                    @event.ReplyTo = ServiceBus.ServiceBusClient.WorkflowAggregationTopicName;
                }
                _logger.WriteInfo(new LogMessage(string.Concat("CreateActionEventAsync -> create action event ", @event.GetType(), " for command ", command.Name)), LogCategories);
                bool res = await _webAPIClient.PushEventAsync(@event);

                if (!res)
                {
                    _logger.WriteError(new LogMessage(string.Concat("CreateActionEventAsync -> error in sending event ", @event.GetType(), " to WebAPI")), LogCategories);
                }
            }
            catch (Exception ex)
            {
                _logger.WriteError(new LogMessage(string.Concat("CreateActionEventAsync -> error on creating workflow event for model ", workflowAction.GetType(), ". Command: ", command.Name)), ex, LogCategories);
            }
        }
Exemplo n.º 5
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);
                }
            }
        }
 async Task IWorkflowActionExecutor.CreateActionEventAsync(ICommandCQRS command, IWorkflowAction workflowAction)
 {
     await CreateActionEventAsync(command, (TWFAction)workflowAction);
 }
 public abstract IEvent BuildEvent(ICommandCQRS command, TWFAction workflowAction);
 IEvent IWorkflowActionExecutor.BuildEvent(ICommandCQRS command, IWorkflowAction workflowAction)
 {
     return(BuildEvent(command, (TWFAction)workflowAction));
 }
        public override IEvent BuildEvent(ICommandCQRS command, WorkflowActionDocumentUnitLinkModel workflowAction)
        {
            EventWorkflowActionDocumentUnitLink @event = new EventWorkflowActionDocumentUnitLink(Guid.NewGuid(), workflowAction.CorrelationId, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity, workflowAction, null);

            return(@event);
        }
        public override IEvent BuildEvent(ICommandCQRS command, WorkflowActionFascicleCloseModel workflowAction)
        {
            EventWorkflowActionFascicleClose @event = new EventWorkflowActionFascicleClose(Guid.NewGuid(), workflowAction.CorrelationId, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity, workflowAction, null);

            return(@event);
        }