예제 #1
0
            public void Execute(IBaseDelegateExecution execution)
            {
                serviceTaskInvokedCount++;

                // leave only 3 out of n subprocesses
                execution.SetVariableLocal("terminate", serviceTaskInvokedCount > 3);
            }
예제 #2
0
        public virtual object GetValue(IVariableScope variableScope, IBaseDelegateExecution contextExecution)
        {
            var elContext = ExpressionManager.GetElContext(variableScope);

            try
            {
                var invocation = new ExpressionGetInvocation(ValueExpression, elContext, contextExecution);
                Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(invocation);
                return(invocation.InvocationResult);
            }
            catch (PropertyNotFoundException pnfe)
            {
                throw new ProcessEngineException(
                          "Unknown property used in expression: " + ExpressionText + ". Cause: " + pnfe.Message, pnfe);
            }
            catch (MethodNotFoundException mnfe)
            {
                throw new ProcessEngineException(
                          "Unknown method used in expression: " + ExpressionText + ". Cause: " + mnfe.Message, mnfe);
            }
            catch (ELException ele)
            {
                throw new ProcessEngineException(
                          "Error while evaluating expression: " + ExpressionText + ". Cause: " + ele.Message, ele);
            }
            catch (System.Exception e)
            {
                throw new ProcessEngineException(
                          "Error while evaluating expression: " + ExpressionText + ". Cause: " + e.Message, e);
            }
        }
        public virtual void Execute(IBaseDelegateExecution Execution)
        {
            JavaSerializable dataObject = (JavaSerializable)Execution.GetVariable("varName");

            Assert.NotNull(dataObject);
            Assert.AreEqual("foo", dataObject.Property);
        }
예제 #4
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string @var = (string)execution.GetVariable(VariableName);

            @var = @var.ToUpper();
            execution.SetVariable(VariableName, @var);
        }
예제 #5
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string VariableName = (string)variable.GetValue(execution);
            string value        = (string)execution.GetVariable(VariableName);

            values.Add(value);
        }
예제 #6
0
        public void Execute(IBaseDelegateExecution execution)
        {
            ITask task = (execution as IDelegateExecution).ProcessEngineServices.TaskService.CreateTaskQuery(c => c.Name == AbstractConditionalEventTestCase.TaskWithCondition).First();

            ((TaskEntity)task).Execution.SetVariableLocal(AbstractConditionalEventTestCase.VariableName, 1);
            execution.SetVariableLocal(AbstractConditionalEventTestCase.VariableName + 1, 1);
        }
예제 #7
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void execute(delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            string engineName     = (string)execution.GetVariable("engineName");
            string processKeyName = (string)execution.GetVariable("processKey");

            Engines[engineName].RuntimeService.StartProcessInstanceByKey(processKeyName);
        }
예제 #8
0
 public ExpressionSetInvocation(ValueExpression valueExpression, ELContext elContext, object value,
                                IBaseDelegateExecution contextExecution) : base(contextExecution, null)
 {
     this.ValueExpression = valueExpression;
     this.Value           = value;
     this.ElContext       = elContext;
 }
예제 #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            foreach (DelegateExecutionAsserter a in Asserts)
            {
                a.DoAssert((IDelegateExecution)execution);
            }
        }
        /// <summary>
        ///     有可能会报错转换失败
        /// </summary>
        /// <param name="execution"></param>
        public void Execute(IBaseDelegateExecution execution)
        {
            var delexecution = (IDelegateExecution)execution;

            ModelInstance = delexecution.BpmnModelInstance;                      // IBpmnModelInstance;//  IExecution.IBpmnModelInstance;
            ServiceTask   = (IServiceTask)delexecution.BpmnModelElementInstance; //BpmnModelElementInstance;
        }
예제 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public void Execute(IBaseDelegateExecution execution)
        {
            var            now          = DateTime.Now;
            IList <string> serializable = new List <string>();

            serializable.Add("one");
            serializable.Add("two");
            serializable.Add("three");

            // Start process instance with different types of variables
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["shortVar"]   = (short)123;
            variables["integerVar"] = 1234;
            variables["longVar"]    = 928374L;

            variables["byteVar"] = new byte[] { 12, 32, 34 };

            variables["stringVar"]       = "coca-cola";
            variables["dateVar"]         = now;
            variables["nullVar"]         = null;
            variables["serializableVar"] = serializable;

            execution.VariablesLocal = variables;
        }
예제 #12
0
        protected internal virtual bool IsCurrentContextExecution(IBaseDelegateExecution execution)
        {
            var coreExecutionContext = Context.CoreExecutionContext;

            //return coreExecutionContext != null && coreExecutionContext.Execution == execution;
            return(coreExecutionContext != null && coreExecutionContext.GetExecution <CoreExecution>() == execution);
        }
예제 #13
0
        public void Execute(IBaseDelegateExecution execution)
        {
            var v = new Variable();

            execution.SetVariable("variable", v);
            v.value = "delegate1";
        }
