Example #1
0
        protected internal override ValidationErrorCollection ValidateChanges(Activity contextActivity)
        {
            if (contextActivity == null)
            {
                throw new ArgumentNullException("contextActivity");
            }

            ValidationErrorCollection errors = new ValidationErrorCollection();

            CompositeActivity ownerActivity = contextActivity.TraverseDottedPathFromRoot(this.OwnerActivityDottedPath) as CompositeActivity;

            if (ownerActivity != null && WorkflowChanges.IsActivityExecutable(ownerActivity))
            {
                foreach (Validator validator in ComponentDispenser.CreateComponents(ownerActivity.GetType(), typeof(ActivityValidatorAttribute)))
                {
                    ValidationError error = validator.ValidateActivityChange(ownerActivity, this);
                    if (error != null)
                    {
                        errors.Add(error);
                    }
                }
            }

            return(errors);
        }
Example #2
0
        private void NotifyChangesCompletedToChildExecutors(IWorkflowCoreRuntime workflowCoreRuntime, Activity contextActivity)
        {
            Queue compositeActivities = new Queue();

            compositeActivities.Enqueue(contextActivity);
            while (compositeActivities.Count > 0)
            {
                CompositeActivity compositeActivity = compositeActivities.Dequeue() as CompositeActivity;
                if (compositeActivity == null || !WorkflowChanges.IsActivityExecutable(compositeActivity))
                {
                    continue;
                }

                ISupportWorkflowChanges compositeActivityExecutor = ActivityExecutors.GetActivityExecutor(compositeActivity) as ISupportWorkflowChanges;
                if (compositeActivityExecutor != null)
                {
                    using (workflowCoreRuntime.SetCurrentActivity(compositeActivity))
                    {
                        using (ActivityExecutionContext executionContext = new ActivityExecutionContext(compositeActivity))
                            compositeActivityExecutor.OnWorkflowChangesCompleted(executionContext);
                    }
                }
                foreach (Activity activity in compositeActivity.Activities)
                {
                    if (activity is CompositeActivity)
                    {
                        compositeActivities.Enqueue(activity);
                    }
                }
            }
        }
Example #3
0
        protected internal override ValidationErrorCollection ValidateChanges(Activity contextActivity)
        {
            ValidationErrorCollection errors  = base.ValidateChanges(contextActivity);
            Activity removedActivityInContext = contextActivity.TraverseDottedPathFromRoot(this.originalRemovedActivity.DottedPath);

            if (WorkflowChanges.IsActivityExecutable(removedActivityInContext) && removedActivityInContext.ExecutionStatus == ActivityExecutionStatus.Executing)
            {
                errors.Add(new ValidationError(SR.GetString(SR.Error_RemoveExecutingActivity, this.originalRemovedActivity.QualifiedName), ErrorNumbers.Error_RemoveExecutingActivity));
            }
            return(errors);
        }
Example #4
0
        private void NotifyChangesToChildExecutors(IWorkflowCoreRuntime workflowCoreRuntime, Activity contextActivity, IList <WorkflowChangeAction> changeActions)
        {
            foreach (WorkflowChangeAction action in changeActions)
            {
                if (!(action is ActivityChangeAction))
                {
                    continue;
                }

                CompositeActivity ownerActivity = contextActivity.TraverseDottedPathFromRoot(((ActivityChangeAction)action).OwnerActivityDottedPath) as CompositeActivity;
                if (ownerActivity == null || !WorkflowChanges.IsActivityExecutable(ownerActivity))
                {
                    continue;
                }

                ISupportWorkflowChanges compositeActivityExecutor = ActivityExecutors.GetActivityExecutor(ownerActivity) as ISupportWorkflowChanges;
                if (compositeActivityExecutor == null)
                {
                    throw new ApplicationException(SR.GetString(SR.Error_WorkflowChangesNotSupported, ownerActivity.GetType().FullName));
                }

                using (workflowCoreRuntime.SetCurrentActivity(ownerActivity))
                {
                    using (ActivityExecutionContext executionContext = new ActivityExecutionContext(ownerActivity))
                    {
                        if (action is AddedActivityAction)
                        {
                            Activity addedActivity = ownerActivity.Activities[((AddedActivityAction)action).Index];
                            if (WorkflowChanges.IsActivityExecutable(addedActivity))
                            {
                                addedActivity.OnActivityExecutionContextLoad(executionContext.Activity.RootActivity.WorkflowCoreRuntime);
                                executionContext.InitializeActivity(addedActivity);
                                compositeActivityExecutor.OnActivityAdded(executionContext, addedActivity);
                            }
                        }
                        else if (action is RemovedActivityAction)
                        {
                            RemovedActivityAction removedActivityAction = (RemovedActivityAction)action;
                            if (WorkflowChanges.IsActivityExecutable(removedActivityAction.OriginalRemovedActivity))
                            {
                                compositeActivityExecutor.OnActivityRemoved(executionContext, removedActivityAction.OriginalRemovedActivity);
                                if (removedActivityAction.OriginalRemovedActivity.ExecutionResult != ActivityExecutionResult.Uninitialized)
                                {
                                    removedActivityAction.OriginalRemovedActivity.Uninitialize(executionContext.Activity.RootActivity.WorkflowCoreRuntime);
                                    removedActivityAction.OriginalRemovedActivity.SetValue(Activity.ExecutionResultProperty, ActivityExecutionResult.Uninitialized);
                                }
                                removedActivityAction.OriginalRemovedActivity.OnActivityExecutionContextUnload(executionContext.Activity.RootActivity.WorkflowCoreRuntime);
                                removedActivityAction.OriginalRemovedActivity.Dispose();
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        protected internal override ValidationErrorCollection ValidateChanges(Activity contextActivity)
        {
            ValidationErrorCollection errors = base.ValidateChanges(contextActivity);
            Activity activity = contextActivity.TraverseDottedPathFromRoot(this.originalRemovedActivity.DottedPath);

            if (WorkflowChanges.IsActivityExecutable(activity) && (activity.ExecutionStatus == ActivityExecutionStatus.Executing))
            {
                errors.Add(new ValidationError(SR.GetString("Error_RemoveExecutingActivity", new object[] { this.originalRemovedActivity.QualifiedName }), 0x11d));
            }
            return(errors);
        }