Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Navigational Workflows Unleashed in WWF/ASP.NET 3.5

, 21 Oct 2008 CPOL
Case-study on the internals of a Navigational Workflow engine for a fictional dating website called “World Wide Dating”.
datesite.zip
DateSite
App_Data
bin
database setup procedure
DateSite.csproj.user
Global.asax
images
complete.png
critical.png
logo2.png
warning.png
Profile.dbml
Profile.dbml.layout
Properties
Service References
NavigationWorkflow
bin
NavigationWorkflow.layout
Properties
Settings.settings
using System;
using System.Workflow.Runtime;
using System.Workflow.Activities;

namespace DateSite
{
    public class Global : System.Web.HttpApplication
    {
        /// <summary>
        /// This method fires when the application is first started and is responsible for
        /// setting up the workflow runtime to be hosted by the asp.net application. It creates
        /// the workflow runtime with the given settings from the web.config. It then proceeds
        /// to add the local services defined in the web.config. Finally it starts the workflow
        /// runtime and stores the instance in an application variable. Only one instance of the
        /// workflow runtime can be running in a single application domain.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Application_Start(object sender, EventArgs e)
        {
            // create an instance of workflow runtime, loading settings from web.config
            WorkflowRuntime workflowRuntime = new WorkflowRuntime(WorkflowManager.WorkflowRuntimeKey);

            // add the external data exchange service to the runtime to allow for local services
            ExternalDataExchangeService exchangeService = new ExternalDataExchangeService(WorkflowManager.LocalServicesKey);
            workflowRuntime.AddService(exchangeService);

            // start the workflow runtime
            workflowRuntime.StartRuntime();

            // save the runtime for use by the entire application
            Application[WorkflowManager.WorkflowRuntimeKey] = workflowRuntime;
        }

        /// <summary>
        /// This method fires when the application stops. It stops the workflow runtime and 
        /// disposes of the resources it was using.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Application_End(object sender, EventArgs e)
        {
            // obtain reference to workflow runtime
            WorkflowRuntime workflowRuntime = Application[WorkflowManager.WorkflowRuntimeKey] as WorkflowRuntime;

            // stop the runtime
            if (workflowRuntime != null)
            {
                workflowRuntime.StopRuntime();
                workflowRuntime.Dispose();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Pero Matić
Software Developer (Senior) Plan A Software
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 21 Oct 2008
Article Copyright 2008 by Pero Matić
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid