public virtual IList Execute(CommandContext commandContext) { EnsureUtil.EnsureNotNull("deploymentId", DeploymentId); foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers) { checker.CheckReadDeployment(DeploymentId); } return(ListExt.ConvertToIlist(context.Impl.Context.CommandContext.ResourceManager.FindResourcesByDeploymentId(DeploymentId))); }
public virtual IProcessInstanceWithVariables Execute(CommandContext commandContext) { var processDefinition = new GetDeployedProcessDefinitionCmd(InstantiationBuilder, false).Execute(commandContext); foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers) { checker.CheckCreateProcessInstance(processDefinition); } var modificationBuilder = InstantiationBuilder.ModificationBuilder; EnsureUtil.EnsureNotEmpty( @"At least one instantiation instruction required (e.g. by invoking startBefore(..), startAfter(..) or startTransition(..))", "instructions", ListExt.ConvertToIlist(modificationBuilder.ModificationOperations)); // instantiate the process var initialActivity = DetermineFirstActivity(processDefinition, modificationBuilder); ExecutionEntity processInstance = (ExecutionEntity)processDefinition.CreateProcessInstance(InstantiationBuilder.BusinessKey, InstantiationBuilder.CaseInstanceId, initialActivity); processInstance.SkipCustomListeners = modificationBuilder.SkipCustomListeners; var variables = modificationBuilder.ProcessVariables; ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance); processInstance.StartWithoutExecuting(variables); // prevent ending of the process instance between instructions processInstance.PreserveScope = true; // apply modifications var instructions = modificationBuilder.ModificationOperations; for (var i = 0; i < instructions.Count; i++) { var instruction = instructions[i]; Log.DebugStartingInstruction(processInstance.Id, i, instruction.Describe()); instruction.ProcessInstanceId = processInstance.Id; instruction.SkipCustomListeners = modificationBuilder.SkipCustomListeners; instruction.SkipIoMappings = modificationBuilder.SkipIoMappings; instruction.Execute(commandContext); } if (!processInstance.HasChildren() && processInstance.IsEnded) { // process instance has ended regularly but this has not been propagated yet // due to preserveScope setting processInstance.PropagateEnd(); } return(new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.Variables)); }
public virtual object Execute(CommandContext commandContext) { EnsureUtil.EnsureNotNull("executionId", ExecutionId); var eventSubscriptionManager = commandContext.EventSubscriptionManager; IList <EventSubscriptionEntity> eventSubscriptions = null; if (!string.ReferenceEquals(MessageName, null)) { eventSubscriptions = eventSubscriptionManager.FindEventSubscriptionsByNameAndExecution(EventType.Message.Name, MessageName, ExecutionId, Exclusive); } else { eventSubscriptions = eventSubscriptionManager.FindEventSubscriptionsByExecutionAndType(ExecutionId, EventType.Message.Name, Exclusive); } EnsureUtil.EnsureNotEmpty("Execution with id '" + ExecutionId + "' does not have a subscription to a message event with name '" + MessageName + "'", "eventSubscriptions", ListExt.ConvertToIlist(eventSubscriptions)); EnsureUtil.EnsureNumberOfElements("More than one matching message subscription found for execution " + ExecutionId, "eventSubscriptions", ListExt.ConvertToIlist(eventSubscriptions), 1); // there can be only one: var eventSubscriptionEntity = eventSubscriptions[0]; // check authorization var processInstanceId = eventSubscriptionEntity.ProcessInstanceId; foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers) { checker.CheckUpdateProcessInstanceById(processInstanceId); } eventSubscriptionEntity.EventReceived(ProcessVariables, false); return(null); }
protected internal virtual void SendSignalToExecution(CommandContext commandContext, string signalName, string executionId) { IExecutionManager executionManager = commandContext.ExecutionManager; ExecutionEntity execution = executionManager.FindExecutionById(executionId); EnsureUtil.EnsureNotNull("Cannot find execution with id '" + executionId + "'", "execution", execution); IEventSubscriptionManager eventSubscriptionManager = commandContext.EventSubscriptionManager; IList <EventSubscriptionEntity> signalEvents = eventSubscriptionManager.FindSignalEventSubscriptionsByNameAndExecution(signalName, executionId); EnsureUtil.EnsureNotEmpty("Execution '" + executionId + "' has not subscribed to a signal event with name '" + signalName + "'.", ListExt.ConvertToIlist(signalEvents)); CheckAuthorizationOfCatchSignals(commandContext, signalEvents); NotifyExecutions(signalEvents); }