Document Approval Process
The DocumentApprovalProcess sample demonstrates the use of many Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) features together. Together they implement a document approval process scenario. A client application can submit documents for approval and approve documents. An approval manager application exists to facilitate communications between clients and to enforce the rules of the approval process. The approval process is a workflow that can execute several types of approval. Activities exist to get a single approval, a quorum approval (a percentage of set of approvers), and a complex approval process that consists of a quorum and single approval in a sequence.
Sample Details
The following graphic demonstrates the document approval process workflow:
From the client's perspective, the approval process functions as follows:
A client subscribes to be a user in the approval process system.
A WCF client sends to a WCF service hosted by the approval manager application.
A unique user ID is returned to the client. The client can now participate in approval processes.
Once joined, a client can send a document for approval using single, quorum or complex approval processes.
A button in the client's interface is clicked, starting a workflow instance in a client Workflow Service Host.
The workflow sends an approval request to the approval manager application.
The workflow manager starts a workflow on its own side to represent an approval process.
Once the manager approval workflow executes, the results are sent back to the client.
The client displays the results.
A client may receive an approval request and respond to the request at any point in time.
A WCF service hosted on the client can receive an approval request from the approval manager application.
The document information is presented on the client for review.
The user can approve or reject the document.
A WCF client is used to send an approval response back to the approval manager application.
From the approval manager application's point of view, the approval process functions as follows:
A client requests to participate to the approval process system.
A WCF service on the approval manager receives a request to be part of the approval process system.
A unique ID is generated for the client. The user information is stored in a database.
The unique ID is sent back to the user.
An approval request is receive. The approval manager executes an approval process.
An approval request is received by the approval manager, starting a new workflow.
Depending on the type of request (simple, quorum, or complex) a different activity is executed.
Send and Receive activities with correlation are used to send the approval request to the client for review and receive the response.
The result of the approval process workflow is sent to the client.
Using the Sample
To set up the database
- From a Visual Studio command prompt opened with Administrator privileges, navigate to this DocumentApprovalProcess folder and run Setup.cmd.
To set up the application
Using Visual Studio, open the DocumentApprovalProcess.sln solution file.
To build the solution, press CTRL+SHIFT+B.
To run the solution, launch the Approval Manager Application by right-clicking the ApprovalManager project in the Solution Explorer and clicking Debug->Start new instance from the right-click menu.
Wait for the manager's output to let you know that it is ready.
To run the single approval scenario
Open a command prompt with administrator permission.
Navigate to the directory that contains the solution.
Navigate to the ApprovalClient\Bin\Debug folder and execute two instances of ApprovalClient.exe.
Click discover, wait until the subscribe button is enabled.
Type any user name and click subscribe. For one client, use
UserType1
and the other typeUserType2
.In the
UserType1
client, select the single approval type from the drop down menu and type a document name and content. Click Request Approval.In the
UserType2
client, a document awaiting approval appears. Select it and press approve or reject. The results should show in theUserType1
client.
To run the quorum approval scenario
Open a command prompt with administrator permission.
Navigate to the directory that contains the solution.
Navigate to the ApprovalClient\Bin\Debug folder and execute three instances of ApprovalClient.exe.
Click discover, wait until the subscribe button is enabled.
Type any user name and click subscribe. For one client use
UserType1
and the other two typeUserType2
.In the
UserType1
client, select the quorum approval type from the drop down menu and type a document name and content. Click Request Approval. This requests that the twoUserType2
clients approve or reject the document. While bothUserType2
clients must respond, only one client must approve the document for it to be approved.In the
UserType2
clients, a document awaiting approval appears. Select it and press approve or reject. The results should show in theUserType1
client.
To run the complex approval scenario
Open a command prompt with administrator permission.
Navigate to the directory that contains the solution.
Navigate to the ApprovalClient\Bin\Debug folder and execute four instances of ApprovalClient.exe.
Click discover, wait until the subscribe button is enabled.
Type any user name and click subscribe. For one client use
UserType1
, in two uses typeUserType2
, and in the last useUserType3
.In the
UserType1
client, select the single approval type from the drop down menu and type a document name and content. Click Request Approval.In the
UserType2
clients, a document awaiting approval appears. Select it and press approve, the document is passed to theUserType3
client.If the document is approved by the first
UserType2
quorum, the document is passed to theUserType3
client.Approve or reject the document from the
UserType3
client. The results should show in theUserType1
client.
To clean up
- From a Visual Studio command prompt, navigate to the DocumentApprovalProcess folder and run Cleanup.cmd.