Ejemplo n.º 1
0
        internal static void LeavingState(ActivityExecutionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            StateActivity state = (StateActivity)context.Activity;

            if (StateMachineHelpers.IsLeafState(state))
            {
                StateFinalizationActivity stateFinalization = GetStateFinalization(context);
                if (stateFinalization == null)
                {
                    Complete(context);
                }
                else
                {
                    ExecuteStateFinalization(context, stateFinalization);
                }
            }
            else
            {
                Complete(context);
            }
        }
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection errors            = base.Validate(manager, obj);
            StateFinalizationActivity compositeActivity = obj as StateFinalizationActivity;

            if (compositeActivity == null)
            {
                throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(StateFinalizationActivity).FullName }), "obj");
            }
            StateActivity parent = compositeActivity.Parent as StateActivity;

            if (parent == null)
            {
                errors.Add(new ValidationError(SR.GetError_StateFinalizationParentNotState(), 0x606));
                return(errors);
            }
            foreach (Activity activity3 in parent.EnabledActivities)
            {
                StateFinalizationActivity activity4 = activity3 as StateFinalizationActivity;
                if ((activity4 != null) && (activity4 != compositeActivity))
                {
                    errors.Add(new ValidationError(SR.GetError_MultipleStateFinalizationActivities(), 0x61a));
                    break;
                }
            }
            if (StateMachineHelpers.ContainsEventActivity(compositeActivity))
            {
                errors.Add(new ValidationError(SR.GetError_EventActivityNotValidInStateFinalization(), 0x603));
            }
            return(errors);
        }
Ejemplo n.º 3
0
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);

            StateFinalizationActivity stateFinalization = obj as StateFinalizationActivity;

            if (stateFinalization == null)
            {
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(StateFinalizationActivity).FullName), "obj");
            }

            StateActivity state = stateFinalization.Parent as StateActivity;

            if (state == null)
            {
                validationErrors.Add(new ValidationError(SR.GetError_StateFinalizationParentNotState(), ErrorNumbers.Error_StateHandlerParentNotState));
                return(validationErrors);
            }

            foreach (Activity activity in state.EnabledActivities)
            {
                StateFinalizationActivity childStateFinalization = activity as StateFinalizationActivity;
                if (childStateFinalization != null)
                {
                    if (childStateFinalization == stateFinalization)
                    {
                        continue;
                    }

                    validationErrors.Add(new ValidationError(
                                             SR.GetError_MultipleStateFinalizationActivities(), ErrorNumbers.Error_MultipleStateFinalizationActivities));
                    break;
                }
            }

            if (StateMachineHelpers.ContainsEventActivity(stateFinalization))
            {
                validationErrors.Add(new ValidationError(SR.GetError_EventActivityNotValidInStateFinalization(), ErrorNumbers.Error_EventActivityNotValidInStateHandler));
            }

            return(validationErrors);
        }
