Merge
This commit is contained in:
@@ -14,6 +14,7 @@ syntax: glob
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
_NCrunch_*/
|
||||
*.ncrunchsolution
|
||||
*.ncrunchsolution.user
|
||||
*.ncrunchproject
|
||||
|
||||
4
src/Umbraco.Core/Events/DatabaseCreationEventArgs.cs
Normal file
4
src/Umbraco.Core/Events/DatabaseCreationEventArgs.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
internal class DatabaseCreationEventArgs : System.ComponentModel.CancelEventArgs{}
|
||||
}
|
||||
@@ -312,6 +312,12 @@ namespace Umbraco.Core.Models
|
||||
clone.Version = Guid.NewGuid();
|
||||
clone.ResetIdentity();
|
||||
|
||||
foreach (var property in clone.Properties)
|
||||
{
|
||||
property.ResetIdentity();
|
||||
property.Version = clone.Version;
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,55 +54,6 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFileBase object as the property value
|
||||
/// </summary>
|
||||
/// <param name="media"><see cref="IMedia"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="value">The <see cref="HttpPostedFileBase"/> containing the file that will be uploaded</param>
|
||||
public static void SetPropertyValue(this IMedia media, string propertyTypeAlias, HttpPostedFileBase value)
|
||||
{
|
||||
var name =
|
||||
IOHelper.SafeFileName(
|
||||
value.FileName.Substring(value.FileName.LastIndexOf(IOHelper.DirSepChar) + 1,
|
||||
value.FileName.Length - value.FileName.LastIndexOf(IOHelper.DirSepChar) - 1)
|
||||
.ToLower());
|
||||
|
||||
if(string.IsNullOrEmpty(name) == false)
|
||||
SetFileOnContent(media, propertyTypeAlias, name, value.InputStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFile object as the property value
|
||||
/// </summary>
|
||||
/// <param name="media"><see cref="IMedia"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="value">The <see cref="HttpPostedFile"/> containing the file that will be uploaded</param>
|
||||
public static void SetPropertyValue(this IMedia media, string propertyTypeAlias, HttpPostedFile value)
|
||||
{
|
||||
var name =
|
||||
IOHelper.SafeFileName(
|
||||
value.FileName.Substring(value.FileName.LastIndexOf(IOHelper.DirSepChar) + 1,
|
||||
value.FileName.Length - value.FileName.LastIndexOf(IOHelper.DirSepChar) - 1)
|
||||
.ToLower());
|
||||
|
||||
if (string.IsNullOrEmpty(name) == false)
|
||||
SetFileOnContent(media, propertyTypeAlias, name, value.InputStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFileWrapper object as the property value
|
||||
/// </summary>
|
||||
/// <param name="media"><see cref="IMedia"/> to add property value to</param>
|
||||
/// <param name="propertyTypeAlias">Alias of the property to save the value on</param>
|
||||
/// <param name="value">The <see cref="HttpPostedFileWrapper"/> containing the file that will be uploaded</param>
|
||||
public static void SetPropertyValue(this IMedia media, string propertyTypeAlias, HttpPostedFileWrapper value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value.FileName) == false)
|
||||
SetFileOnContent(media, propertyTypeAlias, value.FileName, value.InputStream);
|
||||
}
|
||||
*/
|
||||
/// <summary>
|
||||
/// Sets and uploads the file from a HttpPostedFileBase object as the property value
|
||||
/// </summary>
|
||||
@@ -348,21 +299,9 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this media item.
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this content/media item.
|
||||
/// </summary>
|
||||
internal static IProfile GetCreatorProfile(this IMedia media)
|
||||
{
|
||||
using (var repository = RepositoryResolver.Current.Factory.CreateUserRepository(
|
||||
PetaPocoUnitOfWorkProvider.CreateUnitOfWork()))
|
||||
{
|
||||
return repository.GetProfileById(media.CreatorId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this content.
|
||||
/// </summary>
|
||||
public static IProfile GetCreatorProfile(this IContent content)
|
||||
public static IProfile GetCreatorProfile(this IContentBase content)
|
||||
{
|
||||
using (var repository = RepositoryResolver.Current.Factory.CreateUserRepository(
|
||||
PetaPocoUnitOfWorkProvider.CreateUnitOfWork()))
|
||||
@@ -403,7 +342,6 @@ namespace Umbraco.Core.Models
|
||||
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
|
||||
public static XElement ToXml(this IContent content)
|
||||
{
|
||||
|
||||
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
|
||||
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
|
||||
|
||||
@@ -419,7 +357,6 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
return x;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -427,14 +364,16 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
/// <param name="media"><see cref="IContent"/> to generate xml for</param>
|
||||
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
|
||||
internal static XElement ToXml(this IMedia media)
|
||||
public static XElement ToXml(this IMedia media)
|
||||
{
|
||||
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
|
||||
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();
|
||||
|
||||
var x = media.ToXml(nodeName);
|
||||
x.Add(new XAttribute("nodeType", media.ContentType.Id));
|
||||
x.Add(new XAttribute("writerName", media.GetCreatorProfile().Name));
|
||||
//TODO Using the GetCreatorProfile extension method seems to be causing threading/connection problems because of the way the repo is used
|
||||
//x.Add(new XAttribute("writerName", media.GetCreatorProfile().Name));
|
||||
x.Add(new XAttribute("writerName", string.Empty));
|
||||
x.Add(new XAttribute("writerID", media.CreatorId));
|
||||
x.Add(new XAttribute("version", media.Version));
|
||||
x.Add(new XAttribute("template", 0));
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Umbraco.Core.Models.EntityBase
|
||||
}
|
||||
}
|
||||
|
||||
protected void ResetIdentity()
|
||||
internal virtual void ResetIdentity()
|
||||
{
|
||||
_hasIdentity = false;
|
||||
_id = default(int);
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
{
|
||||
@@ -7,13 +11,110 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
/// </summary>
|
||||
internal class DatabaseSchemaCreation
|
||||
{
|
||||
#region Private Members
|
||||
private readonly Database _database;
|
||||
private static readonly Dictionary<int, Type> OrderedTables = new Dictionary<int, Type>
|
||||
{
|
||||
{0, typeof (NodeDto)},
|
||||
{1, typeof (TemplateDto)},
|
||||
{2, typeof (ContentDto)},
|
||||
{3, typeof (ContentVersionDto)},
|
||||
{4, typeof (DocumentDto)},
|
||||
{5, typeof (ContentTypeDto)},
|
||||
{6, typeof (DocumentTypeDto)},
|
||||
{7, typeof (DataTypeDto)},
|
||||
{8, typeof (DataTypePreValueDto)},
|
||||
{9, typeof (DictionaryDto)},
|
||||
{10, typeof (LanguageTextDto)},
|
||||
{11, typeof (LanguageDto)},
|
||||
{12, typeof (DomainDto)},
|
||||
{13, typeof (LogDto)},
|
||||
{14, typeof (MacroDto)},
|
||||
{15, typeof (MacroPropertyTypeDto)},
|
||||
{16, typeof (MacroPropertyDto)},
|
||||
{17, typeof (MemberTypeDto)},
|
||||
{18, typeof (MemberDto)},
|
||||
{19, typeof (Member2MemberGroupDto)},
|
||||
{20, typeof (ContentXmlDto)},
|
||||
{21, typeof (PreviewXmlDto)},
|
||||
{22, typeof (PropertyTypeGroupDto)},
|
||||
{23, typeof (PropertyTypeDto)},
|
||||
{24, typeof (PropertyDataDto)},
|
||||
{25, typeof (RelationTypeDto)},
|
||||
{26, typeof (RelationDto)},
|
||||
{27, typeof (StylesheetDto)},
|
||||
{28, typeof (StylesheetPropertyDto)},
|
||||
{29, typeof (TagDto)},
|
||||
{30, typeof (TagRelationshipDto)},
|
||||
{31, typeof (UserLoginDto)},
|
||||
{32, typeof (UserTypeDto)},
|
||||
{33, typeof (UserDto)},
|
||||
{34, typeof (TaskTypeDto)},
|
||||
{35, typeof (TaskDto)},
|
||||
{36, typeof (ContentType2ContentTypeDto)},
|
||||
{
|
||||
37,
|
||||
typeof (ContentTypeAllowedContentTypeDto)
|
||||
},
|
||||
{38, typeof (User2AppDto)},
|
||||
{39, typeof (User2NodeNotifyDto)},
|
||||
{40, typeof (User2NodePermissionDto)}
|
||||
};
|
||||
#endregion
|
||||
|
||||
public DatabaseSchemaCreation(Database database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the database by creating the umbraco db schema
|
||||
/// </summary>
|
||||
public void InitializeDatabaseSchema()
|
||||
{
|
||||
var e = new DatabaseCreationEventArgs();
|
||||
FireBeforeCreation(e);
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
foreach (var item in OrderedTables.OrderBy(x => x.Key))
|
||||
{
|
||||
_database.CreateTable(false, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
FireAfterCreation(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the schema of the current database
|
||||
/// </summary>
|
||||
public DatabaseSchemaResult ValidateSchema()
|
||||
{
|
||||
var result = new DatabaseSchemaResult();
|
||||
|
||||
foreach (var item in OrderedTables.OrderBy(x => x.Key))
|
||||
{
|
||||
var tableNameAttribute = item.Value.FirstAttribute<TableNameAttribute>();
|
||||
if (tableNameAttribute != null)
|
||||
{
|
||||
var tableExist = _database.TableExist(tableNameAttribute.Value);
|
||||
if (tableExist)
|
||||
{
|
||||
result.Successes.Add(tableNameAttribute.Value, "Table exists");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Errors.Add(tableNameAttribute.Value, "Table does not exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// The save event handler
|
||||
/// </summary>
|
||||
@@ -51,83 +152,6 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the database by creating the umbraco db schema
|
||||
/// </summary>
|
||||
public void InitializeDatabaseSchema()
|
||||
{
|
||||
var e = new DatabaseCreationEventArgs();
|
||||
FireBeforeCreation(e);
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
_database.CreateTable<NodeDto>();
|
||||
|
||||
_database.CreateTable<TemplateDto>();
|
||||
|
||||
_database.CreateTable<ContentDto>();
|
||||
_database.CreateTable<ContentVersionDto>();
|
||||
_database.CreateTable<DocumentDto>();
|
||||
|
||||
_database.CreateTable<ContentTypeDto>();
|
||||
_database.CreateTable<DocumentTypeDto>();
|
||||
|
||||
//_database.CreateTable<AppDto>();
|
||||
//_database.CreateTable<AppTreeDto>();
|
||||
|
||||
_database.CreateTable<DataTypeDto>();
|
||||
_database.CreateTable<DataTypePreValueDto>();
|
||||
|
||||
_database.CreateTable<DictionaryDto>();
|
||||
_database.CreateTable<LanguageTextDto>();
|
||||
|
||||
_database.CreateTable<LanguageDto>();
|
||||
_database.CreateTable<DomainDto>();
|
||||
|
||||
_database.CreateTable<LogDto>();
|
||||
|
||||
_database.CreateTable<MacroDto>();
|
||||
_database.CreateTable<MacroPropertyTypeDto>();
|
||||
_database.CreateTable<MacroPropertyDto>();
|
||||
|
||||
_database.CreateTable<MemberTypeDto>();
|
||||
_database.CreateTable<MemberDto>();
|
||||
_database.CreateTable<Member2MemberGroupDto>();
|
||||
|
||||
_database.CreateTable<ContentXmlDto>();
|
||||
_database.CreateTable<PreviewXmlDto>();
|
||||
|
||||
_database.CreateTable<PropertyTypeGroupDto>();
|
||||
_database.CreateTable<PropertyTypeDto>();
|
||||
_database.CreateTable<PropertyDataDto>();
|
||||
|
||||
_database.CreateTable<RelationTypeDto>();
|
||||
_database.CreateTable<RelationDto>();
|
||||
|
||||
_database.CreateTable<StylesheetDto>();
|
||||
_database.CreateTable<StylesheetPropertyDto>();
|
||||
|
||||
_database.CreateTable<TagDto>();
|
||||
_database.CreateTable<TagRelationshipDto>();
|
||||
|
||||
_database.CreateTable<UserLoginDto>();
|
||||
_database.CreateTable<UserTypeDto>();
|
||||
_database.CreateTable<UserDto>();
|
||||
|
||||
_database.CreateTable<TaskTypeDto>();
|
||||
_database.CreateTable<TaskDto>();
|
||||
|
||||
_database.CreateTable<ContentType2ContentTypeDto>();
|
||||
_database.CreateTable<ContentTypeAllowedContentTypeDto>();
|
||||
|
||||
_database.CreateTable<User2AppDto>();
|
||||
_database.CreateTable<User2NodeNotifyDto>();
|
||||
_database.CreateTable<User2NodePermissionDto>();
|
||||
}
|
||||
|
||||
FireAfterCreation(e);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal class DatabaseCreationEventArgs : System.ComponentModel.CancelEventArgs{}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
{
|
||||
public class DatabaseSchemaResult
|
||||
{
|
||||
public DatabaseSchemaResult()
|
||||
{
|
||||
Errors = new Dictionary<string, string>();
|
||||
Successes = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public IDictionary<string, string> Errors { get; set; }
|
||||
|
||||
public IDictionary<string, string> Successes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
"DELETE FROM umbracoUser2NodeNotify WHERE nodeId = @Id",
|
||||
"DELETE FROM umbracoUser2NodePermission WHERE nodeId = @Id",
|
||||
"UPDATE cmsDocument SET templateId = NULL WHERE nodeId = @Id",
|
||||
"DELETE FROM cmsDocumentType WHERE templateNodeId = @Id",
|
||||
"DELETE FROM cmsTemplate WHERE nodeId = @Id",
|
||||
"DELETE FROM umbracoNode WHERE id = @Id"
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var sql = GetBaseQuery(false);
|
||||
sql.Where(GetBaseWhereClause(), new { Id = id });
|
||||
|
||||
var dto = Database.Query<UserDto>(sql).FirstOrDefault();
|
||||
var dto = Database.FirstOrDefault<UserDto>(sql);
|
||||
|
||||
if (dto == null)
|
||||
return null;
|
||||
@@ -139,7 +139,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var sql = GetBaseQuery(false);
|
||||
sql.Where(GetBaseWhereClause(), new { Id = id });
|
||||
|
||||
var dto = Database.Query<UserDto>(sql).FirstOrDefault();
|
||||
var dto = Database.FirstOrDefault<UserDto>(sql);
|
||||
|
||||
if (dto == null)
|
||||
return null;
|
||||
|
||||
@@ -791,9 +791,8 @@ namespace Umbraco.Core.Services
|
||||
var copy = ((Content)content).Clone();
|
||||
copy.ParentId = parentId;
|
||||
|
||||
// A copy should never be set to published
|
||||
// automatically even if the original was
|
||||
this.UnPublish(copy, userId);
|
||||
// A copy should never be set to published automatically even if the original was.
|
||||
copy.ChangePublishedState(PublishedState.Unpublished);
|
||||
|
||||
if (Copying.IsRaisedEventCancelled(new CopyEventArgs<IContent>(content, copy, parentId), this))
|
||||
return null;
|
||||
@@ -806,14 +805,15 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdate(copy);
|
||||
uow.Commit();
|
||||
|
||||
var uploadFieldId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c");
|
||||
if (content.Properties.Any(x => x.PropertyType.DataTypeId == uploadFieldId))
|
||||
//Special case for the Upload DataType
|
||||
var uploadDataTypeId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c");
|
||||
if (content.Properties.Any(x => x.PropertyType.DataTypeId == uploadDataTypeId))
|
||||
{
|
||||
bool isUpdated = false;
|
||||
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
|
||||
|
||||
//Loop through properties to check if the content contains media that should be deleted
|
||||
foreach (var property in content.Properties.Where(x => x.PropertyType.DataTypeId == uploadFieldId
|
||||
foreach (var property in content.Properties.Where(x => x.PropertyType.DataTypeId == uploadDataTypeId
|
||||
&& string.IsNullOrEmpty(x.Value.ToString()) == false))
|
||||
{
|
||||
if (fs.FileExists(IOHelper.MapPath(property.Value.ToString())))
|
||||
@@ -841,6 +841,17 @@ namespace Umbraco.Core.Services
|
||||
uow.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
//Special case for the Tags DataType
|
||||
var tagsDataTypeId = new Guid("4023e540-92f5-11dd-ad8b-0800200c9a66");
|
||||
if (content.Properties.Any(x => x.PropertyType.DataTypeId == tagsDataTypeId))
|
||||
{
|
||||
var tags = uow.Database.Fetch<TagRelationshipDto>("WHERE nodeId = @Id", new {Id = content.Id});
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
uow.Database.Insert(new TagRelationshipDto {NodeId = copy.Id, TagId = tag.TagId});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//NOTE This 'Relation' part should eventually be delegated to a RelationService
|
||||
@@ -1241,7 +1252,7 @@ namespace Umbraco.Core.Services
|
||||
//We need to check if children and their publish state to ensure that we republish content that was previously published
|
||||
if (HasChildren(content.Id))
|
||||
{
|
||||
var children = GetChildrenDeep(content.Id);
|
||||
var children = GetDescendants(content);
|
||||
var shouldBeRepublished = children.Where(child => HasPublishedVersion(child.Id));
|
||||
|
||||
if (omitCacheRefresh == false)
|
||||
|
||||
@@ -3,9 +3,11 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Auditing;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
@@ -479,6 +481,13 @@ namespace Umbraco.Core.Services
|
||||
SetUser(media, userId);
|
||||
repository.AddOrUpdate(media);
|
||||
uow.Commit();
|
||||
|
||||
var xml = media.ToXml();
|
||||
var poco = new ContentXmlDto { NodeId = media.Id, Xml = xml.ToString(SaveOptions.None) };
|
||||
var exists = uow.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = media.Id }) != null;
|
||||
int result = exists
|
||||
? uow.Database.Update(poco)
|
||||
: Convert.ToInt32(uow.Database.Insert(poco));
|
||||
}
|
||||
|
||||
Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Umbraco.Core.Services
|
||||
_contentService = new Lazy<ContentService>(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy, _userService.Value));
|
||||
|
||||
if(_mediaService == null)
|
||||
_mediaService = new Lazy<MediaService>(() => new MediaService(provider, repositoryFactory.Value));
|
||||
_mediaService = new Lazy<MediaService>(() => new MediaService(provider, repositoryFactory.Value, _userService.Value));
|
||||
|
||||
if(_macroService == null)
|
||||
_macroService = new Lazy<MacroService>(() => new MacroService(fileProvider, repositoryFactory.Value));
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
<Compile Include="Events\CancellableEventArgs.cs" />
|
||||
<Compile Include="Events\ContentCacheEventArgs.cs" />
|
||||
<Compile Include="Events\CopyEventArgs.cs" />
|
||||
<Compile Include="Events\DatabaseCreationEventArgs.cs" />
|
||||
<Compile Include="Events\DeleteEventArgs.cs" />
|
||||
<Compile Include="Events\CancellableObjectEventArgs.cs" />
|
||||
<Compile Include="Events\DeleteRevisionsEventArgs.cs" />
|
||||
@@ -265,6 +266,7 @@
|
||||
<Compile Include="Persistence\Migrations\IMigrationExpression.cs" />
|
||||
<Compile Include="Persistence\Migrations\Initial\BaseDataCreation.cs" />
|
||||
<Compile Include="Persistence\Migrations\Initial\DatabaseSchemaCreation.cs" />
|
||||
<Compile Include="Persistence\Migrations\Initial\DatabaseSchemaResult.cs" />
|
||||
<Compile Include="Persistence\Migrations\MigrationAttribute.cs" />
|
||||
<Compile Include="Persistence\Migrations\MigrationBase.cs" />
|
||||
<Compile Include="Persistence\Migrations\MigrationContext.cs" />
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Web;
|
||||
using umbraco.editorControls.tinyMCE3;
|
||||
using umbraco.interfaces;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Umbraco.Tests.Models
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence;
|
||||
@@ -9,6 +10,8 @@ using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using umbraco.editorControls.tinyMCE3;
|
||||
using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
@@ -18,6 +21,20 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
[SetUp]
|
||||
public override void Initialize()
|
||||
{
|
||||
//NOTE The DataTypesResolver is only necessary because we are using the Save method in the MediaService
|
||||
//this ensures its reset
|
||||
PluginManager.Current = new PluginManager();
|
||||
|
||||
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
|
||||
PluginManager.Current.AssembliesToScan = new[]
|
||||
{
|
||||
typeof(IDataType).Assembly,
|
||||
typeof(tinyMCE3dataType).Assembly
|
||||
};
|
||||
|
||||
DataTypesResolver.Current = new DataTypesResolver(
|
||||
PluginManager.Current.ResolveDataTypes());
|
||||
|
||||
base.Initialize();
|
||||
|
||||
CreateTestData();
|
||||
@@ -288,6 +305,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
//reset the app context
|
||||
DataTypesResolver.Reset();
|
||||
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ using Umbraco.Core.Publishing;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using umbraco.editorControls.tinyMCE3;
|
||||
using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
@@ -25,6 +27,20 @@ namespace Umbraco.Tests.Services
|
||||
[SetUp]
|
||||
public override void Initialize()
|
||||
{
|
||||
//NOTE The DataTypesResolver is only necessary because we are using the Save method in the MediaService
|
||||
//this ensures its reset
|
||||
PluginManager.Current = new PluginManager();
|
||||
|
||||
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
|
||||
PluginManager.Current.AssembliesToScan = new[]
|
||||
{
|
||||
typeof(IDataType).Assembly,
|
||||
typeof(tinyMCE3dataType).Assembly
|
||||
};
|
||||
|
||||
DataTypesResolver.Current = new DataTypesResolver(
|
||||
PluginManager.Current.ResolveDataTypes());
|
||||
|
||||
base.Initialize();
|
||||
|
||||
//we need to use our own custom IDatabaseFactory for the DatabaseContext because we MUST ensure that
|
||||
@@ -47,6 +63,9 @@ namespace Umbraco.Tests.Services
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
//reset the app context
|
||||
DataTypesResolver.Reset();
|
||||
|
||||
_error = null;
|
||||
|
||||
//dispose!
|
||||
|
||||
@@ -175,7 +175,6 @@
|
||||
<Compile Include="Migrations\Upgrades\SqlCeDataUpgradeTest.cs" />
|
||||
<Compile Include="Migrations\Upgrades\SqlCeUpgradeTest.cs" />
|
||||
<Compile Include="Migrations\Upgrades\SqlServerUpgradeTest.cs" />
|
||||
<Compile Include="Models\MediaXmlTest.cs" />
|
||||
<Compile Include="Persistence\Mappers\MappingResolverTests.cs" />
|
||||
<Compile Include="Persistence\Querying\ContentRepositorySqlClausesTest.cs" />
|
||||
<Compile Include="Persistence\Querying\ContentTypeRepositorySqlClausesTest.cs" />
|
||||
@@ -313,6 +312,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="TestHelpers\ExamineHelpers\umbraco.config" />
|
||||
<None Include="unit-test-log4net.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
@@ -402,6 +402,7 @@
|
||||
<Content Include="Migrations\SqlScripts\SqlCe-SchemaAndData-4110.sql" />
|
||||
<Content Include="Migrations\SqlScripts\SqlCeTotal-480.sql" />
|
||||
<Content Include="Migrations\SqlScripts\SqlServerTotal-480.sql" />
|
||||
<Content Include="TestHelpers\ExamineHelpers\media.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -81,15 +81,6 @@ namespace umbraco.cms.businesslogic.media
|
||||
ApplicationContext.Current.Services.MediaService.Save(media);
|
||||
var tmp = new Media(media);
|
||||
|
||||
/*Guid newId = Guid.NewGuid();
|
||||
// Updated to match level from base node
|
||||
CMSNode n = new CMSNode(ParentId);
|
||||
int newLevel = n.Level;
|
||||
newLevel++;
|
||||
CMSNode.MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
|
||||
Media tmp = new Media(newId);
|
||||
tmp.CreateContent(dct);*/
|
||||
|
||||
NewEventArgs e = new NewEventArgs();
|
||||
tmp.OnNew(e);
|
||||
|
||||
@@ -105,16 +96,6 @@ namespace umbraco.cms.businesslogic.media
|
||||
{
|
||||
var children = ApplicationContext.Current.Services.MediaService.GetRootMedia();
|
||||
return children.Select(x => new Media(x)).ToArray();
|
||||
|
||||
/*Guid[] topNodeIds = CMSNode.TopMostNodeIds(_objectType);
|
||||
|
||||
Media[] retval = new Media[topNodeIds.Length];
|
||||
for (int i = 0; i < topNodeIds.Length; i++)
|
||||
{
|
||||
Media d = new Media(topNodeIds[i]);
|
||||
retval[i] = d;
|
||||
}
|
||||
return retval;*/
|
||||
}
|
||||
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetChildren()", false)]
|
||||
@@ -122,26 +103,6 @@ namespace umbraco.cms.businesslogic.media
|
||||
{
|
||||
var children = ApplicationContext.Current.Services.MediaService.GetChildren(nodeId);
|
||||
return children.Select(x => new Media(x)).ToList();
|
||||
|
||||
/*List<Media> tmp = new List<Media>();
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader(
|
||||
string.Format(m_SQLOptimizedMany.Trim()
|
||||
, "umbracoNode.parentID = @parentId"
|
||||
, "umbracoNode.sortOrder")
|
||||
, SqlHelper.CreateParameter("@nodeObjectType", _objectType)
|
||||
, SqlHelper.CreateParameter("@parentId", nodeId)))
|
||||
{
|
||||
|
||||
while (dr.Read())
|
||||
{
|
||||
Media d = new Media(dr.GetInt("id"), true);
|
||||
d.PopulateMediaFromReader(dr);
|
||||
tmp.Add(d);
|
||||
}
|
||||
|
||||
}
|
||||
return tmp;*/
|
||||
}
|
||||
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Services.MediaService.GetMediaOfMediaType()", false)]
|
||||
@@ -149,23 +110,6 @@ namespace umbraco.cms.businesslogic.media
|
||||
{
|
||||
var children = ApplicationContext.Current.Services.MediaService.GetMediaOfMediaType(mediaTypeId);
|
||||
return children.Select(x => new Media(x)).ToList();
|
||||
|
||||
/*var tmp = new List<Media>();
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader(
|
||||
string.Format(m_SQLOptimizedMany.Trim(), "cmsContent.contentType = @contentTypeId", "umbracoNode.sortOrder"),
|
||||
SqlHelper.CreateParameter("@nodeObjectType", _objectType),
|
||||
SqlHelper.CreateParameter("@contentTypeId", mediaTypeId)))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
Media d = new Media(dr.GetInt("id"), true);
|
||||
d.PopulateMediaFromReader(dr);
|
||||
tmp.Add(d);
|
||||
}
|
||||
}
|
||||
|
||||
return tmp.ToArray();*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -178,25 +122,6 @@ namespace umbraco.cms.businesslogic.media
|
||||
public static void DeleteFromType(MediaType dt)
|
||||
{
|
||||
ApplicationContext.Current.Services.MediaService.DeleteMediaOfType(dt.Id);
|
||||
|
||||
//get all document for the document type and order by level (top level first)
|
||||
/*var medias = Media.GetMediaOfMediaType(dt.Id)
|
||||
.OrderByDescending(x => x.Level);
|
||||
|
||||
foreach (Media media in medias)
|
||||
{
|
||||
//before we delete this document, we need to make sure we don't end up deleting other documents that
|
||||
//are not of this document type that are children. So we'll move all of it's children to the trash first.
|
||||
foreach (Media m in media.GetDescendants())
|
||||
{
|
||||
if (m.ContentType.Id != dt.Id)
|
||||
{
|
||||
m.MoveToTrash();
|
||||
}
|
||||
}
|
||||
|
||||
media.DeletePermanently();
|
||||
}*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -320,8 +320,6 @@ namespace umbraco.cms.businesslogic.template
|
||||
|
||||
// remove from documents
|
||||
Document.RemoveTemplateFromDocument(this.Id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void RemoveFromDocumentTypes()
|
||||
@@ -329,6 +327,7 @@ namespace umbraco.cms.businesslogic.template
|
||||
foreach (DocumentType dt in DocumentType.GetAllAsList().Where(x => x.allowedTemplates.Select(t => t.Id).Contains(this.Id)))
|
||||
{
|
||||
dt.RemoveTemplate(this.Id);
|
||||
dt.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -428,6 +428,8 @@ namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
ApplicationContext.Current.DatabaseContext.Database.Execute(
|
||||
"update cmsDocument set templateId = NULL where templateId = @TemplateId", new {TemplateId = templateId});
|
||||
//We need to clear cache for Documents since this is touching the database directly
|
||||
RuntimeCacheProvider.Current.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user