public override void Trigger(IExecutionEntity execution, string signalName, object signalData, bool throwError = true)
        {
            object @delegate = DelegateExpressionUtil.ResolveDelegateExpression(expression, execution, fieldDeclarations);

            if (@delegate is ITriggerableActivityBehavior)
            {
                ((ITriggerableActivityBehavior)@delegate).Trigger(execution, signalName, signalData);
            }
        }
示例#2
0
        public virtual void Notify(IExecutionEntity execution)
        {
            object @delegate = DelegateExpressionUtil.ResolveDelegateExpression(expression, execution, fieldDeclarations);

            if (@delegate is IExecutionListener)
            {
                Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(new ExecutionListenerInvocation((IExecutionListener)@delegate, execution));
            }
            else if (@delegate is ICSharpDelegate)
            {
                Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(new CSharpDelegateInvocation((ICSharpDelegate)@delegate, execution));
            }
            else
            {
                throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + typeof(IExecutionListener) + " nor " + typeof(ICSharpDelegate));
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="delegateTask"></param>
        public virtual void Notify(IDelegateTask delegateTask)
        {
            object @delegate = DelegateExpressionUtil.ResolveDelegateExpression(expression, delegateTask, fieldDeclarations);

            if (@delegate is ITaskListener listener)
            {
                try
                {
                    Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(new TaskListenerInvocation(listener, delegateTask));
                }
                catch (Exception e)
                {
                    throw new ActivitiException("Exception while invoking TaskListener: " + e.Message, e);
                }
            }
            else
            {
                throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + typeof(ITaskListener));
            }
        }
        public override void Execute(IExecutionEntity execution)
        {
            try
            {
                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_DELEGATE_EXPRESSION] != null)
                        {
                            string overrideExpression = taskElementProperties[DynamicBpmnConstants.SERVICE_TASK_DELEGATE_EXPRESSION].ToString();
                            if (!string.IsNullOrWhiteSpace(overrideExpression) && !overrideExpression.Equals(expression.ExpressionText))
                            {
                                expression = Context.ProcessEngineConfiguration.ExpressionManager.CreateExpression(overrideExpression);
                            }
                        }
                    }

                    object @delegate = DelegateExpressionUtil.ResolveDelegateExpression(expression, execution, fieldDeclarations);
                    if (@delegate is IActivityBehavior)
                    {
                        if (@delegate is AbstractBpmnActivityBehavior)
                        {
                            ((AbstractBpmnActivityBehavior)@delegate).MultiInstanceActivityBehavior = MultiInstanceActivityBehavior;
                        }

                        Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(new ActivityBehaviorInvocation((IActivityBehavior)@delegate, execution));
                    }
                    else if (@delegate is ICSharpDelegate)
                    {
                        Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(new CSharpDelegateInvocation((ICSharpDelegate)@delegate, execution));
                        Leave(execution);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did neither resolve to an implementation of " + typeof(IActivityBehavior) + " nor " + typeof(ICSharpDelegate));
                    }
                }
                else
                {
                    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
                {
                    throw new ActivitiException(exc.Message, exc);
                }
            }
        }