Ejemplo n.º 4
0
        private static void ExecuteStateFinalization(ActivityExecutionContext context, StateFinalizationActivity stateFinalization)
        {
            StateMachineExecutionState executionState = GetExecutionState(context);

            ExecuteChild(context, stateFinalization);
        }
		private void InitializeComponent ()
		{
			CanModifyActivities = true;
			CodeCondition codecondition1 = new CodeCondition ();
			ProofReadSetStateQualityNotOK = new SetStateActivity ();
			ProofReadSetStateQualityOK = new SetStateActivity ();
			ProofReadElseBranchActivity2 = new IfElseBranchActivity ();
			ProofReadElseBranch = new IfElseBranchActivity ();
			PrintFinalizationCode = new CodeActivity ();
			PrintSetState = new SetStateActivity ();
			PrintCode = new CodeActivity ();
			PrintDelay = new DelayActivity ();
			ProofReadIfElse = new IfElseActivity ();
			ProofReadDelay = new DelayActivity ();
			CreateInitCode = new CodeActivity ();
			DocumentSetState = new SetStateActivity ();
			CodeDocument = new CodeActivity ();
			CreateDelay = new DelayActivity ();
			PrintFinalization = new StateFinalizationActivity ();
			PrintEventDriven = new EventDrivenActivity ();
			ProofReadEventDriven = new EventDrivenActivity ();
			CreateInitialization = new StateInitializationActivity ();
			CreateDriven = new EventDrivenActivity ();
			End = new StateActivity ();
			Print = new StateActivity ();
			ProofRead = new StateActivity ();
			Create = new StateActivity ();

			// ProofReadSetStateQualityNotOK
			ProofReadSetStateQualityNotOK.Name = "ProofReadSetStateQualityNotOK";
			ProofReadSetStateQualityNotOK.TargetStateName = "Print";

			// ProofReadSetStateQualityOK
			ProofReadSetStateQualityOK.Name = "ProofReadSetStateQualityOK";
			ProofReadSetStateQualityOK.TargetStateName = "End";

			// ProofReadElseBranchActivity2
			ProofReadElseBranchActivity2.Activities.Add (ProofReadSetStateQualityNotOK);
			ProofReadElseBranchActivity2.Name = "ProofReadElseBranchActivity2";

			// ProofReadElseBranch
			ProofReadElseBranch.Activities.Add (ProofReadSetStateQualityOK);
			codecondition1.Condition += new EventHandler <ConditionalEventArgs> (ProofReadIfElseConditionFunction);
			ProofReadElseBranch.Condition = codecondition1;
			ProofReadElseBranch.Name = "ProofReadElseBranch";

			// PrintFinalizationCode
			PrintFinalizationCode.Name = "PrintFinalizationCode";
			PrintFinalizationCode.ExecuteCode += new EventHandler (PrintFinalizationCodeFunction);

			// PrintSetState
			PrintSetState.Name = "PrintSetState";
			PrintSetState.TargetStateName = "End";

			// PrintCode
			PrintCode.Name = "PrintCode";
			PrintCode.ExecuteCode += new EventHandler (PrintCodeFunction);

			// PrintDelay
			PrintDelay.Name = "PrintDelay";
			PrintDelay.TimeoutDuration = TimeSpan.Parse ("00:00:02");

			// ProofReadIfElse
			ProofReadIfElse.Activities.Add (ProofReadElseBranch);
			ProofReadIfElse.Activities.Add (ProofReadElseBranchActivity2);
			ProofReadIfElse.Description = "Quality is OK?";
			ProofReadIfElse.Name = "ProofReadIfElse";

			// ProofReadDelay
			ProofReadDelay.Name = "ProofReadDelay";
			ProofReadDelay.TimeoutDuration = TimeSpan.Parse ("00:00:01");

			// CreateInitCode
			CreateInitCode.Name = "CreateInitCode";
			CreateInitCode.ExecuteCode += new EventHandler (CreateInitCodeFunction);

			// DocumentSetState
			DocumentSetState.Name = "DocumentSetState";
			DocumentSetState.TargetStateName = "ProofRead";

			// CodeDocument
			CodeDocument.Name = "CodeDocument";
			CodeDocument.ExecuteCode += new EventHandler (CodeDocumentFunction);

			// CreateDelay
			CreateDelay.Name = "CreateDelay";
			CreateDelay.TimeoutDuration = TimeSpan.Parse ("00:00:01");

			// PrintFinalization
			PrintFinalization.Activities.Add (PrintFinalizationCode);
			PrintFinalization.Name = "PrintFinalization";

			// PrintEventDriven
			PrintEventDriven.Activities.Add (PrintDelay);
			PrintEventDriven.Activities.Add (PrintCode);
			PrintEventDriven.Activities.Add (PrintSetState);
			PrintEventDriven.Name = "PrintEventDriven";

			// ProofReadEventDriven
			ProofReadEventDriven.Activities.Add (ProofReadDelay);
			ProofReadEventDriven.Activities.Add (ProofReadIfElse);
			ProofReadEventDriven.Name = "ProofReadEventDriven";

			// CreateInitialization
			CreateInitialization.Activities.Add (CreateInitCode);
			CreateInitialization.Name = "CreateInitialization";

			// CreateDriven
			CreateDriven.Activities.Add (CreateDelay);
			CreateDriven.Activities.Add (CodeDocument);
			CreateDriven.Activities.Add (DocumentSetState);
			CreateDriven.Name = "CreateDriven";

			// End
			End.Name = "End";

			// Print
			Print.Activities.Add (PrintEventDriven);
			Print.Activities.Add (PrintFinalization);
			Print.Name = "Print";

			// ProofRead
			ProofRead.Activities.Add (ProofReadEventDriven);
			ProofRead.Name = "ProofRead";

			// Create
			Create.Activities.Add (CreateDriven);
			Create.Activities.Add (CreateInitialization);
			Create.Name = "Create";

			// DocumentCreation
			Activities.Add (Create);
			Activities.Add (ProofRead);
			Activities.Add (Print);
			Activities.Add (End);
			CompletedStateName = "End";
			InitialStateName = "Create";
			Name = "DocumentCreation";
			CanModifyActivities = false;
		}
Ejemplo n.º 6
0
 internal void OnAddStateFinalization(object sender, EventArgs e)
 {
     StateFinalizationActivity stateFinalization = new StateFinalizationActivity();
     AddChild(stateFinalization);
 }
 internal void OnAddStateFinalization(object sender, EventArgs e)
 {
     StateFinalizationActivity child = new StateFinalizationActivity();
     this.AddChild(child);
 }