diff --git a/src/DotNetCore.CAP.MySql/MySqlMonitoringApi.cs b/src/DotNetCore.CAP.MySql/MySqlMonitoringApi.cs index 6fd0888..a8a4bdf 100644 --- a/src/DotNetCore.CAP.MySql/MySqlMonitoringApi.cs +++ b/src/DotNetCore.CAP.MySql/MySqlMonitoringApi.cs @@ -126,7 +126,7 @@ select count(Id) from `{0}.received` where StatusName = N'Failed';", _prefix); { var sqlQuery = $"select count(Id) from `{_prefix}.{tableName}` where StatusName = @state"; - var count = connection.ExecuteScalar(sqlQuery, new {state = statusName}); + var count = connection.ExecuteScalar(sqlQuery, new { state = statusName }); return count; } @@ -167,10 +167,10 @@ select aggr.* from ( group by date_format(`Added`,'%Y-%m-%d-%H') ) aggr where `Key` in @keys;"; - var valuesMap = connection.Query( + var valuesMap = connection.Query( sqlQuery, - new {keys = keyMaps.Keys, statusName}) - .ToDictionary(x => (string) x.Key, x => (int) x.Count); + new { keys = keyMaps.Keys, statusName }) + .ToDictionary(x => x.Key, x => x.Count); foreach (var key in keyMaps.Keys) { diff --git a/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs b/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs index 8fcf9f8..2c73bff 100644 --- a/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs +++ b/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs @@ -128,7 +128,7 @@ select count(""Id"") from ""{0}"".""received"" where ""StatusName"" = N'Failed' var sqlQuery = $"select count(\"Id\") from \"{_options.Schema}\".\"{tableName}\" where Lower(\"StatusName\") = Lower(@state)"; - var count = connection.ExecuteScalar(sqlQuery, new {state = statusName}); + var count = connection.ExecuteScalar(sqlQuery, new { state = statusName }); return count; } @@ -170,9 +170,9 @@ with aggr as ( ) select ""Key"",""Count"" from aggr where ""Key""= Any(@keys);"; - var valuesMap = connection.Query(sqlQuery, new {keys = keyMaps.Keys.ToList(), statusName}) + var valuesMap = connection.Query(sqlQuery, new { keys = keyMaps.Keys.ToList(), statusName }) .ToList() - .ToDictionary(x => (string) x.Key, x => (int) x.Count); + .ToDictionary(x => x.Key, x => x.Count); foreach (var key in keyMaps.Keys) { diff --git a/src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs b/src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs index 732143e..31c4bcd 100644 --- a/src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs +++ b/src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs @@ -128,7 +128,7 @@ select count(Id) from [{0}].Received with (nolock) where StatusName = N'Failed'; var sqlQuery = $"select count(Id) from [{_options.Schema}].{tableName} with (nolock) where StatusName = @state"; - var count = connection.ExecuteScalar(sqlQuery, new {state = statusName}); + var count = connection.ExecuteScalar(sqlQuery, new { state = statusName }); return count; } @@ -171,10 +171,10 @@ with aggr as ( ) select [Key], [Count] from aggr with (nolock) where [Key] in @keys;"; - var valuesMap = connection.Query( + var valuesMap = connection.Query( sqlQuery, - new {keys = keyMaps.Keys, statusName}) - .ToDictionary(x => (string) x.Key, x => (int) x.Count); + new { keys = keyMaps.Keys, statusName }) + .ToDictionary(x => x.Key, x => x.Count); foreach (var key in keyMaps.Keys) { diff --git a/src/DotNetCore.CAP/Dashboard/TimelineCounter.cs b/src/DotNetCore.CAP/Dashboard/TimelineCounter.cs new file mode 100644 index 0000000..c4c1a0b --- /dev/null +++ b/src/DotNetCore.CAP/Dashboard/TimelineCounter.cs @@ -0,0 +1,8 @@ +namespace DotNetCore.CAP.Dashboard +{ + public class TimelineCounter + { + public string Key { get; set; } + public int Count { get; set; } + } +}