public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (((activity.ExecutionStatus != ActivityExecutionStatus.Initialized) && (activity.ExecutionStatus != ActivityExecutionStatus.Executing)) && (activity.ExecutionStatus != ActivityExecutionStatus.Closed))
            {
                return(new ValidationError(SR.GetString("Error_DynamicActivity2", new object[] { activity.QualifiedName, activity.ExecutionStatus, activity.GetType().FullName }), 0x50f));
            }
            RemovedActivityAction action2 = action as RemovedActivityAction;

            if (action2 != null)
            {
                StateActivity originalRemovedActivity = action2.OriginalRemovedActivity as StateActivity;
                if (originalRemovedActivity != null)
                {
                    return(new ValidationError(SR.GetError_CantRemoveState(originalRemovedActivity.QualifiedName), 0x61b));
                }
                if (activity.ExecutionStatus == ActivityExecutionStatus.Executing)
                {
                    EventDrivenActivity activity3 = action2.OriginalRemovedActivity as EventDrivenActivity;
                    if (activity3 != null)
                    {
                        return(new ValidationError(SR.GetError_CantRemoveEventDrivenFromExecutingState(activity3.QualifiedName, activity.QualifiedName), 0x620));
                    }
                }
            }
            return(null);
        }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            RemovedActivityAction removedAction = action as RemovedActivityAction;

            if (removedAction != null && removedAction.RemovedActivityIndex == 0)
            {
                return(new ValidationError(SR.GetString(SR.Error_EventActivityIsImmutable), ErrorNumbers.Error_DynamicActivity, false));
            }
            else
            {
                AddedActivityAction addedAction = action as AddedActivityAction;

                if (addedAction != null && addedAction.Index == 0)
                {
                    return(new ValidationError(SR.GetString(SR.Error_EventActivityIsImmutable), ErrorNumbers.Error_DynamicActivity, false));
                }
            }
            return(base.ValidateActivityChange(activity, action));
        }
Example #3
0
        public virtual ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
                throw new ArgumentNullException("activity");
            if (action == null)
                throw new ArgumentNullException("action");

            return null;
        }
 public virtual ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
 {
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (action == null)
     {
         throw new ArgumentNullException("action");
     }
     return null;
 }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }

            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            AddedActivityAction addedAction = action as AddedActivityAction;

            if (addedAction != null)
            {
                //Check existence of nested PersistOnClose/ICompensatable/SupportsTransaction nested anywhere
                //in the added activity branch
                System.Collections.Generic.Queue <Activity> childrenQueue = new System.Collections.Generic.Queue <Activity>();
                childrenQueue.Enqueue(addedAction.AddedActivity);

                while (childrenQueue.Count != 0)
                {
                    Activity childActivity = childrenQueue.Dequeue();

                    if (childActivity.SupportsTransaction)
                    {
                        return(new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT));
                    }

                    if (childActivity.PersistOnClose)
                    {
                        return(new ValidationError(SR.GetString(SR.Error_NestedPersistOnClose, activity.QualifiedName), ErrorNumbers.Error_NestedPersistOnClose));
                    }

                    if (childActivity is ICompensatableActivity)
                    {
                        return(new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, activity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity));
                    }

                    CompositeActivity compositeActivity = childActivity as CompositeActivity;

                    if (compositeActivity != null)
                    {
                        foreach (Activity grandChild in compositeActivity.EnabledActivities)
                        {
                            childrenQueue.Enqueue(grandChild);
                        }
                    }
                }
            }
            return(base.ValidateActivityChange(activity, action));
        }
Example #6
0
        private void LoadChangesFromReader(SqlDataReader reader, object parameter)
        {
            if (!reader.Read())
            {
                return;
            }
            //
            // Reset the min to the most recent change event
            DateTime tmpDT = _changesMinDT;

            if (!reader.IsDBNull(0))
            {
                tmpDT = reader.GetDateTime(0);
            }

            if (reader.NextResult())
            {
                WorkflowMarkupSerializer     serializer           = new WorkflowMarkupSerializer();
                DesignerSerializationManager serializationManager = new DesignerSerializationManager();
                while (reader.Read())
                {
                    IList errors = null;
                    using (StringReader sr = new StringReader(reader.GetString(0)))
                    {
                        using (serializationManager.CreateSession())
                        {
                            using (XmlReader xmlReader = XmlReader.Create(sr))
                            {
                                ActivityChangeAction aAction = serializer.Deserialize(serializationManager, xmlReader) as ActivityChangeAction;

                                errors = serializationManager.Errors;
                                if (null != aAction)
                                {
                                    aAction.ApplyTo(_def);
                                }
                                else
                                {
                                    throw new WorkflowMarkupSerializationException(ExecutionStringManager.WorkflowMarkupDeserializationError);
                                }
                            }
                        }
                    }
                }
            }

            if (tmpDT > _changesMinDT)
            {
                _changed      = true;
                _changesMinDT = tmpDT;
            }
        }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            if (activity.ExecutionStatus != ActivityExecutionStatus.Initialized &&
                activity.ExecutionStatus != ActivityExecutionStatus.Executing &&
                activity.ExecutionStatus != ActivityExecutionStatus.Closed)
            {
                return(new ValidationError(SR.GetString(SR.Error_DynamicActivity2, activity.QualifiedName, activity.ExecutionStatus, activity.GetType().FullName), ErrorNumbers.Error_DynamicActivity2));
            }

            RemovedActivityAction remove = action as RemovedActivityAction;

            if (remove != null)
            {
                StateActivity removedState = remove.OriginalRemovedActivity as StateActivity;
                if (removedState != null)
                {
                    // we don't have a way to check if the removed
                    // activity is executing or not, so if the user is trying to
                    // remove a StateActivity, we simply disallow it.
                    //

                    return(new ValidationError(
                               SR.GetError_CantRemoveState(removedState.QualifiedName),
                               ErrorNumbers.Error_CantRemoveState));
                }

                if (activity.ExecutionStatus == ActivityExecutionStatus.Executing)
                {
                    EventDrivenActivity removedEventDriven = remove.OriginalRemovedActivity as EventDrivenActivity;
                    if (removedEventDriven != null)
                    {
                        return(new ValidationError(
                                   SR.GetError_CantRemoveEventDrivenFromExecutingState(removedEventDriven.QualifiedName, activity.QualifiedName),
                                   ErrorNumbers.Error_CantRemoveEventDrivenFromExecutingState));
                    }
                }
            }
            return(null);
        }
 public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
 {
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (action == null)
     {
         throw new ArgumentNullException("action");
     }
     if ((activity.ExecutionStatus != ActivityExecutionStatus.Initialized) && (activity.ExecutionStatus != ActivityExecutionStatus.Closed))
     {
         return(new ValidationError(SR.GetString("Error_DynamicActivity", new object[] { activity.QualifiedName, Enum.GetName(typeof(ActivityExecutionStatus), activity.ExecutionStatus) }), 260));
     }
     return(null);
 }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
                throw new ArgumentNullException("activity");
            if (action == null)
                throw new ArgumentNullException("action");

            if (activity.ExecutionStatus != ActivityExecutionStatus.Initialized &&
                activity.ExecutionStatus != ActivityExecutionStatus.Executing &&
                activity.ExecutionStatus != ActivityExecutionStatus.Closed)
            {
                return new ValidationError(SR.GetString(SR.Error_DynamicActivity, activity.QualifiedName, Enum.GetName(typeof(ActivityExecutionStatus), activity.ExecutionStatus)), ErrorNumbers.Error_DynamicActivity);
            }

            return null;
        }
