Пример #1
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();

                //run the first workflow
                Console.WriteLine("Executing WhileWorkflow Test 1");
                wfArguments.Add("TestNumber", 5);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.WhileWorkflow), wfArguments);
                manager.WaitAll(2000);
                Console.WriteLine("Completed WhileWorkflow Test 1\n\r");

                //run the second workflow
                Console.WriteLine("Executing WhileWorkflow Test 2");
                wfArguments.Clear();
                wfArguments.Add("TestNumber", 0);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.WhileWorkflow), wfArguments);
                manager.WaitAll(2000);
                Console.WriteLine("Completed WhileWorkflow Test 2\n\r");
            }
        }
Пример #2
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                manager.MessageEvent
                    += new EventHandler <WorkflowLogEventArgs>(manager_MessageEvent);
                manager.WorkflowRuntime.WorkflowSuspended
                    += new EventHandler <WorkflowSuspendedEventArgs>(WorkflowRuntime_WorkflowSuspended);


                Console.WriteLine("Executing Workflow1");
                WorkflowInstanceWrapper instance
                    = manager.StartWorkflow(
                          typeof(ConsoleSuspend.Workflow1), null);
                manager.WaitAll(10000);

                if (isSuspended)
                {
                    instance.WorkflowInstance.Resume();
                }

                manager.WaitAll(1000);
                Console.WriteLine("Completed Workflow1\n\r");
            }
        }
Пример #3
0
        public static void Run()
        {
#if USE_APP_CONFIG
            //load the tracking service via the app.config.
            //requires a reference to System.Configuration
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(
                             new WorkflowRuntime("WorkflowRuntime")))
#else
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
#endif
            {
#if (!USE_APP_CONFIG)
                //add services that we require
                AddServices(manager.WorkflowRuntime);
#endif
#if CUSTOM_PROFILE
                //add a custom tracking profile for this workflow
                AddCustomTrackingProfile();
#endif
                //start the runtime
                manager.WorkflowRuntime.StartRuntime();

#if RULES_TRACKING
                Console.WriteLine("Executing TrackingRulesWorkflow");
                WorkflowInstanceWrapper instance =
                    manager.StartWorkflow(
                        typeof(SharedWorkflows.TrackingRulesWorkflow), null);
                manager.WaitAll(2000);
                Console.WriteLine("Completed TrackingRulesWorkflow\n\r");
#elif USER_DATA_TRACKING
                Console.WriteLine("Executing TrackingExampleWorkflow");
                WorkflowInstanceWrapper instance =
                    manager.StartWorkflow(
                        typeof(SharedWorkflows.TrackingUserDataWorkflow), null);
                manager.WaitAll(2000);
                Console.WriteLine("Completed TrackingExampleWorkflow\n\r");
#else
                Console.WriteLine("Executing TrackingExampleWorkflow");
                WorkflowInstanceWrapper instance =
                    manager.StartWorkflow(
                        typeof(SharedWorkflows.TrackingExampleWorkflow), null);
                manager.WaitAll(2000);
                Console.WriteLine("Completed TrackingExampleWorkflow\n\r");
#endif

#if (!CUSTOM_SERVICE)
                //query and display tracking data for this single instance
                TrackingConsoleWriter trackingWriter
                    = new TrackingConsoleWriter(_connStringTracking);
                trackingWriter.DisplayTrackingData(instance.Id);
#endif

#if CUSTOM_PROFILE
                //delete the tracking profile that we created
                DeleteCustomTrackingProfile();
#endif
            }
        }
