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 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"); } }
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"); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //create workflow runtime and manager _workflowManager = new WorkflowRuntimeManager( new WorkflowRuntime()); //add the external data exchange service to the runtime ExternalDataExchangeService exchangeService = new ExternalDataExchangeService(); _workflowManager.WorkflowRuntime.AddService(exchangeService); //add our local service _gameService = new GuessingGameService(); exchangeService.AddService(_gameService); //subscribe to the service event that sends us messages _gameService.MessageReceived += new EventHandler <MessageReceivedEventArgs>( gameService_MessageReceived); //handle the terminated event _workflowManager.WorkflowRuntime.WorkflowTerminated += new EventHandler <WorkflowTerminatedEventArgs>( WorkflowRuntime_WorkflowTerminated); }
/// <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); } }
public static void Run() { using (WorkflowRuntimeManager manager = new WorkflowRuntimeManager(new WorkflowRuntime())) { Console.WriteLine("Executing IfElseCodeWorkflow"); //create a dictionary with input arguments Dictionary <String, Object> wfArguments = new Dictionary <string, object>(); //run the first workflow wfArguments.Add("TestNumber", -100); manager.StartWorkflow( typeof(SharedWorkflows.IfElseCodeWorkflow), wfArguments); //run the second workflow wfArguments.Clear(); wfArguments.Add("TestNumber", +200); manager.StartWorkflow( typeof(SharedWorkflows.IfElseCodeWorkflow), wfArguments); //run the third workflow wfArguments.Clear(); wfArguments.Add("TestNumber", 0); manager.StartWorkflow( typeof(SharedWorkflows.IfElseCodeWorkflow), wfArguments); manager.WaitAll(2000); Console.WriteLine("Completed IfElseCodeWorkflow\n\r"); } }
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 } }
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"); } }
public IServiceProvider ConfigureServices(IServiceCollection services) { //MVC services.AddControllersWithViews( options => { options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute()); } ).AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new AbpMvcContractResolver(IocManager.Instance) { NamingStrategy = new CamelCaseNamingStrategy() }; }); IdentityRegistrar.Register(services); AuthConfigurer.Configure(services, _appConfiguration); //WorkflowEngineSampleCode services.AddSingleton <IWorkflowActionProvider, ActionProvider>(); services.AddSingleton((serviceProvider) => WorkflowRuntimeManager.InitWorkflowRuntime(serviceProvider, _appConfiguration)); services.AddSignalR(); // Configure CORS for angular2 UI services.AddCors( options => options.AddPolicy( _defaultCorsPolicyName, builder => builder .WithOrigins( // App:CorsOrigins in appsettings.json can contain more than one address separated by comma. _appConfiguration["App:CorsOrigins"] .Split(",", StringSplitOptions.RemoveEmptyEntries) .Select(o => o.RemovePostFix("/")) .ToArray() ) .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials() ) ); // Swagger - Enable this line and the related lines in Configure method to enable swagger UI ConfigureSwagger(services); // Configure Abp and Dependency Injection return(services.AddAbp <AbpAngularSampleWebHostModule>( // Configure Log4Net logging options => options.IocManager.IocContainer.AddFacility <LoggingFacility>( f => f.UseAbpLog4Net().WithConfig(_hostingEnvironment.IsDevelopment() ? "log4net.config" : "log4net.Production.config" ) ) )); }
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(); } } }
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"); } }
/// <summary> /// Initialize the workflow runtime during startup /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //create workflow runtime and manager _workflowManager = new WorkflowRuntimeManager( new WorkflowRuntime()); #if IDENTIFYEVENTS _workflowManager.WorkflowRuntime.WorkflowIdled += new EventHandler <WorkflowEventArgs>( WorkflowRuntime_WorkflowIdled); #endif //add services to the workflow runtime AddServices(_workflowManager.WorkflowRuntime); }
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"); } }
public static void Run() { using (WorkflowRuntimeManager manager = new WorkflowRuntimeManager(new WorkflowRuntime())) { manager.WorkflowRuntime.StartRuntime(); Console.WriteLine("Executing ExceptionWorkflow Value 1"); ExecuteWorkflow(manager, 1); Console.WriteLine("Completed ExceptionWorkflow Value 1\n\r"); Console.WriteLine("Executing ExceptionWorkflow Value 2"); ExecuteWorkflow(manager, 2); Console.WriteLine("Completed ExceptionWorkflow Value 2\n\r"); } }
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"); } }
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"); } }
/// <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"); } }
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(); } } }
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"); } }
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"); } }
/// <summary> /// Initialize the workflow runtime during startup /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //create workflow runtime and manager _workflowManager = new WorkflowRuntimeManager( new WorkflowRuntime()); //add services to the workflow runtime AddServices(_workflowManager.WorkflowRuntime); _workflowManager.WorkflowRuntime.WorkflowCreated += new EventHandler <WorkflowEventArgs>( WorkflowRuntime_WorkflowCreated); _workflowManager.WorkflowRuntime.WorkflowCompleted += new EventHandler <WorkflowCompletedEventArgs>( WorkflowRuntime_WorkflowCompleted); _workflowManager.WorkflowRuntime.WorkflowPersisted += new EventHandler <WorkflowEventArgs>( WorkflowRuntime_WorkflowPersisted); _workflowManager.WorkflowRuntime.WorkflowUnloaded += new EventHandler <WorkflowEventArgs>( WorkflowRuntime_WorkflowUnloaded); _workflowManager.WorkflowRuntime.WorkflowLoaded += new EventHandler <WorkflowEventArgs>( WorkflowRuntime_WorkflowLoaded); _workflowManager.WorkflowRuntime.WorkflowIdled += new EventHandler <WorkflowEventArgs>( WorkflowRuntime_WorkflowIdled); //initially disable these buttons until a workflow //is selected in the data grid view btnContinue.Enabled = false; btnStop.Enabled = false; //start the runtime prior to checking for any //existing workflows that have been persisted _workflowManager.WorkflowRuntime.StartRuntime(); //load information about any workflows that //have been persisted RetrieveExistingWorkflows(); }
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"); } }
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"); } }
public static void Run() { using (WorkflowRuntimeManager manager = new WorkflowRuntimeManager(new WorkflowRuntime())) { manager.WorkflowRuntime.StartRuntime(); //execute the workflow with parameters that will //result in a normal priced item and shipping Console.WriteLine("Executing SellItemWorkflow"); SalesItem item = new SalesItem(); item.ItemPrice = 10.00; item.Quantity = 4; item.IsNewCustomer = false; ExecuteWorkflow(manager, item); Console.WriteLine("Completed SellItemWorkflow\n\r"); //execute the workflow again with parameters that //will cause a discounted price and shipping Console.WriteLine("Executing SellItemWorkflow (Discounts)"); item = new SalesItem(); item.ItemPrice = 10.00; item.Quantity = 11; item.IsNewCustomer = false; ExecuteWorkflow(manager, item); Console.WriteLine("Completed SellItemWorkflow (Discounts)\n\r"); //execute the workflow once more, this time with the //IsNewCustomer property set to true Console.WriteLine("Executing SellItemWorkflow (New Customer)"); item = new SalesItem(); item.ItemPrice = 10.00; item.Quantity = 11; item.IsNewCustomer = true; ExecuteWorkflow(manager, item); Console.WriteLine("Completed SellItemWorkflow (New Customer)\n\r"); } }
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"); } }
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"); } }
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"); } }
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"); } }
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"); } }
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(); } }