diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs index 81f3e019d8..de200db55c 100644 --- a/src/Umbraco.Web/UmbracoApplication.cs +++ b/src/Umbraco.Web/UmbracoApplication.cs @@ -3,7 +3,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; +using System.Web; +using System.Web.Hosting; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Web.Routing; using umbraco.businesslogic; @@ -60,14 +63,38 @@ namespace Umbraco.Web ApplicationStarted(sender, e); } - protected virtual void Application_Error(object sender, EventArgs e) + /// + /// A method that can be overridden to invoke code when the application has an error. + /// + /// + /// + protected virtual void OnApplicationError(object sender, EventArgs e) { - + } - protected virtual void Application_End(object sender, EventArgs e) + protected void Application_Error(object sender, EventArgs e) { + OnApplicationError(sender, e); + } + /// + /// A method that can be overridden to invoke code when the application shuts down. + /// + /// + /// + protected virtual void OnApplicationEnd(object sender, EventArgs e) + { + + } + + protected void Application_End(object sender, EventArgs e) + { + if (SystemUtilities.GetCurrentTrustLevel() == AspNetHostingPermissionLevel.Unrestricted) + { + LogHelper.Info("Application shutdown. Reason: " + HostingEnvironment.ShutdownReason); + } + OnApplicationEnd(sender, e); } } } diff --git a/src/umbraco.businesslogic/ApplicationRegistrar.cs b/src/umbraco.businesslogic/ApplicationRegistrar.cs index d29d50d90f..2432ad783c 100644 --- a/src/umbraco.businesslogic/ApplicationRegistrar.cs +++ b/src/umbraco.businesslogic/ApplicationRegistrar.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Data.SqlClient; +using System.Linq; using System.Xml.Linq; using Umbraco.Core; using umbraco.BusinessLogic.Utils; @@ -29,6 +31,11 @@ namespace umbraco.BusinessLogic public ApplicationRegistrar() { + + //don't do anything if the application is not configured! + if (!ApplicationContext.Current.IsConfigured) + return; + // Load all Applications by attribute and add them to the XML config var types = PluginManager.Current.ResolveApplications(); @@ -40,7 +47,7 @@ namespace umbraco.BusinessLogic var allAliases = Application.getAll().Select(x => x.alias).Concat(attrs.Select(x => x.Alias)); var inString = "'" + string.Join("','", allAliases) + "'"; - + Application.LoadXml(doc => { foreach (var attr in attrs) @@ -51,16 +58,17 @@ namespace umbraco.BusinessLogic new XAttribute("icon", attr.Icon), new XAttribute("sortOrder", attr.SortOrder))); } - - var dbApps = SqlHelper.ExecuteReader("SELECT * FROM umbracoApp WHERE appAlias NOT IN ("+ inString +")"); - while (dbApps.Read()) - { - doc.Root.Add(new XElement("add", - new XAttribute("alias", dbApps.GetString("appAlias")), - new XAttribute("name", dbApps.GetString("appName")), - new XAttribute("icon", dbApps.GetString("appIcon")), - new XAttribute("sortOrder", dbApps.GetByte("sortOrder")))); - } + + var dbApps = SqlHelper.ExecuteReader("SELECT * FROM umbracoApp WHERE appAlias NOT IN (" + inString + ")"); + while (dbApps.Read()) + { + doc.Root.Add(new XElement("add", + new XAttribute("alias", dbApps.GetString("appAlias")), + new XAttribute("name", dbApps.GetString("appName")), + new XAttribute("icon", dbApps.GetString("appIcon")), + new XAttribute("sortOrder", dbApps.GetByte("sortOrder")))); + } + }, true); diff --git a/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs b/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs index 70f709c84f..97628bbacd 100644 --- a/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs +++ b/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs @@ -30,6 +30,10 @@ namespace umbraco.BusinessLogic public ApplicationTreeRegistrar() { + //don't do anything if the application is not configured! + if (!ApplicationContext.Current.IsConfigured) + return; + // Load all Trees by attribute and add them to the XML config var types = PluginManager.Current.ResolveAttributedTrees();