Ejemplo n.º 1
0
        public WorkFlowIfElse()
        {
            IfElseActivity       ifelse_activity   = new IfElseActivity();
            IfElseBranchActivity branch1           = new IfElseBranchActivity();
            CodeCondition        ifelse_condition1 = new CodeCondition();
            DelayActivity        delay_activity    = new DelayActivity();
            CodeActivity         code_branch1      = new CodeActivity();
            CodeActivity         code_branch2      = new CodeActivity();

            branch2 = new IfElseBranchActivity();

            delay_activity.Name                       = "DelayActivity";
            delay_activity.TimeoutDuration            = TimeSpan.Parse("00:00:05");
            delay_activity.InitializeTimeoutDuration += new EventHandler(DelayActivity_InitializeTimeoutDuration);

            code_branch1.Name         = "Code1";
            code_branch2.Name         = "Code2";
            code_branch1.ExecuteCode += new EventHandler(ExecuteCode1);
            code_branch2.ExecuteCode += new EventHandler(ExecuteCode2);

            branch1.Activities.Add(code_branch1);
            branch2.Activities.Add(code_branch2);

            ifelse_condition1.Condition += new EventHandler <ConditionalEventArgs> (IfElseCondition1);
            branch1.Condition            = ifelse_condition1;

            ifelse_activity.Activities.Add(branch1);
            ifelse_activity.Activities.Add(branch2);

            Activities.Add(delay_activity);
            Activities.Add(ifelse_activity);
        }
Ejemplo n.º 2
0
            public WorkFlowDataBinding()
            {
                IfElseActivity       ifelse_activity   = new IfElseActivity();
                IfElseBranchActivity branch1           = new IfElseBranchActivity();
                IfElseBranchActivity branch2           = new IfElseBranchActivity();
                CodeCondition        ifelse_condition1 = new CodeCondition();
                CodeActivity         code_branch1      = new CodeActivity();
                ourCodeActivity      code_branch2      = new ourCodeActivity();

                code_branch1.Name         = "Code1";
                code_branch2.Name         = "Code2";
                code_branch1.ExecuteCode += new EventHandler(ExecuteCode1);

                branch1.Activities.Add(code_branch1);
                branch2.Activities.Add(code_branch2);

                ifelse_condition1.Condition += new EventHandler <ConditionalEventArgs> (IfElseCondition1);
                branch1.Condition            = ifelse_condition1;

                ifelse_activity.Activities.Add(branch1);
                ifelse_activity.Activities.Add(branch2);

                ActivityBind activitybind1 = new ActivityBind();

                activitybind1.Name = "WorkFlowDataBinding";
                activitybind1.Path = "Address";

                //Console.WriteLine ("DependecyParent {0}", this.GetType ().FullName);
                code_branch2.SetBinding(ourCodeActivity.DataProperty, activitybind1);
                Activities.Add(ifelse_activity);
            }
Ejemplo n.º 3
0
        public WorkFlowIfElseRule()
        {
            IfElseActivity ifelse_activity = new IfElseActivity();

            branch1 = new IfElseBranchActivity();

            CodeActivity code_branch1 = new CodeActivity();
            CodeActivity code_branch2 = new CodeActivity();

            branch2 = new IfElseBranchActivity();

            code_branch1.Name         = "Code1";
            code_branch2.Name         = "Code2";
            code_branch1.ExecuteCode += new EventHandler(ExecuteCode1);
            code_branch2.ExecuteCode += new EventHandler(ExecuteCode2);

            branch1.Activities.Add(code_branch1);
            branch2.Activities.Add(code_branch2);

            RuleConditionReference condition1 = new RuleConditionReference();

            condition1.ConditionName = "Condition1";
            RuleExpressionCondition rc = new RuleExpressionCondition("Condition1",
                                                                     RulesBinaryOpTest.check_condition);

            definitions.Conditions.Add(rc);
            branch1.Condition = condition1;

            ifelse_activity.Activities.Add(branch1);
            ifelse_activity.Activities.Add(branch2);

            SetValue(RuleDefinitions.RuleDefinitionsProperty, definitions);
            Activities.Add(ifelse_activity);
        }
