public void Shutdown(OrchardHostContext context) { if (context == null) { throw new ArgumentNullException("context"); } try { if (context.OrchardHost != null) { LogInfo("Shutting down Orchard session..."); context.OrchardHost.StopSession(); } } catch (AppDomainUnloadedException) { LogInfo("AppDomain already unloaded."); } if (context.OrchardHost != null) { LogInfo("Shutting down ASP.NET AppDomain..."); ApplicationManager.GetApplicationManager().ShutdownAll(); } }
/// <summary> /// Initializes the specified host context. /// </summary> /// <param name="context">The Orchard host context object.</param> private void Initialize(OrchardHostContext context) { if (string.IsNullOrEmpty(this.orchardPath)) { context.WorkingDirectory = Environment.CurrentDirectory; } else { context.WorkingDirectory = this.orchardPath; } LogInfo("Working directory: \"{0}\"", context.WorkingDirectory); context.VirtualPath = "/"; LogInfo("Virtual path: \"{0}\"", context.VirtualPath); LogInfo("Detecting orchard installation root directory..."); context.OrchardDirectory = this.GetOrchardDirectory(context.WorkingDirectory).FullName; LogInfo("Orchard root directory: \"{0}\"", context.OrchardDirectory); LogInfo("Creating ASP.NET AppDomain for command agent..."); context.OrchardHost = CreateOrchardHost(context.VirtualPath, context.OrchardDirectory); LogInfo("Starting Orchard session"); context.StartSessionResult = context.OrchardHost.StartSession(); }
public OrchardHostContext CreateContext() { var context = new OrchardHostContext { RetryResult = ReturnCode.Retry }; this.Initialize(context); return(context); }
/// <summary> /// Initializes the Orchard session. /// </summary> public void Initialize() { OrchardHostContext ctx = this.hostContextProvider.CreateContext(); if (ctx.StartSessionResult == ctx.RetryResult) { ctx = this.hostContextProvider.CreateContext(); } else if (ctx.StartSessionResult == ReturnCode.Fail) { this.hostContextProvider.Shutdown(this.context); throw new OrchardProviderException("Failed to initialize Orchard session."); } this.context = ctx; }