1 / 35

Windows Workflow - An introduction

Mahesh Krishnan Senior Consultant , Readify. Windows Workflow - An introduction. Agenda. Introduction to Windows Workflow What is it? What are activities? Hosting Out of the box Activities Custom Activities and Dependency Properties Handling faults WF Persistence and Tracking.

allan
Télécharger la présentation

Windows Workflow - An introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mahesh Krishnan Senior Consultant, Readify Windows Workflow- An introduction

  2. Agenda • Introduction to Windows Workflow • What is it? • What are activities? • Hosting • Out of the box Activities • Custom Activities and Dependency Properties • Handling faults • WF Persistence and Tracking

  3. Introduction to WF

  4. What is WF? • Stands for Windows Workflow Foundation (not WWF) • One of the 4 pillars of .NET 3.0 • WF provides: • A programming model for building Application workflows • A runtime to host them

  5. Two types of workflows: Sequential State machine Visual Studio provides us the tooling support to create Workflows easily Windows Workflow Foundation

  6. Activities • Activities are building blocks of a WF • To a workflow, an activity is a re-usable program statement • An activity that contains other activities is called a Composite Activity • Examples of out of the box activities: • SequenceActivity • CodeActivity • IfElseActivity • WhileActivity

  7. WF Program • A Workflow program is nothing but a tree of activities • WF programs typically wait for some kind of an input and performs a bunch of activities • Once an activity finishes execution, the next activity in the WF is executed

  8. Creating workflows • Can be created Declaratively (using XAML) • Imperatively via code

  9. Hosting • The program is hosted via WorkflowRuntime class • Can be hosted in any .NET App • WinForms, Console, ASP.NET, WPF... • Integrates with other MS technologies – • SharePoint • BizTalk • WCF

  10. Demonstration Simple Workflow Example (using Code Activity)

  11. Things to cover • IDE • Design surface • Properties window • Document Outline • Sample Workflow using Code activity • Debugging experience

  12. More on Activities Out of the box Activities

  13. Activities for Flow Control • IfElseActivity • WhileActivity • ParallelActivity • ConditionedActivityGroup (or CAG) • Replicator • TerminateActivity • SuspendActivity • InvokeWorkflowActivity

  14. Activities for State Management • StateActivity • SetStateActivity • StateInitializationActivity • StateFinalizationActivity

  15. Activites for Event Handling • ListenActivity • EventDrivenActivity • EventHandlersActivity • EventHandlingScopeActivity

  16. Out of the box Activities (contd) • Heaps of others: • Activities for Calling web services • Transaction handling • Compensation • Fault handling • Synchronization • Calling other workflows • etc

  17. Demonstration Out of the box Activities

  18. Creating your own activities Custom Activities

  19. Custom Activities • Alternative to Code activity • Derived from Activity class (or something derived from it, like SequenceActivity) • Need to over ride Execute method • Promotes re-use and is more testable • Used from the designer • Sometimes increases complexity

  20. Dependency Properties • Properties in Custom activities are usually implemented as Dependency Property • Unlike normal properties, value is not stored in an instance variable • They are registered with Dependency Property Framework and supports these scenarios: • Activity Binding • Attached properties • Meta properties

  21. Dependency Property declaration public static DependencyPropertyCardNumberProperty = DependencyProperty.Register("CardNumber", typeof(string), typeof(ENettActivity)); [DescriptionAttribute(“The Credit Card number of user")] [CategoryAttribute(“Credit Card Details")] [BrowsableAttribute(true)] [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)] public string CardNumber { get { return ((string)(base.GetValue(ENettActivity.CardNumberProperty))); } set { base.SetValue(ENettActivity.CardNumberProperty, value); } }

  22. Demonstration Custom Activity

  23. Handling Faults

  24. Faults • Faults can occur at any time in a WF: • Exceptions thrown • Activity failures • Throw statements in code activities • Throw Activity in WF • If a fault occurs and is not handled, then the WF terminates

  25. Fault handling • try/catch blocks within code will work • In custom activities, the HandleFault method can be overridden to do clean ups • FaultHandlers and FaultHandler Activity can be used to handle specific Exceptions • Throw Activity can be used to throw Exceptions

  26. Demonstration Handling Faults

  27. Workflow Persistence

  28. Why do you need it? • Typically Workflows are long running • You may want to maintain the state of workflows between machine shutdowns • You may want to unload workflow (dehydration) that is idle • Scalability and Resource consumption

  29. Persistence in Windows Workflow • Implemented as an optional core service • A Sql Server persistence service is available out of the box • The database can be created using scripts from the directory - [...]\Framework\v3.0\Windows Workflow Foundation\SQL\en • The service can be added easily via configuration or via code

  30. Tracking Workflows

  31. Why do you need it? • There may be lots of workflows running, each in a different state • You may want to track these workflows and activities at runtime • You may also want to find out what path a certain Workflow instance took

  32. Tracking in Windows Workflow • WF Tracking Framework allows monitoring of workflows by capturing events raised during WF execution • SqlTracking service is used to write this to SQL Server database • Like the persistence service, this can be added easily via configuration or code

  33. Summary

  34. Summary • Windows Workflow provides the runtime and API to create workflows in .NET • Activities are the building blocks of WF • .NET provides a whole bunch of ready-to-use activities, but custom activities can also be created • Persistence services are needed for long running workflows • Tracking services can also be added to track the running of workflows

  35. Questions?

More Related