예제 #14
0
 /// <summary>
 ///     Provide a context execution or resource definition in which context the invocation
 ///     should be performed. If both parameters are null, the invocation is performed in the
 ///     current context.
 /// </summary>
 /// <param name="contextExecution"> set to an execution </param>
 public DelegateInvocation(IBaseDelegateExecution contextExecution, IResourceDefinitionEntity contextResource)
 {
     // This constructor forces sub classes to call it, thereby making it more visible
     // whether a context switch is going to be performed for them.
     this.ContextExecution = contextExecution;
     this.ContextResource  = contextResource;
 }
예제 #15
0
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            IList <string> list = (IList <string>)execution.GetVariable("listVar");

            // implicit update of the list, so no execution.SetVariable call
            list.Add(NEW_ELEMENT);
        }
예제 #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void Execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            IProcessEngineServices services       = ((IDelegateExecution)execution).ProcessEngineServices;
            IRuntimeService        runtimeService = services.RuntimeService;

            runtimeService.SetVariable(execution.Id, "serviceTaskCalled", true);
        }
예제 #17
0
        public void Execute(IBaseDelegateExecution execution)
        {
            int? executionsBeforeError = (int?)execution.GetVariable("executionsBeforeError");
            int? executions            = (int?)execution.GetVariable("executions");
            bool?exceptionType         = (bool?)execution.GetVariable("exceptionType");

            if (executions == null)
            {
                executions = 0;
            }
            executions++;
            if (executionsBeforeError == null || executionsBeforeError < executions)
            {
                if (exceptionType.HasValue && exceptionType.Value)
                {
                    throw new MyBusinessException("This is a business exception, which can be caught by a BPMN Error Event.");
                }
                else
                {
                    throw new BpmnError("23", "This is a business fault, which can be caught by a BPMN Error Event.");
                }
            }
            else
            {
                execution.SetVariable("executions", executions);
            }
        }
예제 #18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            // first set variable to some string
            execution.SetVariable("VariableName", "test");

            // now set to serializable
            execution.SetVariable("VariableName", new SerializableVariable("foo"));
        }
예제 #19
0
 public void Execute(IBaseDelegateExecution execution)
 {
     if (!setterInvoked)
     {
         throw new System.Exception("Setter was not invoked");
     }
     execution.SetVariable("setterVar", ((string)_text.GetValue(execution)).ToUpper());
 }
예제 #20
0
        public void Execute(IBaseDelegateExecution execution)
        {
            int?Count = (int?)execution.GetVariable("Count");

            Count = Count + 1;
            Console.WriteLine("Count = " + Count);
            execution.SetVariable("Count", Count);
        }
        public void Execute(IBaseDelegateExecution execution)
        {
            DateTime currentTime = (DateTime)execution.GetVariable("currentTime");

            //currentTime = DateUtils.AddSeconds(currentTime, 1);
            currentTime           = currentTime.AddSeconds(1);
            ClockUtil.CurrentTime = currentTime;
            execution.SetVariable("currentTime", currentTime);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public void Execute(IBaseDelegateExecution execution)
        {
            var shouldFail = (bool)execution.GetVariable("shouldFail");

            if (shouldFail != null && shouldFail)
            {
                throw new System.Exception("I Assert.Fail as commanded");
            }
        }
        public void Execute(IBaseDelegateExecution execution)
        {
            bool?fail = (bool?)execution.GetVariable("fail");

            if (fail != null && (bool)fail)
            {
                throw new ProcessEngineException("Exception expected.");
            }
        }
예제 #24
0
        public void Execute(IBaseDelegateExecution execution)
        {
            var fail = (bool?)execution.GetVariable("fail");

            if (fail == null || fail == true)
            {
                throw new ProcessEngineException(EXCEPTION_MESSAGE);
            }
        }
예제 #25
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string flight = (string)execution.GetVariable("flight");

            if (!string.ReferenceEquals(flight, null))
            {
                bookedFlights.Add(flight);
            }
        }
예제 #26
0
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            bool?fail = (bool?)execution.GetVariable("secondFail");

            if (fail == null || fail == true)
            {
                throw new ProcessEngineException(SECOND_EXCEPTION_MESSAGE);
            }
        }
예제 #27
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            bool?fail = (bool?)execution.GetVariable("fail");

            if (fail != null && fail == true)
            {
                throw new ProcessEngineException("Expected exception");
            }
        }
예제 #28
0
        public void Execute(IBaseDelegateExecution execution)
        {
            var v = (Variable)execution.GetVariable("variable");

            lock (typeof(ServiceTaskVariablesTest))
            {
                // we expect this to be 'true' as well
                isNullInDelegate3 = !ReferenceEquals(v.value, null) && v.value.Equals("delegate2");
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void Execute(org.Camunda.bpm.Engine.Delegate.IDelegateExecution execution) throws Exception
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            IList <string> list = (IList <string>)execution.GetVariable("listVar");

            // replace the list by another object
            execution.SetVariable("listVar", new List <string>());

            // implicitly update the previous list, should update the variable value
            list.Add(NEW_ELEMENT);
        }
예제 #30
0
 /// <returns> true if the execution context is modified by this invocation </returns>
 protected internal virtual bool SetExecutionContext(IBaseDelegateExecution execution)
 {
     if (execution is ExecutionEntity)
     {
         return(true);
     }
     //if (execution is CaseExecutionEntity)
     //    return true;
     return(false);
 }