Class Registration Sample

The class registration sample demonstrates how to use Windows Workflow Foundation and together in the same application. This sample also makes use of SQL persistence and SQL tracking to run a workflow across multiple applications.

Database Configuration

  1. The SQL services that are installed by Windows Workflow Foundation use Microsoft SQL Server to store information. You can use Microsoft SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE) for these tasks.

  2. Windows Workflow Foundation Setup does not install the databases that are required by these services; however, Setup installs the SQL scripts for creating and configuring the database for these services.

Note

The Microsoft Distributed Transaction Coordinator (MSDTC) service must be enabled for the to function.

  1. The following steps describe how to create and configure the databases that are used for this sample.

To create and configure the Class Registration database

  1. Using SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE), create a new database named ClassRegistration by using the SQL query statement:CREATE DATABASE ClassRegistration

  2. In the SQL Query Analyzer workspace, select the ClassRegistration database that you created in step 1 from the list of available databases.

  3. On the File menu, click Open, and open the SQL script %Sample Root%\ClassRegistration_Schema.sql.

  4. Execute the query by clicking Execute or by pressing F5 to create the registration database tables.

  5. On the File menu, click Open, and open the SQL script %Sample Root%\ClassRegistration_Data.sql.

  6. Execute the query by clicking Execute or by pressing F5 to add data to the class registration database.

To create and configure the SQL persistence and tracking database

  1. Using SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE), create a new databases named ClassRegistrationTracking by using the SQL query statement:CREATE DATABASE ClassRegistrationTracking

  2. In the SQL Query Analyzer workspace, select the ClassRegistrationTracking database that you created in step 1 from the list of available databases.

  3. On the File menu, click Open, and open the SQL script %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<language>\SqlPersistenceService_Schema.sql.

  4. Execute the query by clicking Execute or by pressing F5 to create the SQL persistence tables.

  5. Repeat steps 3 and 4 with the following scripts (these scripts are in the same directory as the script in step 3): SqlPersistenceService_Logic.sql, Tracking_Schema.sql, and Tracking_Logic.sql.

Sample Walkthrough

  • This sample consists of a two applications; Registration and Registrar.

Registration Application

  1. The Registration application is used by students to register for classes. The process for registration is as follows:

  2. The student logs in using their student Id. If the student Id is not in the database, then they are given the option of adding a new student Id.

  3. The student selects Register from the Registration Menu.

  4. The student can add class sessions by selecting a class, then selecting a session and clicking Sign up for Session.

  5. After a student has selected one or more session then they can click Register to register for the selected class sessions.

  6. For each class session a new workflow is started that validates the registration and waits for Registrar approval.

  7. The process of validation checks to see if the student has already registered for the given class session and whether the class is full. If a class is full then their registration is automatically waitlisted and doesn't go to the Registrar for approval.

Registrar Application

  1. The Registrar application is used by the Registrar to accept or reject registrations. The process for the Registrar is as follows:

  2. The registrar is presented with a list of class sessions that are waiting for approval.

  3. To approve registration for a class session, the Registrar selects the desired class session and clicks Approve.

  4. To reject registration for a class session, the Registrar selects the desired class session and clicks Reject.

To build the sample

  • Run MSBuild from the sample root directory or open the solution file (.sln) with Visual Studio and build the solution.

To run the sample

  1. To run the Registration application, double-click Registration.exe or open a Command Prompt and type registration.exe.

  2. To run the Registrar application, double-click Registrar.exe or open a Command Prompt and type registrar.exe.