Пример #4
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //configure services for the workflow runtime
                AddServices(manager.WorkflowRuntime);
                manager.WorkflowRuntime.StartRuntime();

                //run the workflow using a transfer value that should work

                Console.WriteLine("Executing 1st AccountTransferWorkflow");
                DisplayTestData(1001, 2002, "before");

                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("FromAccountId", 1001);
                wfArguments.Add("ToAccountId", 2002);
                wfArguments.Add("Amount", (Decimal)25.00);
                //start the workflow
                WorkflowInstanceWrapper instance = manager.StartWorkflow(
                    typeof(SharedWorkflows.AccountTransferWorkflow), wfArguments);
                manager.WaitAll(5000);
                if (instance.Exception != null)
                {
                    Console.WriteLine("EXCEPTION: {0}",
                                      instance.Exception.Message);
                }
                DisplayTestData(1001, 2002, "after");
                Console.WriteLine("Completed 1st AccountTransferWorkflow\n\r");

                //run the workflow again using an amount that should fail

                Console.WriteLine("Executing 2nd AccountTransferWorkflow");
                DisplayTestData(1001, 2002, "before");

                wfArguments = new Dictionary <string, object>();
                wfArguments.Add("FromAccountId", 1001);
                wfArguments.Add("ToAccountId", 2002);
                //this transfer amount should exceed the available balance
                wfArguments.Add("Amount", (Decimal)200.00);
                instance = manager.StartWorkflow(
                    typeof(SharedWorkflows.AccountTransferWorkflow), wfArguments);
                manager.WaitAll(5000);
                if (instance.Exception != null)
                {
                    Console.WriteLine("EXCEPTION: {0}",
                                      instance.Exception.Message);
                }
                DisplayTestData(1001, 2002, "after");
                Console.WriteLine("Completed 2nd AccountTransferWorkflow\n\r");
            }
        }
Пример #5
0
        /// <summary>
        /// Execute the workflow
        /// </summary>
        /// <param name="item"></param>
        private static void ExecuteWorkflow(
            WorkflowRuntimeManager manager, Int32 testNumber)
        {
            //create a dictionary with input arguments
            Dictionary <String, Object> wfArguments
                = new Dictionary <string, object>();

            wfArguments.Add("TestNumber", testNumber);

            //execute the workflow
#if EXCEPTION_HANDLED
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.ExceptionHandledWorkflow), wfArguments);
#elif EXCEPTION_HANDLED2
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.ExceptionHandled2Workflow), wfArguments);
#elif EXCEPTION_COMPOSITE
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.ExceptionCompositeWorkflow), wfArguments);
#elif EXCEPTION_RETHROW
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.ExceptionRethrowWorkflow), wfArguments);
#else
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.ExceptionWorkflow), wfArguments);
#endif
            manager.WaitAll(5000);

            if (instance.Exception != null)
            {
                Console.WriteLine("EXCEPTION: {0}: {1}",
                                  instance.Exception.GetType().Name,
                                  instance.Exception.Message);
            }
        }
Пример #6
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //configure services for the workflow runtime
                AddServices(manager.WorkflowRuntime);
                manager.WorkflowRuntime.StartRuntime();

                Console.WriteLine("Executing OrderEntryWorkflow");
                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("OrderId", 1234);
                wfArguments.Add("OrderAccountId", 1001);
                wfArguments.Add("ToAccountId", 9000);
                wfArguments.Add("ItemId", 52);
                wfArguments.Add("Quantity", 2);
                wfArguments.Add("Amount", (Decimal)225.00);
                //start the workflow
                WorkflowInstanceWrapper instance = manager.StartWorkflow(
                    typeof(SharedWorkflows.OrderEntryWorkflow), wfArguments);
                manager.WaitAll(20000);
                if (instance.Exception != null)
                {
                    Console.WriteLine("EXCEPTION: {0}",
                                      instance.Exception.Message);
                }
                Console.WriteLine("Completed OrderEntryWorkflow\n\r");
            }
        }
Пример #7
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //start the runtime
                manager.WorkflowRuntime.StartRuntime();
                Console.WriteLine("Executing Workflow");
                //pass a number to test
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("TheNumber", 1);
                //start the workflow
