public void SetWhenCondition(Activity activity, ActivityCondition handler)
 {
     if (activity.Parent is ConditionedActivityGroup)
     {
         activity.SetValue(ConditionedActivityGroup.WhenConditionProperty, handler);
     }
 }
Example #2
0
	      	public IfElseBranchActivity AddBranch (ICollection <Activity> activities, ActivityCondition branchCondition)
	      	{
	      		IfElseBranchActivity branch_activity = new IfElseBranchActivity ();
	      		branch_activity.Condition = branchCondition;

	      		foreach (Activity activity in activities) {
	      			branch_activity.Activities.Add (activity);
	      		}

			return 	branch_activity;
	      	}
Example #3
0
        private void VerifyWorkflowCanBeChanged(IWorkflowCoreRuntime workflowCoreRuntime)
        {
            ActivityCondition condition = workflowCoreRuntime.RootActivity.GetValue(ConditionProperty) as ActivityCondition;

            if (condition != null)
            {
                using (workflowCoreRuntime.SetCurrentActivity(workflowCoreRuntime.RootActivity))
                {
                    if (!condition.Evaluate(workflowCoreRuntime.RootActivity, workflowCoreRuntime))
                    {
                        throw new InvalidOperationException(SR.GetString(CultureInfo.CurrentCulture, "Error_DynamicUpdateEvaluation", new object[] { workflowCoreRuntime.InstanceID.ToString() }));
                    }
                }
            }
        }
Example #4
0
        private void VerifyWorkflowCanBeChanged(IWorkflowCoreRuntime workflowCoreRuntime)
        {
            // check if the update is allowed on this root-activity.
            ActivityCondition dynamicUpdateCondition = ((Activity)workflowCoreRuntime.RootActivity).GetValue(WorkflowChanges.ConditionProperty) as ActivityCondition;

            if (dynamicUpdateCondition != null)
            {
                using (workflowCoreRuntime.SetCurrentActivity(workflowCoreRuntime.RootActivity))
                {
                    if (!dynamicUpdateCondition.Evaluate(workflowCoreRuntime.RootActivity, workflowCoreRuntime))
                    {
                        throw new InvalidOperationException(SR.GetString(CultureInfo.CurrentCulture, SR.Error_DynamicUpdateEvaluation, new object[] { workflowCoreRuntime.InstanceID.ToString() }));
                    }
                }
            }
        }
 private static string ConvertActivityCondition(ActivityCondition condition, RuleDefinitions ruleDefinitions)
 {
     var builder = new StringBuilder();
     if (condition != null)
     {
         if (condition is RuleConditionReference)
         {
             var ruleRef = (RuleConditionReference)condition;
             builder.AppendLine(RuleTranslator.ConvertRuleConditionReference(ruleDefinitions, ruleRef));
         }
         else
         {
             throw new NotSupportedException("Type not found:" + condition.GetType());
         }
     }
     else
     {
         builder.AppendLine("This activity gets executed if the other conditions fail in the evaluation process");
     }
     return builder.ToString();
 }