- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
AZURE .NET SERVICES WORKFLOWS in Visual C#
CHAPTER 7 AZURE .NET SERVICES WORKFLOWS Data Matrix 2d Barcode Maker In C# Using Barcode printer for Visual Studio .NET Control to generate, create ECC200 image in VS .NET applications. www.OnBarcode.comRecognize Data Matrix In Visual C#.NET Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comGo back to the State Machine Workflow design surface and drag and drop four state artifacts onto the design surface and name them WaitingForShoppingCartItem, ShoppingCartItemPlaced, ItemCheckOut, and CartClosed, as shown in Figure 7-8. The process to work out the logic of state transaction is the same as the process to work on the standard WF state machine. Please see http://msdn.microsoft.com/ en-us/netframework/aa663328.aspx to understand Microsoft Windows Workflow Foundation and how to work on the WF state machine design in Visual Studio. EAN-13 Supplement 5 Encoder In C# Using Barcode drawer for Visual Studio .NET Control to generate, create European Article Number 13 image in VS .NET applications. www.OnBarcode.comMatrix Barcode Drawer In Visual C# Using Barcode encoder for .NET framework Control to generate, create Matrix 2D Barcode image in .NET applications. www.OnBarcode.comFigure 7-8. States defined in ShoppingCartWorkflow state machine 5. Now let's build up the state machine used to handle a shopping cart service. Implement a code-behind for the ShoppingCartItemWorkflow state machine as shown in Listing 7-8. The event handler functions in the code-behind will be bound to events in the state machine during the next state machine design. This shopping cart example has four state transaction handlers from the code-behind. These handlers are generated from the WF design surface; insert the code from the listing into the handlers bodies. (Right-click the design surface and select View Code, or press F7, to get into the state transaction handler body.) There is an array called NextItem defined in each handler, which is the data contract of the WCF services in this example. The member items in the array also have the type of NextItem that is used to simulate the business activities, such as shopping cart data insert, update, or delete. The state will be transacted depending on the activities in the handler. Paint PDF 417 In Visual C# Using Barcode printer for Visual Studio .NET Control to generate, create PDF-417 2d barcode image in Visual Studio .NET applications. www.OnBarcode.comMake Code 128C In C# Using Barcode maker for .NET Control to generate, create Code-128 image in .NET applications. www.OnBarcode.comCHAPTER 7 AZURE .NET SERVICES WORKFLOWS
QR Code Encoder In C#.NET Using Barcode drawer for Visual Studio .NET Control to generate, create QR image in Visual Studio .NET applications. www.OnBarcode.comUCC - 14 Printer In Visual C# Using Barcode drawer for Visual Studio .NET Control to generate, create ITF14 image in Visual Studio .NET applications. www.OnBarcode.comListing 7-8. Code-behind for ShoppingCartWorkflow using using using using using using using using using using using using using using using using System; System.ComponentModel; System.ComponentModel.Design; System.Collections; System.Drawing; System.Linq; System.Workflow.ComponentModel.Compiler; System.Workflow.ComponentModel.Serialization; System.Workflow.ComponentModel; System.Workflow.ComponentModel.Design; System.Workflow.Runtime; System.Workflow.Activities; System.Workflow.Activities.Rules; System.ServiceModel.Web; ShoppingCartServiceLibrary; System.ServiceModel; Data Matrix 2d Barcode Generator In Visual Basic .NET Using Barcode creation for .NET framework Control to generate, create ECC200 image in .NET applications. www.OnBarcode.comECC200 Generator In Java Using Barcode maker for Java Control to generate, create ECC200 image in Java applications. www.OnBarcode.comnamespace ShoppingCartWorkflows { using ShoppingCartServiceLibrary; public sealed partial class ShoppingCartItemWorkflow : StateMachineWorkflowActivity { public ShoppingCartItem receivedShoppingCartItem; public string receivedId; public ShoppingCartItem currentShoppingCartItem; public CreditCardPayment ShoppingCartItemCreditCardPayment; public ShoppingCartItemWorkflow() { InitializeComponent(); } private void OnShoppingCartItemPlacedCode_ExecuteCode(object sender, EventArgs { var id = WorkflowEnvironment.WorkflowInstanceId.ToString(); currentShoppingCartItem = new ShoppingCartItem(); currentShoppingCartItem.ShoppingCartItemId = id; currentShoppingCartItem.Price = receivedShoppingCartItem.Price; currentShoppingCartItem.ItemName = receivedShoppingCartItem.ItemName; currentShoppingCartItem.NextItem = new NextItem[] { new NextItem { Relative = ShoppingCartItem.ENDPOINT_CREDITCARD_PAYMENT, Uri = string.Format("{0}{1}", ShoppingCartItem.CREDIT_CARD_PAYMENT_URI, WorkflowEnvironment.WorkflowInstanceId.ToString()), e) QR Code JIS X 0510 Generation In Java Using Barcode encoder for Android Control to generate, create QR Code image in Android applications. www.OnBarcode.comUSS Code 39 Printer In VS .NET Using Barcode creation for ASP.NET Control to generate, create Code 39 image in ASP.NET applications. www.OnBarcode.comCHAPTER 7 AZURE .NET SERVICES WORKFLOWS
Generate Code 128 Code Set B In None Using Barcode generator for Word Control to generate, create Code 128 Code Set C image in Office Word applications. www.OnBarcode.comUPC Symbol Recognizer In None Using Barcode scanner for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.com}, new NextItem { Relative = ShoppingCartItem.ENDPOINT_ITEM_UPDATE, Uri = string.Format("{0}{1}", WorkflowEnvironment.WorkflowInstanceId.ToString()) }, new NextItem { ShoppingCartItem.SHOPPING_CART_URI, Relative = ShoppingCartItem.ENDPOINT_ITEM_DELETE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING_CART_URI, WorkflowEnvironment.WorkflowInstanceId.ToString()) } }; WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } private void codeUpdateShoppingCartItem_ExecuteCode(object sender, EventArgs e) { var id = WorkflowEnvironment.WorkflowInstanceId.ToString(); currentShoppingCartItem.ShoppingCartItemId = receivedId; currentShoppingCartItem.ItemName = receivedShoppingCartItem.ItemName; currentShoppingCartItem.Price = receivedShoppingCartItem.Price; currentShoppingCartItem.NextItem = new NextItem[] { new NextItem { Relative = ShoppingCartItem.ENDPOINT_CREDITCARD_PAYMENT, Uri = string.Format("{0}{1}", ShoppingCartItem.CREDIT_CARD_PAYMENT_URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT_ITEM_UPDATE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING_CART_URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT_ITEM_DELETE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING_CART_URI, id.ToString()), } }; Encode Barcode In VS .NET Using Barcode printer for ASP.NET Control to generate, create Barcode image in ASP.NET applications. www.OnBarcode.comBarcode Generator In .NET Using Barcode creator for .NET framework Control to generate, create Barcode image in .NET applications. www.OnBarcode.comCHAPTER 7 AZURE .NET SERVICES WORKFLOWS
Barcode Maker In Java Using Barcode creation for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comEAN13 Generation In Visual Basic .NET Using Barcode encoder for .NET framework Control to generate, create UPC - 13 image in .NET applications. www.OnBarcode.comWebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK; } private void codePayShoppingCartItem_ExecuteCode(object sender, EventArgs e) { var id = WorkflowEnvironment.WorkflowInstanceId.ToString(); currentShoppingCartItem.ShoppingCartItemId = receivedId; currentShoppingCartItem.ItemName = receivedShoppingCartItem.ItemName; currentShoppingCartItem.Price = receivedShoppingCartItem.Price; currentShoppingCartItem.NextItem = new NextItem[] { new NextItem { Relative = ShoppingCartItem.ENDPOINT_CREDITCARD_PAYMENT, Uri = string.Format("{0}{1}", ShoppingCartItem.CREDIT_CARD_PAYMENT_URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT_ITEM_UPDATE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING_CART_URI, id.ToString()), }, new NextItem { Relative = ShoppingCartItem.ENDPOINT_ITEM_DELETE, Uri = string.Format("{0}{1}", ShoppingCartItem.SHOPPING_CART_URI, id.ToString()), } }; WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } private void codeCheckOutShoppingCartItem_ExecuteCode(object sender, EventArgs e) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } } } Code39 Printer In Visual Studio .NET Using Barcode creator for VS .NET Control to generate, create Code 39 Extended image in .NET framework applications. www.OnBarcode.comCode 3 Of 9 Creation In None Using Barcode encoder for Microsoft Word Control to generate, create Code 39 Extended image in Word applications. www.OnBarcode.comCHAPTER 7 AZURE .NET SERVICES WORKFLOWS
Now we need to bind the state machine workflow item properties to the corresponding handler. Figure 7-9 shows the bindings for WaitingForShoppingCartItem:eventItemAdded. Figure 7-9. Bindings for WaitingForShoppingCartItem:eventItemAdded
CHAPTER 7 AZURE .NET SERVICES WORKFLOWS
The bindings for ShoppingCartItemPlaced:eventItemUpdated are shown in Figure 7-10. Figure 7-10. Bindings for ForShoppingCartItem:eventItemUpdated
CHAPTER 7 AZURE .NET SERVICES WORKFLOWS
Bindings for ShoppingCartItemWorkflow:ShoppingCartItemPlaced are shown in Figure 7-11. Figure 7-11. Bindings for ShoppingCartItemWorkflow:ShoppingCartItemPlaced
CHAPTER 7 AZURE .NET SERVICES WORKFLOWS
Bindings for ShoppingCartItemWorkflow:StateCheckout are shown in Figure 7-12. Figure 7-12. Bindings for ShoppingCartItemWorkflow:StateCheckout
CHAPTER 7 AZURE .NET SERVICES WORKFLOWS
10. Bindings for ShoppingCartItemWorkFlow:Timeout are shown in Figure 7-13. Figure 7-13. Bindings for ShoppingCartItemWorkFlow:Timeout 11. Create a host project, ShoppingCartWorkflowServiceHost, as Listing 7-9 shows. There are three callback delegates created in the Main() method. The first two are used to output trace information regarding the state transaction, and the third one is used to bind the persistence service for the workflow, so we can persist the workflow state. Listing 7-9. Create a Host Project ShoppingCartWorkflowServiceHost to Run the Workflow as a Service using using using using using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading; System.Workflow.Runtime; System.Workflow.Runtime.Hosting; System.ServiceModel; System.ServiceModel.Description;
|
|