public void Execute(IActivityExecution execution) { var more = execution.Activity.FindOutgoingTransition("more"); var done = execution.Activity.FindOutgoingTransition("done"); var value = (int?)execution.GetVariable(_variableName); if (value == null) { execution.SetVariable(_variableName, _from); execution.LeaveActivityViaTransition(more); } else { value = value + 1; if (value < _to) { execution.SetVariable(_variableName, value); execution.LeaveActivityViaTransition(more); } else { execution.LeaveActivityViaTransition(done); } } }
// Helpers ////////////////////////////////////////////////////////////////////// protected internal virtual int ResolveNrOfInstances(IActivityExecution execution) { var nrOfInstances = -1; if (loopCardinalityExpression != null) { nrOfInstances = ResolveLoopCardinality(execution); } else if (collectionExpression != null) { var obj = collectionExpression.GetValue(execution); if (!(obj.GetType().IsAssignableFrom(typeof(ICollection)))) { throw Log.UnresolvableExpressionException(collectionExpression.ExpressionText, "Collection"); } nrOfInstances = ((IList)obj)?.Count ?? 0; } else if (!ReferenceEquals(collectionVariable, null)) { var obj = execution.GetVariable(collectionVariable); if (!(obj.GetType().IsAssignableFrom(typeof(ICollection)))) { throw Log.InvalidVariableTypeException(collectionVariable, "Collection"); } nrOfInstances = ((IList)obj)?.Count ?? 0; } else { throw Log.ResolveCollectionExpressionOrVariableReferenceException(); } return(nrOfInstances); }
public override void Execute(IActivityExecution execution) { Log.LogDebug("WaitStateUndoService执行Execute:", $"execution:{execution.GetType().Name} _counterName is null?:{(_counterName == null).ToString()}"); 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); } Log.LogDebug("WaitStateUndoService执行Execute完毕:", $"variable is null?:{(variable==null).ToString()}"); }
public void Execute(IActivityExecution execution) { string @var = (string)execution.GetVariable("var"); IPvmTransition transition = null; try { ExecuteLogic(@var); transition = execution.Activity.FindOutgoingTransition("no-exception"); } catch (System.Exception) { transition = execution.Activity.FindOutgoingTransition("exception"); } execution.LeaveActivityViaTransition(transition); }
protected internal virtual void EvaluateCollectionVariable(IActivityExecution execution, int loopCounter) { if (UsesCollection() && !ReferenceEquals(collectionElementVariable, null)) { IList collection = null; if (collectionExpression != null) { collection = (IList)collectionExpression.GetValue(execution); } else if (!ReferenceEquals(collectionVariable, null)) { collection = (IList)execution.GetVariable(collectionVariable); } var value = GetElementAtIndex(loopCounter, collection); SetLoopVariable(execution, collectionElementVariable, value); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected void handle(org.Camunda.bpm.engine.impl.pvm.delegate.ActivityExecution execution, String action) throws Exception protected internal virtual void handle(IActivityExecution execution, string action) { execution.SetVariable(action, true); string type = (string)execution.GetVariable("type"); if ("error".Equals(type, StringComparison.CurrentCultureIgnoreCase)) { throw new BpmnError("MyError"); } else if ("exception".Equals(type, StringComparison.CurrentCultureIgnoreCase)) { throw new MyBusinessException("MyException"); } else if ("leave".Equals(type, StringComparison.CurrentCultureIgnoreCase)) { execution.SetVariable("type", null); Leave(execution); } }
public void Execute(IActivityExecution execution) { IPvmTransition transition = null; var creditRating = (string)execution.GetVariable("creditRating"); if (creditRating.Equals("AAA+")) { transition = execution.Activity.FindOutgoingTransition("wow"); } else if (creditRating.Equals("Aaa-")) { transition = execution.Activity.FindOutgoingTransition("nice"); } else { transition = execution.Activity.FindOutgoingTransition("default"); } execution.LeaveActivityViaTransition(transition); }