Removes old 'Application' and renames to LegacySqlHelper
This commit is contained in:
@@ -31,7 +31,7 @@ namespace umbraco.dialogs
|
||||
{
|
||||
_app = Request.CleanForXss("app");
|
||||
//validate the app
|
||||
if (BusinessLogic.Application.getAll().Any(x => x.alias.InvariantEquals(_app)) == false)
|
||||
if (Services.SectionService.GetSections().Any(x => x.Alias.InvariantEquals(_app)) == false)
|
||||
{
|
||||
throw new InvalidOperationException("A requested app: " + Request.GetItemAsString("app") + " was not found");
|
||||
}
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco.DataLayer;
|
||||
|
||||
|
||||
namespace umbraco.BusinessLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for handling all registered applications in Umbraco.
|
||||
/// </summary>
|
||||
[Obsolete("Use ApplicationContext.Current.Services.SectionService and/or Umbraco.Core.Sections.SectionCollection instead")]
|
||||
public class Application
|
||||
{
|
||||
private static ISqlHelper _sqlHelper;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SQL helper.
|
||||
/// </summary>
|
||||
/// <value>The SQL helper.</value>
|
||||
[Obsolete("Do not use SqlHelper anymore, if database querying needs to be done use the DatabaseContext instead")]
|
||||
public static ISqlHelper SqlHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_sqlHelper == null)
|
||||
{
|
||||
var connectionString = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
const string umbracoDsn = Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName;
|
||||
|
||||
var databaseSettings = ConfigurationManager.ConnectionStrings[umbracoDsn];
|
||||
if (databaseSettings != null)
|
||||
connectionString = databaseSettings.ConnectionString;
|
||||
|
||||
// During upgrades we might still have the old appSettings connectionstring, and not the new one, so get that one instead
|
||||
if (string.IsNullOrWhiteSpace(connectionString) &&
|
||||
ConfigurationManager.AppSettings.ContainsKey(umbracoDsn))
|
||||
connectionString = ConfigurationManager.AppSettings[umbracoDsn];
|
||||
|
||||
_sqlHelper = DataLayerHelper.CreateSqlHelper(connectionString, false);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogHelper.Error<Application>(string.Format("Can't instantiate SQLHelper with connectionstring \"{0}\"", connectionString), ex);
|
||||
}
|
||||
}
|
||||
|
||||
return _sqlHelper;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Application"/> class.
|
||||
/// </summary>
|
||||
public Application()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Application"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The application name.</param>
|
||||
/// <param name="alias">The application alias.</param>
|
||||
/// <param name="icon">The application icon.</param>
|
||||
public Application(string name, string alias, string icon)
|
||||
: this(name, alias, icon, 0)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Application"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="alias">The alias.</param>
|
||||
/// <param name="icon">The icon.</param>
|
||||
/// <param name="sortOrder">The sort order.</param>
|
||||
public Application(string name, string alias, string icon, int sortOrder)
|
||||
{
|
||||
this.name = name;
|
||||
this.alias = alias;
|
||||
this.icon = icon;
|
||||
this.sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the application name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the application alias.
|
||||
/// </summary>
|
||||
/// <value>The alias.</value>
|
||||
public string alias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the application icon.
|
||||
/// </summary>
|
||||
/// <value>The application icon.</value>
|
||||
public string icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sort order.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The sort order.
|
||||
/// </value>
|
||||
public int sortOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new applcation if no application with the specified alias is found.
|
||||
/// </summary>
|
||||
/// <param name="name">The application name.</param>
|
||||
/// <param name="alias">The application alias.</param>
|
||||
/// <param name="icon">The application icon, which has to be located in umbraco/images/tray folder.</param>
|
||||
public static void MakeNew(string name, string alias, string icon)
|
||||
{
|
||||
ApplicationContext.Current.Services.SectionService.MakeNew(name, alias, icon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the new.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="alias">The alias.</param>
|
||||
/// <param name="icon">The icon.</param>
|
||||
/// <param name="sortOrder">The sort order.</param>
|
||||
public static void MakeNew(string name, string alias, string icon, int sortOrder)
|
||||
{
|
||||
ApplicationContext.Current.Services.SectionService.MakeNew(name, alias, icon, sortOrder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application by its alias.
|
||||
/// </summary>
|
||||
/// <param name="appAlias">The application alias.</param>
|
||||
/// <returns></returns>
|
||||
public static Application getByAlias(string appAlias)
|
||||
{
|
||||
return Mapper.Map<Section, Application>(
|
||||
ApplicationContext.Current.Services.SectionService.GetByAlias(appAlias));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes this instance.
|
||||
/// </summary>
|
||||
public void Delete()
|
||||
{
|
||||
ApplicationContext.Current.Services.SectionService.DeleteSection(Mapper.Map<Application, Section>(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all applications registered in umbraco from the umbracoApp table..
|
||||
/// </summary>
|
||||
/// <returns>Returns a Application Array</returns>
|
||||
public static List<Application> getAll()
|
||||
{
|
||||
return ApplicationContext.Current.Services.SectionService.GetSections().Select(Mapper.Map<Section, Application>).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
61
src/umbraco.businesslogic/LegacySqlHelper.cs
Normal file
61
src/umbraco.businesslogic/LegacySqlHelper.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using umbraco.DataLayer;
|
||||
|
||||
|
||||
namespace umbraco.BusinessLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for handling all registered applications in Umbraco.
|
||||
/// </summary>
|
||||
[Obsolete("Use ApplicationContext.Current.Services.SectionService and/or Umbraco.Core.Sections.SectionCollection instead")]
|
||||
public class LegacySqlHelper
|
||||
{
|
||||
private static ISqlHelper _sqlHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SQL helper.
|
||||
/// </summary>
|
||||
/// <value>The SQL helper.</value>
|
||||
[Obsolete("Do not use SqlHelper anymore, if database querying needs to be done use the DatabaseContext instead")]
|
||||
public static ISqlHelper SqlHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_sqlHelper == null)
|
||||
{
|
||||
var connectionString = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
const string umbracoDsn = Umbraco.Core.Configuration.GlobalSettings.UmbracoConnectionName;
|
||||
|
||||
var databaseSettings = ConfigurationManager.ConnectionStrings[umbracoDsn];
|
||||
if (databaseSettings != null)
|
||||
connectionString = databaseSettings.ConnectionString;
|
||||
|
||||
// During upgrades we might still have the old appSettings connectionstring, and not the new one, so get that one instead
|
||||
if (string.IsNullOrWhiteSpace(connectionString) &&
|
||||
ConfigurationManager.AppSettings.ContainsKey(umbracoDsn))
|
||||
connectionString = ConfigurationManager.AppSettings[umbracoDsn];
|
||||
|
||||
_sqlHelper = DataLayerHelper.CreateSqlHelper(connectionString, false);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogHelper.Error<LegacySqlHelper>(string.Format("Can't instantiate SQLHelper with connectionstring \"{0}\"", connectionString), ex);
|
||||
}
|
||||
}
|
||||
|
||||
return _sqlHelper;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Application.cs">
|
||||
<Compile Include="LegacySqlHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace umbraco.cms.businesslogic
|
||||
[Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
internal static UmbracoDatabase Database
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace umbraco.cms.businesslogic
|
||||
[Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database")]
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace umbraco.cms.businesslogic.packager
|
||||
{
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
public Package()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace umbraco.cms.businesslogic.packager.standardPackageActions
|
||||
{
|
||||
@@ -27,15 +28,19 @@ namespace umbraco.cms.businesslogic.packager.standardPackageActions
|
||||
string alias = xmlData.Attributes["appAlias"].Value;
|
||||
string icon = xmlData.Attributes["appIcon"].Value;
|
||||
|
||||
BusinessLogic.Application.MakeNew(name, alias, icon);
|
||||
|
||||
ApplicationContext.Current.Services.SectionService.MakeNew(name, alias, icon);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Undo(string packageName, XmlNode xmlData)
|
||||
{
|
||||
string alias = xmlData.Attributes["appAlias"].Value;
|
||||
BusinessLogic.Application.getByAlias(alias).Delete();
|
||||
var section = ApplicationContext.Current.Services.SectionService.GetByAlias(alias);
|
||||
if (section != null)
|
||||
{
|
||||
ApplicationContext.Current.Services.SectionService.DeleteSection(section);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace umbraco.cms.businesslogic.language
|
||||
[Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace umbraco.cms.businesslogic.language
|
||||
[Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace umbraco.cms.businesslogic.macro
|
||||
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace umbraco.cms.businesslogic.macro
|
||||
{
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace umbraco.cms.businesslogic.macro
|
||||
{
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
public static List<MacroPropertyType> GetAll
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
/// <value>The SQL helper.</value>
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
#region Constructors
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace umbraco.cms.businesslogic.relation
|
||||
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
public CMSNode Parent
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace umbraco.cms.businesslogic.task
|
||||
/// <value>The SQL helper.</value>
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace umbraco.cms.businesslogic.task
|
||||
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
private Tasks _tasks;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace umbraco.cms.businesslogic.workflow
|
||||
[Obsolete("Obsolete, For querying the database use the new UmbracoDatabase object ApplicationContext.Current.DatabaseContext.Database", false)]
|
||||
protected static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
get { return LegacySqlHelper.SqlHelper; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user