Using Workflow Foundation within WCSF besides Page Flows

Topics: Web Client Software Factory, User Forum
May 29, 2007 at 1:41 PM
Hello,

Could anybody say how I can use Workflow Foundation within the WCSF besides Page Flows? I would use Workflow Foundation as a host for a State Manager Service. I would add a foundational module and make this service global available in my solution.

The following scenario illustrates what I mean:

an Order could have 5 States
On an Initialize Event each Order gets the UID and an initial state.
All possible transitions are managed via a State Manager Service that is hosted in a Workflow Foundation. If this State Manager Service gets UID it returns all available transitions\states.

What should I consider if I plan to add Page Flow functionality later?
Could I use the same WorkflowRuntime or should I create the second one?

I’m new to this topic so any help will be very appreciated.

KR,
Boris
May 30, 2007 at 1:24 PM
The WorkflowRuntime for page flow is hidden, so you cannot share it (without source changes). It is best to just think of page flow as a black box and use workflow in your application without concern for pageflow.
May 30, 2007 at 3:40 PM
Edited May 30, 2007 at 3:54 PM
Thanks a lot,

I think that there can be only one WorkflowRuntime in an AppDomain, so it’s not possible to use both “pure” Workflow foundation and PageFlow without source code change.
If the workflow runtime is stored in an application global instance, it should be open to foundational modules.
Another issue (if I would decide to drop Page Flows): How can I inject a manual programmed WF logic in the MVPC Model of WCSF? I can’t use foundational module, I should add workflowProject to a solution because a workflow designer will not work else.
I want use the built-in DI via ObjectBuilder.

The general Workflow Foundation functionality placed in WorkflowFoundationPageFlowFactory\WorkflowFoundationPageFlow now could be refactored and made available in foundational modules ( or new wf modules) or does anybody know a workaround? I created a workItem.
May 30, 2007 at 6:31 PM
The documentation does imply that only WorkflowRuntime can be used, but we have an application using two workflow runtimes and so far have not run into any issues.
May 31, 2007 at 8:17 AM
Edited May 31, 2007 at 10:43 AM
It's very interesting. I saw in WF forums that "one WFR per appDomain" restriction is gone but was not sure about it. How can I properly inject WF stuff into the MVP model of WCSF?

Can you please describe what sort of experience have you gained with WF?
I think it could be very interesting for whole community ;)

Yesterday I hit on a sample in web (http://blogs.msdn.com/tomlake/archive/2006/05/02/588617.aspx)
Without WCSF I would do my task like that:
1) add in global. asax
void Application_Start(object sender, EventArgs e)
{
System.Workflow.Runtime.WorkflowRuntime workflowRuntime = new System.Workflow.Runtime.WorkflowRuntime("WorkflowRuntime");
Application"WorkflowRuntime" = workflowRuntime;
workflowRuntime.StartRuntime();
}
2) and then use it in code
WorkflowRuntime workflowRuntime = Application"WorkflowRuntime" as WorkflowRuntime;

// Now get a refernece to the ManualWorkflowSchedulerService
ManualWorkflowSchedulerService scheduler =
workflowRuntime.GetService<ManualWorkflowSchedulerService>();

ExternalDataExchangeService dataService = workflowRuntime.GetService<ExternalDataExchangeService>();
OrderLocalServices.OrderService orderService = workflowRuntime.GetService<OrderLocalServices.OrderService>();

3) change web.config : add httpmodule or/and
<WorkflowRuntime Name="WorkflowServiceContainer">
<Services>
<add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<!--<add type="System.Workflow.Runtime.Hosting.DefaultWorkflowTransactionService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>-->
<add type="System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</Services>
And so on

How can I do it within WCSF?

Is ASP Application Object in WCSF available?

KR,
Boris

May 31, 2007 at 9:08 AM
Edited May 31, 2007 at 9:09 AM
I looked into the Reference solution(GlobalBank.Commercial.EBanking)
So the WebClientApplication class can be extended and a subclass can be placed in the AppCode folder.
In the WebClientApplication I could find a Start method, that runs ApplicationStart logic but there is no method for Application_End.
If I create WorkflowRuntime on Start how can I force workflowRuntime.StopRuntime() on the Application_End?