Ejemplo n.º 4
0
        public WorkFlowIfElse()
        {
            IfElseActivity       ifelse_activity   = new IfElseActivity();
            IfElseBranchActivity branch1           = new IfElseBranchActivity();
            CodeCondition        ifelse_condition1 = new CodeCondition();
            CodeActivity         code_branch1      = new CodeActivity();
            CodeActivity         code_branch2      = new CodeActivity();

            branch2 = new IfElseBranchActivity();

            code_branch1.Name         = "Code1";
            code_branch2.Name         = "Code2";
            code_branch1.ExecuteCode += new EventHandler(ExecuteCode1);
            code_branch2.ExecuteCode += new EventHandler(ExecuteCode2);

            branch1.Activities.Add(code_branch1);
            branch2.Activities.Add(code_branch2);

            ifelse_condition1.Condition += new EventHandler <ConditionalEventArgs> (IfElseCondition1);
            branch1.Condition            = ifelse_condition1;

            ifelse_activity.Activities.Add(branch1);
            ifelse_activity.Activities.Add(branch2);

            Activities.Add(ifelse_activity);
        }
Ejemplo n.º 5
0
        public void GetActivityByNameAndParent()
        {
            SequentialWorkflowActivity sq = new SequentialWorkflowActivity();
            IfElseActivity             ifelse_activity = new IfElseActivity();
            IfElseBranchActivity       branch1         = new IfElseBranchActivity();
            CodeActivity         code_branch1          = new CodeActivity();
            CodeActivity         code_branch2          = new CodeActivity();
            IfElseBranchActivity branch2 = new IfElseBranchActivity();
            Activity             activity;

            code_branch1.Name    = "Code1";
            code_branch2.Name    = "Code2";
            ifelse_activity.Name = "IfElse";
            sq.Name = "Root";
            branch1.Activities.Add(code_branch1);
            branch2.Activities.Add(code_branch2);
            ifelse_activity.Activities.Add(branch1);
            ifelse_activity.Activities.Add(branch2);
            sq.Activities.Add(ifelse_activity);

            // Getting Code1 activity from root
            activity = sq.GetActivityByName("Code1", true);
            Assert.AreEqual(code_branch1, activity, "C1#1");

            activity = sq.GetActivityByName("Code1", false);
            Assert.AreEqual(code_branch1, activity, "C1#2");

            // Getting Root activity from IfElse
            activity = ifelse_activity.GetActivityByName("Root", true);
            Assert.AreEqual(null, activity, "C1#3");

            activity = ifelse_activity.GetActivityByName("Root", false);
            Assert.AreEqual(sq, activity, "C1#4");

            // Getting Root activity from Code1
            activity = code_branch1.GetActivityByName("Root", true);
            Assert.AreEqual(null, activity, "C1#5");

            activity = code_branch1.GetActivityByName("Root", false);
            Assert.AreEqual(sq, activity, "C1#6");

            // Getting Ifelse activity from Code1
            activity = code_branch1.GetActivityByName("IfElse", true);
            Assert.AreEqual(null, activity, "C1#7");

            activity = code_branch2.GetActivityByName("IfElse", false);
            Assert.AreEqual(ifelse_activity, activity, "C1#8");

            // Parent checks
            Assert.AreEqual(ifelse_activity, branch1.Parent, "C1#9");
            Assert.AreEqual(ifelse_activity, branch2.Parent, "C1#10");
            Assert.AreEqual(null, sq.Parent, "C1#11");
        }
Ejemplo n.º 6
0
 // </snippet193>
 void container1()
 {
     // <snippet194>
     this.CanModifyActivities = true;
     System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
     this.ifElseActivity      = new System.Workflow.Activities.IfElseActivity();
     this.approveIfElseBranch = new System.Workflow.Activities.IfElseBranchActivity();
     this.rejecteIfElseBranch = new System.Workflow.Activities.IfElseBranchActivity();
     this.approve             = new System.Workflow.Activities.CodeActivity();
     this.reject = new System.Workflow.Activities.CodeActivity();
     //
     // ifElseActivity
     //
     this.ifElseActivity.Activities.Add(this.approveIfElseBranch);
     this.ifElseActivity.Activities.Add(this.rejecteIfElseBranch);
     this.ifElseActivity.Name = "ifElseActivity";
     // </snippet194>
 }
Ejemplo n.º 7
0
        protected Basic1StepDialogWorkflow(string formDefinitionFile, string containerLabel)
        {
            CanModifyActivities = true;

            var codecondition1                     = new CodeCondition();
            var setStateActivity6                  = new SetStateActivity();
            var setStateActivity5                  = new SetStateActivity();
            var saveCodeActivity                   = new CodeActivity();
            var ifElseBranchActivity2              = new IfElseBranchActivity();
            var ifElseBranchActivity1              = new IfElseBranchActivity();
            var ifElseActivity                     = new IfElseActivity();
            var finishHandleExternalEventActivity  = new FinishHandleExternalEventActivity();
            var setStateActivity4                  = new SetStateActivity();
            var cancelHandleExternalEventActivity1 = new CancelHandleExternalEventActivity();

            var initCodeActivity                   = new CodeActivity();
            var setStateActivity2                  = new SetStateActivity();
            var drivenActivityOk                   = new EventDrivenActivity();
            var drivenActivityCancel               = new EventDrivenActivity();
            var initializationActivity             = new StateInitializationActivity();
            var setStateActivity1                  = new SetStateActivity();
            var cancelHandleExternalEventActivity2 = new CancelHandleExternalEventActivity();
            var stateInitializationActivity        = new StateInitializationActivity();
            var startState = new StateActivity();
            var globalCancelEventDrivenActivity = new EventDrivenActivity();
            var finalState          = new StateActivity();
            var initializationState = new StateActivity();

            //
            // setStateActivity6
            //
            setStateActivity6.Name            = "setStateActivity6";
            setStateActivity6.TargetStateName = "startState";
            //
            // setStateActivity5
            //
            setStateActivity5.Name            = "setStateActivity5";
            setStateActivity5.TargetStateName = "finalState";
            //
            // saveCodeActivity
            //
            saveCodeActivity.Name         = "saveCodeActivity";
            saveCodeActivity.ExecuteCode += (sender, e) => { SetCultureInfo(); OnFinish(sender, e); };
            //
            // ifElseBranchActivity2
            //
            ifElseBranchActivity2.Activities.Add(setStateActivity6);
            ifElseBranchActivity2.Name = "ifElseBranchActivity2";
            //
            // ifElseBranchActivity1
            //
            ifElseBranchActivity1.Activities.Add(saveCodeActivity);
            ifElseBranchActivity1.Activities.Add(setStateActivity5);
            codecondition1.Condition       += (sender, e) => { SetCultureInfo(); OnValidate(sender, e); };
            ifElseBranchActivity1.Condition = codecondition1;
            ifElseBranchActivity1.Name      = "ifElseBranchActivity1";
            //
            // ifElseActivity
            //
            ifElseActivity.Activities.Add(ifElseBranchActivity1);
            ifElseActivity.Activities.Add(ifElseBranchActivity2);
            ifElseActivity.Name = "ifElseActivity";
            //
            // finishHandleExternalEventActivity
            //
            finishHandleExternalEventActivity.EventName     = "Finish";
            finishHandleExternalEventActivity.InterfaceType = typeof(IFormsWorkflowEventService);
            finishHandleExternalEventActivity.Name          = "finishHandleExternalEventActivity";
            //
            // setStateActivity4
            //
            setStateActivity4.Name            = "setStateActivity4";
            setStateActivity4.TargetStateName = "finalState";
            //
            // cancelHandleExternalEventActivity1
            //
            cancelHandleExternalEventActivity1.EventName     = "Cancel";
            cancelHandleExternalEventActivity1.InterfaceType = typeof(IFormsWorkflowEventService);
            cancelHandleExternalEventActivity1.Name          = "cancelHandleExternalEventActivity1";

            if (formDefinitionFile != null)
            {
                var dataDialogFormActivity = new DataDialogFormActivity
                {
                    ContainerLabel         = containerLabel,
                    FormDefinitionFileName = formDefinitionFile,
                    Name = "dataDialogFormActivity"
                };

                initializationActivity.Activities.Add(dataDialogFormActivity);
            }

            //
            // initCodeActivity
            //
            initCodeActivity.Name         = "initCodeActivity";
            initCodeActivity.ExecuteCode += (sender, e) => { SetCultureInfo(); OnInitialize(sender, e); };
            //
            // setStateActivity2
            //
            setStateActivity2.Name            = "setStateActivity2";
            setStateActivity2.TargetStateName = "startState";
            //
            // DrivenActivity_Ok
            //
            drivenActivityOk.Activities.Add(finishHandleExternalEventActivity);
            drivenActivityOk.Activities.Add(ifElseActivity);
            drivenActivityOk.Name = "DrivenActivity_Ok";
            //
            // DrivenActivity_Cancel
            //
            drivenActivityCancel.Activities.Add(cancelHandleExternalEventActivity1);
            drivenActivityCancel.Activities.Add(setStateActivity4);
            drivenActivityCancel.Name = "DrivenActivity_Cancel";
            //
            // initializationActivity
            //
            initializationActivity.Activities.Add(initCodeActivity);

            initializationActivity.Name = "initializationActivity";
            //
            // setStateActivity1
            //
            setStateActivity1.Name            = "setStateActivity1";
            setStateActivity1.TargetStateName = "finalState";
            //
            // cancelHandleExternalEventActivity2
            //
            cancelHandleExternalEventActivity2.EventName     = "Cancel";
            cancelHandleExternalEventActivity2.InterfaceType = typeof(IFormsWorkflowEventService);
            cancelHandleExternalEventActivity2.Name          = "cancelHandleExternalEventActivity2";
            //
            // stateInitializationActivity
            //
            stateInitializationActivity.Activities.Add(setStateActivity2);
            stateInitializationActivity.Name = "stateInitializationActivity";
            //
            // startState
            //
            startState.Activities.Add(initializationActivity);
            startState.Activities.Add(drivenActivityCancel);
            startState.Activities.Add(drivenActivityOk);
            startState.Name = "startState";
            //
            // globalCancelEventDrivenActivity
            //
            globalCancelEventDrivenActivity.Activities.Add(cancelHandleExternalEventActivity2);
            globalCancelEventDrivenActivity.Activities.Add(setStateActivity1);
            globalCancelEventDrivenActivity.Name = "globalCancelEventDrivenActivity";
            //
            // finalState
            //
            finalState.Name = "finalState";
            //
            // initializationState
            //
            initializationState.Activities.Add(stateInitializationActivity);
            initializationState.Name = "initializationState";
            //
            // AddFormWorkflow
            //
            Activities.Add(initializationState);
            Activities.Add(finalState);
            Activities.Add(globalCancelEventDrivenActivity);
            Activities.Add(startState);
            CompletedStateName     = "finalState";
            DynamicUpdateCondition = null;
            InitialStateName       = "initializationState";
            Name = "AddFormWorkflow";
            CanModifyActivities = false;
        }
Ejemplo n.º 8
0
        private void InitializeComponent()
        {
            Console.WriteLine("1");

            CanModifyActivities = true;
            CodeCondition codecondition1 = new CodeCondition();

            CodeCloseMailProgram2           = new CodeActivity();
            CodeCloseMailProgram3           = new CodeActivity();
            DelayWaitForSentMail2           = new DelayActivity();
            DelayWaitForSentMail3           = new DelayActivity();
            PrepareMail2                    = new CodeActivity();
            PrepareMail3                    = new CodeActivity();
            CodeCloseMailProgram1           = new CodeActivity();
            DelayWaitForSentMail1           = new DelayActivity();
            CodePrepareMail1                = new CodeActivity();
            SeqSendMail2                    = new SequenceActivity();
            SeqSendMail1                    = new SequenceActivity();
            SeqSendMail3                    = new SequenceActivity();
            TerminateFinishNoNeedToReadMail = new TerminateActivity();
            Parallel = new ParallelActivity();
            IfElseBranchActivityNoNeed         = new IfElseBranchActivity();
            IfElseBranchActivityNeedToSendMail = new IfElseBranchActivity();
            NeedToSendMail = new IfElseActivity();

            PrepareMail3.Name         = "PrepareMail3";
            PrepareMail3.ExecuteCode += new EventHandler(PrepareMail3_ExecuteCode);

            CodeCloseMailProgram3.Name         = "CodeCloseMailProgram3";
            CodeCloseMailProgram3.ExecuteCode += new EventHandler(CodeCloseMailProgram3_ExecuteCode);

            DelayWaitForSentMail3.Name            = "DelayWaitForSentMail3";
            DelayWaitForSentMail3.TimeoutDuration = TimeSpan.Parse("00:00:03");

            CodeCloseMailProgram2.Name         = "CodeCloseMailProgram2";
            CodeCloseMailProgram2.ExecuteCode += new EventHandler(CodeCloseMailProgram2_ExecuteCode);

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

            PrepareMail2.Name         = "PrepareMail2";
            PrepareMail2.ExecuteCode += new EventHandler(PrepareMail2_ExecuteCode);

            CodeCloseMailProgram1.Name         = "CodeCloseMailProgram1";
            CodeCloseMailProgram1.ExecuteCode += new EventHandler(CodeCloseMailProgram_ExecuteCode);

            DelayWaitForSentMail1.Name            = "DelayWaitForSentMail1";
            DelayWaitForSentMail1.TimeoutDuration = TimeSpan.Parse("00:00:05");
            CodePrepareMail1.Name         = "CodePrepareMail1";
            CodePrepareMail1.ExecuteCode += new EventHandler(CodeActivity1_ExecuteCode);

            SeqSendMail2.Activities.Add(PrepareMail2);
            SeqSendMail2.Activities.Add(DelayWaitForSentMail2);
            SeqSendMail2.Activities.Add(CodeCloseMailProgram2);
            SeqSendMail2.Name = "SeqSendMail2";

            SeqSendMail3.Activities.Add(PrepareMail3);
            SeqSendMail3.Activities.Add(DelayWaitForSentMail3);
            SeqSendMail3.Activities.Add(CodeCloseMailProgram3);
            SeqSendMail3.Name = "SeqSendMail3";

            SeqSendMail1.Activities.Add(CodePrepareMail1);
            SeqSendMail1.Activities.Add(DelayWaitForSentMail1);
            SeqSendMail1.Activities.Add(CodeCloseMailProgram1);
            SeqSendMail1.Name = "SeqSendMail1";

            TerminateFinishNoNeedToReadMail.Name = "TerminateFinishNoNeedToReadMail";

            Parallel.Activities.Add(SeqSendMail1);
            Parallel.Activities.Add(SeqSendMail2);
            Parallel.Activities.Add(SeqSendMail3);
            Parallel.Name = "Parallel";

            IfElseBranchActivityNoNeed.Activities.Add(TerminateFinishNoNeedToReadMail);
            IfElseBranchActivityNoNeed.Name = "IfElseBranchActivityNoNeed";

            IfElseBranchActivityNeedToSendMail.Activities.Add(Parallel);
            codecondition1.Condition += new EventHandler <ConditionalEventArgs>(IfElseCondition);
            IfElseBranchActivityNeedToSendMail.Condition = codecondition1;
            IfElseBranchActivityNeedToSendMail.Name      = "IfElseBranchActivityNeedToSendMail";

            NeedToSendMail.Activities.Add(IfElseBranchActivityNeedToSendMail);
            NeedToSendMail.Activities.Add(IfElseBranchActivityNoNeed);
            NeedToSendMail.Name = "NeedToSendMail";

            Activities.Add(NeedToSendMail);
            Name = "IfElseParalellWorkFlow";
            CanModifyActivities = false;
        }
Ejemplo n.º 9
0
        void container1()
        {
            System.Workflow.ComponentModel.ActivityBind activitybind1  = new System.Workflow.ComponentModel.ActivityBind();
            System.Workflow.Activities.CodeCondition    codecondition1 = new System.Workflow.Activities.CodeCondition();
            WorkflowRuntime workflowRuntime = new WorkflowRuntime();

            //<snippet140>
            workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
            //</snippet140>

            //<snippet141>
            workflowRuntime.WorkflowAborted += OnWorkflowAborted;
            //</snippet141>
            //<snippet142>
            workflowRuntime.StopRuntime();
            //</snippet142>

            // <snippet143>
            //<snippet144>
            this.CompensateRefund = new System.Workflow.ComponentModel.CompensateActivity();
            //</snippet144>
            //<snippet145>
            this.NoProductFaultHandler = new System.Workflow.ComponentModel.FaultHandlerActivity();
            //</snippet145>
            // <snippet146>
            this.Discontinued = new System.Workflow.Activities.IfElseBranchActivity();
            this.Available    = new System.Workflow.Activities.IfElseBranchActivity();
            // </snippet146>
            //<snippet147>
            this.CompensateOrder = new System.Workflow.ComponentModel.CompensationHandlerActivity();
            //</snippet147>
            // </snippet143>
            //<snippet148>
            this.OrderScope = new System.Workflow.ComponentModel.CompensatableTransactionScopeActivity();
            //</snippet148>
            //<snippet149>
            this.CompensateRefund.TargetActivityName = "OrderScope";
            //</snippet149>
            // <snippet150>
            //<snippet151>
            this.NoProductFault.FaultType = typeof(DiscontinuedProductException);
            //</snippet151>
            this.NoProductFault.Name = "NoProductFault";
            this.NoProductFault.SetBinding(System.Workflow.ComponentModel.ThrowActivity.FaultProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
            // </snippet150>

            // <snippet152>
            this.NoProductFaultHandler.Activities.Add(this.DiscontinuedProduct);
            this.NoProductFaultHandler.Activities.Add(this.CompensateRefund);
            this.NoProductFaultHandler.FaultType = typeof(DiscontinuedProductException);
            this.NoProductFaultHandler.Name      = "NoProductFaultHandler";
            // </snippet152>

            // <snippet153>
            this.Available.Activities.Add(this.Ship);
            codecondition1.Condition += new System.EventHandler <System.Workflow.Activities.ConditionalEventArgs>(this.ProductCheckHandler);
            this.Available.Condition  = codecondition1;
            this.Available.Name       = "Available";
            // </snippet153>

            //<snippet154>
            this.OrderScope.TransactionOptions.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
            //</snippet154>

            // <snippet155>
            this.ReceiverOrder.Name         = "ReceiverOrder";
            this.ReceiverOrder.ExecuteCode += new System.EventHandler(this.ReceiveOrderHandler);
            // </snippet155>
        }
Ejemplo n.º 10
0
        protected Basic1StepDocumentWorkflow(string formDefinitionFile, string containerLabel)
        {
            CanModifyActivities = true;

            var codecondition1     = new CodeCondition();
            var saveCodeActivity   = new CodeActivity();
            var elseBranchActivity = new IfElseBranchActivity();
            var ifValidateActivity = new IfElseBranchActivity();
            var setStateActivity2  = new SetStateActivity();
            var ifElseActivity1    = new IfElseActivity();
            var saveHandleExternalEventActivity1 = new SaveHandleExternalEventActivity();

            var initCodeActivity  = new CodeActivity();
            var setStateActivity1 = new SetStateActivity();
            var cancelHandleExternalEventActivity1 = new CancelHandleExternalEventActivity();
            var eventDrivenActivitySave            = new EventDrivenActivity();
            var stateInitializationActivity        = new StateInitializationActivity();
            var globalEventDrivenActivity          = new EventDrivenActivity();
            var finalState          = new StateActivity();
            var initializationState = new StateActivity();

            //
            // SaveCodeActivity
            //
            saveCodeActivity.Name         = "SaveCodeActivity";
            saveCodeActivity.ExecuteCode += (sender, e) => { SetCultureInfo(); OnFinish(sender, e); };

            //
            // elseBranchActivity
            //
            elseBranchActivity.Name = "elseBranchActivity";
            //
            // ifValidateActivity
            //
            ifValidateActivity.Activities.Add(saveCodeActivity);
            codecondition1.Condition    += (sender, e) => { SetCultureInfo(); OnValidate(sender, e); };
            ifValidateActivity.Condition = codecondition1;
            ifValidateActivity.Name      = "ifValidateActivity";
            //
            // setStateActivity2
            //
            setStateActivity2.Name            = "setStateActivity2";
            setStateActivity2.TargetStateName = "initializationState";
            //
            // ifElseActivity1
            //
            ifElseActivity1.Activities.Add(ifValidateActivity);
            ifElseActivity1.Activities.Add(elseBranchActivity);
            ifElseActivity1.Name = "ifElseActivity1";
            //
            // saveHandleExternalEventActivity1
            //
            saveHandleExternalEventActivity1.EventName     = "Save";
            saveHandleExternalEventActivity1.InterfaceType = typeof(IFormsWorkflowEventService);
            saveHandleExternalEventActivity1.Name          = "saveHandleExternalEventActivity1";

            if (formDefinitionFile != null)
            {
                var documentFormActivity1 = new DocumentFormActivity
                {
                    ContainerLabel = containerLabel,
                    CustomToolbarDefinitionFileName = String.Empty,
                    FormDefinitionFileName          = formDefinitionFile,
                    Name = "documentFormActivity1"
                };

                stateInitializationActivity.Activities.Add(documentFormActivity1);
            }

            //
            // initCodeActivity
            //
            initCodeActivity.Name         = "initCodeActivity";
            initCodeActivity.ExecuteCode += (sender, e) => { SetCultureInfo(); OnInitialize(sender, e); };
            //
            // setStateActivity1
            //
            setStateActivity1.Name            = "setStateActivity1";
            setStateActivity1.TargetStateName = "finalState";
            //
            // cancelHandleExternalEventActivity1
            //
            cancelHandleExternalEventActivity1.EventName     = "Cancel";
            cancelHandleExternalEventActivity1.InterfaceType = typeof(IFormsWorkflowEventService);
            cancelHandleExternalEventActivity1.Name          = "cancelHandleExternalEventActivity1";
            //
            // eventDrivenActivity_Save
            //
            eventDrivenActivitySave.Activities.Add(saveHandleExternalEventActivity1);
            eventDrivenActivitySave.Activities.Add(ifElseActivity1);
            eventDrivenActivitySave.Activities.Add(setStateActivity2);
            eventDrivenActivitySave.Name = "eventDrivenActivity_Save";
            //
            // stateInitializationActivity
            //
            stateInitializationActivity.Activities.Add(initCodeActivity);
            stateInitializationActivity.Name = "stateInitializationActivity";
            //
            // GlobalEventDrivenActivity
            //
            globalEventDrivenActivity.Activities.Add(cancelHandleExternalEventActivity1);
            globalEventDrivenActivity.Activities.Add(setStateActivity1);
            globalEventDrivenActivity.Name = "GlobalEventDrivenActivity";
            //
            // finalState
            //
            finalState.Name = "finalState";
            //
            // initializationState
            //
            initializationState.Activities.Add(stateInitializationActivity);
            initializationState.Activities.Add(eventDrivenActivitySave);
            initializationState.Name = "initializationState";
            //
            // EditFormWorkflow
            //
            Activities.Add(initializationState);
            Activities.Add(finalState);
            Activities.Add(globalEventDrivenActivity);
            CompletedStateName     = "finalState";
            DynamicUpdateCondition = null;
            InitialStateName       = "initializationState";
            Name = "EditFormWorkflow";
            CanModifyActivities = false;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create a workflow by hand
        /// </summary>
        /// <returns></returns>
        private static Activity CreateWorkflowInCode()
        {
            MarkupOnlyBaseWorkflow workflow = null;

            //create the root workflow object
            workflow      = new MarkupOnlyBaseWorkflow();
            workflow.Name = "CodedWorkflow";

            //create an IfElseActivity
            IfElseActivity ifElse
                = new IfElseActivity("ifElseActivity1");

            //
            //Add the left side branch to the IfElseActivity
            //
            IfElseBranchActivity branch
                = new IfElseBranchActivity("ifElseBranchActivity1");

#if COMPILE_RULES_WORKFLOW
            //add a rule condition to the branch
            RuleConditionReference ruleCondition
                = new RuleConditionReference();
            ruleCondition.ConditionName = "IsNumberPositive";
            branch.Condition            = ruleCondition;
#else
            //add a condition to the branch
            CodeCondition condition = new CodeCondition();
            //bind the ConditionEvent to the IsNumberPositive member
            ActivityBind bind = new ActivityBind(
                "CodedWorkflow", "IsNumberPositive");
            condition.SetBinding(CodeCondition.ConditionEvent, bind);
            branch.Condition = condition;
#endif
            //add a custom WriteMessageActivity to the branch
            WriteMessageActivity writeMessage = new WriteMessageActivity();
            writeMessage.Name    = "writeMessagePositive";
            writeMessage.Message = "The number is positive";
            branch.Activities.Add(writeMessage);
            //add the branch to the IfElseActivity
            ifElse.Activities.Add(branch);

            //
            //add the right side branch to the IfElseActivity
            //
            branch = new IfElseBranchActivity("ifElseBranchActivity2");
            //add a custom WriteMessageActivity to the branch
            writeMessage         = new WriteMessageActivity();
            writeMessage.Name    = "writeMessageNotPositive";
            writeMessage.Message = "The number is NOT positive";
            branch.Activities.Add(writeMessage);
            //add the branch to the IfElseActivity
            ifElse.Activities.Add(branch);

            //add the IfElseActivity to the workflow
            workflow.Activities.Add(ifElse);

#if COMPILE_WORKFLOW
            //provide a class name for the new workflow
            workflow.SetValue(WorkflowMarkupSerializer.XClassProperty,
                              "ProWF.MyNewWorkflowClass");
#endif
            return(workflow);
        }
Ejemplo n.º 12
0
        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;
        }