#if CODE_SEPARATION
                WorkflowInstanceWrapper instance =
                    manager.StartWorkflow(typeof(
                                              SharedWorkflows.CodeSeparationWorkflow), wfArguments);
#else
                WorkflowInstanceWrapper instance =
                    manager.StartWorkflow(typeof(
                                              SharedWorkflows.CodeOnlyWorkflow), wfArguments);
#endif
                //wait for the workflow to complete
                manager.WaitAll(2000);
                Console.WriteLine("Completed Workflow\n\r");
            }
        }
        public override void ExecuteUnderTransaction(JobExecutionContext context)
        {
            logger.Info("Start QueueMailAccountJob....");

            var smtpServer       = context.JobDetail.JobDataMap["SmtpServer"] != null ? context.JobDetail.JobDataMap["SmtpServer"].ToString() : string.Empty;
            var fromEmailAddress = context.JobDetail.JobDataMap["FromEmailAddress"] != null ? context.JobDetail.JobDataMap["FromEmailAddress"].ToString() : string.Empty;
            var bccEmailAddress  = context.JobDetail.JobDataMap["BccEmailAddress"] != null ? context.JobDetail.JobDataMap["BccEmailAddress"].ToString() : string.Empty;

            if (string.IsNullOrEmpty(smtpServer) || string.IsNullOrEmpty(fromEmailAddress))
            {
                throw new NullReferenceException("QueueMailAccountJob: fromEmailAddress and smtpServer must not be null");
            }

            var accountQueueMailService = (IAccountQueueMailService)ServiceLocator.Current.GetService(typeof(IAccountQueueMailService));

            if (accountQueueMailService == null)
            {
                throw new NullReferenceException("accountQueueMailService must not be null");
            }

            var accountMailQueues = accountQueueMailService.GetAccountMailQueueByStatus(QueueStatusTypeEnum.CREATED);

            using (var workflowRuntime = new WorkflowRuntime())
            {
                workflowRuntime.AddService(new TerminateHelperService());

                using (var manager = new WorkflowRuntimeManager(workflowRuntime))
                {
                    manager.MessageEvent += manager_MessageEvent;

                    for (var i = 0; i < accountMailQueues.Count; i++)
                    {
                        var wfArguments = new Dictionary <string, object> {
                            { "AccountMailQueueId", accountMailQueues[i].Id },
                            { "SmtpServer", smtpServer },
                            { "FromEmailAddress", fromEmailAddress },
                            { "BccEmailAddress", bccEmailAddress }
                        };
                        var wrapper  = manager.StartWorkflow(typeof(MailAccountWorkflow), wfArguments);
                        var waitTest = manager.WaitOne(wrapper.Id, 30000);

                        if (wrapper.Exception != null)
                        {
                            logger.Error(wrapper.Exception.Message);
                        }
                    }

                    manager.WaitAll(300000);
                    manager.ClearAllWorkflows();
                }
            }
        }
Пример #9
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                manager.WorkflowRuntime.StartRuntime();

                Console.WriteLine("Executing CompensateWorkflow");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.CompensateWorkflow), null);
                manager.WaitAll(5000);
                Console.WriteLine("Completed CompensateWorkflow");
            }
        }
Пример #10
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                manager.WorkflowRuntime.StartRuntime();

                //
                //add a new activity to this workflow
                //
                Console.WriteLine("Executing SelfUpdatingWorkflow for 1001");
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("TestNumber", 1001);
                //pass the Type of new activity to add along with the
                //dependency property to bind
                wfArguments.Add("NewActivityType",
                                typeof(NewFunctionActivity));
                wfArguments.Add("NumberProperty",
                                NewFunctionActivity.TestNumberProperty);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.SelfUpdatingWorkflow), wfArguments);
                manager.WaitAll(5000);
                Console.WriteLine("Completed SelfUpdatingWorkflow for 1001\n\r");

                //
                //let this activity execute normally without changes
                //
                Console.WriteLine("Executing SelfUpdatingWorkflow for 2002");
                wfArguments.Clear();
                wfArguments.Add("TestNumber", 2002);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.SelfUpdatingWorkflow), wfArguments);
                manager.WaitAll(5000);
                Console.WriteLine("Completed SelfUpdatingWorkflow for 2002\n\r");
            }
        }
