/// <summary> /// /// </summary> /// <param name="processInstanceExecution"></param> protected internal virtual void HandleProcessInstanceExecution(IExecutionEntity processInstanceExecution) { IExecutionEntityManager executionEntityManager = commandContext.ExecutionEntityManager; string processInstanceId = processInstanceExecution.Id; // No parent execution == process instance id logger.LogDebug($"No parent execution found. Verifying if process instance {processInstanceId} can be stopped."); IExecutionEntity superExecution = processInstanceExecution.SuperExecution; ISubProcessActivityBehavior subProcessActivityBehavior = null; // copy variables before destroying the ended sub process instance (call activity) if (superExecution != null) { FlowNode superExecutionElement = (FlowNode)superExecution.CurrentFlowElement; subProcessActivityBehavior = (ISubProcessActivityBehavior)superExecutionElement.Behavior; try { subProcessActivityBehavior.Completing(superExecution, processInstanceExecution); } //catch (Exception e) //{ // //logger.error("Error while completing sub process of execution {}", processInstanceExecution, e); // throw e; //} catch (Exception e) { logger.LogError($"Error while completing sub process of execution {processInstanceExecution}.Exception Message: {e.Message}"); throw new ActivitiException("Error while completing sub process of execution " + processInstanceExecution, e); } } int activeExecutions = GetNumberOfActiveChildExecutionsForProcessInstance(executionEntityManager, processInstanceId, superExecution); if (activeExecutions == 0) { logger.LogDebug($"No active executions found. Ending process instance {processInstanceId} "); // note the use of execution here vs processinstance execution for getting the flowelement executionEntityManager.DeleteProcessInstanceExecutionEntity(processInstanceId, execution.CurrentFlowElement?.Id, null, false, false); } else { logger.LogDebug($"Active executions found. Process instance {processInstanceId} will not be ended."); } Process process = ProcessDefinitionUtil.GetProcess(processInstanceExecution.ProcessDefinitionId); // Execute execution listeners for process end. if (CollectionUtil.IsNotEmpty(process.ExecutionListeners)) { ExecuteExecutionListeners(process, processInstanceExecution, BaseExecutionListenerFields.EVENTNAME_END); } // and trigger execution afterwards if doing a call activity if (superExecution != null) { superExecution.SubProcessInstance = null; try { subProcessActivityBehavior.Completed(superExecution); } //catch (Exception e) //{ // logger.error("Error while completing sub process of execution {}", processInstanceExecution, e); // throw e; //} catch (Exception e) { logger.LogError($"Error while completing sub process of execution {processInstanceExecution}. Exception Messgae: {e.Message}."); throw new ActivitiException("Error while completing sub process of execution " + processInstanceExecution, e); } } }
public virtual IDictionary <string, IDataObject> Execute(ICommandContext commandContext) { // Verify existance of execution if (executionId is null) { throw new ActivitiIllegalArgumentException("executionId is null"); } IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", typeof(IExecution)); } IDictionary <string, IVariableInstance> variables; if ((dataObjectNames?.Count()).GetValueOrDefault(0) == 0) { // Fetch all if (isLocal) { variables = execution.VariableInstancesLocal; } else { variables = execution.VariableInstances; } } else { // Fetch specific collection of variables if (isLocal) { variables = execution.GetVariableInstancesLocal(dataObjectNames, false); } else { variables = execution.GetVariableInstances(dataObjectNames, false); } } IDictionary <string, IDataObject> dataObjects = null; if (variables != null) { dataObjects = new Dictionary <string, IDataObject>(variables.Count); foreach (KeyValuePair <string, IVariableInstance> entry in variables.SetOfKeyValuePairs()) { string name = entry.Key; IVariableInstance variableEntity = entry.Value; IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(variableEntity.ExecutionId); while (!executionEntity.IsScope) { executionEntity = executionEntity.Parent; } BpmnModel bpmnModel = ProcessDefinitionUtil.GetBpmnModel(execution.ProcessDefinitionId); ValuedDataObject foundDataObject = null; if (executionEntity.ParentId is null) { foreach (ValuedDataObject dataObject in bpmnModel.MainProcess.DataObjects) { if (dataObject.Name.Equals(variableEntity.Name)) { foundDataObject = dataObject; break; } } } else { SubProcess subProcess = (SubProcess)bpmnModel.GetFlowElement(execution.ActivityId); foreach (ValuedDataObject dataObject in subProcess.DataObjects) { if (dataObject.Name.Equals(variableEntity.Name)) { foundDataObject = dataObject; break; } } } string localizedName = null; string localizedDescription = null; if (locale is object && foundDataObject is object) { JToken languageNode = Context.GetLocalizationElementProperties(locale, foundDataObject.Id, execution.ProcessDefinitionId, withLocalizationFallback); if (languageNode != null) { JToken nameNode = languageNode[DynamicBpmnConstants.LOCALIZATION_NAME]; if (nameNode != null) { localizedName = nameNode.ToString(); } JToken descriptionNode = languageNode[DynamicBpmnConstants.LOCALIZATION_DESCRIPTION]; if (descriptionNode != null) { localizedDescription = descriptionNode.ToString(); } } } if (foundDataObject != null) { dataObjects[name] = new DataObjectImpl(variableEntity.Name, variableEntity.Value, foundDataObject.Documentation, foundDataObject.Type, localizedName, localizedDescription, foundDataObject.Id); } } } return(dataObjects); }
public override void Execute(IExecutionEntity execution) { BpmnModel bpmnModel = ProcessDefinitionUtil.GetBpmnModel(execution.ProcessDefinitionId); FlowElement flowElement = execution.CurrentFlowElement; IOSpecification ioSpecification; string operationRef; IList <DataAssociation> dataInputAssociations; IList <DataAssociation> dataOutputAssociations; if (flowElement is SendTask sendTask) { ioSpecification = sendTask.IoSpecification; operationRef = sendTask.OperationRef; dataInputAssociations = sendTask.DataInputAssociations; dataOutputAssociations = sendTask.DataOutputAssociations; } else if (flowElement is ServiceTask serviceTask) { ioSpecification = serviceTask.IoSpecification; operationRef = serviceTask.OperationRef; dataInputAssociations = serviceTask.DataInputAssociations; dataOutputAssociations = serviceTask.DataOutputAssociations; } else { throw new ActivitiException("Unsupported flow element type " + flowElement); } MessageInstance message = null; FillDefinitionMaps(bpmnModel); Webservice.Operation operation = operationMap[operationRef]; try { if (ioSpecification != null) { InitializeIoSpecification(ioSpecification, execution, bpmnModel); if (ioSpecification.DataInputRefs.Count > 0) { string firstDataInputName = ioSpecification.DataInputRefs[0]; ItemInstance inputItem = (ItemInstance)execution.GetVariable(firstDataInputName); message = new MessageInstance(operation.InMessage, inputItem); } } else { message = operation.InMessage.CreateInstance(); } execution.SetVariable(CURRENT_MESSAGE, message); FillMessage(dataInputAssociations, execution); ProcessEngineConfigurationImpl processEngineConfig = Context.ProcessEngineConfiguration; MessageInstance receivedMessage = operation.SendMessage(message, processEngineConfig.WsOverridenEndpointAddresses); execution.SetVariable(CURRENT_MESSAGE, receivedMessage); if (ioSpecification != null && ioSpecification.DataOutputRefs.Count > 0) { string firstDataOutputName = ioSpecification.DataOutputRefs[0]; if (!(firstDataOutputName is null)) { ItemInstance outputItem = (ItemInstance)execution.GetVariable(firstDataOutputName); outputItem.StructureInstance.LoadFrom(receivedMessage.StructureInstance.ToArray()); } } ReturnMessage(dataOutputAssociations, execution); execution.SetVariable(CURRENT_MESSAGE, null); Leave(execution); } catch (Exception exc) { Exception cause = exc; BpmnError error = null; while (cause != null) { if (cause is BpmnError) { error = (BpmnError)cause; break; } cause = cause.InnerException; } if (error != null) { ErrorPropagation.PropagateError(error, execution); } else if (exc is Exception) { throw (Exception)exc; } } }
protected internal static IDictionary <string, IList <Event> > FindCatchingEventsForProcess(string processDefinitionId, string errorCode) { IDictionary <string, IList <Event> > eventMap = new Dictionary <string, IList <Event> >(); Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); BpmnModel bpmnModel = ProcessDefinitionUtil.GetBpmnModel(processDefinitionId); string compareErrorCode = RetrieveErrorCode(bpmnModel, errorCode); IList <EventSubProcess> subProcesses = process.FindFlowElementsOfType <EventSubProcess>(true); foreach (EventSubProcess eventSubProcess in subProcesses) { foreach (FlowElement flowElement in eventSubProcess.FlowElements) { if (flowElement is StartEvent startEvent) { if (CollectionUtil.IsNotEmpty(startEvent.EventDefinitions) && startEvent.EventDefinitions[0] is ErrorEventDefinition) { ErrorEventDefinition errorEventDef = (ErrorEventDefinition)startEvent.EventDefinitions[0]; string eventErrorCode = RetrieveErrorCode(bpmnModel, errorEventDef.ErrorCode); if (eventErrorCode is null || compareErrorCode is null || eventErrorCode.Equals(compareErrorCode)) { IList <Event> startEvents = new List <Event> { startEvent }; eventMap[eventSubProcess.Id] = startEvents; } } } } } IList <BoundaryEvent> boundaryEvents = process.FindFlowElementsOfType <BoundaryEvent>(true); foreach (BoundaryEvent boundaryEvent in boundaryEvents) { if (boundaryEvent.AttachedToRefId is object && CollectionUtil.IsNotEmpty(boundaryEvent.EventDefinitions) && boundaryEvent.EventDefinitions[0] is ErrorEventDefinition) { ErrorEventDefinition errorEventDef = (ErrorEventDefinition)boundaryEvent.EventDefinitions[0]; string eventErrorCode = RetrieveErrorCode(bpmnModel, errorEventDef.ErrorCode); if (eventErrorCode is null || compareErrorCode is null || eventErrorCode.Equals(compareErrorCode)) { IList <Event> elementBoundaryEvents = null; if (!eventMap.ContainsKey(boundaryEvent.AttachedToRefId)) { elementBoundaryEvents = new List <Event>(); eventMap[boundaryEvent.AttachedToRefId] = elementBoundaryEvents; } else { elementBoundaryEvents = eventMap[boundaryEvent.AttachedToRefId]; } elementBoundaryEvents.Add(boundaryEvent); } } } return(eventMap); }
protected internal virtual Process GetProcessDefinition(string processDefinitionId) { // TODO: must be extracted / cache should be accessed in another way return(ProcessDefinitionUtil.GetProcess(processDefinitionId)); }
public virtual object Execute(ICommandContext commandContext) { lock (syncRoot) { ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.ProcessEngineConfiguration; Interceptor.ICommandExecutor commandExecutor = processEngineConfiguration.CommandExecutor; ITaskEntity task = commandExecutor.Execute(new GetTaskByIdCmd(currentTaskId)) as ITaskEntity; if (task is null) { throw new ActivitiObjectNotFoundException(string.Concat("No task found for id '", currentTaskId)); } string currentExecutionId = task.ExecutionId; IExecutionEntity execution = task.Execution; if (execution is null) { throw new ActivitiObjectNotFoundException(string.Concat("No execution found for id '", currentExecutionId)); } var flowElement = ProcessDefinitionUtil.GetFlowElement(execution.ProcessDefinitionId, returnToActivityId); if (flowElement is null) { throw new ActivitiObjectNotFoundException(string.Concat("No execution found for id '", currentExecutionId, "'")); } IHistoricActivityInstanceEntity hisInst = processEngineConfiguration.HistoryService.CreateHistoricActivityInstanceQuery() .SetProcessInstanceId(execution.ProcessInstanceId) .SetActivityId(returnToActivityId) .OrderByHistoricActivityInstanceStartTime() .Desc() .List() .FirstOrDefault() as IHistoricActivityInstanceEntity; IExecutionEntityManager executionEntityManager = commandContext.ExecutionEntityManager; IExecutionEntity returnToExec = executionEntityManager.CreateChildExecution(execution.ProcessInstance); returnToExec.CurrentFlowElement = flowElement; foreach (var key in variables.Keys) { returnToExec.SetVariable(key, variables[key]); } executionEntityManager.Insert(returnToExec); commandContext.Agenda.PlanContinueProcessOperation(returnToExec); IExecutionEntity miRoot = commandExecutor.Execute(new GetMultiInstanceRootExecutionCmd(execution)); List <ITask> tasks = new List <ITask>(); if (miRoot != null) { ITaskQuery query = commandContext.ProcessEngineConfiguration.TaskService.CreateTaskQuery(); IEnumerable <IExecutionEntity> childExecutions = commandExecutor.Execute(new GetChildExecutionsCmd(miRoot)); query.SetExecutionIdIn(childExecutions.Select(x => x.Id).ToArray()); tasks.AddRange(query.List()); } else { tasks.Add(task); } ReturnToTasks(commandContext, commandExecutor, miRoot != null ? miRoot : execution, executionEntityManager, tasks); return(null); } }
protected internal static void ExecuteCatch(IDictionary <string, IList <Event> > eventMap, IExecutionEntity delegateExecution, string errorId) { Event matchingEvent = null; IExecutionEntity currentExecution = delegateExecution; IExecutionEntity parentExecution; if ((eventMap?.ContainsKey(currentExecution.ActivityId)).GetValueOrDefault(false)) { matchingEvent = eventMap[currentExecution.ActivityId][0]; // Check for multi instance if (currentExecution.ParentId is object && currentExecution.Parent.IsMultiInstanceRoot) { parentExecution = currentExecution.Parent; } else { parentExecution = currentExecution; } } else { parentExecution = currentExecution.Parent; // Traverse parents until one is found that is a scope and matches the activity the boundary event is defined on while (matchingEvent == null && parentExecution != null) { IFlowElementsContainer currentContainer = null; if (parentExecution.CurrentFlowElement is IFlowElementsContainer) { currentContainer = (IFlowElementsContainer)parentExecution.CurrentFlowElement; } else if (parentExecution.Id.Equals(parentExecution.ProcessInstanceId)) { currentContainer = ProcessDefinitionUtil.GetProcess(parentExecution.ProcessDefinitionId); } foreach (string refId in eventMap.Keys) { IList <Event> events = eventMap[refId]; if (CollectionUtil.IsNotEmpty(events) && events[0] is StartEvent) { if (currentContainer.FindFlowElement(refId) != null) { matchingEvent = events[0]; } } } if (matchingEvent == null) { if ((eventMap?.ContainsKey(parentExecution.ActivityId)).GetValueOrDefault(false)) { matchingEvent = eventMap[parentExecution.ActivityId][0]; // Check for multi instance if (parentExecution.ParentId is object && parentExecution.Parent.IsMultiInstanceRoot) { parentExecution = parentExecution.Parent; } } else if (!string.IsNullOrWhiteSpace(parentExecution.ParentId)) { parentExecution = parentExecution.Parent; } else { parentExecution = null; } } } } if (matchingEvent != null && parentExecution != null) { ExecuteEventHandler(matchingEvent, parentExecution, currentExecution, errorId); } else { throw new ActivitiException("No matching parent execution for error code " + errorId + " found"); } }
public override void Execute(IExecutionEntity execution) { IExecutionEntity executionEntity = execution; BoundaryEvent boundaryEvent = (BoundaryEvent)execution.CurrentFlowElement; Process process = ProcessDefinitionUtil.GetProcess(execution.ProcessDefinitionId); if (process == null) { throw new ActivitiException("Process model (id = " + execution.Id + ") could not be found"); } Activity compensationActivity = null; IList <Association> associations = process.FindAssociationsWithSourceRefRecursive(boundaryEvent.Id); foreach (Association association in associations) { FlowElement targetElement = process.GetFlowElement(association.TargetRef, true); if (targetElement is Activity activity) { if (activity.ForCompensation) { compensationActivity = activity; break; } } } if (compensationActivity == null) { throw new ActivitiException("Compensation activity could not be found (or it is missing 'isForCompensation=\"true\"'"); } // find SubProcess or Process instance execution IExecutionEntity scopeExecution = null; IExecutionEntity parentExecution = executionEntity.Parent; while (scopeExecution == null && parentExecution != null) { if (parentExecution.CurrentFlowElement is SubProcess) { scopeExecution = parentExecution; } else if (parentExecution.ProcessInstanceType) { scopeExecution = parentExecution; } else { parentExecution = parentExecution.Parent; } } if (scopeExecution == null) { throw new ActivitiException("Could not find a scope execution for compensation boundary event " + boundaryEvent.Id); } Context.CommandContext.EventSubscriptionEntityManager.InsertCompensationEvent(scopeExecution, compensationActivity.Id); //TODO: 观察一下Compenstion execution删除后有无问题 Context.CommandContext.ExecutionEntityManager.Delete(execution); }
public override void Execute(IExecutionEntity execution) { string finalProcessDefinitonKey; if (processDefinitionExpression != null) { finalProcessDefinitonKey = (string)processDefinitionExpression.GetValue(execution); } else { finalProcessDefinitonKey = processDefinitonKey; } IProcessDefinition processDefinition = FindProcessDefinition(finalProcessDefinitonKey, execution.TenantId); // Get model from cache Process subProcess = ProcessDefinitionUtil.GetProcess(processDefinition.Id); if (subProcess == null) { throw new ActivitiException("Cannot start a sub process instance. Process model " + processDefinition.Name + " (id = " + processDefinition.Id + ") could not be found"); } FlowElement initialFlowElement = subProcess.InitialFlowElement; if (initialFlowElement == null) { throw new ActivitiException("No start element found for process definition " + processDefinition.Id); } // Do not start a process instance if the process definition is suspended if (ProcessDefinitionUtil.IsProcessDefinitionSuspended(processDefinition.Id)) { throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.Name + " (id = " + processDefinition.Id + ") is suspended"); } ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration; IExecutionEntityManager executionEntityManager = Context.CommandContext.ExecutionEntityManager; ExpressionManager expressionManager = processEngineConfiguration.ExpressionManager; CallActivity callActivity = (CallActivity)execution.CurrentFlowElement; string businessKey = null; if (!string.IsNullOrWhiteSpace(callActivity.BusinessKey)) { IExpression expression = expressionManager.CreateExpression(callActivity.BusinessKey); businessKey = expression.GetValue(execution).ToString(); } else if (callActivity.InheritBusinessKey) { IExecutionEntity processInstance = executionEntityManager.FindById <IExecutionEntity>(execution.ProcessInstanceId); businessKey = processInstance.BusinessKey; } IExecutionEntity subProcessInstance = Context.CommandContext.ExecutionEntityManager.CreateSubprocessInstance(processDefinition, execution, businessKey); Context.CommandContext.HistoryManager.RecordSubProcessInstanceStart(execution, subProcessInstance, initialFlowElement); // process template-defined data objects IDictionary <string, object> variables = ProcessDataObjects(subProcess.DataObjects); if (callActivity.InheritVariables) { IDictionary <string, object> executionVariables = execution.Variables; foreach (KeyValuePair <string, object> entry in executionVariables.SetOfKeyValuePairs()) { variables[entry.Key] = entry.Value; } } // copy process variables foreach (IOParameter ioParameter in callActivity.InParameters) { object value = null; if (!string.IsNullOrWhiteSpace(ioParameter.SourceExpression)) { IExpression expression = expressionManager.CreateExpression(ioParameter.SourceExpression.Trim()); value = expression.GetValue(execution); } else { value = execution.GetVariable(ioParameter.Source); } variables[ioParameter.Target] = value; } if (variables.Count > 0) { InitializeVariables(subProcessInstance, variables); } // Create the first execution that will visit all the process definition elements IExecutionEntity subProcessInitialExecution = executionEntityManager.CreateChildExecution(subProcessInstance); subProcessInitialExecution.CurrentFlowElement = initialFlowElement; Context.Agenda.PlanContinueProcessOperation(subProcessInitialExecution); Context.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateProcessStartedEvent(subProcessInitialExecution, variables, false)); }
public virtual IDataObject Execute(ICommandContext commandContext) { if (ReferenceEquals(taskId, null)) { throw new ActivitiIllegalArgumentException("taskId is null"); } if (ReferenceEquals(variableName, null)) { throw new ActivitiIllegalArgumentException("variableName is null"); } ITaskEntity task = commandContext.TaskEntityManager.FindById <ITaskEntity>(new KeyValuePair <string, object>("id", taskId)); if (task == null) { throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", typeof(TaskActivity)); } IDataObject dataObject = null; IVariableInstance variableEntity = task.GetVariableInstance(variableName, false); string localizedName = null; string localizedDescription = null; if (variableEntity != null) { IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(variableEntity.ExecutionId); while (!executionEntity.IsScope) { executionEntity = executionEntity.Parent; } BpmnModel bpmnModel = ProcessDefinitionUtil.GetBpmnModel(executionEntity.ProcessDefinitionId); ValuedDataObject foundDataObject = null; if (ReferenceEquals(executionEntity.ParentId, null)) { foreach (ValuedDataObject dataObjectDefinition in bpmnModel.MainProcess.DataObjects) { if (dataObjectDefinition.Name.Equals(variableEntity.Name)) { foundDataObject = dataObjectDefinition; break; } } } else { SubProcess subProcess = (SubProcess)bpmnModel.GetFlowElement(executionEntity.ActivityId); foreach (ValuedDataObject dataObjectDefinition in subProcess.DataObjects) { if (dataObjectDefinition.Name.Equals(variableEntity.Name)) { foundDataObject = dataObjectDefinition; break; } } } if (!ReferenceEquals(locale, null) && foundDataObject != null) { JToken languageNode = Context.GetLocalizationElementProperties(locale, foundDataObject.Id, task.ProcessDefinitionId, withLocalizationFallback); if (languageNode != null) { JToken nameNode = languageNode[DynamicBpmnConstants.LOCALIZATION_NAME]; if (nameNode != null) { localizedName = nameNode.ToString(); } JToken descriptionNode = languageNode[DynamicBpmnConstants.LOCALIZATION_DESCRIPTION]; if (descriptionNode != null) { localizedDescription = descriptionNode.ToString(); } } } if (foundDataObject != null) { dataObject = new DataObjectImpl(variableEntity.Name, variableEntity.Value, foundDataObject.Documentation, foundDataObject.Type, localizedName, localizedDescription, foundDataObject.Id); } } return(dataObject); }
public virtual bool Execute(ICommandContext commandContext) { return(ProcessDefinitionUtil.IsProcessDefinitionSuspended(processDefinitionId)); }
public virtual void HandleEvent(IEventSubscriptionEntity eventSubscription, object payload, ICommandContext commandContext) { string configuration = eventSubscription.Configuration; if (configuration is null) { throw new ActivitiException("Compensating execution not set for compensate event subscription with id " + eventSubscription.Id); } IExecutionEntity compensatingExecution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(configuration); string processDefinitionId = compensatingExecution.ProcessDefinitionId; Process process = ProcessDefinitionUtil.GetProcess(processDefinitionId); if (process == null) { throw new ActivitiException("Cannot start process instance. Process model (id = " + processDefinitionId + ") could not be found"); } IExecutionEntity scopeExecution = null; IExecutionEntity parentExecution = compensatingExecution.Parent; while (scopeExecution == null && parentExecution != null) { if (parentExecution.CurrentFlowElement is SubProcess) { scopeExecution = parentExecution; } else if (parentExecution.ProcessInstanceType) { scopeExecution = parentExecution; } else { parentExecution = parentExecution.Parent; } } FlowElement flowElement = process.GetFlowElement(eventSubscription.ActivityId, true); if (flowElement is SubProcess && !((SubProcess)flowElement).ForCompensation) { // descend into scope: compensatingExecution.IsScope = true; IList <ICompensateEventSubscriptionEntity> eventsForThisScope = commandContext.EventSubscriptionEntityManager.FindCompensateEventSubscriptionsByExecutionId(compensatingExecution.Id); ScopeUtil.ThrowCompensationEvent(eventsForThisScope, compensatingExecution, false); } else { try { //if (flowElement is UserTask) //{ // var userexecution = commandContext.ExecutionEntityManager.CreateChildExecution(scopeExecution); // userexecution.CurrentFlowElement = flowElement; // commandContext.ExecutionEntityManager.Delete(compensatingExecution); // Context.Agenda.PlanContinueProcessInCompensation(userexecution); //} //else //{ if (commandContext.ProcessEngineConfiguration.EventDispatcher.Enabled) { commandContext.ProcessEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateActivityEvent(ActivitiEventType.ACTIVITY_COMPENSATE, flowElement.Id, flowElement.Name, compensatingExecution.Id, compensatingExecution.ProcessInstanceId, compensatingExecution.ProcessDefinitionId, flowElement)); } compensatingExecution.CurrentFlowElement = flowElement; Context.Agenda.PlanContinueProcessInCompensation(compensatingExecution); //} } catch (Exception e) { throw new ActivitiException("Error while handling compensation event " + eventSubscription, e); } } }
protected internal override Process GetProcessDefinition(string processDefinitionId) { return(ProcessDefinitionUtil.GetProcess(processDefinitionId)); }
/// <summary> /// /// </summary> protected internal virtual void ExecuteProcessStartExecutionListeners() { Process process = ProcessDefinitionUtil.GetProcess(execution.ProcessDefinitionId); ExecuteExecutionListeners(process, execution.Parent, BaseExecutionListenerFields.EVENTNAME_START); }