Management Information Systems

Download Report

Transcript Management Information Systems

Building you build
process with
Windows Workflow
Foundation
Abid Quereshi
1
Agenda
Existing build technologies
Promise of Workflow Foundation
Demonstration – reusing Nant scripts
Demonstration - Custom Task
Authoring Modes
Serialization and Deserialization
Designer Re-Hosting
2
Existing build technologies
Cruise Control
MS Build
Nant/Ant
Visual Build
Automated Build Studio
DB Change management tools (DB Ghost,
Embarcadero)
Make files, batch files, any other
3
Existing build technologies
Motivation for new way of building software
Objectives
Visual Configuration (script free)
Real-time distributed feedback
Parallel Task processing
Cheap
4
Promise of Windows Workflow Foundation
Possibilities that WF provides
Design by markup
Access to high level programming language
- Threading, tracing, events
End user configuration
5
Promise of Windows Workflow Foundation
The Four Workflow Tenants:
Co-ordinate work performed by people and software
Long-running and stateful
Based on extensible models
Transparent and dynamic throughout their life cycle
6
Promise of Windows Workflow Foundation
Motive for a Dynamic Build process
Build technologies
New software development technologies and
platforms
Configuration
7
Promise of Windows Workflow Foundation
Start
Scenario
Checkout
ConfigMode
= Release?
Compile in Release
configuration
Compile in Debug
configuration
Deploy
Stop
8
Promise of Windows Workflow Foundation
Build script encapsulation demo
Reuse of existing scripts and build technologies
Example of a code only workflow
9
Promise of Windows Workflow Foundation
Authoring Modes
Full Visual Studio Support
Code Only
Markup (XAML) + Compiled Code Beside
Some Visual Studio Support + Prayer
Markup + Assembly binding
10
Workflow Customization
Custom Activities
Part of Workflow tenants (Based on extensible
models)
Reusable components
Possibility of Software Build DSL
11
Workflow Customization
Domain Specific Language
Limited form of computer language designed for a
specific class of problems.
Library(Framework) + Configuration (Process,
algorithm or how to perform a process)
Most Frameworks in a particular platform address
technical concerns
DSL’s address business concerns (Higher level level
of abstraction)
12
Workflow Customization
Domain Specific Language
DSL’s typically come with a code generation tool
•
•
Constraint syntax
Accessible to non-developers
13
Workflow Customization
Domain Specific Language
•
•
•
May require a Parser
Schemas help to validate instructions
Algorithm Syntax - what is being said – is limited
14
Workflow Customization
Domain Specific Language
Algorithm Syntax - what is being said – is limited
How it is being said may take two forms
• Internal DSL - syntax of instruction is a subset of host
general purpose language code
• External DSL – often a configuration file
15
Workflow Customization
Custom Workflow
DependencyObject
<abstract>
Activity
MyCustomActivity
CompositeActivity
SequenceActivity
SequentialWorkflowActivity
System.Workflow.ComponentModel
MyCustomWorkflow
16
Workflow Customization
Activity Class
DependencyObject
<abstract>
Methods to override:
•
•
•
Execute
Cancel
Initialize
Activity
Execute(ActivityExecutionContext):ActivityExecutionContext
Cancel(ActivityExecutionContext):ActivityExecutionContext
Initialize(IServiceProvider)
These are called by the WF runtime – not manually
17
Workflow State
Activity Class State
Initialized
Executing
Canceling
Closed
Faulting
Compensating
18
Workflow State
Dependency Object & Dependency Properties
DependencyObject
<abstract>
•
•
•
Activity data storage mechanism
Allows activities to project their properties onto their
children
Essential provision for WF tenent (Long-running and
stateful)
19
Workflow State
Dependency Object
•
Hash table
•
Essential provision for WF tenant (Long-running and
stateful)
•
Add a public static instance of Dependency Property
to manage that property for all instances of the activity
•
Implement .NET Property that accesses an activities
Dependency Property
20
Workflow State
Dependency Properties
Must derive from DependencyObject
Register property then define property
21
Workflow State
Dependency Properties
public static DependencyProperty
MyDepPropProperty = DependencyProperty.Register(
“MyDepProp",
typeof(String),
typeof(MyClass)
);
Property name
Property Type
Owner Type
22
Workflow State
Dependency Properties
public String CompilationMode
{
get
{
return (String)(base.GetValue(MyClass.
MyDepPropProperty));
}
set
{
base.SetValue(MyClass.MyDepPropProperty, value);
}
}
23
Workflow State
Parameter Passing
Dictionary<String, Object> Args = new Dictionary<string, object>();
Args.Add("RepositorySource", "C:\\Projects\\BuildManager\\Repository");
Args.Add("CompilationMode", "Release");
Args.Add("Application",
"C:\\Projects\\BuildManager\\Checkout\\BuildMeWinApp\\BuildMeWinA
pp.sln");
Args.Add("Target", "C:\\Projects\\BuildManager\\BuildTarget");
WorkflowInstance instance =
workflowRuntime.CreateWorkflow(typeof(BuildTasks.Builder), Args);
24
Custom Workflow
Build custom workflow demo
Domain specific activities
Domain specific workflow
Example of Code+Markup workflow
25
Authoring Modes
Markup
<SequentialWorkflowActivity x:Class="MarkupBuild.Build" x:Name="Build"
xmlns:ns0="clr-namespace:BuildTasks;Assembly=BuildTasks, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
<ns0:Checkout BuildFile="{x:Null}" x:Name="checkout1" RepositorySource="{x:Null}" />
<ns0:Compile BuildFile="{x:Null}" x:Name="compile1" CompilationMode="{x:Null}"
Application="{x:Null}" />
<ns0:Deploy BuildFile="{x:Null}" x:Name="deploy1" CompilationMode="{x:Null}" Target="{x:Null}" />
</SequentialWorkflowActivity>
26
Authoring Modes
XOML
Extensible Orchestration Markup Language (XOML)
files, a special case of XAML file types, which specify
the workflow logic within an application.
27
Authoring Modes
Binding
<SequentialWorkflowActivity x:Class="MarkupBuild.Build" x:Name="Build"
xmlns:ns0="clr-namespace:BuildTasks;Assembly=BuildTasks, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
<ns0:Checkout x:Name="checkout1" RepositorySource="{ActivityBind Build,Path=RepositorySource}" />
<ns0:Compile x:Name="compile1" CompilationMode="{ActivityBind Build,Path=CompilationMode}"
Application="{ActivityBind Build,Path=Application}" />
<ns0:Deploy x:Name="deploy1" Target="{ActivityBind Build,Path=Target}" CompilationMode="{ActivityBind
Build,Path=CompilationMode}" />
</SequentialWorkflowActivity>
28
Authoring Modes
Binding
gives a dependency property an ActivityBind object to
evaluate when asked for its value
ActivityBind can point to other fields, properties, or
methods of activities inside a workflow.
One activity could bind its input properties to a
previous activity's outputs.
Binding makes the data flow a part of the workflow
model.
29
Authoring Modes
Markup-only workflows
Allows for declarative programming
Facilitates the highest degree of encapsulation
Facilitates usage of code-generation tool
Requires mechanism to serialize and deserialize WF
30
Serialization
Serialization
Serialization
Create a XAML workflow markup file from an inmemory workflow model
Deserialization
Reads markup and creates in-memory object
containing definition of workflow model
31
Serialization
Serialization
private static void SerializeToMarkup(Activity workflow, String fileName)
{
try
{
using (XmlWriter xmlWriter = XmlWriter.Create(fileName))
{
WorkflowMarkupSerializer mrkupSerializer = new WorkflowMarkupSerializer();
mrkupSerializer.Serialize(xmlWriter, workflow);
}
}
catch (Exception e)
{
Console.WriteLine("Exception during serialization: {0}" e.Message);
}
32
}
Serialization
Deserialization
Deserializer needs knowledge of the types referenced
in the markup
ServiceContainer, TypeProvider,
DesignSerializationManager
33
Serialization
Activity workflow = null;
ServiceContainer container = new ServiceContainer();
Add a TypeProvider to resolve BuildTask references
TypeProvider provider = new TypeProvider(container);
provider.AddAssembly(typeof(SharedWorkflows.MarkupOnlyBaseWorkflow).Assembly);
container.AddService(typeof(ITypeProvider), provider);
Add ServiceContainer with the TypeProvider to serialization manager
DesignerSerializationManager dsm = new DesignerSerializationManager(container);
XmlReader xmlReader = XmlReader.Create(fileName)
WorkflowMarkupSerializer markupSerializer = new WorkflowMarkupSerializer();
workflow = markupSerializer.Deserialize(dsm, xmlReader) as Activity;
34
Designer Re-Hosting
Code generation tool
Configurable by end user
35
Designer Re-hosting
Introduction
The logic of a build process is often simple enough for
to allow drag and drop process design by nondevelopers
WF allows for re-hosting the workflow designer in a
windows application (outside of the Visual Studio
environment)
Powerful proposition
36
Designer Classes
System.ComponentModel.Design.DesignSurface
General-purpose design canvas
System.Workflow.ComponentModel.Design.
WorkflowDesignerLoader
Serialization/Deserialization
Loading of services used by the designer
System.Workflow.ComponentModel.Design.WorkflowView
Implements visual representation of your workflow model
37
Designer Classes
IRootDesigner
GetServices method
Design Surface
Load services and
populate visual tree
GetDesigner method
BeginLoad method
MyDesignerLoader:
WorkflowDesignerLoader
IDesignerHost
GetView method
WorkflowView
Persisted
Workflow
Models
(.xoml files)
38
Designer Re-hosting
Property Attributes
Description
Category
Browsable
DesignerSerializationVisibility
39
Designer Re-hosting
WorkflowDesignerLoader
Abstract
Must be implemented in a derived class
Responsible for loading workflow from peristable tore
.xoml and populating tree of visual objects in the
designer and Vise-Versa
40
Designer Re-hosting
Services
IMenuCommandService
ITypeProvider
IToolboxService
IPropertyValueUIService
IEventBindingService
41
Designer Re-hosting
Demo
Simple workflow
Workflow with conditional branch
42
Conclusion
Revisiting Objectives
Visual Configuration (script free)
Real-time distributed feedback
Parallel Task processing
Cheap
43
Conclusion
Real-time distributed feedback
Limitation is due to fact that WF Markup is a subset of
XAML – the markup parser is not extensible
Parallel Task processing
Parallel task activity is not multithreaded
This can be implemented but it’s not out-of-the box
functionality
44
Conclusion
References
•
Pro WF Windows Workflow in .NET 3.0, Apress, Bruce Bukovics
•
Professional Windows Workflow Foundation, Wrox, Todd Kitta
•
Introduction to Domain Specific Languages, Martin Fowler,
http://www.infoq.com/presentations/domain-specific-languages
45
Serialization
Blank Slide
46