One of the greatest challenges facing development teams, or individual departmental developers, is the integration of business logic or rules into an application. A series of posts will show how to integrate Windows Workflow 4.0 for business logic into Excel 2010, Word 2010, Outlook 2010 or Access 2010.
A team leader creates a SharePoint site that has many lists that are required to manage her team’s mission. She wants to change these lists in an ad-hoc manner—perhaps updating announcements and tasks from an Excel spreadsheet or Word document. She has minimal development skills and wants to write a small custom application to help her manage this. She could use an Office Workflow 4.0 designer and SharePoint 2010 Client Side code activities and Office Open Xml activities to create such a solution.
Microsoft Windows Workflow 4.0 (WF4) is an architectural approach for enabling shared business logic between many .NET applications. WF4 can be invoked on the client, such as an Office .NET add-in blended with SharePoint 2010 Client Object Model (CSOM) code activities or as part of a Windows Communication Foundation (WCF) application. In addition to a workflow platform, WF4 ships with a designer capable of being hosted in any .NET application such as an Excel or Word VSTO project. This article and accompanying source code shows how to get started hosting a custom workflow designer in an Excel or Word add-in. The designer includes a toolbox containing some core workflow activities, a custom expression editor, a few custom SharePoint 2010 activity parts and a few Office XML activities. Using the add-in, a user can design and run workflows that integrate with SharePoint 2010 from within Excel 2010 or Word 2010.
The source code of the next few posts is located at http://desktopweb.codeplex.com/SourceControl/changeset/changes/9363.
Security Note The current sample source code allows any desktop user to design and run an Office Workflow. A production application would only allow authorized users to design and run workflows.
The upcoming posts will discuss points of interest when integrating Windows Workflow 4.0 and related technologies into an Office Add-in. Integrating Windows Workflow 4.0 into Office that invoke SharePoint 2010 and Open Office Xml code activities requires numerous technologies. The posts will cover the following topics
Windows Workflow 4.0
- Design Surface and Custom Expression Editor – An activity designer programming model built upon Windows Presentation Foundation (WPF).
- Code and Native Activities – Activities are the core unit of behavior in Workflow 4.0
- Activity Designers – A visual representation of a Code or Native Activity that can be dropped onto the Workflow design surface and are composable with other activity designers.
- Tracking Participates and Profiles – Tracking Participates allow code to subscribe to workflow activity states. Profiles provide participation filtering.
SharePoint 2010 Client Object Model – A client API that allows you to interact with SharePoint sites from a .NET 3.5 or above managed application.
- SharePoint 2010 CRUD Activities
- SharePoint Permissions
Office Open Xml – A managed code API for strongly typed part and content classes to manipulate Open XML documents.
- Composite Office DocumentParts Activity
- Abstract ContentPart Activities
- View Publishers – ViewPublishers are similar to an interface or abstract class in that they define the properties of a View change.
- Using LINQ – Various code snippets showing the use of LINQ for SharePoint CSOM and other uses.
Word and Excel
- Workflow Ribbon
- Activity Task Pane
- Tracking Participant Subscriber
Please refer to the document located at http://desktopweb.codeplex.com/releases/view/70858 for the remainder of this post.
Sample Workflow Designer
The upcoming posts will dissect how to create a custom Workflow Designer that can run in any Office Add-in. The potential of an Office Workflow Designer and custom business activities is to enable more rapid Office application development. The activity designers require .NET development skills; however, the departmental business logic can be created with a Power User skillset.
Sample Activity Designers
The accompanying source code, and future source code, has several sample Activity Designers. A custom activity designer can have any WPF controls including a context sensitive SharePoint 2010 menu. The figure below illustrates a popup menu containing menu items of available SharePoint 2010 lists on localhost.
Office Open Xml DocumentParts
A DocumentParts activity designer allows a workflow user to drag Excel Office Xml content parts into a SharePoint document context. The user simply enters the SharePoint Url , Document Library and Document Name. Then the user drags Excel RangePartActivities into the DocumentParts designer to get cell data. All Office Xml details such as retrieving the Excel Xml stream and getting cell parts are hidden from the user.
Important The sample is intended to show SharePoint CSOM workflow activities. To simplify the sample code, this version returns the complete Office XML stream to the client and then performs client-side filtering. This is not an efficient means to filter Office XML since the Stream could have a large payload. A production application would move parts of the SharePoint related workflow to a WCF workflow service; thus, enabling the server to get the Office XML stream and return filtered office parts to the client.
A ViewPublisher is similar to an interface or abstract class in that they define the properties of a View change. A ViewSubscriber invokes the view change. This decouples the Excel and Word PIA model from the workflow.
A Treeview hosted in an Office Task Pane can act as a Workflow Tracking Participant or Subscriber. The example below shows tracking state event data added to a Treeview on the control’s thread.
The next post will start diving into the source code that enables Office Workflow.