public override void Execute(IExecutionEntity execution) { ICommandContext commandContext = Context.CommandContext; string eventSubscriptionName; if (messageEventName is object) { eventSubscriptionName = messageEventName; } else { IExpression expressionObject = commandContext.ProcessEngineConfiguration.ExpressionManager.CreateExpression(messageExpression); eventSubscriptionName = expressionObject.GetValue(execution).ToString(); } IEventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.EventSubscriptionEntityManager; IList <IMessageEventSubscriptionEntity> subscriptionEntities = eventSubscriptionEntityManager.FindMessageEventSubscriptionsByProcessInstanceAndEventName(execution.ProcessInstanceId, eventSubscriptionName); foreach (IMessageEventSubscriptionEntity messageEventSubscriptionEntity in subscriptionEntities) { Context.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateMessageEvent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEventSubscriptionEntity.ActivityId, eventSubscriptionName, null, messageEventSubscriptionEntity.ExecutionId, messageEventSubscriptionEntity.ProcessInstanceId, messageEventSubscriptionEntity.ProcessDefinitionId)); eventSubscriptionEntityManager.EventReceived(messageEventSubscriptionEntity, null, false); } Context.Agenda.PlanTakeOutgoingSequenceFlowsOperation(execution, true); }
public override void OnEvent(IActivitiEvent @event) { if (IsValidEvent(@event)) { if (@event.ProcessInstanceId is null && processInstanceScope) { throw new ActivitiIllegalArgumentException("Cannot throw process-instance scoped signal, since the dispatched event is not part of an ongoing process instance"); } ICommandContext commandContext = Context.CommandContext; IEventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.EventSubscriptionEntityManager; IList <ISignalEventSubscriptionEntity> subscriptionEntities; if (processInstanceScope) { subscriptionEntities = eventSubscriptionEntityManager.FindSignalEventSubscriptionsByProcessInstanceAndEventName(@event.ProcessInstanceId, signalName); } else { string tenantId = null; if (!(@event.ProcessDefinitionId is null)) { IProcessDefinition processDefinition = commandContext.ProcessEngineConfiguration.DeploymentManager.FindDeployedProcessDefinitionById(@event.ProcessDefinitionId); tenantId = processDefinition.TenantId; } subscriptionEntities = eventSubscriptionEntityManager.FindSignalEventSubscriptionsByEventName(signalName, tenantId); } foreach (ISignalEventSubscriptionEntity signalEventSubscriptionEntity in subscriptionEntities) { eventSubscriptionEntityManager.EventReceived(signalEventSubscriptionEntity, null, false); } } }
public virtual void Execute(IJobEntity job, string configuration, IExecutionEntity execution, ICommandContext commandContext) { IEventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.EventSubscriptionEntityManager; // lookup subscription: IEventSubscriptionEntity eventSubscriptionEntity = eventSubscriptionEntityManager.FindById <IEventSubscriptionEntity>(new KeyValuePair <string, object>("id", configuration)); // if event subscription is null, ignore if (eventSubscriptionEntity != null) { eventSubscriptionEntityManager.EventReceived(eventSubscriptionEntity, null, false); } }
public virtual object Execute(ICommandContext commandContext) { IEventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.EventSubscriptionEntityManager; IList <ISignalEventSubscriptionEntity> signalEvents; if (executionId is null) { signalEvents = eventSubscriptionEntityManager.FindSignalEventSubscriptionsByEventName(eventName, tenantId); } else { IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("Cannot find execution with id '" + executionId + "'", typeof(IExecution)); } if (execution.Suspended) { throw new ActivitiException("Cannot throw signal event '" + eventName + "' because execution '" + executionId + "' is suspended"); } signalEvents = eventSubscriptionEntityManager.FindSignalEventSubscriptionsByNameAndExecution(eventName, executionId); if (signalEvents.Count == 0) { throw new ActivitiException("Execution '" + executionId + "' has not subscribed to a signal event with name '" + eventName + "'."); } } foreach (ISignalEventSubscriptionEntity signalEventSubscriptionEntity in signalEvents) { // We only throw the event to globally scoped signals. // Process instance scoped signals must be thrown within the process itself if (signalEventSubscriptionEntity.GlobalScoped) { Context.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateSignalEvent(ActivitiEventType.ACTIVITY_SIGNALED, signalEventSubscriptionEntity.ActivityId, eventName, payload, signalEventSubscriptionEntity.ExecutionId, signalEventSubscriptionEntity.ProcessInstanceId, signalEventSubscriptionEntity.ProcessDefinitionId)); eventSubscriptionEntityManager.EventReceived(signalEventSubscriptionEntity, payload, async); } } return(null); }
public override void OnEvent(IActivitiEvent @event) { if (IsValidEvent(@event)) { if (@event.ProcessInstanceId is null) { throw new ActivitiIllegalArgumentException("Cannot throw process-instance scoped message, since the dispatched event is not part of an ongoing process instance"); } IEventSubscriptionEntityManager eventSubscriptionEntityManager = Context.CommandContext.EventSubscriptionEntityManager; IList <IMessageEventSubscriptionEntity> subscriptionEntities = eventSubscriptionEntityManager.FindMessageEventSubscriptionsByProcessInstanceAndEventName(@event.ProcessInstanceId, messageName); foreach (IEventSubscriptionEntity messageEventSubscriptionEntity in subscriptionEntities) { eventSubscriptionEntityManager.EventReceived(messageEventSubscriptionEntity, null, false); } } }
protected internal override object Execute(ICommandContext commandContext, IExecutionEntity execution) { if (messageName is null) { throw new ActivitiIllegalArgumentException("messageName cannot be null"); } IEventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.EventSubscriptionEntityManager; IList <IEventSubscriptionEntity> eventSubscriptions = eventSubscriptionEntityManager.FindEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, executionId); if (eventSubscriptions.Count == 0) { throw new ActivitiException("Execution with id '" + executionId + "' does not have a subscription to a message event with name '" + messageName + "'"); } // there can be only one: IEventSubscriptionEntity eventSubscriptionEntity = eventSubscriptions[0]; eventSubscriptionEntityManager.EventReceived(eventSubscriptionEntity, payload, async); return(null); }
public override void Execute(IExecutionEntity execution) { ICommandContext commandContext = Context.CommandContext; string eventSubscriptionName; if (signalEventName is object) { eventSubscriptionName = signalEventName; } else { IExpression expressionObject = commandContext.ProcessEngineConfiguration.ExpressionManager.CreateExpression(signalExpression); eventSubscriptionName = expressionObject.GetValue(execution).ToString(); } IEventSubscriptionEntityManager eventSubscriptionEntityManager = commandContext.EventSubscriptionEntityManager; IList <ISignalEventSubscriptionEntity> subscriptionEntities; if (processInstanceScope) { subscriptionEntities = eventSubscriptionEntityManager.FindSignalEventSubscriptionsByProcessInstanceAndEventName(execution.ProcessInstanceId, eventSubscriptionName); } else { subscriptionEntities = eventSubscriptionEntityManager.FindSignalEventSubscriptionsByEventName(eventSubscriptionName, execution.TenantId); } foreach (ISignalEventSubscriptionEntity signalEventSubscriptionEntity in subscriptionEntities) { Context.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateSignalEvent(ActivitiEventType.ACTIVITY_SIGNALED, signalEventSubscriptionEntity.ActivityId, eventSubscriptionName, null, signalEventSubscriptionEntity.ExecutionId, signalEventSubscriptionEntity.ProcessInstanceId, signalEventSubscriptionEntity.ProcessDefinitionId)); eventSubscriptionEntityManager.EventReceived(signalEventSubscriptionEntity, null, signalEventDefinition.Async); } Context.Agenda.PlanTakeOutgoingSequenceFlowsOperation(execution, true); }