Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / RunTime / Hosting / WorkflowWebHostingModule.cs / 1305376 / WorkflowWebHostingModule.cs
/******************************************************************************** // Copyright (C) 2000-2001 Microsoft Corporation. All rights reserved. // // CONTENTS // Workflow Web Hosting Module. // DESCRIPTION // Implementation of Workflow Web Host Module. // REVISIONS // Date Ver By Remarks // ~~~~~~~~~~ ~~~ ~~~~~~~~ ~~~~~~~~~~~~~~ // 02/22/05 1.0 [....] Implementation. * ****************************************************************************/ #region Using directives using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Web; using System.Collections.Specialized; using System.Threading; #endregion namespace System.Workflow.Runtime.Hosting { ////// Cookie based rotuing module implementation /// public sealed class WorkflowWebHostingModule : IHttpModule { HttpApplication currentApplication; public WorkflowWebHostingModule() { WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Workflow Web Hosting Module Created"); } ////// IHttpModule.Init() /// /// void IHttpModule.Init(HttpApplication application) { WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Workflow Web Hosting Module Initialized"); this.currentApplication = application; //Listen for Acquire and ReleaseRequestState event application.ReleaseRequestState += this.OnReleaseRequestState; application.AcquireRequestState += this.OnAcquireRequestState; } void IHttpModule.Dispose() { } void OnAcquireRequestState(Object sender, EventArgs e) { //Performs Cookie based routing. WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "WebHost Module Routing Begin"); HttpCookie routingCookie = HttpContext.Current.Request.Cookies.Get("WF_WorkflowInstanceId"); if (routingCookie != null) { HttpContext.Current.Items.Add("__WorkflowInstanceId__", new Guid(routingCookie.Value)); } //else no routing information found, it could be activation request or non workflow based request. } void OnReleaseRequestState(Object sender, EventArgs e) { //Saves cookie back to client. HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("WF_WorkflowInstanceId"); if (cookie == null) { cookie = new HttpCookie("WF_WorkflowInstanceId"); Object workflowInstanceId = HttpContext.Current.Items["__WorkflowInstanceId__"]; if (workflowInstanceId != null) { cookie.Value = workflowInstanceId.ToString(); HttpContext.Current.Response.Cookies.Add(cookie); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /******************************************************************************** // Copyright (C) 2000-2001 Microsoft Corporation. All rights reserved. // // CONTENTS // Workflow Web Hosting Module. // DESCRIPTION // Implementation of Workflow Web Host Module. // REVISIONS // Date Ver By Remarks // ~~~~~~~~~~ ~~~ ~~~~~~~~ ~~~~~~~~~~~~~~ // 02/22/05 1.0 [....] Implementation. * ****************************************************************************/ #region Using directives using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Web; using System.Collections.Specialized; using System.Threading; #endregion namespace System.Workflow.Runtime.Hosting { ////// Cookie based rotuing module implementation /// public sealed class WorkflowWebHostingModule : IHttpModule { HttpApplication currentApplication; public WorkflowWebHostingModule() { WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Workflow Web Hosting Module Created"); } ////// IHttpModule.Init() /// /// void IHttpModule.Init(HttpApplication application) { WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Workflow Web Hosting Module Initialized"); this.currentApplication = application; //Listen for Acquire and ReleaseRequestState event application.ReleaseRequestState += this.OnReleaseRequestState; application.AcquireRequestState += this.OnAcquireRequestState; } void IHttpModule.Dispose() { } void OnAcquireRequestState(Object sender, EventArgs e) { //Performs Cookie based routing. WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "WebHost Module Routing Begin"); HttpCookie routingCookie = HttpContext.Current.Request.Cookies.Get("WF_WorkflowInstanceId"); if (routingCookie != null) { HttpContext.Current.Items.Add("__WorkflowInstanceId__", new Guid(routingCookie.Value)); } //else no routing information found, it could be activation request or non workflow based request. } void OnReleaseRequestState(Object sender, EventArgs e) { //Saves cookie back to client. HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("WF_WorkflowInstanceId"); if (cookie == null) { cookie = new HttpCookie("WF_WorkflowInstanceId"); Object workflowInstanceId = HttpContext.Current.Items["__WorkflowInstanceId__"]; if (workflowInstanceId != null) { cookie.Value = workflowInstanceId.ToString(); HttpContext.Current.Response.Cookies.Add(cookie); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UnsafeNativeMethods.cs
- BitmapEffectInput.cs
- UnknownBitmapDecoder.cs
- WebReference.cs
- TextTreeNode.cs
- ListItemParagraph.cs
- glyphs.cs
- HashCryptoHandle.cs
- UDPClient.cs
- TextTreeNode.cs
- MetadataSection.cs
- HttpHandlerActionCollection.cs
- Crc32Helper.cs
- EndpointAddressMessageFilter.cs
- ComboBox.cs
- SpeechSeg.cs
- WindowsStatusBar.cs
- BoolExpression.cs
- WaitHandle.cs
- ZoneMembershipCondition.cs
- XhtmlConformanceSection.cs
- ImageListUtils.cs
- TableCellsCollectionEditor.cs
- ListenerUnsafeNativeMethods.cs
- TextElementCollectionHelper.cs
- DataGridColumnHeadersPresenterAutomationPeer.cs
- XmlDocumentSchema.cs
- BamlVersionHeader.cs
- SoapServerMethod.cs
- SqlCacheDependencyDatabase.cs
- InheritedPropertyDescriptor.cs
- SizeF.cs
- ConnectAlgorithms.cs
- TableCellAutomationPeer.cs
- SchemaTypeEmitter.cs
- Maps.cs
- DataPagerFieldItem.cs
- XmlNodeReader.cs
- HtmlTernaryTree.cs
- TraceContextEventArgs.cs
- ProcessThread.cs
- SystemInformation.cs
- UnsafeNativeMethods.cs
- ReferencedType.cs
- OdbcError.cs
- DnsPermission.cs
- Tablet.cs
- StateBag.cs
- XmlNamespaceMapping.cs
- TextPattern.cs
- CodeTypeParameterCollection.cs
- ListChangedEventArgs.cs
- FullTextBreakpoint.cs
- BindingValueChangedEventArgs.cs
- CorePropertiesFilter.cs
- RotateTransform.cs
- TaiwanCalendar.cs
- HuffModule.cs
- TextEffectResolver.cs
- CoTaskMemHandle.cs
- TextureBrush.cs
- CultureSpecificCharacterBufferRange.cs
- ResourceDescriptionAttribute.cs
- InputLangChangeEvent.cs
- AssociationTypeEmitter.cs
- DesignerSerializationVisibilityAttribute.cs
- ThreadExceptionDialog.cs
- MULTI_QI.cs
- ScriptManager.cs
- GridViewRowEventArgs.cs
- ObjectListComponentEditor.cs
- XmlSchemaExternal.cs
- TypeElement.cs
- ReflectPropertyDescriptor.cs
- CodePageUtils.cs
- DataGridViewSelectedCellCollection.cs
- ComponentResourceKey.cs
- MappingMetadataHelper.cs
- XmlLoader.cs
- SmiSettersStream.cs
- SmtpReplyReaderFactory.cs
- ResXResourceReader.cs
- IssuanceLicense.cs
- Stylesheet.cs
- QuadTree.cs
- PagedDataSource.cs
- MailFileEditor.cs
- InternalTypeHelper.cs
- LinearGradientBrush.cs
- PriorityChain.cs
- GridLength.cs
- CreateUserWizardStep.cs
- DocumentSchemaValidator.cs
- ColumnHeader.cs
- ResXResourceSet.cs
- VariantWrapper.cs
- ActivityDefaults.cs
- XslAstAnalyzer.cs
- SpeechUI.cs
- ProjectionPruner.cs