|
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.