コード例 #1
0
        protected internal static void ExecuteEventHandler(Event @event, IExecutionEntity parentExecution, IExecutionEntity currentExecution, string errorId)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            if (processEngineConfiguration is object && processEngineConfiguration.EventDispatcher.Enabled)
            {
                BpmnModel bpmnModel = ProcessDefinitionUtil.GetBpmnModel(parentExecution.ProcessDefinitionId);
                if (bpmnModel != null)
                {
                    bpmnModel.Errors.TryGetValue(errorId, out string errorCode);
                    if (errorCode is null)
                    {
                        errorCode = errorId;
                    }

                    processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateErrorEvent(ActivitiEventType.ACTIVITY_ERROR_RECEIVED, @event.Id, errorId, errorCode, parentExecution.Id, parentExecution.ProcessInstanceId, parentExecution.ProcessDefinitionId));
                }
            }

            if (@event is StartEvent)
            {
                IExecutionEntityManager executionEntityManager = Context.CommandContext.ExecutionEntityManager;

                if (!currentExecution.ParentId.Equals(parentExecution.Id))
                {
                    Context.Agenda.PlanDestroyScopeOperation(currentExecution);
                }
                else
                {
                    executionEntityManager.DeleteExecutionAndRelatedData(currentExecution, null, false);
                }

                IExecutionEntity eventSubProcessExecution = executionEntityManager.CreateChildExecution(parentExecution);
                eventSubProcessExecution.CurrentFlowElement = @event;
                Context.Agenda.PlanContinueProcessOperation(eventSubProcessExecution);
            }
            else
            {
                IExecutionEntity         boundaryExecution = null;
                IList <IExecutionEntity> childExecutions   = parentExecution.Executions;
                foreach (IExecutionEntity childExecution in childExecutions)
                {
                    if (childExecution.ActivityId.Equals(@event.Id))
                    {
                        boundaryExecution = childExecution;
                    }
                }

                Context.Agenda.PlanTriggerExecutionOperation(boundaryExecution);
            }
        }