Пример #11
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                manager.WorkflowRuntime.StartRuntime();

                //handle the WorkflowCreated event
                manager.WorkflowRuntime.WorkflowCreated
                    += new EventHandler <WorkflowEventArgs>(
                           WorkflowRuntime_WorkflowCreated);

                //
                //modify the rule for this workflow
                //
                Console.WriteLine("Executing DynamicConditionWorkflow - 1st");
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("TestNumber", 200);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicConditionWorkflow), wfArguments);
                manager.WaitAll(5000);
                Console.WriteLine("Completed DynamicConditionWorkflow - 1st\n\r");

                //
                //let this activity execute normally without changes
                //
                Console.WriteLine("Executing DynamicConditionWorkflow - 2nd");
                wfArguments.Clear();
                wfArguments.Add("TestNumber", 200);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicConditionWorkflow), wfArguments);
                manager.WaitAll(5000);
                Console.WriteLine("Completed DynamicConditionWorkflow - 2nd\n\r");
            }
        }
Пример #12
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //start the runtime
                manager.WorkflowRuntime.StartRuntime();

                Console.WriteLine("Executing InvokeWebServiceWorkflow");
                WorkflowInstanceWrapper instance =
                    manager.StartWorkflow(
                        typeof(InvokeWebServiceWorkflow), null);
                manager.WaitAll(10000);
                Console.WriteLine("Completed InvokeWebServiceWorkflow\n\r");
            }
        }
Пример #13
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //start the runtime
                manager.WorkflowRuntime.StartRuntime();

                Console.WriteLine("Executing Workflow");
                //pass a number to test
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("TheNumber", 1);

                try
                {
                    //start the workflow
#if MARKUP_ONLY_RULES
                    WorkflowInstanceWrapper instance =
                        manager.StartWorkflow(
                            "MarkupOnlyRulesWorkflow.xoml",
                            "MarkupOnlyRulesWorkflow.rules",
                            wfArguments);
#else
                    WorkflowInstanceWrapper instance =
                        manager.StartWorkflow(
                            "MarkupOnlyWorkflow.xoml", null, wfArguments);
#endif
                }
                catch (WorkflowValidationFailedException e)
                {
                    foreach (ValidationError error in e.Errors)
                    {
                        Console.WriteLine(error.ErrorText);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                //wait for the workflow to complete
                manager.WaitAll(2000);
                Console.WriteLine("Completed Workflow\n\r");
            }
        }
Пример #14
0
        /// <summary>
        /// Execute the SellItemWorkflow
        /// </summary>
        /// <param name="item"></param>
        private static void ExecuteWorkflow(
            WorkflowRuntimeManager manager, SalesItem item)
        {
            DisplaySalesItem(item, "Before");

            //create a dictionary with input arguments
            Dictionary <String, Object> wfArguments
                = new Dictionary <string, object>();

            wfArguments.Add("SalesItem", item);

            //execute the workflow
#if PRIORITY_TEST
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemPriorityWorkflow), wfArguments);
#elif METHODS_TEST
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemMethodsWorkflow), wfArguments);
#elif INVOKE_METHOD_TEST
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemMethods2Workflow), wfArguments);
#elif UPDATE_TEST
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemUpdateWorkflow), wfArguments);
#elif RULESET_IN_CODE_TEST
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemInCodeWorkflow), wfArguments);
#elif SERIALIZED_RULESET_TEST
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemSerializedWorkflow), wfArguments);
#else
            WorkflowInstanceWrapper instance = manager.StartWorkflow(
                typeof(SharedWorkflows.SellItemWorkflow), wfArguments);
