diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs index 5f39881e92..4e2f60eb3c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs @@ -72,8 +72,8 @@ namespace Umbraco.Core.Persistence.Migrations.Initial _database.CreateTable(); _database.CreateTable(); - _database.CreateTable(); - _database.CreateTable(); + //_database.CreateTable(); + //_database.CreateTable(); _database.CreateTable(); _database.CreateTable(); diff --git a/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs b/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs index e154cb3fbc..aed50a889e 100644 --- a/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs +++ b/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs @@ -127,6 +127,11 @@ namespace Umbraco.Core.Persistence return SyntaxConfig.SqlSyntaxProvider.DoesTableExist(db, tableName); } + public static bool TableExist(this UmbracoDatabase db, string tableName) + { + return SyntaxConfig.SqlSyntaxProvider.DoesTableExist(db, tableName); + } + public static void CreateDatabaseSchema(this Database db) { NewTable += PetaPocoExtensions_NewTable; diff --git a/src/umbraco.businesslogic/Application.cs b/src/umbraco.businesslogic/Application.cs index 89a0d1ed1e..e452771fcc 100644 --- a/src/umbraco.businesslogic/Application.cs +++ b/src/umbraco.businesslogic/Application.cs @@ -1,8 +1,5 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; using System.IO; using System.Linq; using System.Web; @@ -195,15 +192,6 @@ namespace umbraco.BusinessLogic if (!exist) { - // SqlHelper.ExecuteNonQuery(@" - // insert into umbracoApp - // (appAlias,appIcon,appName, sortOrder) - // values (@alias,@icon,@name,@sortOrder)", - // SqlHelper.CreateParameter("@alias", alias), - // SqlHelper.CreateParameter("@icon", icon), - // SqlHelper.CreateParameter("@name", name), - // SqlHelper.CreateParameter("@sortOrder", sortOrder)); - LoadXml(doc => { doc.Root.Add(new XElement("add", @@ -215,16 +203,6 @@ namespace umbraco.BusinessLogic } } - //public static void MakeNew(IApplication Iapp, bool installAppTrees) { - - // MakeNew(Iapp.Name, Iapp.Alias, Iapp.Icon); - - // if (installAppTrees) { - - // } - //} - - /// /// Gets the application by its alias. /// @@ -250,9 +228,6 @@ namespace umbraco.BusinessLogic t.Delete(); } - //SqlHelper.ExecuteNonQuery("delete from umbracoApp where appAlias = @appAlias", - // SqlHelper.CreateParameter("@appAlias", this._alias)); - LoadXml(doc => { doc.Root.Elements("add").Where(x => x.Attribute("alias") != null && x.Attribute("alias").Value == this.alias).Remove(); @@ -299,15 +274,6 @@ namespace umbraco.BusinessLogic { var tmp = new List(); - //using (IRecordsReader dr = - // SqlHelper.ExecuteReader("Select appAlias, appIcon, appName from umbracoApp")) - //{ - // while (dr.Read()) - // { - // tmp.Add(new Application(dr.GetString("appName"), dr.GetString("appAlias"), dr.GetString("appIcon"))); - // } - //} - LoadXml(doc => { diff --git a/src/umbraco.businesslogic/ApplicationTree.cs b/src/umbraco.businesslogic/ApplicationTree.cs index d5a4ff4ffa..07f05cfe71 100644 --- a/src/umbraco.businesslogic/ApplicationTree.cs +++ b/src/umbraco.businesslogic/ApplicationTree.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Web; using System.Xml.Linq; using umbraco.DataLayer; @@ -240,24 +239,6 @@ namespace umbraco.BusinessLogic /// The action. public static void MakeNew(bool silent, bool initialize, byte sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string assemblyName, string type, string action) { - - // SqlHelper.ExecuteNonQuery(@"insert into umbracoAppTree(treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, - // treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType, action) - // values(@treeSilent, @treeInitialize, @treeSortOrder, @appAlias, @treeAlias, @treeTitle, @treeIconClosed, @treeIconOpen, @treeHandlerAssembly, @treeHandlerType, @action)" - // , - // SqlHelper.CreateParameter("@treeSilent", silent), - // SqlHelper.CreateParameter("@treeInitialize", initialize), - // SqlHelper.CreateParameter("@treeSortOrder", sortOrder), - // SqlHelper.CreateParameter("@treeAlias", alias), - // SqlHelper.CreateParameter("@appAlias", applicationAlias), - // SqlHelper.CreateParameter("@treeTitle", title), - // SqlHelper.CreateParameter("@treeIconClosed", iconClosed), - // SqlHelper.CreateParameter("@treeIconOpen", iconOpened), - // SqlHelper.CreateParameter("@treeHandlerAssembly", assemblyName), - // SqlHelper.CreateParameter("@treeHandlerType", type), - // SqlHelper.CreateParameter("@action", action) - // ); - LoadXml(doc => { doc.Root.Add(new XElement("add", @@ -280,22 +261,6 @@ namespace umbraco.BusinessLogic /// public void Save() { - // SqlHelper.ExecuteNonQuery(@"Update umbracoAppTree set treeSilent = @treeSilent, treeInitialize = @treeInitialize, treeSortOrder = @treeSortOrder, treeTitle = @treeTitle, - // treeIconClosed = @treeIconClosed, treeIconOpen = @treeIconOpen, treeHandlerAssembly = @treeHandlerAssembly, treeHandlerType = @treeHandlerType, action = @action - // where treeAlias = @treeAlias AND appAlias = @appAlias", - // SqlHelper.CreateParameter("@treeSilent", this.Silent), - // SqlHelper.CreateParameter("@treeInitialize", this.Initialize), - // SqlHelper.CreateParameter("@treeSortOrder", this.SortOrder), - // SqlHelper.CreateParameter("@treeTitle", this.Title), - // SqlHelper.CreateParameter("@treeIconClosed", this.IconClosed), - // SqlHelper.CreateParameter("@treeIconOpen", this.IconOpened), - // SqlHelper.CreateParameter("@treeHandlerAssembly", this.AssemblyName), - // SqlHelper.CreateParameter("@treeHandlerType", this.Type), - // SqlHelper.CreateParameter("@treeAlias", this.Alias), - // SqlHelper.CreateParameter("@appAlias", this.ApplicationAlias), - // SqlHelper.CreateParameter("@action", this.Action) - // ); - LoadXml(doc => { var el = doc.Root.Elements("add").SingleOrDefault(x => x.Attribute("alias").Value == this.Alias && x.Attribute("application").Value == this.ApplicationAlias); @@ -417,28 +382,6 @@ namespace umbraco.BusinessLogic { var list = new List(); - // using (IRecordsReader dr = SqlHelper.ExecuteReader(@"Select treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, - // treeIconOpen, treeHandlerAssembly, treeHandlerType, action from umbracoAppTree order by treeSortOrder")) - // { - // while (dr.Read()) - // { - - // list.Add(new ApplicationTree( - // dr.GetBoolean("treeSilent"), - // dr.GetBoolean("treeInitialize"), - // dr.GetByte("treeSortOrder"), - // dr.GetString("appAlias"), - // dr.GetString("treeAlias"), - // dr.GetString("treeTitle"), - // dr.GetString("treeIconClosed"), - // dr.GetString("treeIconOpen"), - // dr.GetString("treeHandlerAssembly"), - // dr.GetString("treeHandlerType"), - // dr.GetString("action"))); - - // } - // } - LoadXml(doc => { foreach (var addElement in doc.Root.Elements("add").OrderBy(x => diff --git a/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs b/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs index 15067ca655..16e98ba493 100644 --- a/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs +++ b/src/umbraco.businesslogic/ApplicationTreeRegistrar.cs @@ -2,8 +2,8 @@ using System.Linq; using System.Xml.Linq; using Umbraco.Core; -using umbraco.BusinessLogic.Utils; -using umbraco.DataLayer; +using Umbraco.Core.Models.Rdbms; +using Umbraco.Core.Persistence; using umbraco.businesslogic; using umbraco.interfaces; @@ -11,23 +11,6 @@ namespace umbraco.BusinessLogic { public class ApplicationTreeRegistrar : IApplicationStartupHandler { - private ISqlHelper _sqlHelper; - protected ISqlHelper SqlHelper - { - get - { - if (_sqlHelper == null) - { - try - { - _sqlHelper = DataLayerHelper.CreateSqlHelper(GlobalSettings.DbDSN); - } - catch { } - } - return _sqlHelper; - } - } - public ApplicationTreeRegistrar() { //don't do anything if the application is not configured! @@ -70,23 +53,28 @@ namespace umbraco.BusinessLogic new XAttribute("action", attr.Action))); } - var dbTrees = SqlHelper.ExecuteReader("SELECT * FROM umbracoAppTree WHERE treeAlias NOT IN (" + inString + ")"); - while (dbTrees.Read()) + var db = ApplicationContext.Current.DatabaseContext.Database; + var exist = db.TableExist("umbracoAppTree"); + if (exist) { - var action = dbTrees.GetString("action"); + var appTrees = db.Fetch("WHERE treeAlias NOT IN (" + inString + ")"); + foreach (var appTree in appTrees) + { + var action = appTree.Action; - doc.Root.Add(new XElement("add", - new XAttribute("silent", dbTrees.GetBoolean("treeSilent")), - new XAttribute("initialize", dbTrees.GetBoolean("treeInitialize")), - new XAttribute("sortOrder", dbTrees.GetByte("treeSortOrder")), - new XAttribute("alias", dbTrees.GetString("treeAlias")), - new XAttribute("application", dbTrees.GetString("appAlias")), - new XAttribute("title", dbTrees.GetString("treeTitle")), - new XAttribute("iconClosed", dbTrees.GetString("treeIconClosed")), - new XAttribute("iconOpen", dbTrees.GetString("treeIconOpen")), - new XAttribute("assembly", dbTrees.GetString("treeHandlerAssembly")), - new XAttribute("type", dbTrees.GetString("treeHandlerType")), - new XAttribute("action", string.IsNullOrEmpty(action) ? "" : action))); + doc.Root.Add(new XElement("add", + new XAttribute("silent", appTree.Silent), + new XAttribute("initialize", appTree.Initialize), + new XAttribute("sortOrder", appTree.SortOrder), + new XAttribute("alias", appTree.Alias), + new XAttribute("application", appTree.AppAlias), + new XAttribute("title", appTree.Title), + new XAttribute("iconClosed", appTree.IconClosed), + new XAttribute("iconOpen", appTree.IconOpen), + new XAttribute("assembly", appTree.HandlerAssembly), + new XAttribute("type", appTree.HandlerType), + new XAttribute("action", string.IsNullOrEmpty(action) ? "" : action))); + } } }, true);