Преглед на файлове

add SubscriberPage

master
yangxiaodong преди 7 години
родител
ревизия
a82790c1f5
променени са 10 файла, в които са добавени 325 реда и са изтрити 15 реда
  1. +5
    -0
      src/DotNetCore.CAP/Dashboard/DashboardContext.cs
  2. +1
    -2
      src/DotNetCore.CAP/Dashboard/DashboardRequest.cs
  3. +1
    -1
      src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs
  4. +67
    -0
      src/DotNetCore.CAP/Dashboard/HtmlHelper.cs
  5. +1
    -1
      src/DotNetCore.CAP/Dashboard/IDashboardDispatcher.cs
  6. +0
    -2
      src/DotNetCore.CAP/Dashboard/IMonitoringApi.cs
  7. +22
    -9
      src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.cshtml
  8. +221
    -0
      src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs
  9. +4
    -0
      src/DotNetCore.CAP/Dashboard/RazorPage.cs
  10. +3
    -0
      src/DotNetCore.CAP/DotNetCore.CAP.csproj

+ 5
- 0
src/DotNetCore.CAP/Dashboard/DashboardContext.cs Целия файл

@@ -18,12 +18,16 @@ namespace DotNetCore.CAP.Dashboard
}

public IStorage Storage { get; }

public DashboardOptions Options { get; }

public Match UriMatch { get; set; }

public DashboardRequest Request { get; protected set; }

public DashboardResponse Response { get; protected set; }

public IServiceProvider RequestServices { get; protected set; }
}

public sealed class CapDashboardContext : DashboardContext
@@ -39,6 +43,7 @@ namespace DotNetCore.CAP.Dashboard
HttpContext = httpContext;
Request = new CapDashboardRequest(httpContext);
Response = new CapDashboardResponse(httpContext);
RequestServices = httpContext.RequestServices;
}

public HttpContext HttpContext { get; }


+ 1
- 2
src/DotNetCore.CAP/Dashboard/DashboardRequest.cs Целия файл

@@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Dashboard
public CapDashboardRequest(HttpContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context));
_context = context;
_context = context;
}

public override string Method => _context.Request.Method;
@@ -34,7 +34,6 @@ namespace DotNetCore.CAP.Dashboard
public override string LocalIpAddress => _context.Connection.LocalIpAddress.ToString();
public override string RemoteIpAddress => _context.Connection.RemoteIpAddress.ToString();
public override string GetQuery(string key) => _context.Request.Query[key];

public override async Task<IList<string>> GetFormValuesAsync(string key)
{
var form = await _context.Request.ReadFormAsync();


+ 1
- 1
src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs Целия файл

@@ -133,7 +133,7 @@ namespace DotNetCore.CAP.Dashboard
Routes.AddRazorPage(
"/received/(?<StatusName>.+)",
x => new ReceivedPage(x.Groups["StatusName"].Value));
Routes.AddRazorPage("/subscribers", x => new SubscriberPage());
//Routes.AddRazorPage("/jobs/failed", x => new FailedJobsPage());

//Routes.AddClientBatchCommand(


+ 67
- 0
src/DotNetCore.CAP/Dashboard/HtmlHelper.cs Целия файл

@@ -218,6 +218,73 @@ namespace DotNetCore.CAP.Dashboard
$"<span class=\"labe label-defult text-uppercase\" title=\"{serverId}\">{shortenedId}</span>");
}

public NonEscapedString MethodEscaped(MethodInfo method)
{
var outputString = string.Empty;

var @public = "<span style=\"color:blue\">public </span>";

var key = Hignlight(method.ReturnType);

var name = method.Name;

string paramType = null;
string paramName = null;
string paramString = string.Empty;

var @params = method.GetParameters();
if (@params.Length == 1)
{
var firstParam = @params[0];
var firstParamType = firstParam.ParameterType;
paramType = Hignlight(firstParamType);
paramName = firstParam.Name;
}

if (paramType == null)
{
paramString = "(){ }";
}
else
{
paramString = $"({paramType} {paramName}){{ }}";
}


outputString = @public + key + name + paramString;
return new NonEscapedString(outputString);
}

public string Hignlight(Type type)
{
if(type.Name == "Void")
{
return HighligthKey(type.Name.ToLower());
}
if (Helper.IsComplexType(type))
{
return HighligthClass(type.Name);
}
if (type.IsPrimitive || type.Equals(typeof(string)) || type.Equals(typeof(decimal)))
{
return HighligthKey(type.Name.ToLower());
}
else
{
return HighligthClass(type.Name);
}
}

private string HighligthClass(string key)
{
return $"<span style=\"color:#07c1be\">{key} </span>";
}

private string HighligthKey(string key)
{
return $"<span style=\"color:blue\">{key} </span>";
}

//private static readonly StackTraceHtmlFragments StackTraceHtmlFragments = new StackTraceHtmlFragments
//{
// BeforeFrame = "<span class='st-frame'>" , AfterFrame = "</span>",


+ 1
- 1
src/DotNetCore.CAP/Dashboard/IDashboardDispatcher.cs Целия файл

@@ -7,6 +7,6 @@ namespace DotNetCore.CAP.Dashboard
{
public interface IDashboardDispatcher
{
Task Dispatch( DashboardContext context);
Task Dispatch(DashboardContext context);
}
}

+ 0
- 2
src/DotNetCore.CAP/Dashboard/IMonitoringApi.cs Целия файл

@@ -6,8 +6,6 @@ namespace DotNetCore.CAP.Dashboard
{
public interface IMonitoringApi
{
IList<SubscriberDto> Subscribers();

StatisticsDto GetStatistics();
IList<MessageDto> Messages(MessageQueryDto queryDto);


+ 22
- 9
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.cshtml Целия файл

@@ -1,15 +1,14 @@
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@
@using System
@using System.Linq
@using DotNetCore.CAP.Internal
@using DotNetCore.CAP.Dashboard
@using DotNetCore.CAP.Dashboard.Pages
@using DotNetCore.CAP.Dashboard.Resources
@inherits RazorPage
@{
Layout = new LayoutPage(Strings.ServersPage_Title);
Layout = new LayoutPage(Strings.SubscribersPage_Title);

var monitor = Storage.GetMonitoringApi();
var subscribers = monitor.Subscribers();
var cache = RequestServices.GetService(typeof(MethodMatcherCache)) as MethodMatcherCache;
var subscribers = cache.GetCandidatesMethodsOfGroupNameGrouped();
}

<div class="row">
@@ -28,16 +27,30 @@
<table class="table">
<thead>
<tr>
<th>名称</th>
<th>方法</th>
<th width="20%">分组</th>
<th>
<table class="table subscribe-table margin-bottom-zero"><tr><td width="40%">名称</td><td>方法</td></tr></table>
</th>
</tr>
</thead>
<tbody>
@foreach (var subscriber in subscribers)
{
<tr>
<td>@subscriber.Name</td>
<td>@subscriber.Method</td>
<td style="vertical-align:middle;font-weight:bold;">@subscriber.Key</td>
<td>
<table class="table subscribe-table table-condensed margin-bottom-zero">
@foreach (var column in subscriber.Value)
{
<tr>
<td width="40%">@column.Attribute.Name</td>
<td><span style="color:#00bcd4">@column.ImplTypeInfo.Name</span>:
@Html.MethodEscaped(column.MethodInfo)
</td>
</tr>
}
</table>
</td>
</tr>
}
</tbody>


+ 221
- 0
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs Целия файл

@@ -0,0 +1,221 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace DotNetCore.CAP.Dashboard.Pages
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#line 3 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
using DotNetCore.CAP.Dashboard;
#line default
#line hidden
#line 4 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
using DotNetCore.CAP.Dashboard.Pages;
#line default
#line hidden
#line 5 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
using DotNetCore.CAP.Dashboard.Resources;
#line default
#line hidden
#line 2 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
using DotNetCore.CAP.Internal;
#line default
#line hidden
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
internal partial class SubscriberPage : RazorPage
{
#line hidden

public override void Execute()
{


WriteLiteral("\r\n");







#line 7 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Layout = new LayoutPage(Strings.SubscribersPage_Title);

var cache = RequestServices.GetService(typeof(MethodMatcherCache)) as MethodMatcherCache;
var subscribers = cache.GetCandidatesMethodsOfGroupNameGrouped();


#line default
#line hidden
WriteLiteral("\r\n<div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <h1 class=\"page-header\"" +
">订阅列表</h1>\r\n\r\n");


#line 18 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
if (subscribers.Count == 0)
{

#line default
#line hidden
WriteLiteral(" <div class=\"alert alert-warning\">\r\n ");


#line 21 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(Strings.ServersPage_NoServers);

#line default
#line hidden
WriteLiteral("\r\n </div>\r\n");


#line 23 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
}
else
{

#line default
#line hidden
WriteLiteral(@" <div class=""table-responsive"">
<table class=""table"">
<thead>
<tr>
<th width=""20%"">分组</th>
<th>
<table class=""table subscribe-table margin-bottom-zero""><tr><td width=""40%"">名称</td><td>方法</td></tr></table>
</th>
</tr>
</thead>
<tbody>
");


#line 37 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
foreach (var subscriber in subscribers)
{

#line default
#line hidden
WriteLiteral(" <tr>\r\n <td style=\"vert" +
"ical-align:middle;font-weight:bold;\">");


#line 40 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(subscriber.Key);

#line default
#line hidden
WriteLiteral("</td>\r\n <td>\r\n " +
"<table class=\"table subscribe-table table-condensed margin-bottom-zero\">\r\n");


#line 43 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
foreach (var column in subscriber.Value)
{

#line default
#line hidden
WriteLiteral(" <tr>\r\n " +
" <td width=\"40%\">");


#line 46 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(column.Attribute.Name);

#line default
#line hidden
WriteLiteral("</td>\r\n <td><span style=\"color:#00" +
"bcd4\">");


#line 47 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(column.ImplTypeInfo.Name);

#line default
#line hidden
WriteLiteral("</span>: \r\n ");


#line 48 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(Html.MethodEscaped(column.MethodInfo));

#line default
#line hidden
WriteLiteral("\r\n </td>\r\n " +
" </tr>\r\n");


#line 51 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
}

#line default
#line hidden
WriteLiteral(" </table>\r\n </t" +
"d>\r\n </tr>\r\n");


#line 55 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
}

#line default
#line hidden
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n");


#line 59 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
}

#line default
#line hidden
WriteLiteral(" </div>\r\n</div>");


}
}
}
#pragma warning restore 1591

+ 4
- 0
src/DotNetCore.CAP/Dashboard/RazorPage.cs Целия файл

@@ -41,6 +41,8 @@ namespace DotNetCore.CAP.Dashboard
internal DashboardRequest Request { private get; set; }
internal DashboardResponse Response { private get; set; }

internal IServiceProvider RequestServices { get; private set; }

public string RequestPath => Request.Path;

/// <exclude />
@@ -65,6 +67,7 @@ namespace DotNetCore.CAP.Dashboard
AppPath = parentPage.AppPath;
StatsPollingInterval = parentPage.StatsPollingInterval;
Url = parentPage.Url;
RequestServices = parentPage.RequestServices;

GenerationTime = parentPage.GenerationTime;
_statisticsLazy = parentPage._statisticsLazy;
@@ -74,6 +77,7 @@ namespace DotNetCore.CAP.Dashboard
{
Request = context.Request;
Response = context.Response;
RequestServices = context.RequestServices;

Storage = context.Storage;
AppPath = context.Options.AppPath;


+ 3
- 0
src/DotNetCore.CAP/DotNetCore.CAP.csproj Целия файл

@@ -123,6 +123,9 @@
<Compile Update="Dashboard\Pages\HomePage.cs">
<DependentUpon>HomePage.cshtml</DependentUpon>
</Compile>
<Compile Update="Dashboard\Pages\SubscriberPage.generated.cs">
<DependentUpon>SubscriberPage.cshtml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Dashboard\Content\resx\Strings.resx">


Зареждане…
Отказ
Запис