forked from Kentico/KInspector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EventLogErrorSummary Kentico#217, fix OnlineMarketingTableAnalysis bug
- Loading branch information
1 parent
d372e3d
commit 518ef96
Showing
11 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/KInspector.Reports/EventLogErrorSummary/Metadata/en-US.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
details: | ||
name: Event log error summary | ||
shortDescription: Shows all errors from the Event log. | ||
longDescription: | | ||
Displays all errors, their count, and first/last occurrences from the __Event log__. | ||
terms: | ||
good: No errors found. | ||
information: <totalErrors> total <totalErrors|error|errors>. | ||
eventLogTableName: Event log errors |
17 changes: 17 additions & 0 deletions
17
src/KInspector.Reports/EventLogErrorSummary/Models/CmsErrorEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace KInspector.Reports.EventLogErrorSummary.Models | ||
{ | ||
public class CmsErrorEvent | ||
{ | ||
public int Count { get; set; } | ||
|
||
public string? EventCode { get; set; } | ||
|
||
public string? EventDescription { get; set; } | ||
|
||
public string? Source { get; set; } | ||
|
||
public DateTime? EventFirstDate { get; set; } | ||
|
||
public DateTime? EventLastDate { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/KInspector.Reports/EventLogErrorSummary/Models/Terms.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using KInspector.Core.Models; | ||
|
||
namespace KInspector.Reports.EventLogErrorSummary.Models | ||
{ | ||
public class Terms | ||
{ | ||
public Term? Good { get; set; } | ||
|
||
public Term? Information { get; set; } | ||
|
||
public Term? EventLogTableName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using KInspector.Core; | ||
using KInspector.Core.Constants; | ||
using KInspector.Core.Helpers; | ||
using KInspector.Core.Models; | ||
using KInspector.Core.Services.Interfaces; | ||
using KInspector.Reports.EventLogErrorSummary.Models; | ||
|
||
namespace KInspector.Reports.EventLogErrorSummary | ||
{ | ||
public class Report : AbstractReport<Terms> | ||
{ | ||
private readonly IDatabaseService databaseService; | ||
|
||
public Report(IDatabaseService databaseService, IModuleMetadataService moduleMetadataService) : base(moduleMetadataService) | ||
{ | ||
this.databaseService = databaseService; | ||
} | ||
|
||
public override IList<Version> CompatibleVersions => VersionHelper.GetVersionList("12", "13"); | ||
|
||
public override IList<string> Tags => new List<string> { | ||
ModuleTags.Health, | ||
ModuleTags.Information | ||
}; | ||
|
||
public async override Task<ModuleResults> GetResults() | ||
{ | ||
var errors = await databaseService.ExecuteSqlFromFile<CmsErrorEvent>(Scripts.GetEventLogErrors); | ||
if (!errors.Any()) { | ||
return new ModuleResults | ||
{ | ||
Status = ResultsStatus.Good, | ||
Summary = Metadata.Terms.Good, | ||
Type = ResultsType.NoResults | ||
}; | ||
} | ||
|
||
var totalErrors = errors.Sum(e => e.Count); | ||
var results = new ModuleResults | ||
{ | ||
Status = ResultsStatus.Warning, | ||
Summary = Metadata.Terms.Information?.With(new { totalErrors }), | ||
Type = ResultsType.TableList | ||
}; | ||
results.TableResults.Add(new TableResult | ||
{ | ||
Name = Metadata.Terms.EventLogTableName, | ||
Rows = errors | ||
}); | ||
|
||
return results; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace KInspector.Reports.EventLogErrorSummary | ||
{ | ||
public static class Scripts | ||
{ | ||
public static string BaseDirectory => $"{nameof(EventLogErrorSummary)}/Scripts"; | ||
|
||
public static string GetEventLogErrors => $"{BaseDirectory}/{nameof(GetEventLogErrors)}.sql"; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/KInspector.Reports/EventLogErrorSummary/Scripts/GetEventLogErrors.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SELECT Count(EventDescription) AS Count, | ||
EventCode, | ||
Source, | ||
EventDescription, | ||
MIN(EventTime) AS 'EventFirstDate', | ||
MAX(EventTime) AS 'EventLastDate' | ||
FROM CMS_EventLog | ||
WHERE EventType = 'E' | ||
GROUP BY Source, EventCode, EventDescription | ||
ORDER BY Count DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters