Exemple #1
0
 public DescriptionCreator(WorkflowDefinitionContext workflowDefinitionContext)
 {
     if (workflowDefinitionContext == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowDefinitionContext");
     }
     this.workflowDefinitionContext = workflowDefinitionContext;
 }
Exemple #2
0
        void InitializeDescription(WorkflowDefinitionContext workflowDefinitionContext, UriSchemeKeyedCollection baseAddresses)
        {
            this.workflowDefinitionContext = workflowDefinitionContext;
            this.InitializeDescription(baseAddresses);

            if (!this.Description.Behaviors.Contains(typeof(WorkflowRuntimeBehavior)))
            {
                this.Description.Behaviors.Add(new WorkflowRuntimeBehavior());
            }
        }
        internal WorkflowServiceBehavior(WorkflowDefinitionContext workflowDefinitionContext)
        {
            if (workflowDefinitionContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowDefinitionContext");
            }

            this.workflowDefinitionContext = workflowDefinitionContext;
            this.name = this.workflowDefinitionContext.WorkflowName;
            this.configurationName = this.workflowDefinitionContext.ConfigurationName;
        }
Exemple #4
0
        public WorkflowInstanceContextProvider(ServiceHostBase serviceHostBase, bool isPerCall, WorkflowDefinitionContext workflowDefinitionContext)
            : base(serviceHostBase, isPerCall)
        {
            if (workflowDefinitionContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowDefinitionContext");
            }

            this.workflowDefinitionContext          = workflowDefinitionContext;
            this.serviceHostBase                    = serviceHostBase;
            this.workflowActivationCompleteCallback = Fx.ThunkCallback(new WaitCallback(this.OnWorkflowActivationCompleted));
        }
        public WorkflowDurableInstance(WorkflowInstanceContextProvider instanceContextProvider, Guid instanceId, WorkflowDefinitionContext workflowDefinition, bool createNew)
            :
            base(instanceContextProvider, instanceId)
        {
            if (workflowDefinition == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowDefinition");
            }

            this.workflowDefinition      = workflowDefinition;
            this.shouldCreateNew         = createNew;
            this.instanceContextProvider = instanceContextProvider;
        }
        public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
        {
            WorkflowDefinitionContext workflowDefinitionContext = null;

            Stream workflowDefinitionStream = null;
            Stream ruleDefinitionStream     = null;

            if (string.IsNullOrEmpty(constructorString))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.WorkflowServiceHostFactoryConstructorStringNotProvided)));
            }

            if (!HostingEnvironment.IsHosted)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.ProcessNotExecutingUnderHostedContext)));
            }

            Type workflowType = this.GetTypeFromString(constructorString, baseAddresses);

            if (workflowType != null)
            {
                workflowDefinitionContext = new CompiledWorkflowDefinitionContext(workflowType);
            }
            else
            {
                try
                {
                    IDisposable impersonationContext = null;
                    try
                    {
                        try
                        {
                        }
                        finally
                        {
                            //Ensure thread.Abort doesnt interfere b/w impersonate & assignment.
                            impersonationContext = HostingEnvironment.Impersonate();
                        }

                        string xomlVirtualPath = Path.Combine(AspNetEnvironment.Current.CurrentVirtualPath, constructorString);

                        if (HostingEnvironment.VirtualPathProvider.FileExists(xomlVirtualPath))
                        {
                            workflowDefinitionStream = HostingEnvironment.VirtualPathProvider.GetFile(xomlVirtualPath).Open();
                            string ruleFilePath = Path.ChangeExtension(xomlVirtualPath, WorkflowServiceBuildProvider.ruleFileExtension);

                            if (HostingEnvironment.VirtualPathProvider.FileExists(ruleFilePath))
                            {
                                ruleDefinitionStream      = HostingEnvironment.VirtualPathProvider.GetFile(ruleFilePath).Open();
                                workflowDefinitionContext = new StreamedWorkflowDefinitionContext(workflowDefinitionStream, ruleDefinitionStream, this.typeProvider);
                            }
                            else
                            {
                                workflowDefinitionContext = new StreamedWorkflowDefinitionContext(workflowDefinitionStream, null, this.typeProvider);
                            }
                        }
                    }
                    finally
                    {
                        if (impersonationContext != null)
                        {
                            impersonationContext.Dispose();
                        }
                    }
                }
                catch
                {
                    throw; //Prevent impersonation leak through Exception Filters.
                }
                finally
                {
                    if (workflowDefinitionStream != null)
                    {
                        workflowDefinitionStream.Close();
                    }

                    if (ruleDefinitionStream != null)
                    {
                        ruleDefinitionStream.Close();
                    }
                }
            }

            if (workflowDefinitionContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.CannotResolveConstructorStringToWorkflowType, constructorString)));
            }

            WorkflowServiceHost serviceHost = new WorkflowServiceHost(workflowDefinitionContext, baseAddresses);

            if (DiagnosticUtility.ShouldTraceInformation)
            {
                TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.WorkflowServiceHostCreated, SR.GetString(SR.TraceCodeWorkflowServiceHostCreated), this);
            }
            return(serviceHost);
        }
Exemple #7
0
 internal WorkflowServiceHost(WorkflowDefinitionContext workflowDefinitionContext, params Uri[] baseAddress)
     : base()
 {
     InitializeDescription(workflowDefinitionContext, new UriSchemeKeyedCollection(baseAddress));
 }