Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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(IDelegateExecution execution)
        //{
        //    bool expressionWasExecuted = (bool?)execution.GetVariable("expressionWasExecuted").Value;
        //    bool delegateExpressionWasExecuted = (bool?)execution.GetVariable("delegateExpressionWasExecuted").Value;
        //    bool wasExecuted = (bool?)execution.GetVariable("wasExecuted").Value;

        //    expressionWasExecuted = expressionWasExecuted;
        //    delegateExpressionWasExecuted = delegateExpressionWasExecuted;
        //    wasExecuted = wasExecuted;
        //}

        public void Execute(IBaseDelegateExecution execution)
        {
            bool varExpressionWasExecuted         = (bool)execution.GetVariable("expressionWasExecuted");
            bool varDelegateExpressionWasExecuted = (bool)execution.GetVariable("delegateExpressionWasExecuted");
            bool varWasExecuted = (bool)execution.GetVariable("wasExecuted");

            expressionWasExecuted         = varExpressionWasExecuted;
            delegateExpressionWasExecuted = varDelegateExpressionWasExecuted;
            wasExecuted = varWasExecuted;
        }
//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)
        {
            execution.SetVariableLocal("var", new SimpleSerializableBean());

            var variable = (SimpleSerializableBean)execution.GetVariable("var");

            variable.IntProperty = variable.IntProperty + 1;

            var shouldExplicitlyUpdateVariable = (bool)execution.GetVariable("shouldExplicitlyUpdateVariable");

            if (shouldExplicitlyUpdateVariable)
            {
                execution.SetVariableLocal("var", variable);
            }
        }
Ejemplo n.º 5
0
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            var result = (int?)execution.GetVariable("result");

            var item = (int?)execution.GetVariable("item");

            if (item != null)
            {
                result = result * item;
            }
            else
            {
                result = result * 2;
            }
            execution.SetVariable("result", result);
        }
Ejemplo n.º 6
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string @var = (string)execution.GetVariable(VariableName);

            @var = @var.ToUpper();
            execution.SetVariable(VariableName, @var);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string VariableName = (string)variable.GetValue(execution);
            string value        = (string)execution.GetVariable(VariableName);

            values.Add(value);
        }
        public virtual void Execute(IBaseDelegateExecution Execution)
        {
            JavaSerializable dataObject = (JavaSerializable)Execution.GetVariable("varName");

            Assert.NotNull(dataObject);
            Assert.AreEqual("foo", dataObject.Property);
        }
Ejemplo n.º 10
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)
        {
            // validate integer variable
            int?expectedIntValue = 1234;

            Assert.AreEqual(expectedIntValue, execution.GetVariable("anIntegerVariable"));
            Assert.AreEqual(expectedIntValue, execution.GetVariableTyped <int>("anIntegerVariable")
                            /*.Value*/);
            Assert.AreEqual(ValueTypeFields.Integer, execution.GetVariableTyped <int>("anIntegerVariable")
                            /*.Type*/);
            Assert.IsNull(execution.GetVariableLocal("anIntegerVariable"));
            Assert.IsNull(execution.GetVariableLocalTyped <int>("anIntegerVariable"));

            // set an additional local variable
            execution.SetVariableLocal("aStringVariable", "aStringValue");

            var expectedStringValue = "aStringValue";

            Assert.AreEqual(expectedStringValue, execution.GetVariable("aStringVariable"));
            //Assert.AreEqual(expectedStringValue, execution.GetVariableTyped("aStringVariable")
            //    .Value);
            //Assert.AreEqual(ValueTypeFields.String, execution.GetVariableTyped("aStringVariable")
            //    .Type);
            //Assert.AreEqual(expectedStringValue, execution.GetVariableLocal("aStringVariable"));
            //Assert.AreEqual(expectedStringValue, execution.GetVariableLocalTyped("aStringVariable")
            //    .Value);
            //Assert.AreEqual(ValueTypeFields.String, execution.GetVariableLocalTyped("aStringVariable")
            //    .Type);

            //var objectValue = (SimpleSerializableBean) execution.GetVariable("anObjectValue");
            //Assert.NotNull(objectValue);
            //Assert.AreEqual(10, objectValue.IntProperty);
            //IObjectValue variableTyped = execution.GetVariableTyped("anObjectValue");
            //Assert.AreEqual(10, variableTyped.GetValue(typeof(SimpleSerializableBean))
            //    .IntProperty);
            //Assert.AreEqual(Variables.SerializationDataFormats.JAVA.Name, variableTyped.SerializationDataFormat);

            //objectValue = (SimpleSerializableBean) execution.GetVariable("anUntypedObjectValue");
            //Assert.NotNull(objectValue);
            //Assert.AreEqual(30, objectValue.IntProperty);
            //variableTyped = execution.GetVariableTyped("anUntypedObjectValue");
            //Assert.AreEqual(30, variableTyped.GetValue(typeof(SimpleSerializableBean))
            //    .IntProperty);
            //Assert.AreEqual(Context.ProcessEngineConfiguration.DefaultSerializationFormat,
            //    variableTyped.SerializationDataFormat);
        }
