Global in Workflow

Source: Internet
Author: User
Tags hosting connectionstrings

Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. sessionstate;
Using system. workflow. Activities;
Using system. workflow. runtime;
Using system. workflow. runtime. Hosting;
Using system. Collections. Specialized;
Namespace webservice1
{
Public class Global: system. Web. httpapplication
{

Protected void application_start (Object sender, eventargs E)
{

System. workflow. runtime. workflowruntime = new system. workflow. runtime. workflowruntime ("workflowruntime ");

// System. workflow. runtime. hosting. sqlworkflowpersistenceservice sqlpersistenceservice = new system. workflow. runtime. hosting. sqlworkflowpersistenceservice ("Initial catalog = sqlpersistenceservice; Data Source = localhost; Integrated Security = sspi ");
// Workflowruntime. addservice (sqlpersistenceservice );

Workflowruntime. workflowaborted + = new eventhandler <system. workflow. runtime. workfloweventargs> (workflowruntime_workflowaborted );
Workflowruntime. workflowidled + = new eventhandler <system. workflow. runtime. workfloweventargs> (workflowruntime_workflowidled );
Workflowruntime. workflowterminated + = new eventhandler <system. workflow. runtime. workflowterminatedeventargs> (workflowruntime_workflowterminated );
Workflowruntime. workflowunloaded + = new eventhandler <system. workflow. runtime. workfloweventargs> (workflowruntime_workflowunloaded );
Workflowruntime. workflowsuincluded + = new eventhandler <system. workflow. runtime. workflowsuspendedeventargs> (workflowruntime_workflowsuincluded );
Workflowruntime. workflowcompleted + = new eventhandler <system. workflow. runtime. workflowcompletedeventargs> (workflowruntime_workflowcompleted );

Namevaluecollection parms = new namevaluecollection ();
Parms. Add ("unloadonidle", "true ");
Parms. Add ("connectionstring", configurationmanager. connectionstrings ["sqlconnectionstring"]. connectionstring );
Workflowruntime. addservice (New sqlworkflowpersistenceservice (parms ));
// String conn = configurationmanager. connectionstrings ["sqlconnectionstring"]. connectionstring;
// Workflowruntime. addservice (New sqlworkflowpersistenceservice (conn ));

Application ["workflowruntime"] = workflowruntime;

Workflowruntime. startruntime ();
}

Void workflowruntime_workflowcompleted (Object sender, system. workflow. runtime. workflowcompletedeventargs E)
{
Console. writeline ("finished ");
}

Void workflowruntime_workflowsuincluded (Object sender, system. workflow. runtime. workflowsuspendedeventargs E)
{
Console. writeline ("pending ");
}

Void workflowruntime_workflowunloaded (Object sender, system. workflow. runtime. workfloweventargs E)
{
Console. writeline ("Uninstall ");
}

Void workflowruntime_workflowterminated (Object sender, system. workflow. runtime. workflowterminatedeventargs E)
{
Console. writeline ("Abort ");
}

Void workflowruntime_workflowidled (Object sender, system. workflow. runtime. workfloweventargs E)
{
Console. writeline ("idle ");
}

Void workflowruntime_workflowaborted (Object sender, system. workflow. runtime. workfloweventargs E)
{
Console. writeline ("unexpected ");
}

Protected void application_end (Object sender, eventargs E)
{

System. workflow. runtime. workflowruntime = application ["workflowruntime"] As system. workflow. runtime. workflowruntime;
Workflowruntime. stopruntime ();
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.