I just updated the OData QueryFeed workflow activity sample.
My original entity properties TablePartPublisherDesigner had style names hard-coded in the activity designer. This was okay to demonstrate the concept of an activity publisher. However, I wanted a way for the client hosting the workflow designer to supply style names for any TablePartPublisherDesigner. After some research, I decided to use the workflow designer ModelService to get an enumeration of ModelItems from the ModelItemTree. A LINQ statement returns a collection of ModelItems of type TablePartPublisher. From this collection, the ViewService.GetView(modelItem) is used to get each TablePartPublisherDesigner. Once I had each TablePartPublisherDesigner, I was able to add style names to each activity designer from within the workflow designer client.
With this approach, a client application can supply expression data to an activity designer.
The source code at http://msftdbprodsamples.codeplex.com/releases/view/94486 shows how this is done.
The result is an activity with expression items set by the client host:
|Excel Host||Word Host|
Here is some of the code:
modelService = workflowDesigner.Context.Services.GetService<ModelService>();
IEnumerable<ModelItem> activityCollection = modelService.Find(modelService.Root, typeof(Activity)) ;
var tablePartPublisherDesigners = from mi in activityCollection
where mi.ItemType == typeof(Microsoft.Samples.SqlServer.Activities.ActivityPublishers.TablePartPublisher)
foreach (ModelItem mi in tablePartPublisherDesigners)
this.SetStyleNames(workflowDesigner.Context.Services.GetService<ViewService>().GetView(mi) as TablePartPublisherDesigner);
private void SetStyleNames(TablePartPublisherDesigner activityPublisher)
activityPublisher.StyleNames.Add(“Light Shading – Accent 5”);
activityPublisher.StyleNames.Add(“Light Shading – Accent 2”);
activityPublisher.StyleNames.Add(“Medium List 2 – Accent 5”);
activityPublisher.StyleNames.Add(“Medium Grid 1 – Accent 4”);