Ejemplo n.º 11
0
        public void Execute(IBaseDelegateExecution execution)
        {
            int?Count = (int?)execution.GetVariable("Count");

            Count = Count + 1;
            Console.WriteLine("Count = " + Count);
            execution.SetVariable("Count", Count);
        }
Ejemplo n.º 12
0
        public void Execute(IBaseDelegateExecution execution)
        {
            var fail = (bool?)execution.GetVariable("fail");

            if (fail == null || fail == true)
            {
                throw new ProcessEngineException(EXCEPTION_MESSAGE);
            }
        }
        public void Execute(IBaseDelegateExecution execution)
        {
            bool?fail = (bool?)execution.GetVariable("fail");

            if (fail != null && (bool)fail)
            {
                throw new ProcessEngineException("Exception expected.");
            }
        }
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            IList <string> list;
            var            test = execution.GetVariable("listVar");

            //TODO 待优化
            if (test is UntypedValueImpl)
            {
                list = (IList <string>)(((UntypedValueImpl)test).Value);
            }
            else
            {
                list = (IList <string>)execution.GetVariable("listVar");
            }
            execution.RemoveVariable("listVar");
            // implicitly update the previous list, should update the variable value
            list.Add(NEW_ELEMENT);
        }
Ejemplo n.º 15
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string flight = (string)execution.GetVariable("flight");

            if (!string.ReferenceEquals(flight, null))
            {
                bookedFlights.Add(flight);
            }
        }
Ejemplo n.º 16
0
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            bool?fail = (bool?)execution.GetVariable("secondFail");

            if (fail == null || fail == true)
            {
                throw new ProcessEngineException(SECOND_EXCEPTION_MESSAGE);
            }
        }
Ejemplo n.º 17
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");
            }
        }
        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);
        }
Ejemplo n.º 19
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 shouldFail = (bool)execution.GetVariable("shouldFail");

            if (shouldFail != null && shouldFail)
            {
                throw new System.Exception("I Assert.Fail as commanded");
            }
        }
Ejemplo n.º 20
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);
        }
//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");

            // implicitly update the previous list, should update the variable value
            list.Add(NEW_ELEMENT);

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

            // note that this is the condensed form of more realistic scenarios like
            // an implicit update in task 1 and an explicit update in the following task 2,
            // both in the same transaction.
        }
Ejemplo n.º 23
0
        public void Execute(IBaseDelegateExecution execution)
        {
            string VariableName = (string)counterName.GetValue(execution);
            object variable     = execution.GetVariable(VariableName);

            if (variable == null)
            {
                execution.SetVariable(VariableName, (int?)1);
            }
            else
            {
                execution.SetVariable(VariableName, ((int?)variable) + 1);
            }
        }
Ejemplo n.º 24
0
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            string aVariable = "aVariable";
            int?   newValue  = 1;

            object value = execution.GetVariable(aVariable);

            if (value != null)
            {
                newValue = (int?)value;
                newValue++;
            }

            execution.SetVariable(aVariable, newValue);
        }