Example #10
0
 public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
 {
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (action == null)
     {
         throw new ArgumentNullException("action");
     }
     if ((activity.ExecutionStatus != ActivityExecutionStatus.Initialized) && (activity.ExecutionStatus != ActivityExecutionStatus.Closed))
     {
         return(new ValidationError(string.Format("CompositeActivity '{0}' status is currently '{1}'. Dynamic modifications are allowed only when the activity status is 'Enabled' or 'Suspended'.", activity.QualifiedName, activity.ExecutionStatus.ToString()), 260));
     }
     return(null);
 }
 public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
 {
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (action == null)
     {
         throw new ArgumentNullException("action");
     }
     if (((activity.ExecutionStatus != ActivityExecutionStatus.Initialized) && (activity.ExecutionStatus != ActivityExecutionStatus.Executing)) && (activity.ExecutionStatus != ActivityExecutionStatus.Closed))
     {
         return(new ValidationError(SR.GetString("Error_DynamicActivity2", new object[] { activity.QualifiedName, activity.ExecutionStatus, activity.GetType().FullName }), 0x50f));
     }
     return(null);
 }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            if (activity.ExecutionStatus != ActivityExecutionStatus.Initialized &&
                activity.ExecutionStatus != ActivityExecutionStatus.Closed)
            {
                return(new ValidationError(SR.GetString(SR.Error_DynamicActivity, activity.QualifiedName, Enum.GetName(typeof(ActivityExecutionStatus), activity.ExecutionStatus)), ErrorNumbers.Error_DynamicActivity));
            }
            return(null);
        }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
                throw new ArgumentNullException("activity");

            if (action == null)
                throw new ArgumentNullException("action");

            AddedActivityAction addedAction = action as AddedActivityAction;

            if (addedAction != null)
            {
                //Check existence of nested PersistOnClose/ICompensatable/SupportsTransaction nested anywhere
                //in the added activity branch
                System.Collections.Generic.Queue<Activity> childrenQueue = new System.Collections.Generic.Queue<Activity>();
                childrenQueue.Enqueue(addedAction.AddedActivity);

                while (childrenQueue.Count != 0)
                {
                    Activity childActivity = childrenQueue.Dequeue();

                    if (childActivity.SupportsTransaction)
                        return new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT);

                    if (childActivity.PersistOnClose)
                        return new ValidationError(SR.GetString(SR.Error_NestedPersistOnClose, activity.QualifiedName), ErrorNumbers.Error_NestedPersistOnClose);

                    if (childActivity is ICompensatableActivity)
                        return new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, activity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity);

                    CompositeActivity compositeActivity = childActivity as CompositeActivity;

                    if (compositeActivity != null)
                    {
                        foreach (Activity grandChild in compositeActivity.EnabledActivities)
                        {
                            childrenQueue.Enqueue(grandChild);
                        }
                    }
                }
            }
            return base.ValidateActivityChange(activity, action);
        }
Example #14
0
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            AddedActivityAction action2 = action as AddedActivityAction;

            if (action2 != null)
            {
                Queue <Activity> queue = new Queue <Activity>();
                queue.Enqueue(action2.AddedActivity);
                while (queue.Count != 0)
                {
                    Activity activity2 = queue.Dequeue();
                    if (activity2.SupportsTransaction)
                    {
                        return(new ValidationError(SR.GetString("Error_AtomicScopeNestedInNonLRT"), 0x52e));
                    }
                    if (activity2.PersistOnClose)
                    {
                        return(new ValidationError(SR.GetString("Error_NestedPersistOnClose", new object[] { activity.QualifiedName }), 0x1a2));
                    }
                    if (activity2 is ICompensatableActivity)
                    {
                        return(new ValidationError(SR.GetString("Error_NestedCompensatableActivity", new object[] { activity.QualifiedName }), 0x1a6));
                    }
                    CompositeActivity activity3 = activity2 as CompositeActivity;
                    if (activity3 != null)
                    {
                        foreach (Activity activity4 in activity3.EnabledActivities)
                        {
                            queue.Enqueue(activity4);
                        }
                    }
                }
            }
            return(base.ValidateActivityChange(activity, action));
        }
