Steve1999

Within the WF runtime, i see runtime.GetWorkflow(Guid) and instance.Load().

However, the typical use of my app would be that the user turns it off occasionally (this would prompt me to call Unload() on all the workflows), and turns it back on (this would necessitate restoring all the persisted workflows)

How do i ask the runtime to restore all the persisted workflows I don't see a:

runtime.GetAllWorkflows()

Is there a way to do this

Thanks.


Re: Windows Workflow Foundation restoring all workflows from persisted storage

Pravin Indurkar - MSFT

Hi,

Actually the SQL persistence service does this exact functionality when you start the run time. But in your case I assume the host (and hence the runtime) is still running and you simply want to restore workflows. What you need to do is to access all the instances from the persistence database and iterrate over them and for each one of them call runtime.GetWorkflow(Guid)

Thanks

Pravin Indurkar





Re: Windows Workflow Foundation restoring all workflows from persisted storage

Steve1999

Pravin,

I'm using a windows service. So, in this case, the runtime shuts down and is recreated (Service.Stop and Service.Start). I also use a tracking service layer above the workflow instances (i got this from the WF lab samples), that adds itself as a "TrackingService" to the runtime.  It stores instances in a Dictionary<guid, instance>

We're using the "File peristence" service (temporarily, until we write/find a Oracle service).

So, when the runtime starts up, it'll automatically restore all persisted workflow instances, and i can call:

runtime.GetLoadedWorkflows()

to restore my "tracking service layer"

Thanks again!




Re: Windows Workflow Foundation restoring all workflows from persisted storage

Pravin Indurkar - MSFT

Well are you using the file persistence service form the samples

The functionality of loading all the workflows is specific to the SQL Persistence Service. The runtime.GetLoadedWorkflows() only gets you the workflow loaded in memory. You will need to get a list of all workflowinstances that are in the fiel persistence service and then call runtime.GetWorkflow() on each one of them.

Thanks

Pravin Indurkar





Re: Windows Workflow Foundation restoring all workflows from persisted storage

Steve1999

I understand what you're saying, but it does seem odd that connecting the runtime to a persistence service wouldn't do this automatically and consistently, across any peristence service you use, or better, to have a method like: GetAllWorkflowsFromStorage(). 

Oh well...

One last question on this thread: when you stop the runtime, is it automatic that the runtime will persist all workflows in memory to storage (using non SQL persistence services)   

I'm expecting it wont, because, as you say, it wouldnt be symmetrical with loading.

Thanks!










Re: Windows Workflow Foundation restoring all workflows from persisted storage

Khalid Aggag - MSFT

No, in the case of runtime shutting down, it will in fact iterate on all loaded instances and use whatever persistence service in place to persist the insances before shutting down.

We may look into making the runtime load instances on startup in future releases of WF.