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
- DbProviderConfigurationHandler.cs
- AccessibilityHelperForXpWin2k3.cs
- InternalControlCollection.cs
- StyleBamlRecordReader.cs
- WebConfigurationHost.cs
- TreeIterator.cs
- CodeDomSerializer.cs
- PersistenceMetadataNamespace.cs
- BitArray.cs
- UnsafeNativeMethodsMilCoreApi.cs
- MultiAsyncResult.cs
- TableParagraph.cs
- HttpHandlerAction.cs
- ParseElementCollection.cs
- OracleCommandSet.cs
- PriorityQueue.cs
- DetailsViewDeleteEventArgs.cs
- PrintEvent.cs
- AspNetPartialTrustHelpers.cs
- FramingDecoders.cs
- SchemaNotation.cs
- BindingCompleteEventArgs.cs
- XPathDescendantIterator.cs
- ProvidersHelper.cs
- QilNode.cs
- TemplateInstanceAttribute.cs
- FloatUtil.cs
- ObjectHandle.cs
- ProfileSettingsCollection.cs
- MimeObjectFactory.cs
- FixedDocumentSequencePaginator.cs
- BindingObserver.cs
- StateBag.cs
- WinEventQueueItem.cs
- DetailsViewModeEventArgs.cs
- ProviderConnectionPoint.cs
- OptimisticConcurrencyException.cs
- AuthorizationRule.cs
- AsyncWaitHandle.cs
- CacheMemory.cs
- ManagementQuery.cs
- RelatedImageListAttribute.cs
- HttpHandlerActionCollection.cs
- MarkerProperties.cs
- UrlMapping.cs
- Misc.cs
- XmlArrayAttribute.cs
- LeaseManager.cs
- ListViewInsertionMark.cs
- CellPartitioner.cs
- CollectionChangedEventManager.cs
- TextSelection.cs
- Column.cs
- ToolStripItemClickedEventArgs.cs
- EraserBehavior.cs
- EmptyEnumerator.cs
- __ComObject.cs
- ListBoxItemAutomationPeer.cs
- ContentIterators.cs
- ImageField.cs
- RoutingTable.cs
- VectorKeyFrameCollection.cs
- _SslSessionsCache.cs
- BitmapEffect.cs
- SpotLight.cs
- RemotingConfiguration.cs
- HTTP_SERVICE_CONFIG_URLACL_KEY.cs
- PropertyGeneratedEventArgs.cs
- MarkupCompilePass1.cs
- FixedHyperLink.cs
- IgnoreFlushAndCloseStream.cs
- SchemaExporter.cs
- AstTree.cs
- AnnotationAuthorChangedEventArgs.cs
- ThrowHelper.cs
- InfoCardBaseException.cs
- EntityDataSourceReferenceGroup.cs
- CheckedListBox.cs
- AsyncCompletedEventArgs.cs
- DataObjectEventArgs.cs
- EqualityComparer.cs
- ChtmlTextWriter.cs
- ProbeMatchesMessage11.cs
- Compiler.cs
- AutoGeneratedFieldProperties.cs
- ControlAdapter.cs
- CollectionMarkupSerializer.cs
- XmlSerializerOperationFormatter.cs
- Win32PrintDialog.cs
- StylusButtonEventArgs.cs
- StrongName.cs
- ServiceDescriptionData.cs
- SafeArchiveContext.cs
- LiteralLink.cs
- BuildProviderCollection.cs
- TreeNodeBindingCollection.cs
- DrawingContext.cs
- XmlSubtreeReader.cs
- DataGridViewCell.cs
- RecognizerBase.cs