I am trying to understand how one can resume (load) a previously persisted WF4 activity without knowing the concrete type of the activity.
In order to load a persisted activity, I not only need its workflowId (which I have), but I need to pass in an instance of the activity too - so I need to know it's type:
var workflowApplication = new WorkflowApplication(activity); // what type is activity?
workflowApplication.Load(workflowId);
The problem is that it could be one of a number of types - this activity is intended to be used within other activities and workflows: it sends a message to a message queue, bookmarks and then persists. It is resumed when a corresponding message is received via the message queue but I don't know the exact concrete type of the original workflow without examining the persistence data. This seems like catch-22. I can't load the workflow without knowing the activity type, and I can't know the activity type without loading the workflow and examining the its persisted data.
I feel like I'm missing something here - is there a way to either create a hosting WorkflowActivity without knowing the activity, or a way to reload the persistence data to work out the actual type of activity before creating the WorkflowActivity?
There's no native support to do it through WF API, you've to come up with your own solution.
The fastest approach: Store Extensibility to use InstancePromotedProperties table to save your own properties.
Probably the correct approach: PersistenceIOParticipant seems the correct way of doing it. Just create your own table to store whatever you want including activity's type.
Use a custom activity to save it for you, somewhere, before persist. Not the best nor correct way of doing it for a variety of reasons.
来源:https://stackoverflow.com/questions/10349088/resuming-a-persisted-window-workflow-4-activity-without-knowing-concrete-type-of