Commit 05d92d91 authored by yangxiaodong's avatar yangxiaodong

add home page recevied message real-time

parent 20a06c75
......@@ -6,6 +6,7 @@ using Dapper;
using DotNetCore.CAP.Dashboard;
using DotNetCore.CAP.Dashboard.Monitoring;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States;
namespace DotNetCore.CAP.SqlServer
......@@ -58,25 +59,18 @@ _options.Schema);
return statistics;
}
public IDictionary<DateTime, int> HourlyFailedJobs()
public IDictionary<DateTime, int> HourlyFailedJobs(MessageType type)
{
var tableName = type == MessageType.Publish ? "Published" : "Received";
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 =>
GetHourlyTimelineStats(connection, "Published", SucceededState.StateName));
}
public IDictionary<DateTime, int> SucceededByDatesCount()
{
return new Dictionary<DateTime, int>();
}
public IDictionary<DateTime, int> FailedByDatesCount()
{
return new Dictionary<DateTime, int>();
GetHourlyTimelineStats(connection, tableName, SucceededState.StateName));
}
public IList<MessageDto> Messages(MessageQueryDto queryDto)
......@@ -191,21 +185,6 @@ _options.Schema);
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(
IDbConnection connection,
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}
\ No newline at end of file
.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
......@@ -61,6 +61,7 @@
};
BaseGraph.prototype._initGraph = function (element, settings, xSettings, ySettings) {
console.log(1);
var graph = this._graph = new Rickshaw.Graph($.extend({
element: element,
width: $(element).innerWidth(),
......@@ -93,22 +94,40 @@
}
cap.RealtimeGraph = (function () {
function RealtimeGraph(element, succeeded, failed, succeededStr, failedStr) {
this._succeeded = succeeded;
this._failed = failed;
function RealtimeGraph(element,
pubSucceeded, pubFailed, pubSucceededStr, pubFailedStr,
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, {
renderer: 'bar',
series: new Rickshaw.Series.FixedDuration([
{
name: failedStr,
//color: '#d9534f'
color: 'red'
name: pubFailedStr,
color: '#d9534f'
},
{
name: pubSucceededStr,
color: '#6ACD65'
},
{
name: recFailedStr,
color: '#9c27b0'
},
{
name: succeededStr,
//color: '#5cb85c'
color: '#cb513a'
name: recSucceededStr,
color: '#cddc39'
}
],
undefined,
......@@ -120,39 +139,63 @@
RealtimeGraph.prototype = Object.create(BaseGraph.prototype);
RealtimeGraph.prototype.appendHistory = function (statistics) {
var newSucceeded = parseInt(statistics["published_succeeded:count"].intValue);
var newFailed = parseInt(statistics["published_failed:count"].intValue);
var newPubSucceeded = parseInt(statistics["published_succeeded: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) {
var succeeded = newSucceeded - this._succeeded;
var failed = newFailed - this._failed;
if (this._pubSucceeded !== null && this._pubFailed !== null &&
this._recSucceeded !== null && this._recFailed !== null
) {
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._succeeded = newSucceeded;
this._failed = newFailed;
this._pubSucceeded = newPubSucceeded;
this._pubFailed = newPubFailed;
this._recSucceeded = newRecSucceeded;
this._recFailed = newRecFailed;
};
return RealtimeGraph;
})();
cap.HistoryGraph = (function () {
function HistoryGraph(element, succeeded, failed, succeededStr, failedStr) {
function HistoryGraph(element, pubSucceeded, pubFailed, pubSucceededStr, pubFailedStr,
recSucceeded, recFailed, recSucceededStr, recFailedStr) {
this._initGraph(element, {
renderer: 'area',
series: [
{
color: '#d9534f',
//color: 'red',
data: failed,
name: failedStr
data: pubFailed,
name: pubFailedStr
}, {
color: '#6ACD65',
//color: 'blue',
data: succeeded,
name: succeededStr
data: pubSucceeded,
name: pubSucceededStr
}, {
color: '#9c27b0',
data: recFailed,
name: recFailedStr
}, {
color: '#cddc39',
data: recSucceeded,
name: recSucceededStr
}
]
}, {}, { ticksTreatment: 'glow' });
......@@ -232,12 +275,26 @@
Page.prototype._createRealtimeGraph = function (elementId) {
var realtimeElement = document.getElementById(elementId);
if (realtimeElement) {
var succeeded = parseInt($(realtimeElement).data('succeeded'));
var failed = parseInt($(realtimeElement).data('failed'));
var succeededStr = $(realtimeElement).data('succeeded-string');
var failedStr = $(realtimeElement).data('failed-string');
var realtimeGraph = new Cap.RealtimeGraph(realtimeElement, succeeded, failed, succeededStr, failedStr);
var pubSucceeded = parseInt($(realtimeElement).data('published-succeeded'));
var pubFailed = parseInt($(realtimeElement).data('published-failed'));
var pubSucceededStr = $(realtimeElement).data('published-succeeded-string');
var pubFailedStr = $(realtimeElement).data('published-failed-string');
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) {
realtimeGraph.appendHistory(data);
......@@ -268,13 +325,26 @@
return series;
};
var succeeded = createSeries($(historyElement).data("succeeded"));
var failed = createSeries($(historyElement).data("failed"));
var succeededStr = $(historyElement).data('succeeded-string');
var failedStr = $(historyElement).data('failed-string');
var historyGraph = new Cap.HistoryGraph(historyElement, succeeded, failed, succeededStr, failedStr);
var publishedSucceeded = createSeries($(historyElement).data("published-succeeded"));
var publishedFailed = createSeries($(historyElement).data("published-failed"));
var publishedSucceededStr = $(historyElement).data('published-succeeded-string');
var publishedFailedStr = $(historyElement).data('published-failed-string');
var receivedSucceeded = createSeries($(historyElement).data("received-succeeded"));
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 () {
historyGraph.update();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
using System;
using System.Collections.Generic;
using DotNetCore.CAP.Dashboard.Monitoring;
using DotNetCore.CAP.Models;
namespace DotNetCore.CAP.Dashboard
{
......@@ -22,12 +23,8 @@ namespace DotNetCore.CAP.Dashboard
int ReceivedSucceededCount();
IDictionary<DateTime, int> SucceededByDatesCount();
IDictionary<DateTime, int> HourlySucceededJobs(MessageType type);
IDictionary<DateTime, int> FailedByDatesCount();
IDictionary<DateTime, int> HourlySucceededJobs();
IDictionary<DateTime, int> HourlyFailedJobs();
IDictionary<DateTime, int> HourlyFailedJobs(MessageType type);
}
}
\ No newline at end of file
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@
@using System
@using System.Collections.Generic
@using DotNetCore.CAP.Models;
@using DotNetCore.CAP.Dashboard
@using DotNetCore.CAP.Dashboard.Pages
@using DotNetCore.CAP.Dashboard.Resources
......@@ -8,22 +9,13 @@
@inherits RazorPage
@{
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();
if ("week".Equals(period, StringComparison.OrdinalIgnoreCase))
{
succeeded = monitor.SucceededByDatesCount();
failed = monitor.FailedByDatesCount();
}
else if ("day".Equals(period, StringComparison.OrdinalIgnoreCase))
{
succeeded = monitor.HourlySucceededJobs();
failed = monitor.HourlyFailedJobs();
}
IDictionary<DateTime, int> publishedSucceeded = monitor.HourlySucceededJobs(MessageType.Publish);
IDictionary<DateTime, int> publishedFailed = monitor.HourlyFailedJobs(MessageType.Publish);
IDictionary<DateTime, int> receivedSucceeded = monitor.HourlySucceededJobs(MessageType.Subscribe);
IDictionary<DateTime, int> receivedFailed = monitor.HourlyFailedJobs(MessageType.Subscribe);
}
<div class="row">
......@@ -41,30 +33,35 @@
</div>
}
<h3>@Strings.HomePage_RealtimeGraph</h3>
<div id="realtimeGraph" data-succeeded="@Statistics.PublishedSucceeded" data-failed="@Statistics.PublishedFailed"
data-succeeded-string="@Strings.HomePage_GraphHover_Succeeded"
data-failed-string="@Strings.HomePage_GraphHover_Failed"></div>
<div id="realtimeGraph"
data-published-succeeded="@Statistics.PublishedSucceeded"
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;">
<span data-metric="published_succeeded:count"></span>
<span data-metric="published_failed:count"></span>
<span data-metric="received_succeeded:count"></span>
<span data-metric="received_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 @("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
</h3>
@if (succeeded != null && failed != null)
{
<div id="historyGraph"
data-succeeded="@JsonConvert.SerializeObject(succeeded)"
data-failed="@JsonConvert.SerializeObject(failed)"
data-succeeded-string="@Strings.HomePage_GraphHover_Succeeded"
data-failed-string="@Strings.HomePage_GraphHover_Failed">
</div>
}
<div id="historyGraph"
data-published-succeeded="@JsonConvert.SerializeObject(publishedSucceeded)"
data-published-failed="@JsonConvert.SerializeObject(publishedFailed)"
data-published-succeeded-string="@Strings.HomePage_GraphHover_Succeeded"
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>
\ No newline at end of file
......@@ -27,24 +27,30 @@ namespace DotNetCore.CAP.Dashboard.Pages
using System.Text;
#line 4 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard;
using DotNetCore.CAP.Models;
#line default
#line hidden
#line 5 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard.Pages;
using DotNetCore.CAP.Dashboard;
#line default
#line hidden
#line 6 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard.Resources;
using DotNetCore.CAP.Dashboard.Pages;
#line default
#line hidden
#line 7 "..\..\Dashboard\Pages\HomePage.cshtml"
using DotNetCore.CAP.Dashboard.Resources;
#line default
#line hidden
#line 8 "..\..\Dashboard\Pages\HomePage.cshtml"
using Newtonsoft.Json;
#line default
......@@ -69,26 +75,18 @@ WriteLiteral("\r\n");
#line 9 "..\..\Dashboard\Pages\HomePage.cshtml"
#line 10 "..\..\Dashboard\Pages\HomePage.cshtml"
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();
if ("week".Equals(period, StringComparison.OrdinalIgnoreCase))
{
succeeded = monitor.SucceededByDatesCount();
failed = monitor.FailedByDatesCount();
}
else if ("day".Equals(period, StringComparison.OrdinalIgnoreCase))
{
succeeded = monitor.HourlySucceededJobs();
failed = monitor.HourlyFailedJobs();
}
IDictionary<DateTime, int> publishedSucceeded = monitor.HourlySucceededJobs(MessageType.Publish);
IDictionary<DateTime, int> publishedFailed = monitor.HourlyFailedJobs(MessageType.Publish);
IDictionary<DateTime, int> receivedSucceeded = monitor.HourlySucceededJobs(MessageType.Subscribe);
IDictionary<DateTime, int> receivedFailed = monitor.HourlyFailedJobs(MessageType.Subscribe);
......@@ -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);
......@@ -109,7 +107,7 @@ WriteLiteral("</h1>\r\n");
#line 32 "..\..\Dashboard\Pages\HomePage.cshtml"
#line 24 "..\..\Dashboard\Pages\HomePage.cshtml"
if (Metrics.Count > 0)
{
......@@ -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)
{
......@@ -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));
......@@ -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");
#line 42 "..\..\Dashboard\Pages\HomePage.cshtml"
#line 34 "..\..\Dashboard\Pages\HomePage.cshtml"
}
......@@ -161,172 +159,156 @@ WriteLiteral(" <h3>");
#line 43 "..\..\Dashboard\Pages\HomePage.cshtml"
#line 35 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_RealtimeGraph);
#line default
#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"
Write(Statistics.PublishedSucceeded);
#line 37 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.PublishedSucceeded);
#line default
#line hidden
WriteLiteral("\" data-failed=\"");
WriteLiteral("\"\r\n data-published-failed=\"");
#line 44 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.PublishedFailed);
#line default
#line hidden
WriteLiteral("\"\r\n data-succeeded-string=\"");
#line 45 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Succeeded);
#line 38 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.PublishedFailed);
#line default
#line hidden
WriteLiteral("\"\r\n data-failed-string=\"");
WriteLiteral("\"\r\n data-published-succeeded-string=\"");
#line 46 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Failed);
#line 39 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Succeeded);
#line default
#line hidden
WriteLiteral(@"""></div>
<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 ");
WriteLiteral("\"\r\n data-published-failed-string=\"");
#line 54 "..\..\Dashboard\Pages\HomePage.cshtml"
Write("day".Equals(period, StringComparison.OrdinalIgnoreCase) ? "active" : null);
#line 40 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Failed);
#line default
#line hidden
WriteLiteral("\">");
WriteLiteral("\"\r\n data-received-succeeded=\"");
#line 54 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.Common_PeriodDay);
#line 41 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.ReceivedSucceeded);
#line default
#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"
Write("week".Equals(period, StringComparison.OrdinalIgnoreCase) ? "active" : null);
#line 42 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Statistics.ReceivedFailed);
#line default
#line hidden
WriteLiteral("\">");
#line 55 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.Common_PeriodWeek);
WriteLiteral(@"""
data-received-succeeded-string=""接收成功""
data-received-failed-string=""处理失败""></div>
<div style=""display: none;"">
<span data-metric=""published_succeeded:count""></span>
<span data-metric=""published_failed:count""></span>
<span data-metric=""received_succeeded:count""></span>
<span data-metric=""received_failed:count""></span>
</div>
#line default
#line hidden
WriteLiteral("</a>\r\n </div>\r\n ");
<h3>
");
#line 57 "..\..\Dashboard\Pages\HomePage.cshtml"
#line 53 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_HistoryGraph);
#line default
#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"
if (succeeded != null && failed != null)
{
#line 57 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(publishedSucceeded));
#line default
#line hidden
WriteLiteral(" <div id=\"historyGraph\"\r\n data-succeeded=\"");
WriteLiteral("\"\r\n data-published-failed=\"");
#line 63 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(succeeded));
#line 58 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(publishedFailed));
#line default
#line hidden
WriteLiteral("\"\r\n data-failed=\"");
WriteLiteral("\"\r\n data-published-succeeded-string=\"");
#line 64 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(failed));
#line 59 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Succeeded);
#line default
#line hidden
WriteLiteral("\"\r\n data-succeeded-string=\"");
WriteLiteral("\"\r\n data-published-failed-string=\"");
#line 65 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Succeeded);
#line 60 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Failed);
#line default
#line hidden
WriteLiteral("\"\r\n data-failed-string=\"");
WriteLiteral("\"\r\n data-received-succeeded=\"");
#line 66 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(Strings.HomePage_GraphHover_Failed);
#line 61 "..\..\Dashboard\Pages\HomePage.cshtml"
Write(JsonConvert.SerializeObject(receivedSucceeded));
#line default
#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 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
returnedProcessors.Add(_provider.GetRequiredService<PublishQueuer>());
returnedProcessors.Add(_provider.GetRequiredService<SubscribeQueuer>());
returnedProcessors.Add(_provider.GetRequiredService<FailedJobProcessor>());
//returnedProcessors.Add(_provider.GetRequiredService<FailedJobProcessor>());
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