#endif
            manager.WaitAll(5000);

            if (instance.Exception != null)
            {
                Console.WriteLine("EXCEPTION: {0}",
                                  instance.Exception.Message);
            }
            else
            {
                DisplaySalesItem(item, "After");
            }
        }
Пример #15
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //configure services for the workflow runtime
                AddServices(manager.WorkflowRuntime);
                manager.WorkflowRuntime.StartRuntime();

                Console.WriteLine("Executing BatchedWorkWorkflow");
                //start the workflow
                manager.StartWorkflow(
                    typeof(SharedWorkflows.BatchedWorkWorkflow), null);
                manager.WaitAll(5000);
                Console.WriteLine("Completed BatchedWorkWorkflow\n\r");
            }
        }
Пример #16
0
        public override void ExecuteUnderTransaction(JobExecutionContext context)
        {
            logger.Info("Start ChargingOrderJob....");

            var paymentUrlProvider       = context.JobDetail.JobDataMap["PaymentUrlProvider"].ToString();
            var backupPaymentUrlProvider = context.JobDetail.JobDataMap["BackupPaymentUrlProvider"].ToString();

            var orderService = (IOrderService)ServiceLocator.Current.GetService(typeof(IOrderService));

            if (orderService == null)
            {
                throw new NullReferenceException("orderService must not be null");
            }

            var orders = orderService.GetOrdersByStatus(OrderStatusEnum.Verified);

            using (var workflowRuntime = new WorkflowRuntime())
            {
                workflowRuntime.AddService(new TerminateHelperService());

                using (var manager = new WorkflowRuntimeManager(workflowRuntime))
                {
                    manager.MessageEvent += manager_MessageEvent;

                    for (var i = 0; i < orders.Count; i++)
                    {
                        var wfArguments = new Dictionary <string, object> {
                            { "OrderId", orders[i].Id },
                            { "PaymentProviderUrl", paymentUrlProvider },
                            { "BackupPaymentProviderUrl", backupPaymentUrlProvider }
                        };
                        var wrapper  = manager.StartWorkflow(typeof(ChargingOrderWorkflow), wfArguments);
                        var testWait = manager.WaitOne(wrapper.Id, 30000);

                        if (wrapper.Exception != null)
                        {
                            logger.Error(wrapper.Exception.Message);
                        }
                    }

                    manager.WaitAll(300000);
                    manager.ClearAllWorkflows();
                }
            }
        }
Пример #17
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //add services to the workflow runtime
                AddServices(manager.WorkflowRuntime);
                manager.WorkflowRuntime.StartRuntime();

                //run the first workflow
                Console.WriteLine("Executing CorrelationExampleWorkflow");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.CorrelationExampleWorkflow), null);
                manager.WaitAll(10000);

                Console.WriteLine("Completed CorrelationExampleWorkflow\n\r");
            }
        }
Пример #18
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();

                //run the first workflow
                Console.WriteLine("Executing ParallelDelayWorkflow");
                wfArguments.Add("TestNumber", 2);
                manager.StartWorkflow(
                    typeof(SharedWorkflows.ParallelDelayWorkflow), wfArguments);
                manager.WaitAll(2000);
                Console.WriteLine("Completed ParallelDelayWorkflow\n\r");
            }
        }
Пример #19
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(
                             new WorkflowRuntime("WorkflowRuntime")))
            {
                //add services to the workflow runtime
                AddServices(manager.WorkflowRuntime);
                manager.WorkflowRuntime.StartRuntime();

                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();

                //run the first workflow
                Console.WriteLine("Executing BalanceAdjustmentWorkflow");
                wfArguments.Add("Id", 101);
                wfArguments.Add("Adjustment", -25.00);
                WorkflowInstanceWrapper instance = manager.StartWorkflow(
                    typeof(SharedWorkflows.BalanceAdjustmentWorkflow),
                    wfArguments);
                manager.WaitAll(2000);

                Account account
                    = instance.OutputParameters["Account"] as Account;
                if (account != null)
                {
                    Console.WriteLine(
                        "Revised Account: {0}, Name={1}, Bal={2:C}",
                        account.Id, account.Name, account.Balance);
                }
                else
                {
                    Console.WriteLine("Invalid Account Id\n\r");
                }

                Console.WriteLine("Completed BalanceAdjustmentWorkflow\n\r");
            }
        }
Пример #20
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                List <String> items = new List <string>();
                items.Add("sandwich");
                items.Add("drink");
                items.Add("fries");
                items.Add("drink");
                items.Add("combo");
                wfArguments.Add("LineItems", items);

                Console.WriteLine("Executing CAGWorkflow");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.CAGWorkflow), wfArguments);
                manager.WaitAll(3000);
                Console.WriteLine("Completed CAGWorkflow\n\r");
            }
        }
Пример #21
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();

                //create and populate a list of strings to process
                List <String> inputList = new List <string>();
                inputList.Add("one");
                inputList.Add("two");
                inputList.Add("three");
                wfArguments.Add("InputList", inputList);

                Console.WriteLine("Executing ReplicatorWorkflow");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.ReplicatorWorkflow), wfArguments);
                manager.WaitAll(2000);
                Console.WriteLine("Completed ReplicatorWorkflow\n\r");
            }
        }
Пример #22
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //add services to the workflow runtime
                AddServices(manager.WorkflowRuntime);
                manager.WorkflowRuntime.StartRuntime();

                //start the workflow
                Console.WriteLine("Executing ScopeExampleWorkflow");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.ScopeExampleWorkflow), null);

                //allow the main line of the workflow to execute
                Thread.Sleep(3000);
                //fire some events
                _scopeService.OnEventOne();
                Thread.Sleep(100);
                _scopeService.OnEventOne();
                Thread.Sleep(100);
                _scopeService.OnEventOne();
                Thread.Sleep(100);
                _scopeService.OnEventTwo();
                Thread.Sleep(100);
                _scopeService.OnEventOne();
                //let the main line execute by itself again
                Thread.Sleep(3000);
                //signal that the workflow should stop
                _scopeService.OnEventStop();

                manager.WaitAll(10000);

                Console.WriteLine("Completed ScopeExampleWorkflow\n\r");
            }
        }
Пример #23
0
        public static void Run()
        {
            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                manager.WorkflowRuntime.StartRuntime();

                //handle the WorkflowSuspended event
                manager.WorkflowRuntime.WorkflowSuspended
                    += new EventHandler <WorkflowSuspendedEventArgs>(
                           WorkflowRuntime_WorkflowSuspended);

                //
                //add a new activity to this workflow
                //
                Console.WriteLine("Executing DynamicWorkflow for 1001");
                Dictionary <String, Object> wfArguments
                            = new Dictionary <string, object>();
                _testNumber = 1001;
                wfArguments.Add("TestNumber", _testNumber);
#if UPDATES_RESTRICTED
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicRestrictedWorkflow), wfArguments);
#else
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicWorkflow), wfArguments);
#endif
                manager.WaitAll(5000);
                Console.WriteLine("Completed DynamicWorkflow for 1001\n\r");

                //
                //let this activity execute normally without changes
                //
                Console.WriteLine("Executing DynamicWorkflow for 2002");
                wfArguments.Clear();
                _testNumber = 2002;
                wfArguments.Add("TestNumber", _testNumber);
#if UPDATES_RESTRICTED
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicRestrictedWorkflow), wfArguments);
#else
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicWorkflow), wfArguments);
#endif
                manager.WaitAll(5000);
                Console.WriteLine("Completed DynamicWorkflow for 2002\n\r");

                //
                //remove the first activity from this worfklow
                //
                Console.WriteLine("Executing DynamicWorkflow for 3003");
                wfArguments.Clear();
                _testNumber = 3003;
                wfArguments.Add("TestNumber", _testNumber);
#if UPDATES_RESTRICTED
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicRestrictedWorkflow), wfArguments);
#else
                manager.StartWorkflow(
                    typeof(SharedWorkflows.DynamicWorkflow), wfArguments);
#endif
                manager.WaitAll(5000);
                Console.WriteLine("Completed DynamicWorkflow for 3003\n\r");
            }
        }
Пример #24
0
        public static void Run()
        {
            //create a workflow in code
            Activity workflow = CreateWorkflowInCode();

            //serialize the new workflow to a markup file
            SerializeToMarkup(workflow, "SerializedCodedWorkflow.xoml");

#if COMPILE_WORKFLOW
            //create a new assembly containing the workflow
            CompileWorkflow("SerializedCodedWorkflow.xoml",
                            "MyNewAssembly.dll");
#endif

            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(new WorkflowRuntime()))
            {
                //start the runtime
                manager.WorkflowRuntime.StartRuntime();

                Console.WriteLine("Executing Workflow");
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("TheNumber", 1);

                try
                {
#if COMPILE_WORKFLOW
                    //get a Type object for the newly compiled workflow
                    Type workflowType = Type.GetType(
                        "ProWF.MyNewWorkflowClass,MyNewAssembly");
                    //start the workflow using the Type
                    WorkflowInstanceWrapper instance =
                        manager.StartWorkflow(workflowType, wfArguments);
#else
                    //start the workflow
                    WorkflowInstanceWrapper instance =
                        manager.StartWorkflow(
                            "SerializedCodedWorkflow.xoml",
                            null, wfArguments);
#endif
                }
#if !COMPILE_WORKFLOW
                catch (WorkflowValidationFailedException e)
                {
                    foreach (ValidationError error in e.Errors)
                    {
                        Console.WriteLine(error.ErrorText);
                    }
                }
#endif
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                //wait for the workflow to complete
                manager.WaitAll(2000);
                Console.WriteLine("Completed Workflow\n\r");
            }
        }
Пример #25
0
        public static void Run()
        {
            Console.WriteLine("Running test configured with App.Config");

            using (WorkflowRuntimeManager manager
                       = new WorkflowRuntimeManager(
                             new WorkflowRuntime("WorkflowRuntime")))
            {
                //add event handler to log messages from the manager
                manager.MessageEvent += delegate(
                    Object sender, WorkflowLogEventArgs e)
                {
                    Console.WriteLine(e.Message);
                };

                //start the workflow runtime. It will also autostart if
                //we don't do it here.
                manager.WorkflowRuntime.StartRuntime();

                //create a dictionary with input arguments
                Dictionary <String, Object> wfArguments
                    = new Dictionary <string, object>();
                wfArguments.Add("InputString", "one");
                //run the workflow
                manager.StartWorkflow(
                    typeof(SharedWorkflows.Workflow1), wfArguments);

                //run another instance with different parameters
                wfArguments.Clear();
                wfArguments.Add("InputString", "two");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.Workflow1), wfArguments);

                //run another instance with different parameters
                wfArguments.Clear();
                wfArguments.Add("InputString", "three");
                manager.StartWorkflow(
                    typeof(SharedWorkflows.Workflow1), wfArguments);

                //wait for all workflow instances to complete
                manager.WaitAll(15000);

                //display the results from all workflow instances
                foreach (WorkflowInstanceWrapper wrapper
                         in manager.Workflows.Values)
                {
                    if (wrapper.OutputParameters.ContainsKey("Result"))
                    {
                        Console.WriteLine(wrapper.OutputParameters["Result"]);
                    }
                    else
                    {
                        //must be a problem - see if there is an exception
                        if (wrapper.Exception != null)
                        {
                            Console.WriteLine("{0} - Exception: {1}",
                                              wrapper.Id, wrapper.Exception.Message);
                        }
                    }
                }
                manager.ClearAllWorkflows();
            }
        }