Port 7.7 - WIP

This commit is contained in:
Stephan
2017-09-08 19:39:13 +02:00
parent 00d2ea928d
commit 1c96df83cd
99 changed files with 9987 additions and 909 deletions

View File

@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web.Http;
using Umbraco.Core.Logging;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Web.Editors;
namespace Umbraco.Web.HealthCheck
@@ -13,12 +16,18 @@ namespace Umbraco.Web.HealthCheck
public class HealthCheckController : UmbracoAuthorizedJsonController
{
private readonly HealthCheckCollection _checks;
private readonly IList<Guid> _disabledCheckIds;
private readonly ILogger _logger;
public HealthCheckController(HealthCheckCollection checks, ILogger logger)
{
_checks = checks ?? throw new ArgumentNullException(nameof(checks));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
_disabledCheckIds = healthCheckConfig.DisabledChecks
.Select(x => x.Id)
.ToList();
}
/// <summary>
@@ -28,6 +37,7 @@ namespace Umbraco.Web.HealthCheck
public object GetAllHealthChecks()
{
var groups = _checks
.Where(x => _disabledCheckIds.Contains(x.Id) == false)
.GroupBy(x => x.Group)
.OrderBy(x => x.Key);
var healthCheckGroups = new List<HealthCheckGroup>();
@@ -49,9 +59,8 @@ namespace Umbraco.Web.HealthCheck
[HttpGet]
public object GetStatus(Guid id)
{
var check = _checks.FirstOrDefault(x => x.Id == id);
if (check == null) throw new InvalidOperationException("No health check found with ID " + id);
var check = GetCheckById(id);
try
{
//Core.Logging.LogHelper.Debug<HealthCheckController>("Running health check: " + check.Name);
@@ -67,10 +76,19 @@ namespace Umbraco.Web.HealthCheck
[HttpPost]
public HealthCheckStatus ExecuteAction(HealthCheckAction action)
{
var check = _checks.FirstOrDefault(x => x.Id == action.HealthCheckId);
if (check == null) throw new InvalidOperationException("No health check found with id " + action.HealthCheckId);
var check = GetCheckById(action.HealthCheckId);
return check.ExecuteAction(action);
}
private HealthCheck GetCheckById(Guid id)
{
var check = _checks
.FirstOrDefault(x => x.Id == action.HealthCheckId)
.Where(x => _disabledCheckIds.Contains(x.Id) == false);
if (check == null) throw new InvalidOperationException(string.Format("No health check found with id {0}", id));
return check;
}
}
}