Merge branch 'v8/contrib' into v8/feature/reintroduce-tabs
This commit is contained in:
16
src/Umbraco.Core/Persistence/Dtos/AxisDefintionDto.cs
Normal file
16
src/Umbraco.Core/Persistence/Dtos/AxisDefintionDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class AxisDefintionDto
|
||||
{
|
||||
[Column("nodeId")]
|
||||
public int NodeId { get; set; }
|
||||
|
||||
[Column("alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
[Column("ParentID")]
|
||||
public int ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
25
src/Umbraco.Core/Persistence/Dtos/ColumnInSchemaDto.cs
Normal file
25
src/Umbraco.Core/Persistence/Dtos/ColumnInSchemaDto.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class ColumnInSchemaDto
|
||||
{
|
||||
[Column("TABLE_NAME")]
|
||||
public string TableName { get; set; }
|
||||
|
||||
[Column("COLUMN_NAME")]
|
||||
public string ColumnName { get; set; }
|
||||
|
||||
[Column("ORDINAL_POSITION")]
|
||||
public int OrdinalPosition { get; set; }
|
||||
|
||||
[Column("COLUMN_DEFAULT")]
|
||||
public string ColumnDefault { get; set; }
|
||||
|
||||
[Column("IS_NULLABLE")]
|
||||
public string IsNullable { get; set; }
|
||||
|
||||
[Column("DATA_TYPE")]
|
||||
public string DataType { get; set; }
|
||||
}
|
||||
}
|
||||
16
src/Umbraco.Core/Persistence/Dtos/ConstraintPerColumnDto.cs
Normal file
16
src/Umbraco.Core/Persistence/Dtos/ConstraintPerColumnDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class ConstraintPerColumnDto
|
||||
{
|
||||
[Column("TABLE_NAME")]
|
||||
public string TableName { get; set; }
|
||||
|
||||
[Column("COLUMN_NAME")]
|
||||
public string ColumnName { get; set; }
|
||||
|
||||
[Column("CONSTRAINT_NAME")]
|
||||
public string ConstraintName { get; set; }
|
||||
}
|
||||
}
|
||||
13
src/Umbraco.Core/Persistence/Dtos/ConstraintPerTableDto.cs
Normal file
13
src/Umbraco.Core/Persistence/Dtos/ConstraintPerTableDto.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class ConstraintPerTableDto
|
||||
{
|
||||
[Column("TABLE_NAME")]
|
||||
public string TableName { get; set; }
|
||||
|
||||
[Column("CONSTRAINT_NAME")]
|
||||
public string ConstraintName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class DefaultConstraintPerColumnDto
|
||||
{
|
||||
[Column("TABLE_NAME")]
|
||||
public string TableName { get; set; }
|
||||
|
||||
[Column("COLUMN_NAME")]
|
||||
public string ColumnName { get; set; }
|
||||
|
||||
[Column("NAME")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("DEFINITION")]
|
||||
public string Definition { get; set; }
|
||||
}
|
||||
}
|
||||
20
src/Umbraco.Core/Persistence/Dtos/DefinedIndexDto.cs
Normal file
20
src/Umbraco.Core/Persistence/Dtos/DefinedIndexDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class DefinedIndexDto
|
||||
{
|
||||
|
||||
[Column("TABLE_NAME")]
|
||||
public string TableName { get; set; }
|
||||
|
||||
[Column("INDEX_NAME")]
|
||||
public string IndexName { get; set; }
|
||||
|
||||
[Column("COLUMN_NAME")]
|
||||
public string ColumnName { get; set; }
|
||||
|
||||
[Column("UNIQUE")]
|
||||
public short Unique { get; set; }
|
||||
}
|
||||
}
|
||||
20
src/Umbraco.Core/Persistence/Dtos/UserNotificationDto.cs
Normal file
20
src/Umbraco.Core/Persistence/Dtos/UserNotificationDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using NPoco;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Dtos
|
||||
{
|
||||
internal class UserNotificationDto
|
||||
{
|
||||
[Column("nodeId")]
|
||||
public int NodeId { get; set; }
|
||||
|
||||
[Column("userId")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Column("nodeObjectType")]
|
||||
public Guid NodeObjectType { get; set; }
|
||||
|
||||
[Column("action")]
|
||||
public string Action { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -901,7 +901,7 @@ namespace Umbraco.Core.Persistence
|
||||
return -1;
|
||||
}
|
||||
|
||||
var p = new Process
|
||||
using (var p = new Process
|
||||
{
|
||||
StartInfo =
|
||||
{
|
||||
@@ -913,13 +913,16 @@ namespace Umbraco.Core.Persistence
|
||||
CreateNoWindow = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
}
|
||||
};
|
||||
p.Start();
|
||||
output = p.StandardOutput.ReadToEnd();
|
||||
error = p.StandardError.ReadToEnd();
|
||||
p.WaitForExit();
|
||||
})
|
||||
{
|
||||
p.Start();
|
||||
output = p.StandardOutput.ReadToEnd();
|
||||
error = p.StandardError.ReadToEnd();
|
||||
p.WaitForExit();
|
||||
|
||||
return p.ExitCode;
|
||||
return p.ExitCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,22 +37,22 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
sql
|
||||
.OrderBy<UserDto>(x => x.Id)
|
||||
.OrderBy<NodeDto>(dto => dto.NodeId);
|
||||
return AmbientScope.Database.Fetch<dynamic>(sql).Select(x => new Notification(x.nodeId, x.userId, x.action, objectType));
|
||||
return AmbientScope.Database.Fetch<UserNotificationDto>(sql).Select(x => new Notification(x.NodeId, x.UserId, x.Action, objectType));
|
||||
}
|
||||
|
||||
public IEnumerable<Notification> GetUserNotifications(IUser user)
|
||||
{
|
||||
var sql = AmbientScope.SqlContext.Sql()
|
||||
.Select("DISTINCT umbracoNode.id, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action")
|
||||
.Select("DISTINCT umbracoNode.id AS nodeId, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action")
|
||||
.From<User2NodeNotifyDto>()
|
||||
.InnerJoin<NodeDto>()
|
||||
.On<User2NodeNotifyDto, NodeDto>(dto => dto.NodeId, dto => dto.NodeId)
|
||||
.Where<User2NodeNotifyDto>(dto => dto.UserId == (int)user.Id)
|
||||
.OrderBy<NodeDto>(dto => dto.NodeId);
|
||||
|
||||
var dtos = AmbientScope.Database.Fetch<dynamic>(sql);
|
||||
var dtos = AmbientScope.Database.Fetch<UserNotificationDto>(sql);
|
||||
//need to map the results
|
||||
return dtos.Select(d => new Notification(d.id, d.userId, d.action, d.nodeObjectType)).ToList();
|
||||
return dtos.Select(d => new Notification(d.NodeId, d.UserId, d.Action, d.NodeObjectType)).ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Notification> SetNotifications(IUser user, IEntity entity, string[] actions)
|
||||
@@ -64,16 +64,16 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
public IEnumerable<Notification> GetEntityNotifications(IEntity entity)
|
||||
{
|
||||
var sql = AmbientScope.SqlContext.Sql()
|
||||
.Select("DISTINCT umbracoNode.id, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action")
|
||||
.Select("DISTINCT umbracoNode.id as nodeId, umbracoUser2NodeNotify.userId, umbracoNode.nodeObjectType, umbracoUser2NodeNotify.action")
|
||||
.From<User2NodeNotifyDto>()
|
||||
.InnerJoin<NodeDto>()
|
||||
.On<User2NodeNotifyDto, NodeDto>(dto => dto.NodeId, dto => dto.NodeId)
|
||||
.Where<User2NodeNotifyDto>(dto => dto.NodeId == entity.Id)
|
||||
.OrderBy<NodeDto>(dto => dto.NodeId);
|
||||
|
||||
var dtos = AmbientScope.Database.Fetch<dynamic>(sql);
|
||||
var dtos = AmbientScope.Database.Fetch<UserNotificationDto>(sql);
|
||||
//need to map the results
|
||||
return dtos.Select(d => new Notification(d.id, d.userId, d.action, d.nodeObjectType)).ToList();
|
||||
return dtos.Select(d => new Notification(d.NodeId, d.UserId, d.Action, d.NodeObjectType)).ToList();
|
||||
}
|
||||
|
||||
public int DeleteNotifications(IEntity entity)
|
||||
|
||||
@@ -302,12 +302,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
.Where("umbracoNode." + SqlContext.SqlSyntax.GetQuotedColumnName("id") + " IN (@parentIds) OR umbracoNode.parentID IN (@childIds)",
|
||||
new {parentIds = templates.Select(x => x.NodeDto.ParentId), childIds = templates.Select(x => x.NodeId)});
|
||||
|
||||
var childIds = Database.Fetch<dynamic>(childIdsSql)
|
||||
var childIds = Database.Fetch<AxisDefintionDto>(childIdsSql)
|
||||
.Select(x => new EntitySlim
|
||||
{
|
||||
Id = x.nodeId,
|
||||
ParentId = x.parentID,
|
||||
Name = x.alias
|
||||
Id = x.NodeId,
|
||||
ParentId = x.ParentId,
|
||||
Name = x.Alias
|
||||
});
|
||||
return childIds;
|
||||
}
|
||||
|
||||
@@ -149,30 +149,22 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
public IDictionary<UserState, int> GetUserStates()
|
||||
{
|
||||
var sql = @"SELECT '1CountOfAll' AS colName, COUNT(id) AS num FROM umbracoUser
|
||||
// These keys in this query map to the `Umbraco.Core.Models.Membership.UserState` enum
|
||||
var sql = @"SELECT -1 AS [Key], COUNT(id) AS [Value] FROM umbracoUser
|
||||
UNION
|
||||
SELECT '2CountOfActive' AS colName, COUNT(id) AS num FROM umbracoUser WHERE userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NOT NULL
|
||||
SELECT 0 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NOT NULL
|
||||
UNION
|
||||
SELECT '3CountOfDisabled' AS colName, COUNT(id) AS num FROM umbracoUser WHERE userDisabled = 1
|
||||
SELECT 1 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 1
|
||||
UNION
|
||||
SELECT '4CountOfLockedOut' AS colName, COUNT(id) AS num FROM umbracoUser WHERE userNoConsole = 1
|
||||
SELECT 2 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userNoConsole = 1
|
||||
UNION
|
||||
SELECT '5CountOfInvited' AS colName, COUNT(id) AS num FROM umbracoUser WHERE lastLoginDate IS NULL AND userDisabled = 1 AND invitedDate IS NOT NULL
|
||||
SELECT 3 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE lastLoginDate IS NULL AND userDisabled = 1 AND invitedDate IS NOT NULL
|
||||
UNION
|
||||
SELECT '6CountOfDisabled' AS colName, COUNT(id) AS num FROM umbracoUser WHERE userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NULL
|
||||
ORDER BY colName";
|
||||
SELECT 4 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0 AND userNoConsole = 0 AND lastLoginDate IS NULL";
|
||||
|
||||
var result = Database.Fetch<dynamic>(sql);
|
||||
var result = Database.Dictionary<int, int>(sql);
|
||||
|
||||
return new Dictionary<UserState, int>
|
||||
{
|
||||
{UserState.All, (int) result[0].num},
|
||||
{UserState.Active, (int) result[1].num},
|
||||
{UserState.Disabled, (int) result[2].num},
|
||||
{UserState.LockedOut, (int) result[3].num},
|
||||
{UserState.Invited, (int) result[4].num},
|
||||
{UserState.Inactive, (int) result[5].num}
|
||||
};
|
||||
return result.ToDictionary(x => (UserState)x.Key, x => x.Value);
|
||||
}
|
||||
|
||||
public Guid CreateLoginSession(int userId, string requestingIpAddress, bool cleanStaleSessions = true)
|
||||
|
||||
@@ -9,6 +9,7 @@ using NPoco;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Scoping;
|
||||
|
||||
namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
@@ -175,51 +176,50 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
/// <returns></returns>
|
||||
public IEnumerable<Tuple<string, string, string, string>> GetDefaultConstraintsPerColumn(IDatabase db)
|
||||
{
|
||||
var items = db.Fetch<dynamic>("SELECT TableName = t.Name, ColumnName = c.Name, dc.Name, dc.[Definition] FROM sys.tables t INNER JOIN sys.default_constraints dc ON t.object_id = dc.parent_object_id INNER JOIN sys.columns c ON dc.parent_object_id = c.object_id AND c.column_id = dc.parent_column_id INNER JOIN sys.schemas as s on t.[schema_id] = s.[schema_id] WHERE s.name = (SELECT SCHEMA_NAME())");
|
||||
var items = db.Fetch<DefaultConstraintPerColumnDto>("SELECT TableName = t.Name, ColumnName = c.Name, dc.Name, dc.[Definition] FROM sys.tables t INNER JOIN sys.default_constraints dc ON t.object_id = dc.parent_object_id INNER JOIN sys.columns c ON dc.parent_object_id = c.object_id AND c.column_id = dc.parent_column_id INNER JOIN sys.schemas as s on t.[schema_id] = s.[schema_id] WHERE s.name = (SELECT SCHEMA_NAME())");
|
||||
return items.Select(x => new Tuple<string, string, string, string>(x.TableName, x.ColumnName, x.Name, x.Definition));
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetTablesInSchema(IDatabase db)
|
||||
{
|
||||
var items = db.Fetch<dynamic>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
return items.Select(x => x.TABLE_NAME).Cast<string>().ToList();
|
||||
return db.Fetch<string>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
}
|
||||
|
||||
public override IsolationLevel DefaultIsolationLevel => IsolationLevel.ReadCommitted;
|
||||
|
||||
public override IEnumerable<ColumnInfo> GetColumnsInSchema(IDatabase db)
|
||||
{
|
||||
var items = db.Fetch<dynamic>("SELECT TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
var items = db.Fetch<ColumnInSchemaDto>("SELECT TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
return
|
||||
items.Select(
|
||||
item =>
|
||||
new ColumnInfo(item.TABLE_NAME, item.COLUMN_NAME, item.ORDINAL_POSITION, item.COLUMN_DEFAULT,
|
||||
item.IS_NULLABLE, item.DATA_TYPE)).ToList();
|
||||
new ColumnInfo(item.TableName, item.ColumnName, item.OrdinalPosition, item.ColumnDefault,
|
||||
item.IsNullable, item.DataType)).ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<Tuple<string, string>> GetConstraintsPerTable(IDatabase db)
|
||||
{
|
||||
var items =
|
||||
db.Fetch<dynamic>(
|
||||
db.Fetch<ConstraintPerTableDto>(
|
||||
"SELECT TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
return items.Select(item => new Tuple<string, string>(item.TABLE_NAME, item.CONSTRAINT_NAME)).ToList();
|
||||
return items.Select(item => new Tuple<string, string>(item.TableName, item.ConstraintName)).ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<Tuple<string, string, string>> GetConstraintsPerColumn(IDatabase db)
|
||||
{
|
||||
var items =
|
||||
db.Fetch<dynamic>(
|
||||
db.Fetch<ConstraintPerColumnDto>(
|
||||
"SELECT TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
return items.Select(item => new Tuple<string, string, string>(item.TABLE_NAME, item.COLUMN_NAME, item.CONSTRAINT_NAME)).ToList();
|
||||
return items.Select(item => new Tuple<string, string, string>(item.TableName, item.ColumnName, item.ConstraintName)).ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<Tuple<string, string, string, bool>> GetDefinedIndexes(IDatabase db)
|
||||
{
|
||||
var items =
|
||||
db.Fetch<dynamic>(
|
||||
db.Fetch<DefinedIndexDto>(
|
||||
@"select T.name as TABLE_NAME, I.name as INDEX_NAME, AC.Name as COLUMN_NAME,
|
||||
CASE WHEN I.is_unique_constraint = 1 OR I.is_unique = 1 THEN 1 ELSE 0 END AS [UNIQUE]
|
||||
from sys.tables as T inner join sys.indexes as I on T.[object_id] = I.[object_id]
|
||||
@@ -228,8 +228,8 @@ from sys.tables as T inner join sys.indexes as I on T.[object_id] = I.[object_id
|
||||
inner join sys.schemas as S on T.[schema_id] = S.[schema_id]
|
||||
WHERE S.name = (SELECT SCHEMA_NAME()) AND I.is_primary_key = 0
|
||||
order by T.name, I.name");
|
||||
return items.Select(item => new Tuple<string, string, string, bool>(item.TABLE_NAME, item.INDEX_NAME, item.COLUMN_NAME,
|
||||
item.UNIQUE == 1)).ToList();
|
||||
return items.Select(item => new Tuple<string, string, string, bool>(item.TableName, item.IndexName, item.ColumnName,
|
||||
item.Unique == 1)).ToList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user