Commit 05d92d91 authored by yangxiaodong's avatar yangxiaodong

add home page recevied message real-time

parent 20a06c75
...@@ -6,6 +6,7 @@ using Dapper; ...@@ -6,6 +6,7 @@ using Dapper;
using DotNetCore.CAP.Dashboard; using DotNetCore.CAP.Dashboard;
using DotNetCore.CAP.Dashboard.Monitoring; using DotNetCore.CAP.Dashboard.Monitoring;
using DotNetCore.CAP.Infrastructure; using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States; using DotNetCore.CAP.Processor.States;
namespace DotNetCore.CAP.SqlServer namespace DotNetCore.CAP.SqlServer
...@@ -58,25 +59,18 @@ _options.Schema); ...@@ -58,25 +59,18 @@ _options.Schema);
return statistics; return statistics;
} }
public IDictionary<DateTime, int> HourlyFailedJobs() public IDictionary<DateTime, int> HourlyFailedJobs(MessageType type)
{ {
var tableName = type == MessageType.Publish ? "Published" : "Received";
return UseConnection(connection => return UseConnection(connection =>
GetHourlyTimelineStats(connection, "Published", FailedState.StateName)); GetHourlyTimelineStats(connection, tableName, FailedState.StateName));
} }
public IDictionary<DateTime, int> HourlySucceededJobs() public IDictionary<DateTime, int> HourlySucceededJobs(MessageType type)
{ {
var tableName = type == MessageType.Publish ? "Published" : "Received";
return UseConnection(connection => return UseConnection(connection =>
GetHourlyTimelineStats(connection, "Published", SucceededState.StateName)); GetHourlyTimelineStats(connection, tableName, SucceededState.StateName));
}
public IDictionary<DateTime, int> SucceededByDatesCount()
{
return new Dictionary<DateTime, int>();
}
public IDictionary<DateTime, int> FailedByDatesCount()
{
return new Dictionary<DateTime, int>();
} }
public IList<MessageDto> Messages(MessageQueryDto queryDto) public IList<MessageDto> Messages(MessageQueryDto queryDto)
...@@ -191,21 +185,6 @@ _options.Schema); ...@@ -191,21 +185,6 @@ _options.Schema);
return GetTimelineStats(connection, tableName, statusName, keyMaps); return GetTimelineStats(connection, tableName, statusName, keyMaps);
} }
//private Dictionary<DateTime, int> GetTimelineStats(IDbConnection connection, string type)
//{
// var endDate = DateTime.UtcNow.Date;
// var dates = new List<DateTime>();
// for (var i = 0; i < 7; i++)
// {
// dates.Add(endDate);
// endDate = endDate.AddDays(-1);
// }
// var keyMaps = dates.ToDictionary(x => $"stats:{type}:{x.ToString("yyyy-MM-dd")}", x => x);
// return GetTimelineStats(connection, keyMaps);
//}
private Dictionary<DateTime, int> GetTimelineStats( private Dictionary<DateTime, int> GetTimelineStats(
IDbConnection connection, IDbConnection connection,
string tableName, string tableName,
......
.rickshaw_graph .detail{pointer-events:none;position:absolute;top:0;z-index:2;background:rgba(0,0,0,.1);bottom:0;width:1px;transition:opacity .25s linear;-moz-transition:opacity .25s linear;-o-transition:opacity .25s linear;-webkit-transition:opacity .25s linear}.rickshaw_graph .detail.inactive{opacity:0}.rickshaw_graph .detail .item.active{opacity:1}.rickshaw_graph .detail .x_label{font-family:Arial,sans-serif;border-radius:3px;padding:6px;opacity:.5;border:1px solid #e0e0e0;font-size:12px;position:absolute;background:#fff;white-space:nowrap}.rickshaw_graph .detail .item{position:absolute;z-index:2;border-radius:3px;padding:.25em;font-size:12px;font-family:Arial,sans-serif;opacity:0;background:rgba(0,0,0,.4);color:#fff;border:1px solid rgba(0,0,0,.4);margin-left:1em;margin-top:-1em;white-space:nowrap}.rickshaw_graph .detail .item.active{opacity:1;background:rgba(0,0,0,.8)}.rickshaw_graph .detail .item:before{content:"\25c2";position:absolute;left:-.5em;color:rgba(0,0,0,.7);width:0}.rickshaw_graph .detail .dot{width:4px;height:4px;margin-left:-4px;margin-top:-3px;border-radius:5px;position:absolute;box-shadow:0 0 2px rgba(0,0,0,.6);background:#fff;border-width:2px;border-style:solid;display:none;background-clip:padding-box}.rickshaw_graph .detail .dot.active{display:block}.rickshaw_graph{position:relative}.rickshaw_graph svg{display:block;overflow:hidden}.rickshaw_graph .x_tick{position:absolute;top:0;bottom:0;width:0;border-left:1px dotted rgba(0,0,0,.2);pointer-events:none}.rickshaw_graph .x_tick .title{position:absolute;font-size:12px;font-family:Arial,sans-serif;opacity:.5;white-space:nowrap;margin-left:3px;bottom:1px}.rickshaw_annotation_timeline{height:1px;border-top:1px solid #e0e0e0;margin-top:10px;position:relative}.rickshaw_annotation_timeline .annotation{position:absolute;height:6px;width:6px;margin-left:-2px;top:-3px;border-radius:5px;background-color:rgba(0,0,0,.25)}.rickshaw_graph .annotation_line{position:absolute;top:0;bottom:-6px;width:0;border-left:2px solid rgba(0,0,0,.3);display:none}.rickshaw_graph .annotation_line.active{display:block}.rickshaw_graph .annotation_range{background:rgba(0,0,0,.1);display:none;position:absolute;top:0;bottom:-6px}.rickshaw_graph .annotation_range.active{display:block}.rickshaw_graph .annotation_range.active.offscreen{display:none}.rickshaw_annotation_timeline .annotation .content{background:#fff;color:#000;opacity:.9;padding:5px;box-shadow:0 0 2px rgba(0,0,0,.8);border-radius:3px;position:relative;z-index:20;font-size:12px;padding:6px 8px 8px;top:18px;left:-11px;width:160px;display:none;cursor:pointer}.rickshaw_annotation_timeline .annotation .content:before{content:"\25b2";position:absolute;top:-11px;color:#fff;text-shadow:0 -1px 1px rgba(0,0,0,.8)}.rickshaw_annotation_timeline .annotation.active,.rickshaw_annotation_timeline .annotation:hover{background-color:rgba(0,0,0,.8);cursor:none}.rickshaw_annotation_timeline .annotation .content:hover{z-index:50}.rickshaw_annotation_timeline .annotation.active .content{display:block}.rickshaw_annotation_timeline .annotation:hover .content{display:block;z-index:50}.rickshaw_graph .y_axis,.rickshaw_graph .x_axis_d3{fill:none}.rickshaw_graph .y_ticks .tick,.rickshaw_graph .x_ticks_d3 .tick{stroke:rgba(0,0,0,.16);stroke-width:2px;shape-rendering:crisp-edges;pointer-events:none}.rickshaw_graph .y_grid .tick,.rickshaw_graph .x_grid_d3 .tick{z-index:-1;stroke:rgba(0,0,0,.2);stroke-width:1px;stroke-dasharray:1 1}.rickshaw_graph .y_grid path,.rickshaw_graph .x_grid_d3 path{fill:none;stroke:none}.rickshaw_graph .y_ticks path,.rickshaw_graph .x_ticks_d3 path{fill:none;stroke:gray}.rickshaw_graph .y_ticks text,.rickshaw_graph .x_ticks_d3 text{opacity:.5;font-size:12px;pointer-events:none}.rickshaw_graph .x_tick.glow .title,.rickshaw_graph .y_ticks.glow text{fill:#000;color:#000;text-shadow:-1px 1px 0 rgba(255,255,255,.1),1px -1px 0 rgba(255,255,255,.1),1px 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.1),0 -1px 0 rgba(255,255,255,.1),1px 0 0 rgba(255,255,255,.1),-1px 0 0 rgba(255,255,255,.1),-1px -1px 0 rgba(255,255,255,.1)}.rickshaw_graph .x_tick.inverse .title,.rickshaw_graph .y_ticks.inverse text{fill:#fff;color:#fff;text-shadow:-1px 1px 0 rgba(0,0,0,.8),1px -1px 0 rgba(0,0,0,.8),1px 1px 0 rgba(0,0,0,.8),0 1px 0 rgba(0,0,0,.8),0 -1px 0 rgba(0,0,0,.8),1px 0 0 rgba(0,0,0,.8),-1px 0 0 rgba(0,0,0,.8),-1px -1px 0 rgba(0,0,0,.8)}.rickshaw_legend{font-family:Arial;font-size:12px;color:#fff;background:#404040;display:inline-block;padding:12px 5px;border-radius:2px;position:relative}.rickshaw_legend:hover{z-index:10}.rickshaw_legend .swatch{width:10px;height:10px;border:1px solid rgba(0,0,0,.2)}.rickshaw_legend .line{clear:both;line-height:140%;padding-right:15px}.rickshaw_legend .line .swatch{display:inline-block;margin-right:3px;border-radius:2px}.rickshaw_legend .label{margin:0;white-space:nowrap;display:inline;font-size:inherit;background-color:transparent;color:inherit;font-weight:400;line-height:normal;padding:0;text-shadow:none}.rickshaw_legend .action:hover{opacity:.6}.rickshaw_legend .action{margin-right:.2em;font-size:10px;opacity:.2;cursor:pointer;font-size:14px}.rickshaw_legend .line.disabled{opacity:.4}.rickshaw_legend ul{list-style-type:none;margin:0;padding:0;margin:2px;cursor:pointer}.rickshaw_legend li{padding:0 0 0 2px;min-width:80px;white-space:nowrap}.rickshaw_legend li:hover{background:rgba(255,255,255,.08);border-radius:3px}.rickshaw_legend li:active{background:rgba(255,255,255,.2);border-radius:3px} .rickshaw_graph .detail .item.left,.rickshaw_graph .detail .x_label.left{left:0}.rickshaw_graph .detail .item.right,.rickshaw_graph .detail .x_label.right{right:0}.rickshaw_graph .detail .item,.rickshaw_graph .detail .x_label,.rickshaw_graph .x_tick .title{font-family:Arial,sans-serif;font-size:12px;white-space:nowrap}.rickshaw_graph .detail{pointer-events:none;position:absolute;top:0;z-index:2;background:rgba(0,0,0,.1);bottom:0;width:1px;transition:opacity .25s linear;-moz-transition:opacity .25s linear;-o-transition:opacity .25s linear;-webkit-transition:opacity .25s linear}.rickshaw_graph .detail.inactive{opacity:0}.rickshaw_graph .detail .item.active{opacity:1}.rickshaw_graph .detail .x_label{border-radius:3px;padding:6px;opacity:.5;border:1px solid #e0e0e0;position:absolute;background:#fff}.rickshaw_graph .detail .item{position:absolute;z-index:2;border-radius:3px;padding:.25em;opacity:0;background:rgba(0,0,0,.4);color:#fff;border:1px solid rgba(0,0,0,.4);margin-left:1em;margin-right:1em;margin-top:-1em}.rickshaw_graph .detail .item.active{background:rgba(0,0,0,.8)}.rickshaw_graph .detail .item:after{position:absolute;display:block;width:0;height:0;content:"";border:5px solid transparent}.rickshaw_graph .detail .item.left:after{top:1em;left:-5px;margin-top:-5px;border-right-color:rgba(0,0,0,.8);border-left-width:0}.rickshaw_graph .detail .item.right:after{top:1em;right:-5px;margin-top:-5px;border-left-color:rgba(0,0,0,.8);border-right-width:0}.rickshaw_graph .detail .dot{width:4px;height:4px;margin-left:-3px;margin-top:-3.5px;border-radius:5px;position:absolute;box-shadow:0 0 2px rgba(0,0,0,.6);box-sizing:content-box;-moz-box-sizing:content-box;background:#fff;border-width:2px;border-style:solid;display:none;background-clip:padding-box}.rickshaw_graph .detail .dot.active{display:block}.rickshaw_graph{position:relative}.rickshaw_graph svg{display:block;overflow:hidden}.rickshaw_graph .x_tick{position:absolute;top:0;bottom:0;width:0;border-left:1px dotted rgba(0,0,0,.2);pointer-events:none}.rickshaw_graph .x_tick .title{position:absolute;opacity:.5;margin-left:3px;bottom:1px}.rickshaw_annotation_timeline{height:1px;border-top:1px solid #e0e0e0;margin-top:10px;position:relative}.rickshaw_annotation_timeline .annotation{position:absolute;height:6px;width:6px;margin-left:-2px;top:-3px;border-radius:5px;background-color:rgba(0,0,0,.25)}.rickshaw_graph .annotation_line{position:absolute;top:0;bottom:-6px;width:0;border-left:2px solid rgba(0,0,0,.3);display:none}.rickshaw_graph .annotation_line.active{display:block}.rickshaw_graph .annotation_range{background:rgba(0,0,0,.1);display:none;position:absolute;top:0;bottom:-6px}.rickshaw_graph .annotation_range.active{display:block}.rickshaw_graph .annotation_range.active.offscreen{display:none}.rickshaw_annotation_timeline .annotation .content{background:#fff;color:#000;opacity:.9;box-shadow:0 0 2px rgba(0,0,0,.8);border-radius:3px;position:relative;z-index:20;font-size:12px;padding:6px 8px 8px;top:18px;left:-11px;width:160px;display:none;cursor:pointer}.rickshaw_annotation_timeline .annotation .content:before{content:"\25b2";position:absolute;top:-11px;color:#fff;text-shadow:0 -1px 1px rgba(0,0,0,.8)}.rickshaw_annotation_timeline .annotation.active,.rickshaw_annotation_timeline .annotation:hover{background-color:rgba(0,0,0,.8);cursor:none}.rickshaw_annotation_timeline .annotation .content:hover{z-index:50}.rickshaw_annotation_timeline .annotation.active .content{display:block}.rickshaw_annotation_timeline .annotation:hover .content{display:block;z-index:50}.rickshaw_graph .x_axis_d3,.rickshaw_graph .y_axis{fill:none}.rickshaw_graph .x_ticks_d3 .tick,.rickshaw_graph .y_ticks .tick line{stroke:rgba(0,0,0,.16);stroke-width:2px;shape-rendering:crisp-edges;pointer-events:none}.rickshaw_graph .x_grid_d3 .tick,.rickshaw_graph .y_grid .tick{z-index:-1;stroke:rgba(0,0,0,.2);stroke-width:1px;stroke-dasharray:1 1}.rickshaw_graph .y_grid .tick[data-y-value="0"]{stroke-dasharray:1 0}.rickshaw_graph .x_grid_d3 path,.rickshaw_graph .y_grid path{fill:none;stroke:none}.rickshaw_graph .x_ticks_d3 path,.rickshaw_graph .y_ticks path{fill:none;stroke:grey}.rickshaw_graph .x_ticks_d3 text,.rickshaw_graph .y_ticks text{opacity:.5;font-size:12px;pointer-events:none}.rickshaw_graph .x_tick.glow .title,.rickshaw_graph .y_ticks.glow text{fill:#000;color:#000;text-shadow:-1px 1px 0 rgba(255,255,255,.1),1px -1px 0 rgba(255,255,255,.1),1px 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.1),0 -1px 0 rgba(255,255,255,.1),1px 0 0 rgba(255,255,255,.1),-1px 0 0 rgba(255,255,255,.1),-1px -1px 0 rgba(255,255,255,.1)}.rickshaw_graph .x_tick.inverse .title,.rickshaw_graph .y_ticks.inverse text{fill:#fff;color:#fff;text-shadow:-1px 1px 0 rgba(0,0,0,.8),1px -1px 0 rgba(0,0,0,.8),1px 1px 0 rgba(0,0,0,.8),0 1px 0 rgba(0,0,0,.8),0 -1px 0 rgba(0,0,0,.8),1px 0 0 rgba(0,0,0,.8),-1px 0 0 rgba(0,0,0,.8),-1px -1px 0 rgba(0,0,0,.8)}.rickshaw_legend{font-family:Arial;font-size:12px;color:#fff;background:#404040;display:inline-block;padding:12px 5px;border-radius:2px;position:relative}.rickshaw_legend:hover{z-index:10}.rickshaw_legend .swatch{width:10px;height:10px;border:1px solid rgba(0,0,0,.2)}.rickshaw_legend .line{clear:both;line-height:140%;padding-right:15px}.rickshaw_legend .line .swatch{display:inline-block;margin-right:3px;border-radius:2px}.rickshaw_legend .label{margin:0;white-space:nowrap;display:inline;font-size:inherit;background-color:transparent;color:inherit;font-weight:400;line-height:normal;padding:0;text-shadow:none}.rickshaw_legend .action:hover{opacity:.6}.rickshaw_legend .action{margin-right:.2em;opacity:.2;cursor:pointer;font-size:14px}.rickshaw_legend .line.disabled{opacity:.4}.rickshaw_legend ul{list-style-type:none;padding:0;margin:2px;cursor:pointer}.rickshaw_legend li{padding:0 0 0 2px;min-width:80px;white-space:nowrap}.rickshaw_legend li:hover{background:rgba(255,255,255,.08);border-radius:3px}.rickshaw_legend li:active{background:rgba(255,255,255,.2);border-radius:3px}
\ No newline at end of file \ No newline at end of file
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
}; };
BaseGraph.prototype._initGraph = function (element, settings, xSettings, ySettings) { BaseGraph.prototype._initGraph = function (element, settings, xSettings, ySettings) {
console.log(1);
var graph = this._graph = new Rickshaw.Graph($.extend({ var graph = this._graph = new Rickshaw.Graph($.extend({
element: element, element: element,
width: $(element).innerWidth(), width: $(element).innerWidth(),
...@@ -93,22 +94,40 @@ ...@@ -93,22 +94,40 @@
} }
cap.RealtimeGraph = (function () { cap.RealtimeGraph = (function () {
function RealtimeGraph(element, succeeded, failed, succeededStr, failedStr) { function RealtimeGraph(element,
this._succeeded = succeeded; pubSucceeded, pubFailed, pubSucceededStr, pubFailedStr,
this._failed = failed; recSucceeded, recFailed, recSucceededStr, recFailedStr
) {
this._pubSucceeded = pubSucceeded;
this._pubSucceededStr = pubSucceededStr;
this._pubFailed = pubFailed;
this._pubFailedStr = pubFailedStr;
this._recSucceeded = recSucceeded;
this._recSucceededStr = recSucceededStr;
this._recFailed = recFailed;
this._recFailedStr = recFailedStr;
this._initGraph(element, { this._initGraph(element, {
renderer: 'bar', renderer: 'bar',
series: new Rickshaw.Series.FixedDuration([ series: new Rickshaw.Series.FixedDuration([
{ {
name: failedStr, name: pubFailedStr,
//color: '#d9534f' color: '#d9534f'
color: 'red' },
{
name: pubSucceededStr,
color: '#6ACD65'
},
{
name: recFailedStr,
color: '#9c27b0'
}, },
{ {
name: succeededStr, name: recSucceededStr,
//color: '#5cb85c' color: '#cddc39'
color: '#cb513a'
} }
], ],
undefined, undefined,
...@@ -120,39 +139,63 @@ ...@@ -120,39 +139,63 @@
RealtimeGraph.prototype = Object.create(BaseGraph.prototype); RealtimeGraph.prototype = Object.create(BaseGraph.prototype);
RealtimeGraph.prototype.appendHistory = function (statistics) { RealtimeGraph.prototype.appendHistory = function (statistics) {
var newSucceeded = parseInt(statistics["published_succeeded:count"].intValue); var newPubSucceeded = parseInt(statistics["published_succeeded:count"].intValue);
var newFailed = parseInt(statistics["published_failed:count"].intValue); var newPubFailed = parseInt(statistics["published_failed:count"].intValue);
var newRecSucceeded = parseInt(statistics["received_succeeded:count"].intValue);
var newRecFailed = parseInt(statistics["received_failed:count"].intValue);
if (this._succeeded !== null && this._failed !== null) { if (this._pubSucceeded !== null && this._pubFailed !== null &&
var succeeded = newSucceeded - this._succeeded; this._recSucceeded !== null && this._recFailed !== null
var failed = newFailed - this._failed; ) {
var pubSucceeded = newPubSucceeded - this._pubSucceeded;
var pubFailed = newPubFailed - this._pubFailed;
this._graph.series.addData({ failed: failed, succeeded: succeeded }); var recSucceeded = newRecSucceeded - this._recSucceeded;
var recFailed = newRecFailed - this._recFailed;
var dataObj = {};
dataObj[this._pubFailedStr] = pubFailed;
dataObj[this._pubSucceededStr] = pubSucceeded;
dataObj[this._recFailedStr] = recFailed;
dataObj[this._recSucceededStr] = recSucceeded;
this._graph.series.addData(dataObj);
this._graph.render(); this._graph.render();
} }
this._succeeded = newSucceeded; this._pubSucceeded = newPubSucceeded;
this._failed = newFailed; this._pubFailed = newPubFailed;
this._recSucceeded = newRecSucceeded;
this._recFailed = newRecFailed;
}; };
return RealtimeGraph; return RealtimeGraph;
})(); })();
cap.HistoryGraph = (function () { cap.HistoryGraph = (function () {
function HistoryGraph(element, succeeded, failed, succeededStr, failedStr) { function HistoryGraph(element, pubSucceeded, pubFailed, pubSucceededStr, pubFailedStr,
recSucceeded, recFailed, recSucceededStr, recFailedStr) {
this._initGraph(element, { this._initGraph(element, {
renderer: 'area', renderer: 'area',
series: [ series: [
{ {
color: '#d9534f', color: '#d9534f',
//color: 'red', data: pubFailed,
data: failed, name: pubFailedStr
name: failedStr
}, { }, {
color: '#6ACD65', color: '#6ACD65',
//color: 'blue', data: pubSucceeded,
data: succeeded, name: pubSucceededStr
name: succeededStr }, {
color: '#9c27b0',
data: recFailed,
name: recFailedStr
}, {
color: '#cddc39',
data: recSucceeded,
name: recSucceededStr
} }
] ]
}, {}, { ticksTreatment: 'glow' }); }, {}, { ticksTreatment: 'glow' });
...@@ -232,12 +275,26 @@ ...@@ -232,12 +275,26 @@
Page.prototype._createRealtimeGraph = function (elementId) { Page.prototype._createRealtimeGraph = function (elementId) {
var realtimeElement = document.getElementById(elementId); var realtimeElement = document.getElementById(elementId);
if (realtimeElement) { if (realtimeElement) {
var succeeded = parseInt($(realtimeElement).data('succeeded')); var pubSucceeded = parseInt($(realtimeElement).data('published-succeeded'));
var failed = parseInt($(realtimeElement).data('failed')); var pubFailed = parseInt($(realtimeElement).data('published-failed'));
var pubSucceededStr = $(realtimeElement).data('published-succeeded-string');
var succeededStr = $(realtimeElement).data('succeeded-string'); var pubFailedStr = $(realtimeElement).data('published-failed-string');
var failedStr = $(realtimeElement).data('failed-string');
var realtimeGraph = new Cap.RealtimeGraph(realtimeElement, succeeded, failed, succeededStr, failedStr); var recSucceeded = parseInt($(realtimeElement).data('received-succeeded'));
var recFailed = parseInt($(realtimeElement).data('received-failed'));
var recSucceededStr = $(realtimeElement).data('received-succeeded-string');
var recFailedStr = $(realtimeElement).data('received-failed-string');
var realtimeGraph = new Cap.RealtimeGraph(realtimeElement,
pubSucceeded,
pubFailed,
pubSucceededStr,
pubFailedStr,
recSucceeded,
recFailed,
recSucceededStr,
recFailedStr
);
this._poller.addListener(function (data) { this._poller.addListener(function (data) {
realtimeGraph.appendHistory(data); realtimeGraph.appendHistory(data);
...@@ -268,13 +325,26 @@ ...@@ -268,13 +325,26 @@
return series; return series;
}; };
var succeeded = createSeries($(historyElement).data("succeeded")); var publishedSucceeded = createSeries($(historyElement).data("published-succeeded"));
var failed = createSeries($(historyElement).data("failed")); var publishedFailed = createSeries($(historyElement).data("published-failed"));
var publishedSucceededStr = $(historyElement).data('published-succeeded-string');
var succeededStr = $(historyElement).data('succeeded-string'); var publishedFailedStr = $(historyElement).data('published-failed-string');
var failedStr = $(historyElement).data('failed-string');
var receivedSucceeded = createSeries($(historyElement).data("received-succeeded"));
var historyGraph = new Cap.HistoryGraph(historyElement, succeeded, failed, succeededStr, failedStr); var receivedFailed = createSeries($(historyElement).data("received-failed"));
var receivedSucceededStr = $(historyElement).data('received-succeeded-string');
var receivedFailedStr = $(historyElement).data('received-failed-string');
var historyGraph = new Cap.HistoryGraph(historyElement,
publishedSucceeded,
publishedFailed,
publishedSucceededStr,
publishedFailedStr,
receivedSucceeded,
receivedFailed,
receivedSucceededStr,
receivedFailedStr,
);
$(window).resize(function () { $(window).resize(function () {
historyGraph.update(); historyGraph.update();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using DotNetCore.CAP.Dashboard.Monitoring; using DotNetCore.CAP.Dashboard.Monitoring;
using DotNetCore.CAP.Models;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
{ {
...@@ -22,12 +23,8 @@ namespace DotNetCore.CAP.Dashboard ...@@ -22,12 +23,8 @@ namespace DotNetCore.CAP.Dashboard
int ReceivedSucceededCount(); int ReceivedSucceededCount();
IDictionary<DateTime, int> SucceededByDatesCount(); IDictionary<DateTime, int> HourlySucceededJobs(MessageType type);
IDictionary<DateTime, int> FailedByDatesCount(); IDictionary<DateTime, int> HourlyFailedJobs(MessageType type);
IDictionary<DateTime, int> HourlySucceededJobs();
IDictionary<DateTime, int> HourlyFailedJobs();
} }
} }
\ No newline at end of file
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@ @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@
@using System @using System
@using System.Collections.Generic @using System.Collections.Generic
@using DotNetCore.CAP.Models;
@using DotNetCore.CAP.Dashboard @using DotNetCore.CAP.Dashboard
@using DotNetCore.CAP.Dashboard.Pages @using DotNetCore.CAP.Dashboard.Pages
@using DotNetCore.CAP.Dashboard.Resources @using DotNetCore.CAP.Dashboard.Resources
...@@ -8,22 +9,13 @@ ...@@ -8,22 +9,13 @@
@inherits RazorPage @inherits RazorPage
@{ @{
Layout = new LayoutPage(Strings.HomePage_Title); Layout = new LayoutPage(Strings.HomePage_Title);
IDictionary<DateTime, int> succeeded = null;
IDictionary<DateTime, int> failed = null;
var period = Query("period") ?? "day";
var monitor = Storage.GetMonitoringApi(); var monitor = Storage.GetMonitoringApi();
if ("week".Equals(period, StringComparison.OrdinalIgnoreCase)) IDictionary<DateTime, int> publishedSucceeded = monitor.HourlySucceededJobs(MessageType.Publish);
{ IDictionary<DateTime, int> publishedFailed = monitor.HourlyFailedJobs(MessageType.Publish);
succeeded = monitor.SucceededByDatesCount();
failed = monitor.FailedByDatesCount(); IDictionary<DateTime, int> receivedSucceeded = monitor.HourlySucceededJobs(MessageType.Subscribe);
} IDictionary<DateTime, int> receivedFailed = monitor.HourlyFailedJobs(MessageType.Subscribe);
else if ("day".Equals(period, StringComparison.OrdinalIgnoreCase))
{
succeeded = monitor.HourlySucceededJobs();
failed = monitor.HourlyFailedJobs();
}
} }
<div class="row"> <div class="row">
...@@ -41,30 +33,35 @@ ...@@ -41,30 +33,35 @@
</div> </div>
} }
<h3>@Strings.HomePage_RealtimeGraph</h3> <h3>@Strings.HomePage_RealtimeGraph</h3>
<div id="realtimeGraph" data-succeeded="@Statistics.PublishedSucceeded" data-failed="@Statistics.PublishedFailed" <div id="realtimeGraph"
data-succeeded-string="@Strings.HomePage_GraphHover_Succeeded" data-published-succeeded="@Statistics.PublishedSucceeded"
data-failed-string="@Strings.HomePage_GraphHover_Failed"></div> data-published-failed="@Statistics.PublishedFailed"
data-published-succeeded-string="@Strings.HomePage_GraphHover_Succeeded"
data-published-failed-string="@Strings.HomePage_GraphHover_Failed"
data-received-succeeded="@Statistics.ReceivedSucceeded"
data-received-failed="@Statistics.ReceivedFailed"
data-received-succeeded-string="接收成功"
data-received-failed-string="处理失败"></div>
<div style="display: none;"> <div style="display: none;">
<span data-metric="published_succeeded:count"></span> <span data-metric="published_succeeded:count"></span>
<span data-metric="published_failed:count"></span> <span data-metric="published_failed:count"></span>
<span data-metric="received_succeeded:count"></span>
<span data-metric="received_failed:count"></span>
</div> </div>
<h3> <h3>
<div class="btn-group pull-right" style="margin-top: 2px;">
<a href="?period=day" class="btn btn-sm btn-default @("day".Equals(period, StringComparison.OrdinalIgnoreCase) ? "active" : null)">@Strings.Common_PeriodDay</a>
<a href="?period=week" class="btn btn-sm btn-default @("week".Equals(period, StringComparison.OrdinalIgnoreCase) ? "active" : null)">@Strings.Common_PeriodWeek</a>
</div>
@Strings.HomePage_HistoryGraph @Strings.HomePage_HistoryGraph
</h3> </h3>
@if (succeeded != null && failed != null)
{
<div id="historyGraph" <div id="historyGraph"
data-succeeded="@JsonConvert.SerializeObject(succeeded)" data-published-succeeded="@JsonConvert.SerializeObject(publishedSucceeded)"
data-failed="@JsonConvert.SerializeObject(failed)" data-published-failed="@JsonConvert.SerializeObject(publishedFailed)"
data-succeeded-string="@Strings.HomePage_GraphHover_Succeeded" data-published-succeeded-string="@Strings.HomePage_GraphHover_Succeeded"
data-failed-string="@Strings.HomePage_GraphHover_Failed"> data-published-failed-string="@Strings.HomePage_GraphHover_Failed"
data-received-succeeded="@JsonConvert.SerializeObject(receivedSucceeded)"
data-received-failed="@JsonConvert.SerializeObject(receivedFailed)"
data-received-succeeded-string="接收成功"
data-received-failed-string="处理失败">
</div> </div>
}
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -27,24 +27,30 @@ namespace DotNetCore.CAP.Dashboard.Pages ...@@ -27,24 +27,30 @@ namespace DotNetCore.CAP.Dashboard.Pages
using System.Text; using System.Text;
#line 4 "..\..\Dashboard\Pages\HomePage.cshtml" #line 4 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard; using DotNetCore.CAP.Models;
#line default #line default
#line hidden #line hidden
#line 5 "..\..\Dashboard\Pages\HomePage.cshtml" #line 5 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard.Pages; using DotNetCore.CAP.Dashboard;
#line default #line default
#line hidden #line hidden
#line 6 "..\..\Dashboard\Pages\HomePage.cshtml" #line 6 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard.Resources; using DotNetCore.CAP.Dashboard.Pages;
#line default #line default
#line hidden #line hidden
#line 7 "..\..\Dashboard\Pages\HomePage.cshtml" #line 7 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard.Resources;
#line default
#line hidden
#line 8 "..\..\Dashboard\Pages\HomePage.cshtml"
using Newtonsoft.Json; using Newtonsoft.Json;
#line default #line default
...@@ -70,25 +76,17 @@ WriteLiteral("\r\n"); ...@@ -70,25 +76,17 @@ WriteLiteral("\r\n");
#line 9 "..\..\Dashboard\Pages\HomePage.cshtml"
Layout = new LayoutPage(Strings.HomePage_Title); #line 10 "..\..\Dashboard\Pages\HomePage.cshtml"
IDictionary<DateTime, int> succeeded = null;
IDictionary<DateTime, int> failed = null;
var period = Query("period") ?? "day"; Layout = new LayoutPage(Strings.HomePage_Title);
var monitor = Storage.GetMonitoringApi(); var monitor = Storage.GetMonitoringApi();
if ("week".Equals(period, StringComparison.OrdinalIgnoreCase)) IDictionary<DateTime, int> publishedSucceeded = monitor.HourlySucceededJobs(MessageType.Publish);
{ IDictionary<DateTime, int> publishedFailed = monitor.HourlyFailedJobs(MessageType.Publish);
succeeded = monitor.SucceededByDatesCount();
failed = monitor.FailedByDatesCount(); IDictionary<DateTime, int> receivedSucceeded = monitor.HourlySucceededJobs(MessageType.Subscribe);
} IDictionary<DateTime, int> receivedFailed = monitor.HourlyFailedJobs(MessageType.Subscribe);
else if ("day".Equals(period, StringComparison.OrdinalIgnoreCase))
{
succeeded = monitor.HourlySucceededJobs();
failed = monitor.HourlyFailedJobs();
}
...@@ -99,7 +97,7 @@ WriteLiteral("\r\n<div class=\"row\">\r\n <div class=\"col-md-12\">\r\n ...@@ -99,7 +97,7 @@ WriteLiteral("\r\n<div class=\"row\">\r\n <div class=\"col-md-12\">\r\n
#line 31 "..\..\Dashboard\Pages\HomePage.cshtml" #line 23 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_Title); Write(Strings.HomePage_Title);
...@@ -109,7 +107,7 @@ WriteLiteral("</h1>\r\n"); ...@@ -109,7 +107,7 @@ WriteLiteral("</h1>\r\n");
#line 32 "..\..\Dashboard\Pages\HomePage.cshtml" #line 24 "..\..\Dashboard\Pages\HomePage.cshtml"
if (Metrics.Count > 0) if (Metrics.Count > 0)
{ {
...@@ -120,7 +118,7 @@ WriteLiteral(" <div class=\"row\">\r\n"); ...@@ -120,7 +118,7 @@ WriteLiteral(" <div class=\"row\">\r\n");
#line 35 "..\..\Dashboard\Pages\HomePage.cshtml" #line 27 "..\..\Dashboard\Pages\HomePage.cshtml"
foreach (var metric in Metrics) foreach (var metric in Metrics)
{ {
...@@ -131,7 +129,7 @@ WriteLiteral(" <div class=\"col-md-2\">\r\n ...@@ -131,7 +129,7 @@ WriteLiteral(" <div class=\"col-md-2\">\r\n
#line 38 "..\..\Dashboard\Pages\HomePage.cshtml" #line 30 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Html.BlockMetric(metric)); Write(Html.BlockMetric(metric));
...@@ -141,7 +139,7 @@ WriteLiteral("\r\n </div>\r\n"); ...@@ -141,7 +139,7 @@ WriteLiteral("\r\n </div>\r\n");
#line 40 "..\..\Dashboard\Pages\HomePage.cshtml" #line 32 "..\..\Dashboard\Pages\HomePage.cshtml"
} }
...@@ -151,7 +149,7 @@ WriteLiteral(" </div>\r\n"); ...@@ -151,7 +149,7 @@ WriteLiteral(" </div>\r\n");
#line 42 "..\..\Dashboard\Pages\HomePage.cshtml" #line 34 "..\..\Dashboard\Pages\HomePage.cshtml"
} }
...@@ -161,172 +159,156 @@ WriteLiteral(" <h3>"); ...@@ -161,172 +159,156 @@ WriteLiteral(" <h3>");
#line 43 "..\..\Dashboard\Pages\HomePage.cshtml" #line 35 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_RealtimeGraph); Write(Strings.HomePage_RealtimeGraph);
#line default #line default
#line hidden #line hidden
WriteLiteral("</h3>\r\n <div id=\"realtimeGraph\" data-succeeded=\""); WriteLiteral("</h3>\r\n <div id=\"realtimeGraph\"\r\n data-published-succeeded=\"");
#line 44 "..\..\Dashboard\Pages\HomePage.cshtml" #line 37 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.PublishedSucceeded); Write(Statistics.PublishedSucceeded);
#line default #line default
#line hidden #line hidden
WriteLiteral("\" data-failed=\""); WriteLiteral("\"\r\n data-published-failed=\"");
#line 44 "..\..\Dashboard\Pages\HomePage.cshtml" #line 38 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.PublishedFailed); Write(Statistics.PublishedFailed);
#line default #line default
#line hidden #line hidden
WriteLiteral("\"\r\n data-succeeded-string=\""); WriteLiteral("\"\r\n data-published-succeeded-string=\"");
#line 45 "..\..\Dashboard\Pages\HomePage.cshtml" #line 39 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Succeeded); Write(Strings.HomePage_GraphHover_Succeeded);
#line default #line default
#line hidden #line hidden
WriteLiteral("\"\r\n data-failed-string=\""); WriteLiteral("\"\r\n data-published-failed-string=\"");
#line 46 "..\..\Dashboard\Pages\HomePage.cshtml" #line 40 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Failed); Write(Strings.HomePage_GraphHover_Failed);
#line default #line default
#line hidden #line hidden
WriteLiteral(@"""></div> WriteLiteral("\"\r\n data-received-succeeded=\"");
<div style=""display: none;"">
<span data-metric=""published_succeeded:count""></span>
<span data-metric=""published_failed:count""></span>
</div>
<h3>
<div class=""btn-group pull-right"" style=""margin-top: 2px;"">
<a href=""?period=day"" class=""btn btn-sm btn-default ");
#line 41 "..\..\Dashboard\Pages\HomePage.cshtml"
#line 54 "..\..\Dashboard\Pages\HomePage.cshtml" Write(Statistics.ReceivedSucceeded);
Write("day".Equals(period, StringComparison.OrdinalIgnoreCase) ? "active" : null);
#line default
#line hidden
WriteLiteral("\">");
#line 54 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.Common_PeriodDay);
#line default #line default
#line hidden #line hidden
WriteLiteral("</a>\r\n <a href=\"?period=week\" class=\"btn btn-sm btn-default "); WriteLiteral("\"\r\n data-received-failed=\"");
#line 55 "..\..\Dashboard\Pages\HomePage.cshtml" #line 42 "..\..\Dashboard\Pages\HomePage.cshtml"
Write("week".Equals(period, StringComparison.OrdinalIgnoreCase) ? "active" : null); Write(Statistics.ReceivedFailed);
#line default #line default
#line hidden #line hidden
WriteLiteral("\">"); WriteLiteral(@"""
data-received-succeeded-string=""接收成功""
data-received-failed-string=""处理失败""></div>
<div style=""display: none;"">
#line 55 "..\..\Dashboard\Pages\HomePage.cshtml" <span data-metric=""published_succeeded:count""></span>
Write(Strings.Common_PeriodWeek); <span data-metric=""published_failed:count""></span>
<span data-metric=""received_succeeded:count""></span>
<span data-metric=""received_failed:count""></span>
</div>
#line default <h3>
#line hidden ");
WriteLiteral("</a>\r\n </div>\r\n ");
#line 57 "..\..\Dashboard\Pages\HomePage.cshtml" #line 53 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_HistoryGraph); Write(Strings.HomePage_HistoryGraph);
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n </h3>\r\n\r\n"); WriteLiteral("\r\n </h3>\r\n\r\n <div id=\"historyGraph\"\r\n data-published-su" +
"cceeded=\"");
#line 60 "..\..\Dashboard\Pages\HomePage.cshtml" #line 57 "..\..\Dashboard\Pages\HomePage.cshtml"
if (succeeded != null && failed != null) Write(JsonConvert.SerializeObject(publishedSucceeded));
{
#line default #line default
#line hidden #line hidden
WriteLiteral(" <div id=\"historyGraph\"\r\n data-succeeded=\""); WriteLiteral("\"\r\n data-published-failed=\"");
#line 63 "..\..\Dashboard\Pages\HomePage.cshtml" #line 58 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(succeeded)); Write(JsonConvert.SerializeObject(publishedFailed));
#line default #line default
#line hidden #line hidden
WriteLiteral("\"\r\n data-failed=\""); WriteLiteral("\"\r\n data-published-succeeded-string=\"");
#line 64 "..\..\Dashboard\Pages\HomePage.cshtml" #line 59 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(failed)); Write(Strings.HomePage_GraphHover_Succeeded);
#line default #line default
#line hidden #line hidden
WriteLiteral("\"\r\n data-succeeded-string=\""); WriteLiteral("\"\r\n data-published-failed-string=\"");
#line 65 "..\..\Dashboard\Pages\HomePage.cshtml" #line 60 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Succeeded); Write(Strings.HomePage_GraphHover_Failed);
#line default #line default
#line hidden #line hidden
WriteLiteral("\"\r\n data-failed-string=\""); WriteLiteral("\"\r\n data-received-succeeded=\"");
#line 66 "..\..\Dashboard\Pages\HomePage.cshtml" #line 61 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Failed); Write(JsonConvert.SerializeObject(receivedSucceeded));
#line default #line default
#line hidden #line hidden
WriteLiteral("\">\r\n </div>\r\n"); WriteLiteral("\"\r\n data-received-failed=\"");
#line 68 "..\..\Dashboard\Pages\HomePage.cshtml" #line 62 "..\..\Dashboard\Pages\HomePage.cshtml"
} Write(JsonConvert.SerializeObject(receivedFailed));
#line default #line default
#line hidden #line hidden
WriteLiteral(" </div>\r\n</div>"); WriteLiteral("\"\r\n data-received-succeeded-string=\"接收成功\"\r\n data-received" +
"-failed-string=\"处理失败\"> \r\n </div>\r\n </div>\r\n</div>");
} }
......
...@@ -118,7 +118,7 @@ namespace DotNetCore.CAP.Processor ...@@ -118,7 +118,7 @@ namespace DotNetCore.CAP.Processor
returnedProcessors.Add(_provider.GetRequiredService<PublishQueuer>()); returnedProcessors.Add(_provider.GetRequiredService<PublishQueuer>());
returnedProcessors.Add(_provider.GetRequiredService<SubscribeQueuer>()); returnedProcessors.Add(_provider.GetRequiredService<SubscribeQueuer>());
returnedProcessors.Add(_provider.GetRequiredService<FailedJobProcessor>()); //returnedProcessors.Add(_provider.GetRequiredService<FailedJobProcessor>());
returnedProcessors.Add(_provider.GetRequiredService<IAdditionalProcessor>()); returnedProcessors.Add(_provider.GetRequiredService<IAdditionalProcessor>());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment