Reputation: 57
1) I have a UI page which invokes a Workflow service(say via a button named Invoke) which is having say around 5 steps.Steps 1,3,5 are implemented as Code Activities while steps 2 and 4 are implemented as Activities(i.e. xaml files) and each of these activities have internal steps which are again implemented as Code Activities.Now the user enters data in UI and presses a button which invokes the service but then the service may throw Business exception at any of the steps within the service or the Activities.If any such error occurs, the user is provided a link with Re-Run option, clicking of which loads the WF Service instance with the same wf instance id but what I want is that now the WF Service should start processing from the step where it threw the error?
Probably this may be achieved by using Bookmarks but I know only to use Bookmarks statically.Is there any way that I can insert some bookmark somewhere in the workflow definition for some specific instance at runtime dynamically?If not then how do I implement the above functionality?
I am looking for some generic maintainable solution for the above scenario.
Thanks and Regards,
Sandip
Upvotes: 0
Views: 175
Reputation: 8406
One way is to put a Persist activity (from Toolbox | Runtime | Persist) before every Activity where you expect a business exception. Now when you Load the workflow it will load to the last Persist activity and then proceed to the next Activity.
You just need to make sure that you don't Persist the workflow after the Buisness Exception.
Another way that I like to use is to have the call back PersistableIdleAction attached to the workflow. Then in the workflow I have an activity to "Prepare for Persistence" followed by a delay (which triggers the persist) followed by a "Return from Persistence" activity. "Return from Persistence" is the first activity that will run after a workflow.Load The advantage is that I can clean up data in the "Return from Persistence" or read a flag to unload the workflow and I can do extra work in the PersistableIdleAction callback ( like informing the UI that an error has occurred)
Upvotes: 1