();
if (!report.Ok)
{
actions.Add(new HealthCheckAction(actionAlias, Id)
{
Name = actionName
});
}
return new HealthCheckStatus(GetReport(report, entityType, detailedReport))
{
ResultType = report.Ok ? StatusResultType.Success : StatusResultType.Error,
Actions = actions
};
}
private static string GetReport(ContentDataIntegrityReport report, string entityType, bool detailed)
{
var sb = new StringBuilder();
if (report.Ok)
{
sb.AppendLine($"All {entityType} paths are valid
");
if (!detailed)
return sb.ToString();
}
else
{
sb.AppendLine($"{report.DetectedIssues.Count} invalid {entityType} paths detected.
");
}
if (detailed && report.DetectedIssues.Count > 0)
{
sb.AppendLine("");
foreach (var issueGroup in report.DetectedIssues.GroupBy(x => x.Value.IssueType))
{
var countByGroup = issueGroup.Count();
var fixedByGroup = issueGroup.Count(x => x.Value.Fixed);
sb.AppendLine("- ");
sb.AppendLine($"{countByGroup} issues of type
{issueGroup.Key} ... {fixedByGroup} fixed");
sb.AppendLine(" ");
}
sb.AppendLine("
");
}
return sb.ToString();
}
public override HealthCheckStatus ExecuteAction(HealthCheckAction action)
{
switch (action.Alias)
{
case _fixContentPaths:
return CheckDocuments(true);
case _fixMediaPaths:
return CheckMedia(true);
default:
throw new InvalidOperationException("Action not supported");
}
}
}
}