Example #15
0
 private void LoadChangesFromReader(SqlDataReader reader, object parameter)
 {
     if (reader.Read())
     {
         DateTime dateTime = this._changesMinDT;
         if (!reader.IsDBNull(0))
         {
             dateTime = reader.GetDateTime(0);
         }
         if (reader.NextResult())
         {
             WorkflowMarkupSerializer     serializer           = new WorkflowMarkupSerializer();
             DesignerSerializationManager serializationManager = new DesignerSerializationManager();
             while (reader.Read())
             {
                 using (StringReader reader2 = new StringReader(reader.GetString(0)))
                 {
                     using (serializationManager.CreateSession())
                     {
                         using (XmlReader reader3 = XmlReader.Create(reader2))
                         {
                             ActivityChangeAction action = serializer.Deserialize(serializationManager, reader3) as ActivityChangeAction;
                             IList errors = serializationManager.Errors;
                             if (action == null)
                             {
                                 throw new WorkflowMarkupSerializationException(ExecutionStringManager.WorkflowMarkupDeserializationError);
                             }
                             action.ApplyTo(this._def);
                             continue;
                         }
                     }
                 }
             }
         }
         if (dateTime > this._changesMinDT)
         {
             this._changed      = true;
             this._changesMinDT = dateTime;
         }
     }
 }
Example #16
0
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            if (activity.ExecutionStatus != ActivityExecutionStatus.Initialized &&
                activity.ExecutionStatus != ActivityExecutionStatus.Executing &&
                activity.ExecutionStatus != ActivityExecutionStatus.Closed)
            {
                return(new ValidationError(SR.GetString(SR.Error_DynamicActivity2, activity.QualifiedName, activity.ExecutionStatus, activity.GetType().FullName), ErrorNumbers.Error_DynamicActivity2));
            }

            // if we are currently executing, make sure that we are not changing something already running
            // removed since changes mean that the child activity is going to get validated anyway

            return(null);
        }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            RemovedActivityAction action2 = action as RemovedActivityAction;

            if ((action2 != null) && (action2.RemovedActivityIndex == 0))
            {
                return(new ValidationError(SR.GetString("Error_EventActivityIsImmutable"), 260, false));
            }
            AddedActivityAction action3 = action as AddedActivityAction;

            if ((action3 != null) && (action3.Index == 0))
            {
                return(new ValidationError(SR.GetString("Error_EventActivityIsImmutable"), 260, false));
            }
            return(base.ValidateActivityChange(activity, action));
        }
Example #18
0
        private void LoadWorkflowChangeEventArgsFromReader(SqlDataReader reader, object parameter)
        {
            if (null == reader)
            {
                throw new ArgumentNullException("reader");
            }

            if (null == parameter)
            {
                throw new ArgumentNullException("parameter");
            }

            WorkflowTrackingRecord record = parameter as WorkflowTrackingRecord;

            if (null == record)
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsParameter, "parameter");
            }

            if (!reader.Read())
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsReader);
            }

            StringReader sr = new StringReader(reader.GetString(0));

            //Deserialize the xoml and set the root activity
            Activity def = null;
            WorkflowMarkupSerializer     serializer           = new WorkflowMarkupSerializer();
            DesignerSerializationManager serializationManager = new DesignerSerializationManager();
            IList errors = null;

            try
            {
                using (serializationManager.CreateSession())
                {
                    using (XmlReader xmlReader = XmlReader.Create(sr))
                    {
                        def    = serializer.Deserialize(serializationManager, xmlReader) as Activity;
                        errors = serializationManager.Errors;
                    }
                }
            }
            finally
            {
                sr.Close();
            }

            if ((null == def) || ((null != errors) && (errors.Count > 0)))
            {
                throw new WorkflowMarkupSerializationException(ExecutionStringManager.WorkflowMarkupDeserializationError);
            }

            if (!reader.NextResult())
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsReader);
            }
            //
            // There is a result set that we don't care about for this scenario, skip it
            if (!reader.NextResult())
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsReader);
            }

            List <WorkflowChangeAction> actions = new List <WorkflowChangeAction>();
            DateTime currDT         = DateTime.MinValue;
            int      currEventOrder = -1;
            int      currOrder      = -1;

            while (reader.Read())
            {
                DateTime dt         = reader.GetDateTime(1);
                int      eventOrder = reader.GetInt32(2);
                int      order      = reader.GetInt32(3);
                //
                // Build temp lists as we read the results but
                // only save the last set of change actions
                if (dt > currDT && eventOrder > currEventOrder)
                {
                    currEventOrder = eventOrder;
                    currOrder      = order;
                    currDT         = dt;
                    actions        = new List <WorkflowChangeAction>();
                }

                using (sr = new StringReader(reader.GetString(0)))
                {
                    using (serializationManager.CreateSession())
                    {
                        using (XmlReader xmlReader = XmlReader.Create(sr))
                        {
                            ActivityChangeAction aAction = serializer.Deserialize(serializationManager, xmlReader) as ActivityChangeAction;

                            errors = serializationManager.Errors;
                            if (null == aAction)
                            {
                                throw new WorkflowMarkupSerializationException(ExecutionStringManager.WorkflowMarkupDeserializationError);
                            }

                            actions.Add(aAction);
                            aAction.ApplyTo(def);
                        }
                    }
                }
            }

            record.EventArgs = new TrackingWorkflowChangedEventArgs(actions, def);
        }
