How to tell the Activity type when loading a persisted workflow
Question:
I开发者_如何学Pythons there an easy way to find out what Activity Type was used to create a workflow?
Background:
I am writing my own WorkflowApplication
based Windows Workflow 4 hosting engine and I am having some issues trying to load persisted workflows out of the database. I am using the WorkflowApplication.Load(Guid)
method to start the workflow, but this requires me to already create the WorkflowApplication
.
Looking at the SqlWorkflowInstanceStore
databases, I don't see the type name stored anywhere and I don't see an easy to to associate it short of making another table myself just to store that information.
When you are using workflow services the relative URL is used to determine if a WorkflowServiceHost owns the workflow instance, this is done through the ServiceDeploymentsTable table in the database. There is no similar mechanism when you are using a WorkflowApplication so you have to roll your own.
One thing you could do is use property promotion to store the type in the InstancePromotedPropertiesTable. It will save you from creating a new table but is hardly an ideal way of solving the problem.
I guess you have 2 options for doing that, neither of them optimal:
- You could use promoted properties as Maurice already suggested to store the info in the InstancePromotedPropertiesTable and avoid having to create your own table. There's a nice article on MSDN.
- if you decide to create your own table, I'd suggest you implement a PersistenceIOParticipant. Check out the sample, you could always store the type name or your XAML instead of the path.
精彩评论