A basic question about WF, plz help me

Hello,
I have been learning Windows WF recently. But I've got a big block at the beginning. I want to develop an overtime management system. And it’s a long flow system,I think.
I create 2 projects. One is a web project, the other is Squence Workflow Library project.
My expectation is:
1. One user logs in this system and submit his overtime application in apply.aspx.
2. System sends a mail to the user's supervisor, in which is a message and a url which links to audit.aspx flowid= .
3. The supervisor receives the mail and clicks the link, by which he logs in the system and finds this application according to flowid And …. …

My question is how to keep the workflow running in the memory. I think when I access this system, the workflow instance will be initialized by asp.net. , but when I close my browser, the session will be lost, and the workflow instantce will be disposed by GC too. Therefore, the supervisor will not find the correct workflow instance when he logs in the system.

As far as I know, Windows WF supports long flow, but i don't know how to apply it.

Is my analysis correct How to realize this process correctly. Please help me :-)

Thanks and best regards


Answer this question

A basic question about WF, plz help me

  • duck16

    Hi,

    In order to achieve your desired long-running functionality, you need to involve a form of workflow persistence (either SQL or any other custom persistence service) into your project. More details about workflow persistence can be found at: http://msdn2.microsoft.com/en-us/library/aa349367.aspx .

    Once that you configured the out-of-the-box SqlWorkflowPersistenceService OR your own custom persistence service, all you need to cache through the Session mechanism (or any other persistence form) is the worklow instance ID for your running workflow instance. You can always retrieve such a passivated (persisted) workflow instance through one of the WorkflowRuntime's methods whenever you have the workflow instance ID (handle) available. This gives you process-agility in terms of accessing a running workflow instance (create it in one process and access it from a different process as long as you know it's workflow instance ID).

    You may also want ot search http://wf.netfx3.com for keywords like "Persistence from ASP.NET" for more concrete examples.

    Best regards!


  • yoga80

    hi all, i have got a try. and it's running well. thanks in advance


  • Avi888

    Don't put the workflow in session. The WorkflowRuntime will hold the instance for you (or persist it if you use persistence). When the supervisor comes back - you just ask the runtime for that instance (via its GUID).

  • mAh3u

    Hi Kevin,

    If I can assume you are using Sql Server, then you should look into using SqlWorkflowPersistenceService - Plenty of googling!

    Essentially, you can have your in-progress workflow "persist" to a database, which it does by serializing the workflow instance. You can then use the InstanceID (guid) to open the persisted workflow and resume it as required. So you have to store this Instance ID somewhere (another database table perhaps) and then retrieve as needed.

    Regards,
    Dave



  • A basic question about WF, plz help me