Example #1
0
        public override void OnEvent(IActivitiEvent @event)
        {
            if (IsValidEvent(@event))
            {
                var commandContext = Context.CommandContext;

                IExecutionEntity execution = null;
                if (@event.ExecutionId is object)
                {
                    // Get the execution based on the event's execution ID instead
                    execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(@event.ExecutionId);
                }

                if (execution is null)
                {
                    throw new ActivitiException("No execution context active and event is not related to an execution. No compensation event can be thrown.");
                }

                try
                {
                    ErrorPropagation.PropagateError(errorCode, execution);
                }
                catch (Exception e)
                {
                    throw new ActivitiException("Error while propagating error-event", e);
                }
            }
        }
        public override void OnEvent(IActivitiEvent @event)
        {
            if (IsValidEvent(@event))
            {
                //仅是为了执行一次退栈操作
                _ = Context.CommandContext;

                IExecutionEntity execution = null;

                if (@event.ExecutionId is object)
                {
                    // Get the execution based on the event's execution ID instead execution = Context.CommandContext.ExecutionEntityManager.findById<instead>(new KeyValuePair<string, object>("id", @event.ExecutionId));
                }

                if (execution == null)
                {
                    throw new ActivitiException("No execution context active and event is not related to an execution. No compensation event can be thrown.");
                }

                try
                {
                    ErrorPropagation.PropagateError(errorCode, execution);
                }
                catch (Exception e)
                {
                    throw new ActivitiException("Error while propagating error-event", e);
                }
            }
        }
Example #3
0
        // Activity Behavior
        public override void Execute(IExecutionEntity execution)
        {
            bool isSkipExpressionEnabled = SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpression);

            if (!isSkipExpressionEnabled || (isSkipExpressionEnabled && !SkipExpressionUtil.ShouldSkipFlowElement(execution, skipExpression)))
            {
                if (Context.ProcessEngineConfiguration.EnableProcessDefinitionInfoCache)
                {
                    JToken taskElementProperties = Context.GetBpmnOverrideElementProperties(serviceTaskId, execution.ProcessDefinitionId);
                    if (taskElementProperties != null && taskElementProperties[DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME] != null)
                    {
                        string overrideClassName = taskElementProperties[DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME].ToString();
                        if (!string.IsNullOrWhiteSpace(overrideClassName) && !overrideClassName.Equals(className))
                        {
                            className = overrideClassName;
                            activityBehaviorInstance = null;
                        }
                    }
                }

                if (activityBehaviorInstance == null)
                {
                    activityBehaviorInstance = ActivityBehaviorInstance;
                }

                try
                {
                    activityBehaviorInstance.Execute(execution);
                }
                catch (BpmnError error)
                {
                    ErrorPropagation.PropagateError(error, execution);
                }
                catch (Exception e)
                {
                    if (!ErrorPropagation.MapException(e, execution, mapExceptions))
                    {
                        throw e;
                    }
                }
            }
        }