public virtual IExecution Execute(ICommandContext commandContext) { IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("No execution found for id '" + executionId + "'", typeof(IExecutionEntity)); } if (!(execution.CurrentFlowElement is AdhocSubProcess)) { throw new ActivitiException("The current flow element of the requested execution is not an ad-hoc sub process"); } FlowNode foundNode = null; AdhocSubProcess adhocSubProcess = (AdhocSubProcess)execution.CurrentFlowElement; // if sequential ordering, only one child execution can be active if (adhocSubProcess.HasSequentialOrdering()) { if (execution.Executions.Count > 0) { throw new ActivitiException("Sequential ad-hoc sub process already has an active execution"); } } foreach (FlowElement flowElement in adhocSubProcess.FlowElements) { if (activityId.Equals(flowElement.Id) && flowElement is FlowNode) { FlowNode flowNode = (FlowNode)flowElement; if (flowNode.IncomingFlows.Count == 0) { foundNode = flowNode; } } } IExecutionEntity activityExecution = Context.CommandContext.ExecutionEntityManager.CreateChildExecution(execution); activityExecution.CurrentFlowElement = foundNode ?? throw new ActivitiException("The requested activity with id " + activityId + " can not be enabled"); Context.Agenda.PlanContinueProcessOperation(activityExecution); return(activityExecution); }
public virtual IList <FlowNode> Execute(ICommandContext commandContext) { IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("No execution found for id '" + executionId + "'", typeof(IExecutionEntity)); } if (!(execution.CurrentFlowElement is AdhocSubProcess)) { throw new ActivitiException("The current flow element of the requested execution is not an ad-hoc sub process"); } IList <FlowNode> enabledFlowNodes = new List <FlowNode>(); AdhocSubProcess adhocSubProcess = (AdhocSubProcess)execution.CurrentFlowElement; // if sequential ordering, only one child execution can be active, so no enabled activities if (adhocSubProcess.HasSequentialOrdering()) { if (execution.Executions.Count > 0) { return(enabledFlowNodes); } } foreach (FlowElement flowElement in adhocSubProcess.FlowElements) { if (flowElement is FlowNode flowNode) { if (flowNode.IncomingFlows.Count == 0) { enabledFlowNodes.Add(flowNode); } } } return(enabledFlowNodes); }