Title: Aspose.Workflow Introduction
1Aspose.Workflow Introduction
2Aspose.Workflow Introduction
- Pure .Net components
- Fully XPDL (http//www.wfmc.org/standards/XPDL.htm
) supports - Implements WFMC (http//www.wfmc.org) standards
- Integrate with Asp.Net, VB.Net, WinForm
applications. - Support .Net Framework 1.1 and above (tested with
.Net Framework 2.0beta) - Popular database system support (SQLServer and
oracle)
3Aspose.Workflow Status
- Aspose.Workflow 1.0.5 released.
- Aspose.Workflow Designer is in progress, and it
will be ready in next major release. - For one month, there will be at least 1 maintain
release, at most 2. - HotFix will based on customer request and no time
restrictions.
4Designer
- Aspose.Workflow will provide an pure C written
graphical designer - Currently the Designer is 50 finished, it will
coming in the next major release (Aspose.Workflow
1.1.0)
5Designer (Cont.)
- Dock pannels
- Shape Explores
- Mini Map
- Zoom In/Out
6Designer (Cont.)
- Package Explorer
- Properties Editors
7WFMC and XPDL Introduction
8XPDL Introduction
- WFMC provides an interface for workflow process
definition. That interface defines a common
meta-model for describing the process definition
and XML schema for interchange of process
definitions - XPDL (XML Process Definition
Language) - The workflow process definition interface defines
a common interchange format, which supports the
transfer of workflow process definitions between
different products.
9XPDL Introduction (Cont.)
- A workflow process definition, generated by
Aspose.Workflow designer or JAWE, is capable of
interpretation in different workflow run-time
products.
10XPDL Introduction (Cont.)
- The principles of Process Definition Interchange
are based on Meta-Model framework. This meta-data
model identifies commonly used entities within a
process definition, their relationships and
attributes. A variety of attributes describe the
characteristics of this limited set of entities.
11XPDL Meta Model
- Workflow Package
- Workflow Process Definition
- Workflow Process Activity
- Transition Information
- Workflow Participant Declaration
- Workflow Application Declaration
- Workflow Relevant Data
- System Environmental Data
- Resource Repository or Organizational Model
- Data Types and Expressions
12XPDL Package
- Workflow Process Definition,
- Workflow Participant Specification,
- Workflow Application Declaration and
- Workflow Relevant Data
- External Workflow Package references
13XPDL Process
- Workflow Activity set
- Workflow Activity Definition
- Transitions
- Workflow Participant Specification,
- Workflow Application Declaration and
- Workflow Relevant Data
- All process will inherit the Relevant data,
Participant, Application from the parent
package.
14Contract Workflow Tutorial
- Design the Contract Workflow Model using Designer
15Contract Preparation Process Description
- Contract coordinators create new contracts.
- Contract reviewers review and either approve or
deny contracts. - A consultant will do some consultant work on
based on the contracts - When consultant work done, the invoice creator
will send out a invoice.
16Create new Package
- Set the ID to ContractWorkflow_Tutorial
- The Id must be unique inside the whole engine
- Also give a new name to the package
- Set the script type to VB
17New Created Package XPDL
- lt?xml version"1.0" encoding"UTF-8"?gt
- ltPackage xmlns"http//www.wfmc.org/2002/XPDL1.0"
xmlnsxpdl"http//www.wfmc.org/2002/XPDL1.0"
xmlnsxsi"http//www.w3.org/2001/XMLSchema-instan
ce" Id"ContractWorkflow_Tutorial"
Name"ContractWorkflow_Tutorial"
xsischemaLocation"http//www.wfmc.org/2002/XPDL1
.0 http//wfmc.org/standards/docs/TC-1025_schema_1
0_xpdl.xsd"gt - ltPackageHeadergt
- ltXPDLVersiongt1.0lt/XPDLVersiongt
- ltVendorgtAspose.Workflowlt/Vendorgt
- ltCreatedgt2005-09-16 103114lt/Createdgt
- lt/PackageHeadergt
- ltRedefinableHeader PublicationStatus"UNDER_TEST"/
gt - ltConformanceClass GraphConformance"NON_BLOCKED"/gt
- ltScript Type"VB"/gt
- ltExtendedAttributesgt
- ltExtendedAttribute Name"MadeBy"
ValueAspose.Workflow Designer"/gt - ltExtendedAttribute Name"Version" Value"1.0"/gt
- ltExtendedAttribute Name"Owner"
Value"Aspose.Workflow"/gt - lt/ExtendedAttributesgt
- lt/Packagegt
18Add Participants
- Add the three participant of the contract
preparation process - Create Reviewer,consultant,invoiceCreator
- Set each participant type to Role
19Participants
20Participant XPDL
- ltParticipantsgt
- ltParticipant Id"reviewer" Name"reviewer"gt
- ltParticipantType Type"ROLE"/gt
- ltDescriptiongtThis is the Contract
reviewerlt/Descriptiongt - lt/Participantgt
- ltParticipant Id"Consultant" Name"Consultant"gt
- ltParticipantType Type"ROLE"/gt
- ltDescriptiongtThis is the Consultantlt/Descriptiongt
- lt/Participantgt
- ltParticipant Id"InvoiceCreator"
Name"InvoiceCreator"gt - ltParticipantType Type"ROLE"/gt
- ltDescriptiongtThis is the InvoiceCreatorlt/Descripti
ongt - lt/Participantgt
- lt/Participantsgt
21Create the Contract Process
- Create the new workflow process called
Contract_Preparation
22Contract Process (Cont.)
- ltWorkflowProcessesgt
- ltWorkflowProcess AccessLevel"PUBLIC"
Id"Contract_Preparation" Name"Contract_Preparati
on"gt - ltProcessHeader DurationUnit"D"gt
- ltCreatedgt2005-09-16 104715lt/Createdgt
- lt/ProcessHeadergt
- ltRedefinableHeader PublicationStatus"UNDER_TEST"gt
- ltAuthorgtAspose.Workflowlt/Authorgt
- ltVersiongt1.0lt/Versiongt
- lt/RedefinableHeadergt
- lt/WorkflowProcessgt
- lt/WorkflowProcessesgt
23Contract Workflow (Cont.)
24Create Applications
- Applications is using to interactive with
external system. For this tutorial, the
applications will operate on the Contracts
database table. - There are four applications currently
- ApproveContract
- UpateContractState
- ConsultantContract
- CreateInvoice
25Create Application (Cont.)create parameters for
application
- Set the parameter id
- Mode In/Out/Inout
- Set the parameter type
26Parameters (Cont.)
- The application ApproveContract has four
parameters - ContractId In String
- Reviewer In String
- IsRejected In Boolean
- State Inout String
27The Applications XPDL(ApproveContract)
- ltApplication Id"ApproveContract"gt
- ltFormalParametersgt
- ltFormalParameter Id"ContractId" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"Reviewer" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"IsRejected" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"BOOLEAN"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"State" Mode"INOUT"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- lt/FormalParametersgt
- lt/Applicationgt
28The Applications XPDL (Cont.)(UpdateContractState
)
- ltApplication Id"UpdateContractState"gt
- ltFormalParametersgt
- ltFormalParameter Id"ContractId" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"State" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- lt/FormalParametersgt
- lt/Applicationgt
29The Applications XPDL (Cont.) (ConsultContract)
- ltApplication Id"ConsultContract"gt
- ltFormalParametersgt
- ltFormalParameter Id"ContractId" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"Consultant" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"Advice" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- lt/FormalParametersgt
- lt/Applicationgt
30The Applications XPDL (Cont.) (CreateInvoice)
- ltApplication Id"CreateInvoice"gt
- ltFormalParametersgt
- ltFormalParameter Id"ContractId" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"Amount" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"FLOAT"/gt
- lt/DataTypegt
- lt/FormalParametergt
- ltFormalParameter Id"InvoiceCreator" Mode"IN"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/FormalParametergt
- lt/FormalParametersgt
- lt/Applicationgt
- lt/Applicationsgt
31Create DataFields
- Data fields is the process/package local
variables to hold process instance related data - Data fields can use as the actual parameter for
the applications formal parameter
32Contract Workflow DataFields
- ContractId string indicate the id of contract
- Reviewer string the reviewers name
- Creator string the contract creator.
- IsRejcted boolean indicate if the contract is
rejected - State string indicate current contract state
- Consultant string the contract consultants name
- Advice string the consultants advice
- Amount string the invoice amount
- InvoiceCreator the creator of invoice
33Contract Workflow Data Fields XPDL
- ltDataFieldsgt
- ltDataField Id"ContractId" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- ltDataField Id"Reviewer" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- ltDataField Id"Creator" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- ltDataField Id"IsRejected" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"BOOLEAN"/gt
- lt/DataTypegt
- lt/DataFieldgt
34Contract Workflow Data Fields XPDL (Cont.)
- ltDataField Id"State" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- ltDataField Id"Consultant" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- ltDataField Id"Amount" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- ltDataField Id"InvoiceCreator" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
- lt/DataFieldsgt
35Contract Workflow Data Fields XPDL (Cont.)
- ltDataField Id"Advice" IsArray"FALSE"gt
- ltDataTypegt
- ltBasicType Type"STRING"/gt
- lt/DataTypegt
- lt/DataFieldgt
36Create the process
- Add Start (Black round shape), End to the graph
- Each process must at least have one start and one
end
37Create Process (cont.)
- Add the first activity of contract preparation
Approve Contract - The Approve Contract performer will be the
pre-created participant Reviewer - When Approve Contract is done, it will call two
applications - ApproveContract
- UpdateContractState
- Be sure to map the data fields to the
applications parameters
38Approve Contract XPDL
- ltActivity Id"ContractModel_Act1" Name"Contract
Review"gt - ltImplementationgt
- ltTool Id"ApproveContract" Type"APPLICATION"gt
- ltActualParametersgt
- ltActualParametergtContractIdlt/ActualParametergt
- ltActualParametergtReviewerlt/ActualParametergt
- ltActualParametergtIsRejectedlt/ActualParametergt
- ltActualParametergtStatelt/ActualParametergt
- lt/ActualParametersgt
- lt/Toolgt
- ltTool Id"UpdateContractState" Type"APPLICATION"gt
- ltActualParametersgt
- ltActualParametergtContractIdlt/ActualParametergt
- ltActualParametergtStatelt/ActualParametergt
- lt/ActualParametersgt
- lt/Toolgt
- lt/Implementationgt
- ltPerformergtReviewerlt/Performergt
- ltStartModegt
- ltManual/gt
- lt/StartModegt
- ltFinishModegt
- ltAutomatic/gt
- lt/FinishModegt
- lt/Activitygt
39Create process (Cont.)
- Based on the review result the continue process
will go to different transitions - Approved go to consultant work
- Rejected go to contract rejcted
- The condition test will be store in activities
Transition restriction
40Transition Restriction XPDL
- ltTransitionRestrictionsgt
- ltTransitionRestrictiongt
- ltSplit Type"XOR"gt
- ltTransitionRefsgt
- ltTransitionRef Id"ContractWorkflow_Tra2"/gt
- ltTransitionRef Id"ContractWorkflow_Tra3"/gt
- lt/TransitionRefsgt
- lt/Splitgt
- lt/TransitionRestrictiongt
- lt/TransitionRestrictionsgt
- Split Type XOR means only one transition can be
followed - The detailed transition settings is stored in
transition definition here only reference them
using TransitionRef
41Transition XPDL
- ltTransition FromApproveContract"
Id"ContractWorkflow_Tra2" ToContractRejcted"gt - ltCondition Type"CONDITION"gtIsRejectedlt/Conditiongt
- ltExtendedAttributesgt
- ltExtendedAttribute Name"RoutingType"
Value"NOROUTING"/gt - lt/ExtendedAttributesgt
- lt/Transitiongt
- This transition is the From ApproveContract to
ContractRejected - The condition expression IsRejected means when
the data field IsRejected is true, this
transition will be followed - You can set the condition type to OTHERWISE,
means follow the transition if all other
transition from the same activity whose condition
result are false
42Continue
- The activity follow Contract Rejected will be end
- The activity follow Consultant work will be
Create Invoice - Like Approve Contract, Consultant work will
also have two applications need to call when the
activity execute - ConsultantContract
- UpdateContractState
- ConsultantWorks performer will be Consultant
- Contract Rejected is a special activity, it
will execute automatically by the Workflow engine
system. - Set the performer type to SYSTEM
- Set the Start Mode to AUTOMATIC
43Continue.
- Create Invoice will call application
- CreateInvoice
- UpdateContractState
- Send Invoice is same as Contract Rejected, it
is an automatically state - Performer type is SYSTEM
- Start Mode is AUTOMATIC
44Modeling End
- Save the model into file
- A full version of the XPDL can be found at
- http//www.aspose.com/Products/Aspose.Workflow/Liv
eDemo/ContractModel.xpdl
45Contract Workflow Tutorial
- Run the Contract Workflow Model using
Aspose.Workflow engine
46Aspose.Workfow Engine Runtime Overview
- Aspose.Workflow engine runtime include below
steps - Configuration the Aspose.Workflow Engine
- Upload the XPDL model file to the engine
- Map the applications defined in the XPDL file to
real tool agent implementation classes - Map the participant defined in XPDL file to real
username - Start Process instance
- Using worklist to accept/complete tasks.
- Monitoring the engine using Monitor Service
47ContractWorkflow Asp.Net implementation
- All source can be found in the installer package
- Find the online version on http//www.aspose.com/P
roducts/Aspose.Workflow/Demos/ContractWorkflow/
48Aspose.Workflow configuration
- ltappSettingsgt
- ltadd key"RootDirectoryPath" value"D\stone\work
\dotnet\Workflow\src\Demos\ContractWorkflow"/gt - ltadd key"engine.name" value"Aspose.Workflow.Dem
os.ContractWorkflow" /gt - ltadd key"ConnectionString" value"ProviderMicro
soft.Jet.OLEDB.4.0User IDAdminData
SourceRootDirectoryPath\storage\repository\Asp
ose.Workflow.mdb" /gt - ltadd key"LogFilePath" value"RootDirectoryPath
\storage\log\Aspose.Workflow.log" /gt - ltadd key"LogLevel" value"INFO" /gt
- ltadd key"package.repository.path"
value"RootDirectoryPath\storage\repository\ext
ernal" /gt - lt/appSettingsgt
49Initialization of ContractWorkflow
- Please refer to the Initialize.aspx.cs in the
demos source code - Get the Aspose.Workflow engine Instance
- IEngine engine EngineManager.Instance.Engine
- engine.Login("aspose","aspose")
- Upload package
- IPackage package engine.PackageAdmin.UploadPacka
ge( - engine.Properties"RootDirectoryPath"
_at_"\ContractPackage.xpdl")
50Map the Participant to User
- IParticipant participants package.GetAllProces
ses()0.Participants - foreach(IParticipant part in participants)
-
- if (part.Id.Equals("Reviewer"))
-
- part.MapUser("reviewer1")
-
- else if (part.Id.Equals("Consultant"))
-
- part.MapUser("consultant1")
-
- else if (part.Id.Equals("InvoiceCreator"))
-
- part.MapUser("invoiceCreator1")
-
-
51Map Applications to Tool agent Implementation
classes
- IApplicationAdmin appAdmin
- engine.ApplicationAdmin
- IApplication apps
- appAdmin.GetAllApplicationsInPackage(package.Id)
- foreach(IApplication app in apps)
-
- if (app.Id.Equals("ApproveContract"))
-
- appAdmin.SetApplicationToolAgent(
- app.PackageId,app.ProcessId,
- app.Id,app.Name,app.UserName,
- app.Password,
- typeof(ToolAgent.ApproveContract).AssemblyQualifie
dName) -
-
52Page Design
- When each user login to the Contract Workflow
system, they got a task list page, some times
include a history list.
53Populate the Task List
- Please refer to the TaskList.aspx.cs in demos
source code. - IEngine engine EngineManager.Instance.Engine
- engine.Login(txtUsername.Text.Trim(),txtPassword.T
ext.Trim()) - ITask tasks engine.Worklist.GetAllTasks()
- Will return the tasks assigned to current login
user. - So for different user we can get difference task
list and display different data using the same
Asp.Net page.
54Detail Page
- For different user, we have task detail page,
ReviewContract.aspx,Invoice.aspx,ConsultantReport.
aspx - When PageLoad Accept the task
- if (!engine.Worklist.IsTaskAccepted(txtTaskId.Tex
t)) -
- engine.Worklist.AcceptTask(txtTaskId.Text)
-
- Since all task are assigned to the Reviewer
role, any user in the Reviewer role accept
task, other reviewers cans see this task until
the user release the task
55Finish the task (OK button)
- Ok button clicked
- private void btnOk_Click(object sender,
System.EventArgs e) -
- System.Collections.Hashtable result new
Hashtable() - result"Reviewer" Session"Username"
- result"IsRejected" reviewState.SelectedValue.
Equals("Reject") - result"State" "Reviewed"
- IEngine engine Session"Engine" as IEngine
- engine.Worklist.CompleteTask(txtTaskId.Text,resul
t) - Server.Transfer("TaskList.aspx")
-
- First Accept the task, then complete the task
56Finish the Task (Cancel Button)
- Cancel button clicked
- private void btnCancel_Click(object sender,
System.EventArgs e) -
- IEngine engine Session"Engine" as IEngine
- engine.Worklist.ReleaseTask(txtTaskId.Text)
- Server.Transfer("TaskList.aspx")
-
- When user cancel the page, it will release the
task and let other user in the same role can
process task.
57Enhance the Contract Workflow
58Overview
- The old style application when you want to add a
new step in the process, it has to modify code. - For workflow enable application, it is very easy,
just change the model without/simple change to
the code.
59New Step
- When invoice creator create the invoice, if the
invoice amount gt 1000, we want the review to
review again
60New Step (Cont.)
- Add a new activity Review Invoice after Create
Invoice activity - Set the Create Invoice split type property to
XOR - Set the performer of Review Invoice to reviewer
61New Step (Cont.)
- Set the to Review Invoice transition Properties
- Set Conditions Type to Condition, expression to
Amount gt 1000, the Amount is predefined process
DataField
62New Step (Cont.)
- Set the transition to Send Invoice condition
type to Otherwise
63New Step (Cont.)
- Link the Review Invoice to Send Invoice
- If Invoice approved, will go to send invoice
activity
64New Step (Cont.)
- When Invoice rejected, the process will end.
- Since Aspose.Workflow still not support LOOP,
if support, we can go to Invoice Create or
Consultant work until the invoice is approved.
65No Code Change
- For current ContractWorkflow demo included in the
installer package, no code change needed, when
the amount of invoice gt 1000, the reviewer will
find a new task of Review Invoice on the task
list. - After modify the model, please reinitialize the
contract workflow by call the initialize.aspx