locked
How to resume a previous bookmark after other bookmarks have been created RRS feed

  • Question

  • I have a workflow (WF 4.5) which is basically a series of questions, where each "Question" is a custom activity. However, I need to be able to persist this workflow so that the user can resume at the last question he answered, or at any question before that one, so that he can change his answers.

    For example, if the workflow has a total of 10 questions (question 1 to 10), and the user answered them up to question number 7, I want him to be able to choose which question he wants to resume up to question 7, which would allow him to choose any question from 1 to 7. If he chooses question 3, the workflow will continue to hold the answers he had for questions 1 and 2, and he will be able to give a new answer to question 3, 4, 5, 6, 7 and continue up to question 10.

    Is it possible to accomplish that through bookmarks? Could I create a different bookmark for each question, and even if the user is already at question 7 (with 7 bookmarks created up to this point), can I resume the workflow from the bookmark created at question 3, for example? If not, how can this be accomplished?

    Tuesday, May 28, 2013 2:33 PM

Answers

  • As far as I know (and I may be wrong) Bookmark mechanism is not intended as a rerun/rewind mechanism, nor do I think it would be even possible in your case because your context may change with every activity execution.

    Maybe you can somehow serialize each of your WF instances on every bookmark (in your case question answered) and then retrieve a version of a WF based what you call a bookmark (isn't the same as true WF bookmark) but that will lead to maintaining multiple WF instances for every answered question...

    You can probably intercept a point when a workflow is being serialized, and make a copy of it and store it somehow...

    • Marked as answer by Molly Chen_ Tuesday, June 4, 2013 8:46 AM
    Tuesday, May 28, 2013 6:44 PM

All replies

  • I don't think using multiple bookmarks will address your needs, however I would suggest you build a state machine where each consecutive state will have a transition to next state and to all previous states. each state contains your custom activity on entry and contains another custom activity. When you resume your workflow on a bookmark (you only need one) you also pass a parameter which drives the question number, and based on that parameter you make a decision which transition to take.

    That's the most simplistic and "intuitive" approach as its very visual, however it may get pretty messy if you have many questions (with N questions you would have N (N+1) / 2).

    Another approach could be to hold your questions an array (You can build a workflow that builds that array as a sequence of AddToCollection activities) of some sort and drive your logic by producing indexing the question you want to answer from within that array. In that case, you solution will likely split into 2 sections, one being a composition of that array (I assume you want WF to be used to control the sequence of the questions) and second section is an execution. Same mechanism as #1, you "sleep" your workflow and on resume you ask a user which question he wants to answer and you just retrieve a question activity from collection.

    I could think of many implementation of your problem, but this is a design exercise, not a technology question.

    Tuesday, May 28, 2013 3:56 PM
  • Rodion, my problem is that it is my end user who will be building the workflows by using a rehosted workflow designer. I need to provide this ability of, when executing the workflow he built, he could return the "point of execution" to any previous "idle-inducing" activities he might have put in the workflow. The workflow is consisted of both "idle-inducing" and "non-idle-inducing" activities, and those "idle-inducing" activities would be the questions. Therefore, to make this a techonlogy question, I wanted to know if Workflow Foundation provides any way for me to return workflow execution to a previous activity, perhaps through its "DebuggerService" or any other way.

    Tuesday, May 28, 2013 6:14 PM
  • As far as I know (and I may be wrong) Bookmark mechanism is not intended as a rerun/rewind mechanism, nor do I think it would be even possible in your case because your context may change with every activity execution.

    Maybe you can somehow serialize each of your WF instances on every bookmark (in your case question answered) and then retrieve a version of a WF based what you call a bookmark (isn't the same as true WF bookmark) but that will lead to maintaining multiple WF instances for every answered question...

    You can probably intercept a point when a workflow is being serialized, and make a copy of it and store it somehow...

    • Marked as answer by Molly Chen_ Tuesday, June 4, 2013 8:46 AM
    Tuesday, May 28, 2013 6:44 PM