Refactoring the creation of database schema and base/default data creation.
Adding extension method to get all properties for interfaces in PetaPoco used for mapping. Creating ServiceContext and adding it to the UmbracoContext to provide access to the various services. Adding UmbracoContext to BaseDatabaseFactory test.
This commit is contained in:
@@ -9,12 +9,12 @@ namespace Umbraco.Core.Models.Rdbms
|
||||
internal class ContentTypeAllowedContentTypeDto
|
||||
{
|
||||
[Column("Id")]
|
||||
[ForeignKey(typeof(ContentTypeDto), Name = "FK_cmsContentTypeAllowedContentType_cmsContentType")]
|
||||
[PrimaryKeyColumn(AutoIncrement = false, Clustered = true, Name = "PK_cmsContentTypeAllowedContentType", OnColumns = "[Id], [AllowedId]")]
|
||||
[ForeignKey(typeof(ContentTypeDto), Name = "FK_cmsContentTypeAllowedContentType_cmsContentType", Column = "nodeId")]
|
||||
[PrimaryKeyColumn(AutoIncrement = false, Clustered = true, Name = "PK_cmsContentTypeAllowedContentType", OnColumns = "Id, AllowedId")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("AllowedId")]
|
||||
[ForeignKey(typeof(ContentTypeDto), Name = "FK_cmsContentTypeAllowedContentType_cmsContentType1")]
|
||||
[ForeignKey(typeof(ContentTypeDto), Name = "FK_cmsContentTypeAllowedContentType_cmsContentType1", Column = "nodeId")]
|
||||
public int AllowedId { get; set; }
|
||||
|
||||
[Column("SortOrder")]
|
||||
|
||||
@@ -4,12 +4,12 @@ using Umbraco.Core.Persistence.DatabaseAnnotations;
|
||||
namespace Umbraco.Core.Models.Rdbms
|
||||
{
|
||||
[TableName("umbracoUser")]
|
||||
[PrimaryKey("id")]
|
||||
[PrimaryKey("id", autoIncrement = true)]
|
||||
[ExplicitColumns]
|
||||
internal class UserDto
|
||||
{
|
||||
[Column("id")]
|
||||
[PrimaryKeyColumn]
|
||||
[PrimaryKeyColumn(Name = "PK_user")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("userDisabled")]
|
||||
|
||||
@@ -48,6 +48,9 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
|
||||
internal override string Map(string propertyName)
|
||||
{
|
||||
if (!PropertyInfoCache.ContainsKey(propertyName))
|
||||
return string.Empty;
|
||||
|
||||
var dtoTypeProperty = PropertyInfoCache[propertyName];
|
||||
|
||||
return base.GetColumnName(dtoTypeProperty.Type, dtoTypeProperty.PropertyInfo);
|
||||
|
||||
@@ -16,49 +16,112 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
if (pi.DeclaringType == typeof(Content) || pi.DeclaringType == typeof(IContent))
|
||||
{
|
||||
columnName = ContentMapper.Instance.Map(pi.Name);
|
||||
var mappedName = ContentMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(Models.Media) || pi.DeclaringType == typeof(IMedia))
|
||||
{
|
||||
columnName = MediaMapper.Instance.Map(pi.Name);
|
||||
var mappedName = MediaMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(ContentType) || pi.DeclaringType == typeof(IContentType) || pi.DeclaringType == typeof(IMediaType))
|
||||
{
|
||||
columnName = ContentTypeMapper.Instance.Map(pi.Name);
|
||||
var mappedName = ContentTypeMapper.Instance.Map(pi.Name);
|
||||
if (!string.IsNullOrEmpty(mappedName))
|
||||
{
|
||||
columnName = mappedName;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(DataTypeDefinition))
|
||||
if (pi.DeclaringType == typeof(DataTypeDefinition) || pi.DeclaringType == typeof(IDataTypeDefinition))
|
||||
{
|
||||
columnName = DataTypeDefinitionMapper.Instance.Map(pi.Name);
|
||||
var mappedName = DataTypeDefinitionMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(DictionaryItem))
|
||||
if (pi.DeclaringType == typeof(DictionaryItem) || pi.DeclaringType == typeof(IDictionaryItem))
|
||||
{
|
||||
columnName = DictionaryMapper.Instance.Map(pi.Name);
|
||||
var mappedName = DictionaryMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(DictionaryTranslation))
|
||||
if (pi.DeclaringType == typeof(DictionaryTranslation) || pi.DeclaringType == typeof(IDictionaryTranslation))
|
||||
{
|
||||
columnName = DictionaryTranslationMapper.Instance.Map(pi.Name);
|
||||
var mappedName = DictionaryTranslationMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(Language))
|
||||
if (pi.DeclaringType == typeof(Language) || pi.DeclaringType == typeof(ILanguage))
|
||||
{
|
||||
columnName = LanguageMapper.Instance.Map(pi.Name);
|
||||
var mappedName = LanguageMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(Relation))
|
||||
{
|
||||
columnName = RelationMapper.Instance.Map(pi.Name);
|
||||
var mappedName = RelationMapper.Instance.Map(pi.Name);
|
||||
if (!string.IsNullOrEmpty(mappedName))
|
||||
{
|
||||
columnName = mappedName;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(RelationType))
|
||||
{
|
||||
columnName = RelationTypeMapper.Instance.Map(pi.Name);
|
||||
var mappedName = RelationTypeMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(PropertyType))
|
||||
{
|
||||
var mappedName = PropertyTypeMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pi.DeclaringType == typeof(PropertyGroup))
|
||||
{
|
||||
var mappedName = PropertyGroupMapper.Instance.Map(pi.Name);
|
||||
if (mappedName == string.Empty)
|
||||
return false;
|
||||
|
||||
columnName = mappedName;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -17,71 +17,124 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the base data creation by inserting the data foundation for umbraco
|
||||
/// specific to a table
|
||||
/// </summary>
|
||||
public void InitializeBaseData()
|
||||
/// <param name="tableName">Name of the table to create base data for</param>
|
||||
public void InitializeBaseData(string tableName)
|
||||
{
|
||||
using (var transaction = _database.GetTransaction())
|
||||
if(tableName.Equals("umbracoNode"))
|
||||
{
|
||||
CreateUmbracNodeData();
|
||||
CreateCmsContentTypeData();
|
||||
CreateUmbracoUserData();
|
||||
CreateUmbracoUserTypeData();
|
||||
CreateUmbracoUser2AppData();
|
||||
CreateCmsMacroPropertyTypeData();
|
||||
CreateCmsPropertyTypeGroupData();
|
||||
CreateCmsPropertyTypeData();
|
||||
CreateUmbracoLanguageData();
|
||||
CreateCmsContentTypeAllowedContentType();
|
||||
CreateCmsDataTypeData();
|
||||
}
|
||||
|
||||
transaction.Complete();
|
||||
if(tableName.Equals("cmsContentType"))
|
||||
{
|
||||
CreateCmsContentTypeData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("umbracoUser"))
|
||||
{
|
||||
CreateUmbracoUserData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("umbracoUserType"))
|
||||
{
|
||||
CreateUmbracoUserTypeData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("umbracoUser2app"))
|
||||
{
|
||||
CreateUmbracoUser2AppData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("cmsMacroPropertyType"))
|
||||
{
|
||||
CreateCmsMacroPropertyTypeData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("cmsPropertyTypeGroup"))
|
||||
{
|
||||
CreateCmsPropertyTypeGroupData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("cmsPropertyType"))
|
||||
{
|
||||
CreateCmsPropertyTypeData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("umbracoLanguage"))
|
||||
{
|
||||
CreateUmbracoLanguageData();
|
||||
}
|
||||
|
||||
if (tableName.Equals("cmsContentTypeAllowedContentType"))
|
||||
{
|
||||
CreateCmsContentTypeAllowedContentTypeData();
|
||||
}
|
||||
|
||||
if(tableName.Equals("cmsDataType"))
|
||||
{
|
||||
CreateCmsDataTypeData();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUmbracNodeData()
|
||||
{
|
||||
_database.Insert(new NodeDto { NodeId = -1, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1", SortOrder = 0, UniqueId = new Guid("916724a5-173d-4619-b97e-b9de133dd6f5"), Text = "SYSTEM DATA: umbraco master root", NodeObjectType = new Guid("ea7d8624-4cfe-4578-a871-24aa946bf34d"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -20, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,-20", SortOrder = 0, UniqueId = new Guid("0F582A79-1E41-4CF0-BFA0-76340651891A"), Text = "Recycle Bin", NodeObjectType = new Guid("01BB7FF2-24DC-4C0C-95A2-C24EF72BBAC8"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -92, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-92", SortOrder = 35, UniqueId = new Guid("f0bc4bfb-b499-40d6-ba86-058885a5178c"), Text = "Label", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow});
|
||||
_database.Insert(new NodeDto { NodeId = -90, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-90", SortOrder = 34, UniqueId = new Guid("84c6b441-31df-4ffe-b67e-67d5bc3ae65a"), Text = "Upload", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -89, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-89", SortOrder = 33, UniqueId = new Guid("c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3"), Text = "Textbox multiple", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -88, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-88", SortOrder = 32, UniqueId = new Guid("0cc0eba1-9960-42c9-bf9b-60e150b429ae"), Text = "Textstring", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -87, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-87", SortOrder = 4, UniqueId = new Guid("ca90c950-0aff-4e72-b976-a30b1ac57dad"), Text = "Richtext editor", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -51, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-51", SortOrder = 2, UniqueId = new Guid("2e6d3631-066e-44b8-aec4-96f09099b2b5"), Text = "Numeric", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -49, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-49", SortOrder = 2, UniqueId = new Guid("2897bc6-a5f3-4ffe-ae27-f2e7e33dda49"), Text = "True/false", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -43, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-43", SortOrder = 2, UniqueId = new Guid("fbaf13a8-4036-41f2-93a3-974f678c312a"), Text = "Checkbox list", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -42, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-42", SortOrder = 2, UniqueId = new Guid("b6a45e7-44ba-430d-9da5-4e46060b9e03"), Text = "Dropdown", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -41, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-41", SortOrder = 2, UniqueId = new Guid("046194e-4237-453c-a547-15db3a07c4e1"), Text = "Date Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -40, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-40", SortOrder = 2, UniqueId = new Guid("bb5f57c9-ce2b-4bb9-b697-4caca783a805"), Text = "Radiobox", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -39, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-39", SortOrder = 2, UniqueId = new Guid("f38f0ac7-1d27-439c-9f3f-089cd8825a53"), Text = "Dropdown multiple", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -38, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-38", SortOrder = 2, UniqueId = new Guid("fd9f1447-6c61-4a7c-9595-5aa39147d318"), Text = "Folder Browser", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -37, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-37", SortOrder = 2, UniqueId = new Guid("0225af17-b302-49cb-9176-b9f35cab9c17"), Text = "Approved Color", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = -36, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-36", SortOrder = 2, UniqueId = new Guid("e4d66c0f-b935-4200-81f0-025f7256b89a"), Text = "Date Picker with time", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1031, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1031", SortOrder = 2, UniqueId = new Guid("f38bd2d7-65d0-48e6-95dc-87ce06ec2d3d"), Text = "Folder", NodeObjectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1032, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1032", SortOrder = 2, UniqueId = new Guid("cc07b313-0843-4aa8-bbda-871c8da728c8"), Text = "Image", NodeObjectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1033, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1033", SortOrder = 2, UniqueId = new Guid("4c52d8ab-54e6-40cd-999c-7a5f24903e4d"), Text = "File", NodeObjectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1034, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1034", SortOrder = 2, UniqueId = new Guid("a6857c73-d6e9-480c-b6e6-f15f6ad11125"), Text = "Content Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1035, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1035", SortOrder = 2, UniqueId = new Guid("93929b9a-93a2-4e2a-b239-d99334440a59"), Text = "Media Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1036, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1036", SortOrder = 2, UniqueId = new Guid("2b24165f-9782-4aa3-b459-1de4a4d21f60"), Text = "Member Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1038, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1038", SortOrder = 2, UniqueId = new Guid("1251c96c-185c-4e9b-93f4-b48205573cbd"), Text = "Simple Editor", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1039, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1039", SortOrder = 2, UniqueId = new Guid("06f349a9-c949-4b6a-8660-59c10451af42"), Text = "Ultimate Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1040, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1040", SortOrder = 2, UniqueId = new Guid("21e798da-e06e-4eda-a511-ed257f78d4fa"), Text = "Related Links", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1041, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1041", SortOrder = 2, UniqueId = new Guid("b6b73142-b9c1-4bf8-a16d-e1c23320b549"), Text = "Tags", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1042, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1042", SortOrder = 2, UniqueId = new Guid("0a452bd5-83f9-4bc3-8403-1286e13fb77e"), Text = "Macro Container", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert(new NodeDto { NodeId = 1043, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1043", SortOrder = 2, UniqueId = new Guid("1df9f033-e6d4-451f-b8d2-e0cbc50a836f"), Text = "Image Cropper", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
using (var transaction = _database.GetTransaction())
|
||||
{
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [umbracoNode] ON "));
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -1, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1", SortOrder = 0, UniqueId = new Guid("916724a5-173d-4619-b97e-b9de133dd6f5"), Text = "SYSTEM DATA: umbraco master root", NodeObjectType = new Guid("ea7d8624-4cfe-4578-a871-24aa946bf34d"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -20, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,-20", SortOrder = 0, UniqueId = new Guid("0F582A79-1E41-4CF0-BFA0-76340651891A"), Text = "Recycle Bin", NodeObjectType = new Guid("01BB7FF2-24DC-4C0C-95A2-C24EF72BBAC8"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -92, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-92", SortOrder = 35, UniqueId = new Guid("f0bc4bfb-b499-40d6-ba86-058885a5178c"), Text = "Label", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -90, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-90", SortOrder = 34, UniqueId = new Guid("84c6b441-31df-4ffe-b67e-67d5bc3ae65a"), Text = "Upload", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -89, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-89", SortOrder = 33, UniqueId = new Guid("c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3"), Text = "Textbox multiple", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -88, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-88", SortOrder = 32, UniqueId = new Guid("0cc0eba1-9960-42c9-bf9b-60e150b429ae"), Text = "Textstring", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -87, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-87", SortOrder = 4, UniqueId = new Guid("ca90c950-0aff-4e72-b976-a30b1ac57dad"), Text = "Richtext editor", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -51, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-51", SortOrder = 2, UniqueId = new Guid("2e6d3631-066e-44b8-aec4-96f09099b2b5"), Text = "Numeric", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -49, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-49", SortOrder = 2, UniqueId = new Guid("92897bc6-a5f3-4ffe-ae27-f2e7e33dda49"), Text = "True/false", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -43, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-43", SortOrder = 2, UniqueId = new Guid("fbaf13a8-4036-41f2-93a3-974f678c312a"), Text = "Checkbox list", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -42, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-42", SortOrder = 2, UniqueId = new Guid("0b6a45e7-44ba-430d-9da5-4e46060b9e03"), Text = "Dropdown", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -41, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-41", SortOrder = 2, UniqueId = new Guid("5046194e-4237-453c-a547-15db3a07c4e1"), Text = "Date Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -40, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-40", SortOrder = 2, UniqueId = new Guid("bb5f57c9-ce2b-4bb9-b697-4caca783a805"), Text = "Radiobox", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -39, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-39", SortOrder = 2, UniqueId = new Guid("f38f0ac7-1d27-439c-9f3f-089cd8825a53"), Text = "Dropdown multiple", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -38, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-38", SortOrder = 2, UniqueId = new Guid("fd9f1447-6c61-4a7c-9595-5aa39147d318"), Text = "Folder Browser", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -37, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-37", SortOrder = 2, UniqueId = new Guid("0225af17-b302-49cb-9176-b9f35cab9c17"), Text = "Approved Color", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -36, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-36", SortOrder = 2, UniqueId = new Guid("e4d66c0f-b935-4200-81f0-025f7256b89a"), Text = "Date Picker with time", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1031, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1031", SortOrder = 2, UniqueId = new Guid("f38bd2d7-65d0-48e6-95dc-87ce06ec2d3d"), Text = "Folder", NodeObjectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1032, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1032", SortOrder = 2, UniqueId = new Guid("cc07b313-0843-4aa8-bbda-871c8da728c8"), Text = "Image", NodeObjectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1033, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1033", SortOrder = 2, UniqueId = new Guid("4c52d8ab-54e6-40cd-999c-7a5f24903e4d"), Text = "File", NodeObjectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1034, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1034", SortOrder = 2, UniqueId = new Guid("a6857c73-d6e9-480c-b6e6-f15f6ad11125"), Text = "Content Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1035, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1035", SortOrder = 2, UniqueId = new Guid("93929b9a-93a2-4e2a-b239-d99334440a59"), Text = "Media Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1036, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1036", SortOrder = 2, UniqueId = new Guid("2b24165f-9782-4aa3-b459-1de4a4d21f60"), Text = "Member Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1038, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1038", SortOrder = 2, UniqueId = new Guid("1251c96c-185c-4e9b-93f4-b48205573cbd"), Text = "Simple Editor", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1039, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1039", SortOrder = 2, UniqueId = new Guid("06f349a9-c949-4b6a-8660-59c10451af42"), Text = "Ultimate Picker", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1040, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1040", SortOrder = 2, UniqueId = new Guid("21e798da-e06e-4eda-a511-ed257f78d4fa"), Text = "Related Links", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1041, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1041", SortOrder = 2, UniqueId = new Guid("b6b73142-b9c1-4bf8-a16d-e1c23320b549"), Text = "Tags", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1042, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1042", SortOrder = 2, UniqueId = new Guid("0a452bd5-83f9-4bc3-8403-1286e13fb77e"), Text = "Macro Container", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1043, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1043", SortOrder = 2, UniqueId = new Guid("1df9f033-e6d4-451f-b8d2-e0cbc50a836f"), Text = "Image Cropper", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow });
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [umbracoNode] OFF "));
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateCmsContentTypeData()
|
||||
{
|
||||
_database.Insert(new ContentTypeDto { PrimaryKey = 532, NodeId = 1031, Alias = "Folder", Icon = "folder.gif", IsContainer = true, AllowAtRoot = true});
|
||||
_database.Insert(new ContentTypeDto { PrimaryKey = 533, NodeId = 1032, Alias = "Image", Icon = "mediaPhoto.gif" });
|
||||
_database.Insert(new ContentTypeDto { PrimaryKey = 534, NodeId = 1033, Alias = "File", Icon = "mediaFile.gif" });
|
||||
_database.Insert(new ContentTypeDto { PrimaryKey = 532, NodeId = 1031, Alias = "Folder", Icon = "folder.gif", Thumbnail = "folder.png", IsContainer = true, AllowAtRoot = true });
|
||||
_database.Insert(new ContentTypeDto { PrimaryKey = 533, NodeId = 1032, Alias = "Image", Icon = "mediaPhoto.gif", Thumbnail = "folder.png" });
|
||||
_database.Insert(new ContentTypeDto { PrimaryKey = 534, NodeId = 1033, Alias = "File", Icon = "mediaFile.gif", Thumbnail = "folder.png" });
|
||||
}
|
||||
|
||||
private void CreateUmbracoUserData()
|
||||
{
|
||||
_database.Insert(new UserDto{ Id = 0, Disabled = false, NoConsole = false, Type = 1, ContentStartId = -1, MediaStartId = -1, UserName = "Administrator", Login = "admin", Password = "default", Email = "", UserLanguage = "en"});
|
||||
using (var transaction = _database.GetTransaction())
|
||||
{
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [umbracoUser] ON "));
|
||||
_database.Insert("umbracoUser", "id", false, new UserDto { Id = 0, Disabled = false, NoConsole = false, Type = 1, ContentStartId = -1, MediaStartId = -1, UserName = "Administrator", Login = "admin", Password = "default", Email = "", UserLanguage = "en", DefaultPermissions = null, DefaultToLiveEditing = false });
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [umbracoUser] OFF "));
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUmbracoUserTypeData()
|
||||
@@ -124,23 +177,36 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
private void CreateCmsPropertyTypeGroupData()
|
||||
{
|
||||
_database.Insert(new PropertyTypeGroupDto { Id = 3, ContentTypeNodeId = 1032, Text = "Image", SortOrder = 1});
|
||||
_database.Insert(new PropertyTypeGroupDto { Id = 4, ContentTypeNodeId = 1033, Text = "File", SortOrder = 1 });
|
||||
_database.Insert(new PropertyTypeGroupDto { Id = 5, ContentTypeNodeId = 1031, Text = "Contents", SortOrder = 1 });
|
||||
using (var transaction = _database.GetTransaction())
|
||||
{
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyTypeGroup] ON "));
|
||||
_database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 3, ContentTypeNodeId = 1032, Text = "Image", SortOrder = 1 });
|
||||
_database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 4, ContentTypeNodeId = 1033, Text = "File", SortOrder = 1 });
|
||||
_database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 5, ContentTypeNodeId = 1031, Text = "Contents", SortOrder = 1 });
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyTypeGroup] OFF "));
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateCmsPropertyTypeData()
|
||||
{
|
||||
_database.Insert(new PropertyTypeDto { Id = 6, DataTypeId = -90, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoFile", Name = "Upload image", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null});
|
||||
_database.Insert(new PropertyTypeDto { Id = 7, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoWidth", Name = "Width", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 8, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoHeight", Name = "Height", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 9, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoBytes", Name = "Size", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 10, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoExtension", Name = "Type", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 24, DataTypeId = -90, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoFile", Name = "Upload file", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 25, DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoExtension", Name = "Type", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 26, DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoBytes", Name = "Size", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert(new PropertyTypeDto { Id = 27, DataTypeId = -38, ContentTypeId = 1031, PropertyTypeGroupId = 5, Alias = "contents", Name = "Contents:", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
using (var transaction = _database.GetTransaction())
|
||||
{
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyType] ON "));
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 6, DataTypeId = -90, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoFile", Name = "Upload image", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 7, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoWidth", Name = "Width", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 8, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoHeight", Name = "Height", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 9, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoBytes", Name = "Size", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 10, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoExtension", Name = "Type", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 24, DataTypeId = -90, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoFile", Name = "Upload file", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 25, DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoExtension", Name = "Type", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 26, DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoBytes", Name = "Size", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 27, DataTypeId = -38, ContentTypeId = 1031, PropertyTypeGroupId = 5, Alias = "contents", Name = "Contents:", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyType] OFF "));
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUmbracoLanguageData()
|
||||
@@ -148,7 +214,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
_database.Insert(new LanguageDto { Id = 1, IsoCode = "en-US", CultureName = "en-US" });
|
||||
}
|
||||
|
||||
private void CreateCmsContentTypeAllowedContentType()
|
||||
private void CreateCmsContentTypeAllowedContentTypeData()
|
||||
{
|
||||
_database.Insert(new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1031 });
|
||||
_database.Insert(new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1032 });
|
||||
@@ -157,41 +223,48 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
private void CreateCmsDataTypeData()
|
||||
{
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 4, DataTypeId = -49, ControlId = new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"), DbType = "Integer" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 6, DataTypeId = -51, ControlId = new Guid("1413afcb-d19a-4173-8e9a-68288d2a73b8"), DbType = "Integer" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 8, DataTypeId = -87, ControlId = new Guid("5E9B75AE-FACE-41c8-B47E-5F4B0FD82F83"), DbType = "Ntext" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 9, DataTypeId = -88, ControlId = new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 10, DataTypeId = -89, ControlId = new Guid("67db8357-ef57-493e-91ac-936d305e0f2a"), DbType = "Ntext" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 11, DataTypeId = -90, ControlId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 12, DataTypeId = -91, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 13, DataTypeId = -92, ControlId = new Guid("6c738306-4c17-4d88-b9bd-6546f3771597"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 14, DataTypeId = -36, ControlId = new Guid("b6fb1622-afa5-4bbf-a3cc-d9672a442222"), DbType = "Date" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 15, DataTypeId = -37, ControlId = new Guid("f8d60f68-ec59-4974-b43b-c46eb5677985"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 16, DataTypeId = -38, ControlId = new Guid("cccd4ae9-f399-4ed2-8038-2e88d19e810c"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 17, DataTypeId = -39, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 18, DataTypeId = -40, ControlId = new Guid("a52c7c1c-c330-476e-8605-d63d3b84b6a6"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 19, DataTypeId = -41, ControlId = new Guid("23e93522-3200-44e2-9f29-e61a6fcbb79a"), DbType = "Date" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 20, DataTypeId = -42, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Integer" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 21, DataTypeId = -43, ControlId = new Guid("b4471851-82b6-4c75-afa4-39fa9c6a75e9"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 22, DataTypeId = -44, ControlId = new Guid("a3776494-0574-4d93-b7de-efdfdec6f2d1"), DbType = "Ntext" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 23, DataTypeId = -128, ControlId = new Guid("a52c7c1c-c330-476e-8605-d63d3b84b6a6"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 24, DataTypeId = -129, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 25, DataTypeId = -130, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 26, DataTypeId = -131, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 27, DataTypeId = -132, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 28, DataTypeId = -133, ControlId = new Guid("6c738306-4c17-4d88-b9bd-6546f3771597"), DbType = "Ntext" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 29, DataTypeId = -134, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 30, DataTypeId = -50, ControlId = new Guid("aaf99bb2-dbbe-444d-a296-185076bf0484"), DbType = "Date"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 31, DataTypeId = 1034, ControlId = new Guid("158aa029-24ed-4948-939e-c3da209e5fba"), DbType = "Integer"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 32, DataTypeId = 1035, ControlId = new Guid("ead69342-f06d-4253-83ac-28000225583b"), DbType = "Integer"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 33, DataTypeId = 1036, ControlId = new Guid("39f533e4-0551-4505-a64b-e0425c5ce775"), DbType = "Integer"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 35, DataTypeId = 1038, ControlId = new Guid("60b7dabf-99cd-41eb-b8e9-4d2e669bbde9"), DbType = "Ntext"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 36, DataTypeId = 1039, ControlId = new Guid("cdbf0b5d-5cb2-445f-bc12-fcaaec07cf2c"), DbType = "Ntext"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 37, DataTypeId = 1040, ControlId = new Guid("71b8ad1a-8dc2-425c-b6b8-faa158075e63"), DbType = "Ntext"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 38, DataTypeId = 1041, ControlId = new Guid("4023e540-92f5-11dd-ad8b-0800200c9a66"), DbType = "Ntext"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 39, DataTypeId = 1042, ControlId = new Guid("474FCFF8-9D2D-11DE-ABC6-AD7A56D89593"), DbType = "Ntext"});
|
||||
_database.Insert(new DataTypeDto { PrimaryKey = 40, DataTypeId = 1043, ControlId = new Guid("7A2D436C-34C2-410F-898F-4A23B3D79F54"), DbType = "Ntext"});
|
||||
using (var transaction = _database.GetTransaction())
|
||||
{
|
||||
//TODO Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors.
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [cmsDataType] ON "));
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 4, DataTypeId = -49, ControlId = new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"), DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 6, DataTypeId = -51, ControlId = new Guid("1413afcb-d19a-4173-8e9a-68288d2a73b8"), DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 8, DataTypeId = -87, ControlId = new Guid("5E9B75AE-FACE-41c8-B47E-5F4B0FD82F83"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 9, DataTypeId = -88, ControlId = new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 10, DataTypeId = -89, ControlId = new Guid("67db8357-ef57-493e-91ac-936d305e0f2a"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 11, DataTypeId = -90, ControlId = new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 12, DataTypeId = -91, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 13, DataTypeId = -92, ControlId = new Guid("6c738306-4c17-4d88-b9bd-6546f3771597"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 14, DataTypeId = -36, ControlId = new Guid("b6fb1622-afa5-4bbf-a3cc-d9672a442222"), DbType = "Date" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 15, DataTypeId = -37, ControlId = new Guid("f8d60f68-ec59-4974-b43b-c46eb5677985"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 16, DataTypeId = -38, ControlId = new Guid("cccd4ae9-f399-4ed2-8038-2e88d19e810c"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 17, DataTypeId = -39, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 18, DataTypeId = -40, ControlId = new Guid("a52c7c1c-c330-476e-8605-d63d3b84b6a6"), DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 19, DataTypeId = -41, ControlId = new Guid("23e93522-3200-44e2-9f29-e61a6fcbb79a"), DbType = "Date" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 20, DataTypeId = -42, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 21, DataTypeId = -43, ControlId = new Guid("b4471851-82b6-4c75-afa4-39fa9c6a75e9"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 22, DataTypeId = -44, ControlId = new Guid("a3776494-0574-4d93-b7de-efdfdec6f2d1"), DbType = "Ntext" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = -128, ControlId = new Guid("a52c7c1c-c330-476e-8605-d63d3b84b6a6"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 24, DataTypeId = -129, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 25, DataTypeId = -130, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 26, DataTypeId = -131, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 27, DataTypeId = -132, ControlId = new Guid("a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 28, DataTypeId = -133, ControlId = new Guid("6c738306-4c17-4d88-b9bd-6546f3771597"), DbType = "Ntext" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 29, DataTypeId = -134, ControlId = new Guid("928639ed-9c73-4028-920c-1e55dbb68783"), DbType = "Nvarchar" });
|
||||
//_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 30, DataTypeId = -50, ControlId = new Guid("aaf99bb2-dbbe-444d-a296-185076bf0484"), DbType = "Date" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 31, DataTypeId = 1034, ControlId = new Guid("158aa029-24ed-4948-939e-c3da209e5fba"), DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 32, DataTypeId = 1035, ControlId = new Guid("ead69342-f06d-4253-83ac-28000225583b"), DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 33, DataTypeId = 1036, ControlId = new Guid("39f533e4-0551-4505-a64b-e0425c5ce775"), DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 35, DataTypeId = 1038, ControlId = new Guid("60b7dabf-99cd-41eb-b8e9-4d2e669bbde9"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 36, DataTypeId = 1039, ControlId = new Guid("cdbf0b5d-5cb2-445f-bc12-fcaaec07cf2c"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 37, DataTypeId = 1040, ControlId = new Guid("71b8ad1a-8dc2-425c-b6b8-faa158075e63"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 38, DataTypeId = 1041, ControlId = new Guid("4023e540-92f5-11dd-ad8b-0800200c9a66"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 39, DataTypeId = 1042, ControlId = new Guid("474FCFF8-9D2D-11DE-ABC6-AD7A56D89593"), DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 40, DataTypeId = 1043, ControlId = new Guid("7A2D436C-34C2-410F-898F-4A23B3D79F54"), DbType = "Ntext" });
|
||||
_database.Execute(new Sql("SET IDENTITY_INSERT [cmsDataType] OFF "));
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,52 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
_database = database;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The save event handler
|
||||
/// </summary>
|
||||
internal delegate void DatabaseEventHandler(DatabaseCreationEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [before save].
|
||||
/// </summary>
|
||||
internal static event DatabaseEventHandler BeforeCreation;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="BeforeCreation"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected internal virtual void FireBeforeCreation(DatabaseCreationEventArgs e)
|
||||
{
|
||||
if (BeforeCreation != null)
|
||||
{
|
||||
BeforeCreation(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [after save].
|
||||
/// </summary>
|
||||
internal static event DatabaseEventHandler AfterCreation;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="AfterCreation"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void FireAfterCreation(DatabaseCreationEventArgs e)
|
||||
{
|
||||
if (AfterCreation != null)
|
||||
{
|
||||
AfterCreation(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the database by creating the umbraco db schema
|
||||
/// </summary>
|
||||
public void InitializeDatabaseSchema()
|
||||
{
|
||||
//NOTE Please mind the order of the table creation, as some references requires other tables.
|
||||
using(var transaction = _database.GetTransaction())
|
||||
var e = new DatabaseCreationEventArgs();
|
||||
FireBeforeCreation(e);
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
_database.CreateTable<NodeDto>();
|
||||
|
||||
@@ -35,7 +74,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
_database.CreateTable<AppDto>();
|
||||
_database.CreateTable<AppTreeDto>();
|
||||
|
||||
|
||||
_database.CreateTable<DataTypeDto>();
|
||||
_database.CreateTable<DataTypePreValueDto>();
|
||||
|
||||
@@ -50,24 +89,24 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
_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>();
|
||||
|
||||
@@ -84,9 +123,80 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
_database.CreateTable<User2AppDto>();
|
||||
_database.CreateTable<User2NodeNotifyDto>();
|
||||
_database.CreateTable<User2NodePermissionDto>();
|
||||
|
||||
transaction.Complete();
|
||||
|
||||
//NOTE Please mind the order of the table creation, as some references requires other tables.
|
||||
/*using (var transaction = _database.GetTransaction())
|
||||
{
|
||||
_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>();
|
||||
|
||||
transaction.Complete();
|
||||
}*/
|
||||
}
|
||||
|
||||
FireAfterCreation(e);
|
||||
}
|
||||
}
|
||||
|
||||
internal class DatabaseCreationEventArgs : System.ComponentModel.CancelEventArgs{}
|
||||
}
|
||||
@@ -1769,8 +1769,11 @@ namespace Umbraco.Core.Persistence
|
||||
// Work out bound properties
|
||||
bool ExplicitColumns = t.GetCustomAttributes(typeof(ExplicitColumnsAttribute), true).Length > 0;
|
||||
Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
|
||||
//MCH NOTE: Changing bindingflags on GetProperties() to include internal properties
|
||||
foreach (var pi in t.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
|
||||
|
||||
//MCH NOTE: Changing bindingflags and using GetAllProperties() to include internal
|
||||
//properties as well as work for interfaces by flattening the hierarchy.
|
||||
var properties = t.GetAllProperties();
|
||||
foreach (var pi in properties)
|
||||
{
|
||||
// Work out if properties is to be included
|
||||
var ColAttrs = pi.GetCustomAttributes(typeof(ColumnAttribute), true);
|
||||
|
||||
@@ -7,6 +7,10 @@ namespace Umbraco.Core.Persistence
|
||||
{
|
||||
public static class PetaPocoExtensions
|
||||
{
|
||||
internal delegate void CreateTableEventHandler(string tableName, Database db, TableCreationEventArgs e);
|
||||
|
||||
internal static event CreateTableEventHandler NewTable;
|
||||
|
||||
public static void CreateTable<T>(this Database db)
|
||||
where T : new()
|
||||
{
|
||||
@@ -54,6 +58,15 @@ namespace Umbraco.Core.Persistence
|
||||
{
|
||||
int created = db.Execute(new Sql(createSql));
|
||||
|
||||
if (NewTable != null)
|
||||
{
|
||||
var e = new TableCreationEventArgs();
|
||||
NewTable(tableName, db, e);
|
||||
}
|
||||
|
||||
//TODO Figure out how to deal with base data before/after db and constraint creation
|
||||
//Possibly add an internal task to trigger the data creation prior to creating constraints?
|
||||
|
||||
if(!string.IsNullOrEmpty(createPrimaryKeySql))
|
||||
db.Execute(new Sql(createPrimaryKeySql));
|
||||
|
||||
@@ -96,14 +109,18 @@ namespace Umbraco.Core.Persistence
|
||||
|
||||
public static void Initialize(this Database db)
|
||||
{
|
||||
NewTable += PetaPocoExtensions_NewTable;
|
||||
|
||||
var creation = new DatabaseCreation(db);
|
||||
creation.InitializeDatabaseSchema();
|
||||
}
|
||||
|
||||
public static void InstallBaseData(this Database db)
|
||||
static void PetaPocoExtensions_NewTable(string tableName, Database db, TableCreationEventArgs e)
|
||||
{
|
||||
var baseDataCreation = new BaseDataCreation(db);
|
||||
baseDataCreation.InitializeBaseData();
|
||||
baseDataCreation.InitializeBaseData(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
internal class TableCreationEventArgs : System.ComponentModel.CancelEventArgs{}
|
||||
}
|
||||
@@ -205,6 +205,52 @@ namespace Umbraco.Core
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all properties in a flat hierarchy
|
||||
/// </summary>
|
||||
/// <remarks>Includes both Public and Non-Public properties</remarks>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static PropertyInfo[] GetAllProperties(this Type type)
|
||||
{
|
||||
if (type.IsInterface)
|
||||
{
|
||||
var propertyInfos = new List<PropertyInfo>();
|
||||
|
||||
var considered = new List<Type>();
|
||||
var queue = new Queue<Type>();
|
||||
considered.Add(type);
|
||||
queue.Enqueue(type);
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var subType = queue.Dequeue();
|
||||
foreach (var subInterface in subType.GetInterfaces())
|
||||
{
|
||||
if (considered.Contains(subInterface)) continue;
|
||||
|
||||
considered.Add(subInterface);
|
||||
queue.Enqueue(subInterface);
|
||||
}
|
||||
|
||||
var typeProperties = subType.GetProperties(
|
||||
BindingFlags.FlattenHierarchy
|
||||
| BindingFlags.Public
|
||||
| BindingFlags.NonPublic
|
||||
| BindingFlags.Instance);
|
||||
|
||||
var newPropertyInfos = typeProperties
|
||||
.Where(x => !propertyInfos.Contains(x));
|
||||
|
||||
propertyInfos.InsertRange(0, newPropertyInfos);
|
||||
}
|
||||
|
||||
return propertyInfos.ToArray();
|
||||
}
|
||||
|
||||
return type.GetProperties(BindingFlags.FlattenHierarchy
|
||||
| BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified actual type is type.
|
||||
/// </summary>
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace Umbraco.Tests.Services
|
||||
[TestFixture]
|
||||
public class ContentServiceTests : BaseDatabaseFactoryTest
|
||||
{
|
||||
/*[Test]*/
|
||||
[Test]
|
||||
public void Can_Create_Content()
|
||||
{
|
||||
// Arrange
|
||||
var contentService = new ContentService();
|
||||
var contentService = GetUmbracoContext("/test", 1234).Services.ContentService;
|
||||
|
||||
// Act
|
||||
IContent content = contentService.CreateContent(-1, "umbTextpage");
|
||||
|
||||
@@ -2,9 +2,18 @@
|
||||
using System.Configuration;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using System.Web.Routing;
|
||||
using System.Xml;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Tests.Stubs;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Routing;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
@@ -21,6 +30,14 @@ namespace Umbraco.Tests.TestHelpers
|
||||
string path = TestHelper.CurrentAssemblyDirectory;
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", path);
|
||||
|
||||
Resolution.Freeze();
|
||||
ApplicationContext = new ApplicationContext() { IsReady = true };
|
||||
//we need to clear out all currently created template files
|
||||
var masterPages = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Masterpages));
|
||||
masterPages.GetFiles().ForEach(x => x.Delete());
|
||||
var mvcViews = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.MvcViews));
|
||||
mvcViews.GetFiles().ForEach(x => x.Delete());
|
||||
|
||||
//Delete database file before continueing
|
||||
string filePath = string.Concat(path, "\\test.sdf");
|
||||
if (File.Exists(filePath))
|
||||
@@ -39,7 +56,6 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
//Create the umbraco database
|
||||
DatabaseFactory.Current.Database.Initialize();
|
||||
DatabaseFactory.Current.Database.InstallBaseData();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -47,5 +63,89 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", null);
|
||||
}
|
||||
|
||||
protected ApplicationContext ApplicationContext { get; private set; }
|
||||
|
||||
protected UmbracoContext GetUmbracoContext(string url, int templateId, RouteData routeData = null)
|
||||
{
|
||||
var ctx = new UmbracoContext(
|
||||
GetHttpContextFactory(url, routeData).HttpContext,
|
||||
ApplicationContext,
|
||||
GetRoutesCache());
|
||||
SetupUmbracoContextForTest(ctx, templateId);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
protected FakeHttpContextFactory GetHttpContextFactory(string url, RouteData routeData = null)
|
||||
{
|
||||
var factory = routeData != null
|
||||
? new FakeHttpContextFactory(url, routeData)
|
||||
: new FakeHttpContextFactory(url);
|
||||
|
||||
|
||||
//set the state helper
|
||||
StateHelper.HttpContext = factory.HttpContext;
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
internal virtual IRoutesCache GetRoutesCache()
|
||||
{
|
||||
return new FakeRoutesCache();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initlializes the UmbracoContext with specific XML
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
/// <param name="templateId"></param>
|
||||
protected void SetupUmbracoContextForTest(UmbracoContext umbracoContext, int templateId)
|
||||
{
|
||||
umbracoContext.GetXmlDelegate = () =>
|
||||
{
|
||||
var xDoc = new XmlDocument();
|
||||
|
||||
//create a custom xml structure to return
|
||||
|
||||
xDoc.LoadXml(GetXmlContent(templateId));
|
||||
//return the custom x doc
|
||||
return xDoc;
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual string GetXmlContent(int templateId)
|
||||
{
|
||||
return @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<!DOCTYPE root[
|
||||
<!ELEMENT Home ANY>
|
||||
<!ATTLIST Home id ID #REQUIRED>
|
||||
<!ELEMENT CustomDocument ANY>
|
||||
<!ATTLIST CustomDocument id ID #REQUIRED>
|
||||
]>
|
||||
<root id=""-1"">
|
||||
<Home id=""1046"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""1"" createDate=""2012-06-12T14:13:17"" updateDate=""2012-07-20T18:50:43"" nodeName=""Home"" urlName=""home"" writerName=""admin"" creatorName=""admin"" path=""-1,1046"" isDoc="""">
|
||||
<content><![CDATA[]]></content>
|
||||
<umbracoUrlAlias><![CDATA[this/is/my/alias, anotheralias]]></umbracoUrlAlias>
|
||||
<umbracoNaviHide>1</umbracoNaviHide>
|
||||
<Home id=""1173"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-20T18:06:45"" updateDate=""2012-07-20T19:07:31"" nodeName=""Sub1"" urlName=""sub1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173"" isDoc="""">
|
||||
<content><![CDATA[<div>This is some content</div>]]></content>
|
||||
<umbracoUrlAlias><![CDATA[page2/alias, 2ndpagealias]]></umbracoUrlAlias>
|
||||
<Home id=""1174"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-20T18:07:54"" updateDate=""2012-07-20T19:10:27"" nodeName=""Sub2"" urlName=""sub2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1174"" isDoc="""">
|
||||
<content><![CDATA[]]></content>
|
||||
<umbracoUrlAlias><![CDATA[only/one/alias]]></umbracoUrlAlias>
|
||||
<creatorName><![CDATA[Custom data with same property name as the member name]]></creatorName>
|
||||
</Home>
|
||||
<Home id=""1176"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-20T18:08:08"" updateDate=""2012-07-20T19:10:52"" nodeName=""Sub 3"" urlName=""sub-3"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1176"" isDoc="""">
|
||||
<content><![CDATA[]]></content>
|
||||
</Home>
|
||||
<CustomDocument id=""1177"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""custom sub 1"" urlName=""custom-sub-1"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1177"" isDoc="""" />
|
||||
<CustomDocument id=""1178"" parentID=""1173"" level=""3"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""4"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-16T14:23:35"" nodeName=""custom sub 2"" urlName=""custom-sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1173,1178"" isDoc="""" />
|
||||
</Home>
|
||||
<Home id=""1175"" parentID=""1046"" level=""2"" writerID=""0"" creatorID=""0"" nodeType=""1044"" template=""" + templateId + @""" sortOrder=""3"" createDate=""2012-07-20T18:08:01"" updateDate=""2012-07-20T18:49:32"" nodeName=""Sub 2"" urlName=""sub-2"" writerName=""admin"" creatorName=""admin"" path=""-1,1046,1175"" isDoc=""""><content><![CDATA[]]></content>
|
||||
</Home>
|
||||
</Home>
|
||||
<CustomDocument id=""1172"" parentID=""-1"" level=""1"" writerID=""0"" creatorID=""0"" nodeType=""1234"" template=""" + templateId + @""" sortOrder=""2"" createDate=""2012-07-16T15:26:59"" updateDate=""2012-07-18T14:23:35"" nodeName=""Test"" urlName=""test-page"" writerName=""admin"" creatorName=""admin"" path=""-1,1172"" isDoc="""" />
|
||||
</root>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,12 +49,12 @@ namespace Umbraco.Web.Services
|
||||
var contentTypes = repository.GetByQuery(query);
|
||||
|
||||
if (!contentTypes.Any())
|
||||
throw new Exception(string.Format("No ContentType matching the passed in Alias: {0} was found", contentTypeAlias));
|
||||
throw new Exception(string.Format("No ContentType matching the passed in Alias: '{0}' was found", contentTypeAlias));
|
||||
|
||||
var contentType = contentTypes.First();
|
||||
|
||||
if (contentType == null)
|
||||
throw new Exception(string.Format("No ContentType matching the passed in Alias: {0} was found", contentTypeAlias));
|
||||
throw new Exception(string.Format("No ContentType matching the passed in Alias: '{0}' was found", contentTypeAlias));
|
||||
|
||||
return new Content(parentId, contentType);
|
||||
}
|
||||
|
||||
106
src/Umbraco.Web/Services/ServiceContext.cs
Normal file
106
src/Umbraco.Web/Services/ServiceContext.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
using Umbraco.Web.Publishing;
|
||||
|
||||
namespace Umbraco.Web.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// The Umbraco ServiceContext, which provides access to the following services:
|
||||
/// <see cref="IContentService"/>, <see cref="IContentTypeService"/>, <see cref="IDataTypeService"/>,
|
||||
/// <see cref="IFileService"/>, <see cref="ILocalizationService"/> and <see cref="IMediaService"/>.
|
||||
/// </summary>
|
||||
public class ServiceContext
|
||||
{
|
||||
#region Singleton
|
||||
private static readonly Lazy<ServiceContext> lazy = new Lazy<ServiceContext>(() => new ServiceContext());
|
||||
|
||||
public static ServiceContext Current { get { return lazy.Value; } }
|
||||
|
||||
private ServiceContext()
|
||||
{
|
||||
if(_cache.IsEmpty)
|
||||
{
|
||||
BuildServiceCache();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private readonly ConcurrentDictionary<string, IService> _cache = new ConcurrentDictionary<string, IService>();
|
||||
|
||||
/// <summary>
|
||||
/// Builds the various services and adds them to the internal cache
|
||||
/// </summary>
|
||||
private void BuildServiceCache()
|
||||
{
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var publishingStrategy = new PublishingStrategy();
|
||||
|
||||
var contentService = new ContentService(provider, publishingStrategy);
|
||||
_cache.AddOrUpdate(typeof (IContentService).Name, contentService, (x, y) => contentService);
|
||||
|
||||
var mediaService = new MediaService(provider);
|
||||
_cache.AddOrUpdate(typeof(IMediaService).Name, mediaService, (x, y) => mediaService);
|
||||
|
||||
var contentTypeService = new ContentTypeService(contentService, mediaService, provider);
|
||||
_cache.AddOrUpdate(typeof(IContentTypeService).Name, contentTypeService, (x, y) => contentTypeService);
|
||||
|
||||
var dataTypeService = new DataTypeService(provider);
|
||||
_cache.AddOrUpdate(typeof(IDataTypeService).Name, dataTypeService, (x, y) => dataTypeService);
|
||||
|
||||
var fileService = new FileService(provider);
|
||||
_cache.AddOrUpdate(typeof(IFileService).Name, fileService, (x, y) => fileService);
|
||||
|
||||
var localizationService = new LocalizationService(provider);
|
||||
_cache.AddOrUpdate(typeof(ILocalizationService).Name, localizationService, (x, y) => localizationService);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IContentService"/>
|
||||
/// </summary>
|
||||
public IContentService ContentService
|
||||
{
|
||||
get { return _cache[typeof (IContentService).Name] as IContentService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IContentTypeService"/>
|
||||
/// </summary>
|
||||
public IContentTypeService ContentTypeService
|
||||
{
|
||||
get { return _cache[typeof(IContentTypeService).Name] as IContentTypeService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IDataTypeService"/>
|
||||
/// </summary>
|
||||
public IDataTypeService DataTypeService
|
||||
{
|
||||
get { return _cache[typeof(IDataTypeService).Name] as IDataTypeService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IFileService"/>
|
||||
/// </summary>
|
||||
public IFileService FileService
|
||||
{
|
||||
get { return _cache[typeof (IFileService).Name] as IFileService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ILocalizationService"/>
|
||||
/// </summary>
|
||||
public ILocalizationService LocalizationService
|
||||
{
|
||||
get { return _cache[typeof(ILocalizationService).Name] as ILocalizationService; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IMediaService"/>
|
||||
/// </summary>
|
||||
public IMediaService MediaService
|
||||
{
|
||||
get { return _cache[typeof(IMediaService).Name] as IMediaService; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,6 +327,7 @@
|
||||
<Compile Include="Services\IService.cs" />
|
||||
<Compile Include="Services\LocalizationService.cs" />
|
||||
<Compile Include="Services\MediaService.cs" />
|
||||
<Compile Include="Services\ServiceContext.cs" />
|
||||
<Compile Include="Templates\TemplateUtilities.cs" />
|
||||
<Compile Include="umbraco.presentation\Default.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Services;
|
||||
using umbraco;
|
||||
using umbraco.IO;
|
||||
using umbraco.presentation;
|
||||
@@ -51,6 +52,8 @@ namespace Umbraco.Web
|
||||
Application = applicationContext;
|
||||
RoutesCache = routesCache;
|
||||
|
||||
Services = ServiceContext.Current;
|
||||
|
||||
// set the urls
|
||||
this.RequestUrl = httpContext.Request.Url;
|
||||
//RawUrl gets preserved across rewrites
|
||||
@@ -113,6 +116,11 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public ApplicationContext Application { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current ServiceContext, which exposes the various services
|
||||
/// </summary>
|
||||
public ServiceContext Services { get; private set; }
|
||||
|
||||
internal IRoutesCache RoutesCache { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user