Example #19
0
        private void LoadWorkflowChangeEventArgsFromReader(SqlDataReader reader, object parameter)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }
            WorkflowTrackingRecord record = parameter as WorkflowTrackingRecord;

            if (record == null)
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsParameter, "parameter");
            }
            if (!reader.Read())
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsReader);
            }
            StringReader                 input                = new StringReader(reader.GetString(0));
            Activity                     rootActivity         = null;
            WorkflowMarkupSerializer     serializer           = new WorkflowMarkupSerializer();
            DesignerSerializationManager serializationManager = new DesignerSerializationManager();
            IList errors = null;

            try
            {
                using (serializationManager.CreateSession())
                {
                    using (XmlReader reader3 = XmlReader.Create(input))
                    {
                        rootActivity = serializer.Deserialize(serializationManager, reader3) as Activity;
                        errors       = serializationManager.Errors;
                    }
                }
            }
            finally
            {
                input.Close();
            }
            if ((rootActivity == null) || ((errors != null) && (errors.Count > 0)))
            {
                throw new WorkflowMarkupSerializationException(ExecutionStringManager.WorkflowMarkupDeserializationError);
            }
            if (!reader.NextResult())
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsReader);
            }
            if (!reader.NextResult())
            {
                throw new ArgumentException(ExecutionStringManager.InvalidWorkflowChangeEventArgsReader);
            }
            List <WorkflowChangeAction> changes = new List <WorkflowChangeAction>();
            DateTime minValue = DateTime.MinValue;
            int      num      = -1;

            while (reader.Read())
            {
                DateTime dateTime = reader.GetDateTime(1);
                int      num2     = reader.GetInt32(2);
                int      num3     = reader.GetInt32(3);
                if ((dateTime > minValue) && (num2 > num))
                {
                    num      = num2;
                    minValue = dateTime;
                    changes  = new List <WorkflowChangeAction>();
                }
                using (input = new StringReader(reader.GetString(0)))
                {
                    using (serializationManager.CreateSession())
                    {
                        using (XmlReader reader4 = XmlReader.Create(input))
                        {
                            ActivityChangeAction item = serializer.Deserialize(serializationManager, reader4) as ActivityChangeAction;
                            errors = serializationManager.Errors;
                            if (item == null)
                            {
                                throw new WorkflowMarkupSerializationException(ExecutionStringManager.WorkflowMarkupDeserializationError);
                            }
                            changes.Add(item);
                            item.ApplyTo(rootActivity);
                        }
                    }
                    continue;
                }
            }
            record.EventArgs = new TrackingWorkflowChangedEventArgs(changes, rootActivity);
        }