Share via


Common AppFabric Sample Application

This sample application is composed of a sample sale client application and a sale service application. This sample application is intended to be used with the other Microsoft AppFabric 1.1 for Windows Server samples as a common application to help demonstrate the AppFabric features shown in the samples.

The sale service application models a simple workflow for order processing that can take advantage of built-in persistence and tracking support provided by AppFabric. The service application provides a catalog of items to client applications, and then simulates processing the orders placed by each client.

Note

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.

The samples package for AppFabric, which includes the sample application, can be downloaded from https://go.microsoft.com/fwlink/?LinkId=169336.

Prerequisites

This sample application is oriented toward readers who have the following experience or knowledge levels:

  • Basic knowledge of Internet Information Services (IIS)

  • Basic knowledge of Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) applications

  • Basic knowledge of Windows PowerShell

  • Basic knowledge of Microsoft SQL Server

Sample Application Location and Files

File Name Description

OrderApplication.sln

Solution file for the two projects

SaleClient

Folder containing the Sale Client project files

App.config, OrderManager.cs, Program.cs, SaleClient.csproj, SaleClientForm.cs, SaleClientForm.Designer.cs, SaleClientForm.resx, AssemblyInfo.cs, Resources.Designer.cs, Resources.resx, Settings.Designer.cs, Settings.settings

Sale Client project files

OrderApplication

Folder containing the Sale Service project files

CancelOrder.cs, CatalogInitializer.cs, CatalogTypes.cs, ProcessNewOrder.cs, SaleService.csproj, SaleService.xamlx, SaleServiceTracking.tp, ShippingProcessor.cs, web.config, AssemblyInfo.cs

Sale Service project files

Setting Up This Sample Application

  1. Start Visual Studio 2010 with administrative permissions and open <samples>\SampleApplication\OrderApplication\OrderApplication.sln, where <samples> is the path under which you have installed the AppFabric samples. When you receive the prompt to create the virtual directory, click Yes.

    Note

    These steps demonstrate how to deploy and build the Order Application with Visual Studio 2010 and how to configure the default application pool for use with the sale service.

  2. Click the Build menu, and then click Build Solution. Verify that the two projects build with no errors in the output window.

  3. Start Internet Information Services (IIS) Manager by clicking Start, All Programs, Microsoft AppFabric 1.1 for Windows Server, and then Internet Information Services (IIS) Manager.

  4. Expand the server node in the tree view on the left, and then click Application Pools.

  5. Right-click DefaultAppPool in the Application Pools list, and then click Advanced Settings.

  6. Set .NET Framework Version to v4.0 using the drop-down selection, and then click OK.

Running This Sample

  1. Run the client application: <samples>\SampleApplication\ OrderApplication\SaleClient\bin\Debug\SaleClient.exe.

  2. The form application issues a request to the Sale service to send the current daily sale catalog. Depending on the running state of the service this may take about ten seconds.

  3. Notice the expiration information for the returned catalog, which indicates that the catalog expires in approximately three minutes if an order is not placed. Change the Order Quantity for 24-inch monitors to 2, and then press the TAB key to update the order form. Billing Total should now be $531.98. If the catalog does expire, you can click Get New Catalog to request a new sale catalog from the service.

  4. Within three minutes of receiving the sale catalog (the catalog expires in three minutes), click Place Order and make sure that the order status changes to Order Received. The StatusText variable in the workflow captures this status change. You can configure the application with a tracking profile to track this variable. The Sale Client application will poll the workflow and show that the order has been filled within one minute. After one more minute the order will be shipped. The order can be canceled by clicking Cancel Order any time before the order has been shipped, but do not cancel this order.

  5. Right-click the selected value in the Order Id text box, and then click Copy to copy the order ID to the Clipboard.

  6. Close the Sale Client application. While no action is needed in a hosted workflow, the workflow can be persisted for scalability. In this sample, the order ID you just copied is used for correlating persisted workflow instances with client requests.

  7. Start a new instance of the client application <samples>\SampleApplication \OrderApplication\SaleClient\bin\Debug\SaleClient.exe.

  8. Right-click inside the Order Id text box, and then click Paste to paste the order ID from the Clipboard into the Order Id text box at the bottom of the form.

  9. Click Recall PO. This should recall your active order and present its current status. The workflow simulates back-end processing of an order with delays. After approximately two minutes, Order Status will cycle through the following states: Order Received, Order Filled, and Order Shipped. The host can be configured with the custom tracking profile to track the order's status changes for custom reporting. While this order is being processed, you will run a new instance of the Sale Client application to cancel an order.

  10. Move the Sale Client application that contains your placed order to the right of your screen.

  11. Start a new instance of the client application <samples>\SampleApplication \OrderApplication\SaleClient\bin\Debug\SaleClient.exe.

  12. Click Get Sale Catalog to receive a new catalog. Depending on the running state of the service this may take about ten seconds.

  13. When the sale catalog is populated in the form, change the Order Quantity for "Quad Core 2.8 Ghz Processor" to 20. Press the TAB key to update the order form. Billing Total should now be $6,119.80.

  14. Click Place Order before the new catalog expires and verify that the order status changes to Order Received.

  15. Immediately click Cancel Order before the order is shipped, and verify that the order status changes to Order Canceled.

Removing the Deployed Sale Service Web Application

  1. Start Internet Information Services (IIS) Manager by clicking Start, All Programs, Microsoft AppFabric 1.1 for Windows Server, and then Internet Information Services (IIS) Manager.

  2. Expand the server node in the tree view on the left. Then expand Sites, and then expand Default Web Site.

  3. Click the OrderApplication node, and then press Remove.

  4. Click Yes to confirm removing the selected application.

Demonstrates

The Sale Service application was built using the WCF workflow service application template in Microsoft Visual Studio 2010. The catalog provided by the sale service is intended to resemble a sale run in a newspaper or online site. The sale is available for only a limited time. After the form-based client application requests the sale catalog, the user has three minutes to place an order before the workflow expires the catalog.

When the user places an order, an order ID is provided by the Sale service. This order ID is used for correlating persisted workflow instances with client requests. The client request can reactivate the workflow through correlation to check the status of an order or cancel the order if it has not been shipped. After an order is placed with the Sale service, its status will move from "Order Received" to "Order Filled" in approximately three minutes. After approximately three more minutes the status of the order will change to "Order Shipped".

A sample tracking profile (SaleServiceTracking.tp) can be used to enable tracking on the "StatusText" and "PurchaseTotal" variables in the workflow. This allows the service to be configured to track information related to these variables at different points in the workflow. The following information is tracked by using the tracking profile provided in this sample:

  • Expired catalogs

  • Orders canceled

  • Orders filled

  • Orders shipped ReplaceThisText

  • Purchase total associated with shipped orders

After the tracking information is recorded in the tracking database, you can build a status report off the tracked data. This tracking information is intended to be used in other samples.

  2012-09-12