@@ -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 sqlQuery = $"select count(Id) from `{_prefix}.{tableName}` where StatusName = @state"; | ||||
var count = connection.ExecuteScalar<int>(sqlQuery, new {state = statusName}); | |||||
var count = connection.ExecuteScalar<int>(sqlQuery, new { state = statusName }); | |||||
return count; | return count; | ||||
} | } | ||||
@@ -167,10 +167,10 @@ select aggr.* from ( | |||||
group by date_format(`Added`,'%Y-%m-%d-%H') | group by date_format(`Added`,'%Y-%m-%d-%H') | ||||
) aggr where `Key` in @keys;"; | ) aggr where `Key` in @keys;"; | ||||
var valuesMap = connection.Query( | |||||
var valuesMap = connection.Query<TimelineCounter>( | |||||
sqlQuery, | 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) | foreach (var key in keyMaps.Keys) | ||||
{ | { | ||||
@@ -128,7 +128,7 @@ select count(""Id"") from ""{0}"".""received"" where ""StatusName"" = N'Failed' | |||||
var sqlQuery = | var sqlQuery = | ||||
$"select count(\"Id\") from \"{_options.Schema}\".\"{tableName}\" where Lower(\"StatusName\") = Lower(@state)"; | $"select count(\"Id\") from \"{_options.Schema}\".\"{tableName}\" where Lower(\"StatusName\") = Lower(@state)"; | ||||
var count = connection.ExecuteScalar<int>(sqlQuery, new {state = statusName}); | |||||
var count = connection.ExecuteScalar<int>(sqlQuery, new { state = statusName }); | |||||
return count; | return count; | ||||
} | } | ||||
@@ -170,9 +170,9 @@ with aggr as ( | |||||
) | ) | ||||
select ""Key"",""Count"" from aggr where ""Key""= Any(@keys);"; | select ""Key"",""Count"" from aggr where ""Key""= Any(@keys);"; | ||||
var valuesMap = connection.Query(sqlQuery, new {keys = keyMaps.Keys.ToList(), statusName}) | |||||
var valuesMap = connection.Query<TimelineCounter>(sqlQuery, new { keys = keyMaps.Keys.ToList(), statusName }) | |||||
.ToList() | .ToList() | ||||
.ToDictionary(x => (string) x.Key, x => (int) x.Count); | |||||
.ToDictionary(x => x.Key, x => x.Count); | |||||
foreach (var key in keyMaps.Keys) | foreach (var key in keyMaps.Keys) | ||||
{ | { | ||||
@@ -128,7 +128,7 @@ select count(Id) from [{0}].Received with (nolock) where StatusName = N'Failed'; | |||||
var sqlQuery = | var sqlQuery = | ||||
$"select count(Id) from [{_options.Schema}].{tableName} with (nolock) where StatusName = @state"; | $"select count(Id) from [{_options.Schema}].{tableName} with (nolock) where StatusName = @state"; | ||||
var count = connection.ExecuteScalar<int>(sqlQuery, new {state = statusName}); | |||||
var count = connection.ExecuteScalar<int>(sqlQuery, new { state = statusName }); | |||||
return count; | return count; | ||||
} | } | ||||
@@ -171,10 +171,10 @@ with aggr as ( | |||||
) | ) | ||||
select [Key], [Count] from aggr with (nolock) where [Key] in @keys;"; | select [Key], [Count] from aggr with (nolock) where [Key] in @keys;"; | ||||
var valuesMap = connection.Query( | |||||
var valuesMap = connection.Query<TimelineCounter>( | |||||
sqlQuery, | 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) | foreach (var key in keyMaps.Keys) | ||||
{ | { | ||||
@@ -0,0 +1,8 @@ | |||||
namespace DotNetCore.CAP.Dashboard | |||||
{ | |||||
public class TimelineCounter | |||||
{ | |||||
public string Key { get; set; } | |||||
public int Count { get; set; } | |||||
} | |||||
} |