From c4f4f5f484942f89853ec3934d6e1461b83f2a6f Mon Sep 17 00:00:00 2001 From: Savorboard Date: Tue, 5 Nov 2019 18:26:28 +0800 Subject: [PATCH] upgrade dashoboard module --- .../Controllers/ValuesController.cs | 7 + .../Sample.RabbitMQ.MySql.csproj | 1 + samples/Sample.RabbitMQ.MySql/Startup.cs | 2 +- src/DotNetCore.CAP.Dashboard/AwaitableInfo.cs | 128 +++ .../CAP.DashboardMiddleware.cs | 74 +- .../CAP.DashboardOptionsExtensions.cs | 3 + src/DotNetCore.CAP.Dashboard/CapCache.cs | 378 ++++++++ .../CoercedAwaitableInfo.cs | 44 + .../CombinedResourceDispatcher.cs | 11 +- .../DashboardContext.cs | 7 +- .../DashboardRoutes.cs | 10 +- .../DotNetCore.CAP.Dashboard.csproj | 168 +++- .../EmbeddedResourceDispatcher.cs | 15 +- .../GatewayProxy/GatewayProxyMiddleware.cs | 2 +- src/DotNetCore.CAP.Dashboard/HtmlHelper.cs | 2 +- .../JsonDispatcher.cs | 2 +- src/DotNetCore.CAP.Dashboard/JsonStats.cs | 4 +- .../LocalRequestsOnlyAuthorizationFilter.cs | 2 +- .../MessageHistoryRenderer.cs | 18 +- .../Pages/BlockMetric.cs | 4 +- .../Pages/HomePage.generated.cs | 438 +++++---- .../Pages/LayoutPage.generated.cs | 419 +++++---- .../Pages/NodePage.cs | 2 +- .../Pages/NodePage.generated.cs | 325 ++++--- .../Pages/PublishedPage.cs | 9 +- .../Pages/PublishedPage.cshtml | 8 +- .../Pages/PublishedPage.generated.cs | 870 +++++++++--------- .../Pages/ReceivedPage.cs | 3 +- .../Pages/ReceivedPage.cshtml | 2 +- .../Pages/ReceivedPage.generated.cs | 852 ++++++++--------- .../Pages/SubscriberPage.generated.cs | 131 ++- .../Pages/_BlockMetric.cshtml | 11 +- .../Pages/_BlockMetric.generated.cs | 32 +- .../Pages/_Breadcrumbs.generated.cs | 32 +- .../Pages/_InlineMetric.generated.cs | 14 +- .../Pages/_Navigation.generated.cs | 31 +- .../Pages/_Paginator.generated.cs | 50 +- .../Pages/_PerPageSelector.generated.cs | 46 +- .../Pages/_SidebarMenu.generated.cs | 32 +- src/DotNetCore.CAP.Dashboard/RazorPage.cs | 12 +- src/DotNetCore.CAP.MySql/MySqlDataStorage.cs | 29 +- src/DotNetCore.CAP/Internal/Helper.cs | 8 + .../Internal/MethodMatcherCache.cs | 2 +- .../Persistence/IDataStorage.cs | 12 +- .../Persistence/MediumMessage.cs | 2 + 45 files changed, 2481 insertions(+), 1773 deletions(-) create mode 100644 src/DotNetCore.CAP.Dashboard/AwaitableInfo.cs create mode 100644 src/DotNetCore.CAP.Dashboard/CapCache.cs create mode 100644 src/DotNetCore.CAP.Dashboard/CoercedAwaitableInfo.cs diff --git a/samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs b/samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs index 8e9ae75..ae934e7 100644 --- a/samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs +++ b/samples/Sample.RabbitMQ.MySql/Controllers/ValuesController.cs @@ -75,5 +75,12 @@ namespace Sample.RabbitMQ.MySql.Controllers { Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); } + + [NonAction] + [CapSubscribe("sample.rabbitmq.mysql", Group = "group.test2")] + public void Subscriber2(DateTime p, [FromCap]CapHeader header) + { + Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); + } } } diff --git a/samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj b/samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj index ce72296..5e1dcee 100644 --- a/samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj +++ b/samples/Sample.RabbitMQ.MySql/Sample.RabbitMQ.MySql.csproj @@ -8,6 +8,7 @@ + diff --git a/samples/Sample.RabbitMQ.MySql/Startup.cs b/samples/Sample.RabbitMQ.MySql/Startup.cs index f29e53f..3b76a4b 100644 --- a/samples/Sample.RabbitMQ.MySql/Startup.cs +++ b/samples/Sample.RabbitMQ.MySql/Startup.cs @@ -15,7 +15,7 @@ namespace Sample.RabbitMQ.MySql { x.UseEntityFramework(); x.UseRabbitMQ("192.168.2.120"); - //x.UseDashboard(); + x.UseDashboard(); x.FailedRetryCount = 5; x.FailedThresholdCallback = (type, msg) => { diff --git a/src/DotNetCore.CAP.Dashboard/AwaitableInfo.cs b/src/DotNetCore.CAP.Dashboard/AwaitableInfo.cs new file mode 100644 index 0000000..5c494e9 --- /dev/null +++ b/src/DotNetCore.CAP.Dashboard/AwaitableInfo.cs @@ -0,0 +1,128 @@ +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace Microsoft.Extensions.Internal +{ + internal struct AwaitableInfo + { + public Type AwaiterType { get; } + public PropertyInfo AwaiterIsCompletedProperty { get; } + public MethodInfo AwaiterGetResultMethod { get; } + public MethodInfo AwaiterOnCompletedMethod { get; } + public MethodInfo AwaiterUnsafeOnCompletedMethod { get; } + public Type ResultType { get; } + public MethodInfo GetAwaiterMethod { get; } + + public AwaitableInfo( + Type awaiterType, + PropertyInfo awaiterIsCompletedProperty, + MethodInfo awaiterGetResultMethod, + MethodInfo awaiterOnCompletedMethod, + MethodInfo awaiterUnsafeOnCompletedMethod, + Type resultType, + MethodInfo getAwaiterMethod) + { + AwaiterType = awaiterType; + AwaiterIsCompletedProperty = awaiterIsCompletedProperty; + AwaiterGetResultMethod = awaiterGetResultMethod; + AwaiterOnCompletedMethod = awaiterOnCompletedMethod; + AwaiterUnsafeOnCompletedMethod = awaiterUnsafeOnCompletedMethod; + ResultType = resultType; + GetAwaiterMethod = getAwaiterMethod; + } + + public static bool IsTypeAwaitable(Type type, out AwaitableInfo awaitableInfo) + { + // Based on Roslyn code: http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/Shared/Extensions/ISymbolExtensions.cs,db4d48ba694b9347 + + // Awaitable must have method matching "object GetAwaiter()" + var getAwaiterMethod = type.GetRuntimeMethods().FirstOrDefault(m => + m.Name.Equals("GetAwaiter", StringComparison.OrdinalIgnoreCase) + && m.GetParameters().Length == 0 + && m.ReturnType != null); + if (getAwaiterMethod == null) + { + awaitableInfo = default(AwaitableInfo); + return false; + } + + var awaiterType = getAwaiterMethod.ReturnType; + + // Awaiter must have property matching "bool IsCompleted { get; }" + var isCompletedProperty = awaiterType.GetRuntimeProperties().FirstOrDefault(p => + p.Name.Equals("IsCompleted", StringComparison.OrdinalIgnoreCase) + && p.PropertyType == typeof(bool) + && p.GetMethod != null); + if (isCompletedProperty == null) + { + awaitableInfo = default(AwaitableInfo); + return false; + } + + // Awaiter must implement INotifyCompletion + var awaiterInterfaces = awaiterType.GetInterfaces(); + var implementsINotifyCompletion = awaiterInterfaces.Any(t => t == typeof(INotifyCompletion)); + if (!implementsINotifyCompletion) + { + awaitableInfo = default(AwaitableInfo); + return false; + } + + // INotifyCompletion supplies a method matching "void OnCompleted(Action action)" + var iNotifyCompletionMap = awaiterType + .GetTypeInfo() + .GetRuntimeInterfaceMap(typeof(INotifyCompletion)); + var onCompletedMethod = iNotifyCompletionMap.InterfaceMethods.Single(m => + m.Name.Equals("OnCompleted", StringComparison.OrdinalIgnoreCase) + && m.ReturnType == typeof(void) + && m.GetParameters().Length == 1 + && m.GetParameters()[0].ParameterType == typeof(Action)); + + // Awaiter optionally implements ICriticalNotifyCompletion + var implementsICriticalNotifyCompletion = + awaiterInterfaces.Any(t => t == typeof(ICriticalNotifyCompletion)); + MethodInfo unsafeOnCompletedMethod; + if (implementsICriticalNotifyCompletion) + { + // ICriticalNotifyCompletion supplies a method matching "void UnsafeOnCompleted(Action action)" + var iCriticalNotifyCompletionMap = awaiterType + .GetTypeInfo() + .GetRuntimeInterfaceMap(typeof(ICriticalNotifyCompletion)); + unsafeOnCompletedMethod = iCriticalNotifyCompletionMap.InterfaceMethods.Single(m => + m.Name.Equals("UnsafeOnCompleted", StringComparison.OrdinalIgnoreCase) + && m.ReturnType == typeof(void) + && m.GetParameters().Length == 1 + && m.GetParameters()[0].ParameterType == typeof(Action)); + } + else + { + unsafeOnCompletedMethod = null; + } + + // Awaiter must have method matching "void GetResult" or "T GetResult()" + var getResultMethod = awaiterType.GetRuntimeMethods().FirstOrDefault(m => + m.Name.Equals("GetResult") + && m.GetParameters().Length == 0); + if (getResultMethod == null) + { + awaitableInfo = default(AwaitableInfo); + return false; + } + + awaitableInfo = new AwaitableInfo( + awaiterType, + isCompletedProperty, + getResultMethod, + onCompletedMethod, + unsafeOnCompletedMethod, + getResultMethod.ReturnType, + getAwaiterMethod); + return true; + } + } +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs index 70d85be..543cf33 100644 --- a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs +++ b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs @@ -6,19 +6,89 @@ using System.Linq; using System.Net; using System.Threading.Tasks; using DotNetCore.CAP.Dashboard; +using DotNetCore.CAP.Dashboard.GatewayProxy; +using DotNetCore.CAP.Dashboard.NodeDiscovery; +using DotNetCore.CAP.Persistence; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP { + public static class CapBuilderExtension + { + public static IApplicationBuilder UseCapDashboard(this IApplicationBuilder app) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + CheckRequirement(app); + + var provider = app.ApplicationServices; + + if (provider.GetService() != null) + { + if (provider.GetService() != null) + { + app.UseMiddleware(); + } + + app.UseMiddleware(); + } + + return app; + } + + private static void CheckRequirement(IApplicationBuilder app) + { + var marker = app.ApplicationServices.GetService(); + if (marker == null) + { + throw new InvalidOperationException( + "AddCap() must be called on the service collection. eg: services.AddCap(...)"); + } + + var messageQueueMarker = app.ApplicationServices.GetService(); + if (messageQueueMarker == null) + { + throw new InvalidOperationException( + "You must be config used message queue provider at AddCap() options! eg: services.AddCap(options=>{ options.UseKafka(...) })"); + } + + var databaseMarker = app.ApplicationServices.GetService(); + if (databaseMarker == null) + { + throw new InvalidOperationException( + "You must be config used database provider at AddCap() options! eg: services.AddCap(options=>{ options.UseSqlServer(...) })"); + } + } + } + + sealed class CapStartupFilter : IStartupFilter + { + public Action Configure(Action next) + { + return app => + { + app.UseCapDashboard(); + + next(app); + }; + } + } + public class DashboardMiddleware { private readonly RequestDelegate _next; private readonly DashboardOptions _options; private readonly RouteCollection _routes; - private readonly IStorage _storage; + private readonly IDataStorage _storage; - public DashboardMiddleware(RequestDelegate next, DashboardOptions options, IStorage storage, + public DashboardMiddleware(RequestDelegate next, DashboardOptions options, IDataStorage storage, RouteCollection routes) { _next = next ?? throw new ArgumentNullException(nameof(next)); diff --git a/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptionsExtensions.cs b/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptionsExtensions.cs index cfc1bf5..5a27d66 100644 --- a/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptionsExtensions.cs +++ b/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptionsExtensions.cs @@ -6,6 +6,7 @@ using DotNetCore.CAP; using DotNetCore.CAP.Dashboard; using DotNetCore.CAP.Dashboard.GatewayProxy; using DotNetCore.CAP.Dashboard.GatewayProxy.Requester; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP @@ -23,11 +24,13 @@ namespace DotNetCore.CAP { var dashboardOptions = new DashboardOptions(); _options?.Invoke(dashboardOptions); + services.AddTransient(); services.AddSingleton(dashboardOptions); services.AddSingleton(DashboardRoutes.Routes); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + } } } diff --git a/src/DotNetCore.CAP.Dashboard/CapCache.cs b/src/DotNetCore.CAP.Dashboard/CapCache.cs new file mode 100644 index 0000000..2aa827b --- /dev/null +++ b/src/DotNetCore.CAP.Dashboard/CapCache.cs @@ -0,0 +1,378 @@ +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +namespace DotNetCore.CAP.Dashboard +{ + #region Cache class + + /// + /// This is a generic cache subsystem based on key/value pairs, where key is generic, too. Key must be unique. + /// Every cache entry has its own timeout. + /// Cache is thread safe and will delete expired entries on its own using System.Threading.Timers (which run on + /// threads). + /// + // ReSharper disable once InheritdocConsiderUsage + // ReSharper disable once InconsistentNaming + internal class Cache : IDisposable + { + #region Constructor and class members + + private readonly Dictionary _cache = new Dictionary(); + private readonly Dictionary _timers = new Dictionary(); + private readonly ReaderWriterLockSlim _locker = new ReaderWriterLockSlim(); + + #endregion + + #region IDisposable implementation & Clear + + private bool disposed; + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases unmanaged and - optionally - managed resources. + /// + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + /// + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + disposed = true; + + if (disposing) + { + // Dispose managed resources. + Clear(); + _locker.Dispose(); + } + + // Dispose unmanaged resources + } + } + + /// + /// Clears the entire cache and disposes all active timers. + /// + public void Clear() + { + _locker.EnterWriteLock(); + try + { + try + { + foreach (var t in _timers.Values) + { + t.Dispose(); + } + } + catch + { + } + + _timers.Clear(); + _cache.Clear(); + } + finally + { + _locker.ExitWriteLock(); + } + } + + #endregion + + #region CheckTimer + + // Checks whether a specific timer already exists and adds a new one, if not + private void CheckTimer(K key, TimeSpan? cacheTimeout, bool restartTimerIfExists) + { + Timer timer; + + if (_timers.TryGetValue(key, out timer)) + { + if (restartTimerIfExists) + { + timer.Change( + cacheTimeout ?? Timeout.InfiniteTimeSpan, + Timeout.InfiniteTimeSpan); + } + } + else + { + _timers.Add( + key, + new Timer( + RemoveByTimer, + key, + cacheTimeout ?? Timeout.InfiniteTimeSpan, + Timeout.InfiniteTimeSpan)); + } + } + + private void RemoveByTimer(object state) + { + Remove((K) state); + } + + #endregion + + #region AddOrUpdate, Get, Remove, Exists, Clear + + /// + /// Adds or updates the specified cache-key with the specified cacheObject and applies a specified timeout (in seconds) + /// to this key. + /// + /// The cache-key to add or update. + /// The cache object to store. + /// + /// The cache timeout (lifespan) of this object. Must be 1 or greater. + /// Specify Timeout.Infinite to keep the entry forever. + /// + /// + /// (Optional). If set to true, the timer for this cacheObject will be reset if the object already + /// exists in the cache. (Default = false). + /// + public void AddOrUpdate(K key, T cacheObject, TimeSpan? cacheTimeout, bool restartTimerIfExists = false) + { + if (disposed) + { + return; + } + + _locker.EnterWriteLock(); + try + { + CheckTimer(key, cacheTimeout, restartTimerIfExists); + + if (!_cache.ContainsKey(key)) + { + _cache.Add(key, cacheObject); + } + else + { + _cache[key] = cacheObject; + } + } + finally + { + _locker.ExitWriteLock(); + } + } + + /// + /// Adds or updates the specified cache-key with the specified cacheObject and applies Timeout.Infinite to this + /// key. + /// + /// The cache-key to add or update. + /// The cache object to store. + public void AddOrUpdate(K key, T cacheObject) + { + AddOrUpdate(key, cacheObject, Timeout.InfiniteTimeSpan); + } + + /// + /// Gets the cache entry with the specified key or returns default(T) if the key is not found. + /// + /// The cache-key to retrieve. + /// The object from the cache or default(T), if not found. + public T this[K key] => Get(key); + + /// + /// Gets the cache entry with the specified key or return default(T) if the key is not found. + /// + /// The cache-key to retrieve. + /// The object from the cache or default(T), if not found. + public T Get(K key) + { + if (disposed) + { + return default(T); + } + + _locker.EnterReadLock(); + try + { + T rv; + return _cache.TryGetValue(key, out rv) ? rv : default(T); + } + finally + { + _locker.ExitReadLock(); + } + } + + /// + /// Tries to gets the cache entry with the specified key. + /// + /// The key. + /// (out) The value, if found, or default(T), if not. + /// True, if key exists, otherwise false. + public bool TryGet(K key, out T value) + { + if (disposed) + { + value = default(T); + return false; + } + + _locker.EnterReadLock(); + try + { + return _cache.TryGetValue(key, out value); + } + finally + { + _locker.ExitReadLock(); + } + } + + /// + /// Removes a series of cache entries in a single call for all key that match the specified key pattern. + /// + /// The key pattern to remove. The Predicate has to return true to get key removed. + public void Remove(Predicate keyPattern) + { + if (disposed) + { + return; + } + + _locker.EnterWriteLock(); + try + { + var removers = (from k in _cache.Keys.Cast() + where keyPattern(k) + select k).ToList(); + + foreach (var workKey in removers) + { + try + { + _timers[workKey].Dispose(); + } + catch + { + } + + _timers.Remove(workKey); + _cache.Remove(workKey); + } + } + finally + { + _locker.ExitWriteLock(); + } + } + + /// + /// Removes the specified cache entry with the specified key. + /// If the key is not found, no exception is thrown, the statement is just ignored. + /// + /// The cache-key to remove. + public void Remove(K key) + { + if (disposed) + { + return; + } + + _locker.EnterWriteLock(); + try + { + if (_cache.ContainsKey(key)) + { + try + { + _timers[key].Dispose(); + } + catch + { + } + + _timers.Remove(key); + _cache.Remove(key); + } + } + finally + { + _locker.ExitWriteLock(); + } + } + + /// + /// Checks if a specified key exists in the cache. + /// + /// The cache-key to check. + /// True if the key exists in the cache, otherwise False. + public bool Exists(K key) + { + if (disposed) + { + return false; + } + + _locker.EnterReadLock(); + try + { + return _cache.ContainsKey(key); + } + finally + { + _locker.ExitReadLock(); + } + } + + #endregion + } + + #endregion + + #region Other Cache classes (derived) + + /// + /// This is a generic cache subsystem based on key/value pairs, where key is a string. + /// You can add any item to this cache as long as the key is unique, so treat keys as something like namespaces and + /// build them with a + /// specific system/syntax in your application. + /// Every cache entry has its own timeout. + /// Cache is thread safe and will delete expired entries on its own using System.Threading.Timers (which run on + /// threads). + /// + /// + /// The non-generic Cache class instanciates a Cache{object} that can be used with any type of (mixed) contents. + /// It also publishes a static .Global member, so a cache can be used even without creating a dedicated + /// instance. + /// The .Global member is lazy instanciated. + /// + internal class CapCache : Cache + { + #region Static Global Cache instance + + private static readonly Lazy global = new Lazy(); + + /// + /// Gets the global shared cache instance valid for the entire process. + /// + /// + /// The global shared cache instance. + /// + public static CapCache Global => global.Value; + + #endregion + } + + #endregion +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.Dashboard/CoercedAwaitableInfo.cs b/src/DotNetCore.CAP.Dashboard/CoercedAwaitableInfo.cs new file mode 100644 index 0000000..be1725f --- /dev/null +++ b/src/DotNetCore.CAP.Dashboard/CoercedAwaitableInfo.cs @@ -0,0 +1,44 @@ +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Linq.Expressions; +using Microsoft.Extensions.Internal; + +namespace DotNetCore.CAP.Dashboard +{ + internal struct CoercedAwaitableInfo + { + public AwaitableInfo AwaitableInfo { get; } + public Expression CoercerExpression { get; } + public Type CoercerResultType { get; } + public bool RequiresCoercion => CoercerExpression != null; + + public CoercedAwaitableInfo(AwaitableInfo awaitableInfo) + { + AwaitableInfo = awaitableInfo; + CoercerExpression = null; + CoercerResultType = null; + } + + public CoercedAwaitableInfo(Expression coercerExpression, Type coercerResultType, + AwaitableInfo coercedAwaitableInfo) + { + CoercerExpression = coercerExpression; + CoercerResultType = coercerResultType; + AwaitableInfo = coercedAwaitableInfo; + } + + public static bool IsTypeAwaitable(Type type, out CoercedAwaitableInfo info) + { + if (AwaitableInfo.IsTypeAwaitable(type, out var directlyAwaitableInfo)) + { + info = new CoercedAwaitableInfo(directlyAwaitableInfo); + return true; + } + + info = default(CoercedAwaitableInfo); + return false; + } + } +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.Dashboard/CombinedResourceDispatcher.cs b/src/DotNetCore.CAP.Dashboard/CombinedResourceDispatcher.cs index 65875c4..e8e5f2a 100644 --- a/src/DotNetCore.CAP.Dashboard/CombinedResourceDispatcher.cs +++ b/src/DotNetCore.CAP.Dashboard/CombinedResourceDispatcher.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System.Reflection; +using System.Threading.Tasks; namespace DotNetCore.CAP.Dashboard { @@ -22,14 +23,14 @@ namespace DotNetCore.CAP.Dashboard _resourceNames = resourceNames; } - protected override void WriteResponse(DashboardResponse response) + protected override async Task WriteResponse(DashboardResponse response) { foreach (var resourceName in _resourceNames) { - WriteResource( - response, - _assembly, - $"{_baseNamespace}.{resourceName}"); + await WriteResource( + response, + _assembly, + $"{_baseNamespace}.{resourceName}"); } } } diff --git a/src/DotNetCore.CAP.Dashboard/DashboardContext.cs b/src/DotNetCore.CAP.Dashboard/DashboardContext.cs index c97a308..00b5655 100644 --- a/src/DotNetCore.CAP.Dashboard/DashboardContext.cs +++ b/src/DotNetCore.CAP.Dashboard/DashboardContext.cs @@ -3,13 +3,14 @@ using System; using System.Text.RegularExpressions; +using DotNetCore.CAP.Persistence; using Microsoft.AspNetCore.Http; namespace DotNetCore.CAP.Dashboard { public abstract class DashboardContext { - protected DashboardContext(IStorage storage, DashboardOptions options) + protected DashboardContext(IDataStorage storage, DashboardOptions options) { if (storage == null) { @@ -25,7 +26,7 @@ namespace DotNetCore.CAP.Dashboard Options = options; } - public IStorage Storage { get; } + public IDataStorage Storage { get; } public DashboardOptions Options { get; } @@ -41,7 +42,7 @@ namespace DotNetCore.CAP.Dashboard public sealed class CapDashboardContext : DashboardContext { public CapDashboardContext( - IStorage storage, + IDataStorage storage, DashboardOptions options, HttpContext httpContext) : base(storage, options) diff --git a/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs b/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs index 34f3aee..3ba3ba8 100644 --- a/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs +++ b/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs @@ -83,14 +83,14 @@ namespace DotNetCore.CAP.Dashboard Routes.AddJsonResult("/published/message/(?.+)", x => { var id = long.Parse(x.UriMatch.Groups["Id"].Value); - var message = x.Storage.GetConnection().GetPublishedMessageAsync(id) + var message = x.Storage.GetMonitoringApi().GetPublishedMessageAsync(id) .GetAwaiter().GetResult(); return message.Content; }); Routes.AddJsonResult("/received/message/(?.+)", x => { var id = long.Parse(x.UriMatch.Groups["Id"].Value); - var message = x.Storage.GetConnection().GetReceivedMessageAsync(id) + var message = x.Storage.GetMonitoringApi().GetReceivedMessageAsync(id) .GetAwaiter().GetResult(); return message.Content; }); @@ -99,7 +99,7 @@ namespace DotNetCore.CAP.Dashboard "/published/requeue", (client, messageId) => { - var msg = client.Storage.GetConnection().GetPublishedMessageAsync(messageId) + var msg = client.Storage.GetMonitoringApi().GetPublishedMessageAsync(messageId) .GetAwaiter().GetResult(); client.RequestServices.GetService().EnqueueToPublish(msg); }); @@ -107,9 +107,9 @@ namespace DotNetCore.CAP.Dashboard "/received/requeue", (client, messageId) => { - var msg = client.Storage.GetConnection().GetReceivedMessageAsync(messageId) + var msg = client.Storage.GetMonitoringApi().GetReceivedMessageAsync(messageId) .GetAwaiter().GetResult(); - client.RequestServices.GetService().EnqueueToExecute(msg); + client.RequestServices.GetService().ExecuteAsync(msg); }); Routes.AddRazorPage( diff --git a/src/DotNetCore.CAP.Dashboard/DotNetCore.CAP.Dashboard.csproj b/src/DotNetCore.CAP.Dashboard/DotNetCore.CAP.Dashboard.csproj index 1d40d14..d934d76 100644 --- a/src/DotNetCore.CAP.Dashboard/DotNetCore.CAP.Dashboard.csproj +++ b/src/DotNetCore.CAP.Dashboard/DotNetCore.CAP.Dashboard.csproj @@ -2,8 +2,21 @@ netstandard2.0 + false + 1591 + + C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe + Razor.build + GenerateRazorClasses;Build + + + + + + + @@ -25,83 +38,129 @@ + + + + + + + + - + True True Strings.resx - + + True + True + _BlockMetric.cshtml + + _SidebarMenu.cshtml + True + True - + _SidebarMenu.cshtml - + ReceivedPage.cshtml + True + True - + ReceivedPage.cshtml - - _BlockMetric.cshtml - - + _BlockMetric.cshtml - + _Breadcrumbs.cshtml - + _Breadcrumbs.cshtml + True + True - + _Paginator.cshtml + True + True - + _Paginator.cshtml - + _PerPageSelector.cshtml - + _PerPageSelector.cshtml + True + True - + PublishedPage.cshtml - + PublishedPage.cshtml - + LayoutPage.cshtml - + LayoutPage.cshtml - + _InlineMetric.cshtml - + + True + True + LayoutPage.cshtml + + + True + True + PublishedPage.cshtml + + _InlineMetric.cshtml + True + True - + _Navigation.cshtml + True + True - + HomePage.cshtml + True + True - + HomePage.cshtml - + SubscriberPage.cshtml + True + True + + + NodePage.cshtml - + + + + + True + True NodePage.cshtml @@ -115,11 +174,66 @@ - + PublicResXFileCodeGenerator DotNetCore.CAP.Dashboard.Resources Strings.Designer.cs + + + RazorGenerator + HomePage.generated.cs + + + RazorGenerator + LayoutPage.generated.cs + + + RazorGenerator + NodePage.generated.cs + + + RazorGenerator + PublishedPage.generated.cs + + + RazorGenerator + ReceivedPage.generated.cs + + + RazorGenerator + SubscriberPage.generated.cs + + + RazorGenerator + _BlockMetric.generated.cs + + + RazorGenerator + _Breadcrumbs.generated.cs + + + RazorGenerator + _InlineMetric.generated.cs + + + RazorGenerator + _Navigation.generated.cs + + + RazorGenerator + _Paginator.generated.cs + + + RazorGenerator + _PerPageSelector.generated.cs + + + RazorGenerator + _SidebarMenu.generated.cs + + + diff --git a/src/DotNetCore.CAP.Dashboard/EmbeddedResourceDispatcher.cs b/src/DotNetCore.CAP.Dashboard/EmbeddedResourceDispatcher.cs index c48257c..926bfdf 100644 --- a/src/DotNetCore.CAP.Dashboard/EmbeddedResourceDispatcher.cs +++ b/src/DotNetCore.CAP.Dashboard/EmbeddedResourceDispatcher.cs @@ -30,22 +30,20 @@ namespace DotNetCore.CAP.Dashboard } } - public Task Dispatch(DashboardContext context) + public async Task Dispatch(DashboardContext context) { context.Response.ContentType = _contentType; context.Response.SetExpire(DateTimeOffset.Now.AddYears(1)); - WriteResponse(context.Response); - - return Task.FromResult(true); + await WriteResponse(context.Response); } - protected virtual void WriteResponse(DashboardResponse response) + protected virtual Task WriteResponse(DashboardResponse response) { - WriteResource(response, _assembly, _resourceName); + return WriteResource(response, _assembly, _resourceName); } - protected void WriteResource(DashboardResponse response, Assembly assembly, string resourceName) + protected async Task WriteResource(DashboardResponse response, Assembly assembly, string resourceName) { using (var inputStream = assembly.GetManifestResourceStream(resourceName)) { @@ -54,8 +52,7 @@ namespace DotNetCore.CAP.Dashboard throw new ArgumentException( $@"Resource with name {resourceName} not found in assembly {assembly}."); } - - inputStream.CopyTo(response.Body); + await inputStream.CopyToAsync(response.Body); } } } diff --git a/src/DotNetCore.CAP.Dashboard/GatewayProxy/GatewayProxyMiddleware.cs b/src/DotNetCore.CAP.Dashboard/GatewayProxy/GatewayProxyMiddleware.cs index 000f9b1..57df839 100644 --- a/src/DotNetCore.CAP.Dashboard/GatewayProxy/GatewayProxyMiddleware.cs +++ b/src/DotNetCore.CAP.Dashboard/GatewayProxy/GatewayProxyMiddleware.cs @@ -9,7 +9,7 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; using DotNetCore.CAP.Dashboard.GatewayProxy.Requester; -using DotNetCore.CAP.NodeDiscovery; +using DotNetCore.CAP.Dashboard.NodeDiscovery; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; diff --git a/src/DotNetCore.CAP.Dashboard/HtmlHelper.cs b/src/DotNetCore.CAP.Dashboard/HtmlHelper.cs index 6b896a7..6721235 100644 --- a/src/DotNetCore.CAP.Dashboard/HtmlHelper.cs +++ b/src/DotNetCore.CAP.Dashboard/HtmlHelper.cs @@ -10,7 +10,7 @@ using System.Text; using System.Text.RegularExpressions; using DotNetCore.CAP.Dashboard.Pages; using DotNetCore.CAP.Dashboard.Resources; -using DotNetCore.CAP.Infrastructure; +using DotNetCore.CAP.Internal; using DotNetCore.CAP.Messages; using Microsoft.Extensions.Internal; diff --git a/src/DotNetCore.CAP.Dashboard/JsonDispatcher.cs b/src/DotNetCore.CAP.Dashboard/JsonDispatcher.cs index dc6df96..97e1259 100644 --- a/src/DotNetCore.CAP.Dashboard/JsonDispatcher.cs +++ b/src/DotNetCore.CAP.Dashboard/JsonDispatcher.cs @@ -38,7 +38,7 @@ namespace DotNetCore.CAP.Dashboard { new StringEnumConverter { - NamingStrategy = new CamelCaseNamingStrategy() + CamelCaseText= true } } }; diff --git a/src/DotNetCore.CAP.Dashboard/JsonStats.cs b/src/DotNetCore.CAP.Dashboard/JsonStats.cs index 126fc42..6e13ccf 100644 --- a/src/DotNetCore.CAP.Dashboard/JsonStats.cs +++ b/src/DotNetCore.CAP.Dashboard/JsonStats.cs @@ -34,7 +34,7 @@ namespace DotNetCore.CAP.Dashboard { new StringEnumConverter { - NamingStrategy = new CamelCaseNamingStrategy() + CamelCaseText = true } } }; @@ -46,7 +46,7 @@ namespace DotNetCore.CAP.Dashboard private class StubPage : RazorPage { - protected override void Execute() + public override void Execute() { } } diff --git a/src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.cs b/src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.cs index dafd845..0a26fad 100644 --- a/src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.cs +++ b/src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -using DotNetCore.CAP.Infrastructure; +using DotNetCore.CAP.Internal; namespace DotNetCore.CAP.Dashboard { diff --git a/src/DotNetCore.CAP.Dashboard/MessageHistoryRenderer.cs b/src/DotNetCore.CAP.Dashboard/MessageHistoryRenderer.cs index 2df3b98..32db299 100644 --- a/src/DotNetCore.CAP.Dashboard/MessageHistoryRenderer.cs +++ b/src/DotNetCore.CAP.Dashboard/MessageHistoryRenderer.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Net; using System.Text; -using DotNetCore.CAP.Infrastructure; +using DotNetCore.CAP.Internal; namespace DotNetCore.CAP.Dashboard { @@ -24,16 +24,16 @@ namespace DotNetCore.CAP.Dashboard [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] static MessageHistoryRenderer() { - Register(StatusName.Succeeded, SucceededRenderer); - Register(StatusName.Failed, FailedRenderer); + Register(nameof(StatusName.Succeeded), SucceededRenderer); + Register(nameof(StatusName.Failed), FailedRenderer); - BackgroundStateColors.Add(StatusName.Succeeded, "#EDF7ED"); - BackgroundStateColors.Add(StatusName.Failed, "#FAEBEA"); - BackgroundStateColors.Add(StatusName.Scheduled, "#E0F3F8"); + BackgroundStateColors.Add(nameof(StatusName.Succeeded), "#EDF7ED"); + BackgroundStateColors.Add(nameof(StatusName.Failed), "#FAEBEA"); + BackgroundStateColors.Add(nameof(StatusName.Scheduled), "#E0F3F8"); - ForegroundStateColors.Add(StatusName.Succeeded, "#5cb85c"); - ForegroundStateColors.Add(StatusName.Failed, "#d9534f"); - ForegroundStateColors.Add(StatusName.Scheduled, "#5bc0de"); + ForegroundStateColors.Add(nameof(StatusName.Succeeded), "#5cb85c"); + ForegroundStateColors.Add(nameof(StatusName.Failed), "#d9534f"); + ForegroundStateColors.Add(nameof(StatusName.Scheduled), "#5bc0de"); } public static void AddBackgroundStateColor(string stateName, string color) diff --git a/src/DotNetCore.CAP.Dashboard/Pages/BlockMetric.cs b/src/DotNetCore.CAP.Dashboard/Pages/BlockMetric.cs index faa0c84..d36ec3f 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/BlockMetric.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/BlockMetric.cs @@ -7,9 +7,9 @@ namespace DotNetCore.CAP.Dashboard.Pages { public BlockMetric(DashboardMetric dashboardMetric) { - DashboardMetric = dashboardMetric; + Metric = dashboardMetric; } - public DashboardMetric DashboardMetric { get; } + public DashboardMetric Metric { get; } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP.Dashboard/Pages/HomePage.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/HomePage.generated.cs index 12947d4..060844e 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/HomePage.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/HomePage.generated.cs @@ -1,6 +1,4 @@ -using DotNetCore.CAP.Messages; - -#pragma warning disable 1591 +#pragma warning disable 1591 //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -13,63 +11,45 @@ namespace DotNetCore.CAP.Dashboard.Pages { - -#line 2 "..\..\HomePage.cshtml" using System; - -#line default -#line hidden - -#line 3 "..\..\HomePage.cshtml" using System.Collections.Generic; - -#line default -#line hidden using System.Linq; using System.Text; - -#line 5 "..\..\HomePage.cshtml" - using DotNetCore.CAP.Dashboard; - -#line default -#line hidden - -#line 6 "..\..\HomePage.cshtml" + + #line 2 "..\..\Pages\HomePage.cshtml" using DotNetCore.CAP.Dashboard.Pages; - -#line default -#line hidden - -#line 7 "..\..\HomePage.cshtml" + + #line default + #line hidden + + #line 3 "..\..\Pages\HomePage.cshtml" using DotNetCore.CAP.Dashboard.Resources; - -#line default -#line hidden - -#line 4 "..\..\HomePage.cshtml" -#line default -#line hidden - -#line 8 "..\..\HomePage.cshtml" + + #line default + #line hidden + + #line 4 "..\..\Pages\HomePage.cshtml" + using DotNetCore.CAP.Messages; + + #line default + #line hidden + + #line 5 "..\..\Pages\HomePage.cshtml" using Newtonsoft.Json; - -#line default -#line hidden - + + #line default + #line hidden + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class HomePage : RazorPage + internal partial class HomePage : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { - WriteLiteral("\r\n"); - - - - +WriteLiteral("\r\n"); @@ -77,175 +57,177 @@ namespace DotNetCore.CAP.Dashboard.Pages -#line 10 "..\..\HomePage.cshtml" + + #line 7 "..\..\Pages\HomePage.cshtml" + + Layout = new LayoutPage(Strings.HomePage_Title); - Layout = new LayoutPage(Strings.HomePage_Title); + var monitor = Storage.GetMonitoringApi(); + var publishedSucceeded = monitor.HourlySucceededJobs(MessageType.Publish); + var publishedFailed = monitor.HourlyFailedJobs(MessageType.Publish); - var monitor = Storage.GetMonitoringApi(); - IDictionary publishedSucceeded = monitor.HourlySucceededJobs(MessageType.Publish); - IDictionary publishedFailed = monitor.HourlyFailedJobs(MessageType.Publish); + var receivedSucceeded = monitor.HourlySucceededJobs(MessageType.Subscribe); + var receivedFailed = monitor.HourlyFailedJobs(MessageType.Subscribe); - IDictionary receivedSucceeded = monitor.HourlySucceededJobs(MessageType.Subscribe); - IDictionary receivedFailed = monitor.HourlyFailedJobs(MessageType.Subscribe); + + #line default + #line hidden +WriteLiteral("\r\n
\r\n
\r\n

"); -#line default -#line hidden - WriteLiteral("\r\n
\r\n
\r\n

"); - - - -#line 23 "..\..\HomePage.cshtml" - Write(Strings.HomePage_Title); - - -#line default -#line hidden - WriteLiteral("

\r\n"); + + #line 20 "..\..\Pages\HomePage.cshtml" + Write(Strings.HomePage_Title); + + #line default + #line hidden +WriteLiteral("

\r\n"); -#line 24 "..\..\HomePage.cshtml" - if (Metrics.Count > 0) - { - - -#line default -#line hidden - WriteLiteral("
\r\n"); + + #line 21 "..\..\Pages\HomePage.cshtml" + if (Metrics.Count > 0) + { + + #line default + #line hidden +WriteLiteral("
\r\n"); -#line 27 "..\..\HomePage.cshtml" - foreach (var metric in Metrics) + + #line 24 "..\..\Pages\HomePage.cshtml" + foreach (var metric in Metrics) { + + #line default + #line hidden +WriteLiteral("
\r\n "); -#line default -#line hidden - WriteLiteral("
\r\n "); - - - -#line 30 "..\..\HomePage.cshtml" - Write(Html.BlockMetric(metric)); + + #line 27 "..\..\Pages\HomePage.cshtml" + Write(Html.BlockMetric(metric)); -#line default -#line hidden - WriteLiteral("\r\n
\r\n"); - + + #line default + #line hidden +WriteLiteral("\r\n
\r\n"); -#line 32 "..\..\HomePage.cshtml" + + #line 29 "..\..\Pages\HomePage.cshtml" } - -#line default -#line hidden - WriteLiteral("
\r\n"); - - - -#line 34 "..\..\HomePage.cshtml" - } - - -#line default -#line hidden - WriteLiteral("

"); - + + #line default + #line hidden +WriteLiteral("

\r\n"); -#line 35 "..\..\HomePage.cshtml" - Write(Strings.HomePage_RealtimeGraph); - - -#line default -#line hidden - WriteLiteral("\r\n
@@ -257,95 +239,95 @@ namespace DotNetCore.CAP.Dashboard.Pages "); + + #line 51 "..\..\Pages\HomePage.cshtml" + Write(Strings.HomePage_HistoryGraph); -#line 53 "..\..\HomePage.cshtml" - Write(Strings.HomePage_HistoryGraph); - + + #line default + #line hidden +WriteLiteral("\r\n \r\n\r\n \r\n
"); + + #line default + #line hidden +WriteLiteral("\">\r\n
\r\n
\r\n"); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/LayoutPage.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/LayoutPage.generated.cs index 374062b..1e1fccf 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/LayoutPage.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/LayoutPage.generated.cs @@ -11,313 +11,306 @@ namespace DotNetCore.CAP.Dashboard.Pages { - -#line 2 "..\..\LayoutPage.cshtml" + + #line 2 "..\..\Pages\LayoutPage.cshtml" using System; - -#line default -#line hidden + + #line default + #line hidden using System.Collections.Generic; - -#line 3 "..\..\LayoutPage.cshtml" + + #line 3 "..\..\Pages\LayoutPage.cshtml" using System.Globalization; - -#line default -#line hidden + + #line default + #line hidden using System.Linq; - -#line 4 "..\..\LayoutPage.cshtml" + + #line 4 "..\..\Pages\LayoutPage.cshtml" using System.Reflection; - -#line default -#line hidden + + #line default + #line hidden using System.Text; - -#line 5 "..\..\LayoutPage.cshtml" + + #line 5 "..\..\Pages\LayoutPage.cshtml" using DotNetCore.CAP.Dashboard.Pages; - -#line default -#line hidden - -#line 6 "..\..\LayoutPage.cshtml" + + #line default + #line hidden + + #line 6 "..\..\Pages\LayoutPage.cshtml" using DotNetCore.CAP.Dashboard.Resources; - -#line default -#line hidden - + + #line default + #line hidden + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] public partial class LayoutPage : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { - WriteLiteral("\r\n"); - - - - - - +WriteLiteral("\r\n"); - WriteLiteral("\r\n\r\n\r\n "); -#line 11 "..\..\LayoutPage.cshtml" - Write(Title); +WriteLiteral("<!DOCTYPE html>\r\n<html lang=\""); -#line default -#line hidden - WriteLiteral(" - CAP\r\n \r\n \r\n \r\n"); + + #line 9 "..\..\Pages\LayoutPage.cshtml" + Write(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName); + + #line default + #line hidden +WriteLiteral("\">\r\n\r\n "); -#line 15 "..\..\LayoutPage.cshtml" - var version = GetType().GetTypeInfo().Assembly.GetName().Version; + + #line 11 "..\..\Pages\LayoutPage.cshtml" + Write(Title); + + #line default + #line hidden +WriteLiteral(" - CAP\r\n \r\n \r\n \r\n"); -#line default -#line hidden - WriteLiteral(" + + #line default + #line hidden +WriteLiteral(@"""> - -
- - -
-
-
- - \r\n
\r\n
\r\n "); - - - -#line 34 "..\..\LayoutPage.cshtml" - Write(Html.RenderPartial(new Navigation())); - - -#line default -#line hidden - WriteLiteral("\r\n"); - - - -#line 35 "..\..\LayoutPage.cshtml" - if (AppPath != null) - { - - -#line default -#line hidden - WriteLiteral(" \r\n
\r\n
\r\n "); + + #line 34 "..\..\Pages\LayoutPage.cshtml" + Write(Html.RenderPartial(new Navigation())); -#line 45 "..\..\LayoutPage.cshtml" - } + + #line default + #line hidden +WriteLiteral("\r\n"); -#line default -#line hidden - WriteLiteral("
\r\n \r\n \r\n
\r\n\r\n \r\n
\r\n "); + + #line 35 "..\..\Pages\LayoutPage.cshtml" + if (AppPath != null) + { + + #line default + #line hidden +WriteLiteral("
\r\n"); -#line 62 "..\..\LayoutPage.cshtml" - Write($"{version.Major}.{version.Minor}.{version.Build}"); + + #line 45 "..\..\Pages\LayoutPage.cshtml" + } + + #line default + #line hidden +WriteLiteral("
\r\n \r\n
\r\n \r\n\r\n \r\n
\r\n "); -#line default -#line hidden - WriteLiteral("\r\n \r\n \r\n
  • "); + + #line 53 "..\..\Pages\LayoutPage.cshtml" + Write(RenderBody()); + + #line default + #line hidden +WriteLiteral("\r\n
  • \r\n
    \r\n\r\n
    \r\n
    \r\n <" + +"ul class=\"list-inline credit\">\r\n
  • \r\n \r\n CAP "); -#line 65 "..\..\LayoutPage.cshtml" - Write(Storage); + + #line 62 "..\..\Pages\LayoutPage.cshtml" + Write($"{version.Major}.{version.Minor}.{version.Build}"); -#line default -#line hidden - WriteLiteral("
  • \r\n
  • "); + + #line default + #line hidden +WriteLiteral("\r\n \r\n
  • \r\n
  • "); + + #line 65 "..\..\Pages\LayoutPage.cshtml" + Write(Storage); -#line 66 "..\..\LayoutPage.cshtml" - Write(Strings.LayoutPage_Footer_Time); + + #line default + #line hidden +WriteLiteral("
  • \r\n
  • "); -#line default -#line hidden - WriteLiteral(" "); + + #line 66 "..\..\Pages\LayoutPage.cshtml" + Write(Strings.LayoutPage_Footer_Time); + + #line default + #line hidden +WriteLiteral(" "); -#line 66 "..\..\LayoutPage.cshtml" - Write(Html.LocalTime(DateTime.UtcNow)); + + #line 66 "..\..\Pages\LayoutPage.cshtml" + Write(Html.LocalTime(DateTime.UtcNow)); - -#line default -#line hidden - WriteLiteral("
  • \r\n
  • "); + + #line default + #line hidden +WriteLiteral("
  • \r\n
  • "); + + #line 67 "..\..\Pages\LayoutPage.cshtml" + Write(string.Format(Strings.LayoutPage_Footer_Generatedms, GenerationTime.Elapsed.TotalMilliseconds.ToString("N"))); -#line 67 "..\..\LayoutPage.cshtml" - Write(string.Format(Strings.LayoutPage_Footer_Generatedms, GenerationTime.Elapsed.TotalMilliseconds.ToString("N"))); + + #line default + #line hidden +WriteLiteral("
  • \r\n"); -#line default -#line hidden - WriteLiteral("\r\n"); - - - -#line 68 "..\..\LayoutPage.cshtml" - if (NodeName != null) + + #line 68 "..\..\Pages\LayoutPage.cshtml" + if (NodeName != null) { - -#line default -#line hidden - WriteLiteral("
  • "); + + #line default + #line hidden +WriteLiteral("
  • "); + + #line 70 "..\..\Pages\LayoutPage.cshtml" + Write(string.Format(Strings.LayoutPage_Footer_NodeCurrent, NodeName)); -#line 70 "..\..\LayoutPage.cshtml" - Write(string.Format(Strings.LayoutPage_Footer_NodeCurrent, NodeName)); + + #line default + #line hidden +WriteLiteral("
  • \r\n"); -#line default -#line hidden - WriteLiteral("\r\n"); - - - -#line 71 "..\..\LayoutPage.cshtml" + + #line 71 "..\..\Pages\LayoutPage.cshtml" } + + #line default + #line hidden +WriteLiteral(" \r\n
    \r\n
    \r\n\r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n"); + + #line default + #line hidden +WriteLiteral("\">\r\n\r\n"); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/NodePage.cs b/src/DotNetCore.CAP.Dashboard/Pages/NodePage.cs index 9f677b8..c95b4df 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/NodePage.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/NodePage.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System.Collections.Generic; -using DotNetCore.CAP.NodeDiscovery; +using DotNetCore.CAP.Dashboard.NodeDiscovery; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP.Dashboard.Pages diff --git a/src/DotNetCore.CAP.Dashboard/Pages/NodePage.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/NodePage.generated.cs index 9b205b1..e7a049d 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/NodePage.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/NodePage.generated.cs @@ -15,243 +15,242 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Collections.Generic; using System.Linq; using System.Text; - -#line 2 "..\..\NodePage.cshtml" + + #line 2 "..\..\Pages\NodePage.cshtml" using DotNetCore.CAP.Dashboard.Pages; - -#line default -#line hidden - -#line 3 "..\..\NodePage.cshtml" + + #line default + #line hidden + + #line 3 "..\..\Pages\NodePage.cshtml" using DotNetCore.CAP.Dashboard.Resources; - -#line default -#line hidden - + + #line default + #line hidden + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] internal partial class NodePage : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { - WriteLiteral("\r\n"); - - - - - - -#line 5 "..\..\NodePage.cshtml" - - Layout = new LayoutPage(Strings.NodePage_Title); - - - -#line default -#line hidden - WriteLiteral("
    \r\n
    \r\n

    "); - - - -#line 10 "..\..\NodePage.cshtml" - Write(Strings.NodePage_Title); - - -#line default -#line hidden - WriteLiteral("

    \r\n\r\n"); - - - -#line 12 "..\..\NodePage.cshtml" - if (Nodes == null || Nodes.Count == 0) - { - - -#line default -#line hidden - WriteLiteral("
    \r\n "); - - - -#line 15 "..\..\NodePage.cshtml" - Write(Strings.NodePage_NoNodes); - - -#line default -#line hidden - WriteLiteral("\r\n
    \r\n"); - - - -#line 17 "..\..\NodePage.cshtml" - } - else - { - - -#line default -#line hidden - WriteLiteral("
    \r\n " + - "\r\n \r\n \r\n " + - " \r\n \r\n \r\n \r\n \r\n "); + + #line 10 "..\..\Pages\NodePage.cshtml" + Write(Strings.NodePage_Title); + + #line default + #line hidden +WriteLiteral("\r\n\r\n"); -#line 29 "..\..\NodePage.cshtml" - Write(Strings.NodePage_Switch); + + #line 12 "..\..\Pages\NodePage.cshtml" + if (Nodes == null || Nodes.Count == 0) + { + + #line default + #line hidden +WriteLiteral("
    \r\n "); -#line default -#line hidden - WriteLiteral("\r\n
    \r\n \r\n " + - " \r\n"); + + #line 15 "..\..\Pages\NodePage.cshtml" + Write(Strings.NodePage_NoNodes); + + #line default + #line hidden +WriteLiteral("\r\n \r\n"); -#line 33 "..\..\NodePage.cshtml" - foreach (var node in Nodes) - { + + #line 17 "..\..\Pages\NodePage.cshtml" + } + else + { -#line default -#line hidden - WriteLiteral(" \r\n
    "); - - - -#line 24 "..\..\NodePage.cshtml" - Write(Strings.Common_Id); - - -#line default -#line hidden - WriteLiteral(""); - - - -#line 25 "..\..\NodePage.cshtml" - Write(Strings.NodePage_Table_NodeName); - - -#line default -#line hidden - WriteLiteral(""); - +WriteLiteral("\r\n"); -#line 26 "..\..\NodePage.cshtml" - Write(Strings.NodePage_Table_IP); -#line default -#line hidden - WriteLiteral(""); + + #line 5 "..\..\Pages\NodePage.cshtml" + + Layout = new LayoutPage(Strings.NodePage_Title); -#line 27 "..\..\NodePage.cshtml" - Write(Strings.NodePage_Table_Port); + + #line default + #line hidden +WriteLiteral("
    \r\n
    \r\n

    "); -#line default -#line hidden - WriteLiteral("

    Tags
    " + +"\r\n \r\n \r\n " + +" \r\n \r\n \r\n \r\n \r\n " + +" \r\n"); + + #line 33 "..\..\Pages\NodePage.cshtml" + foreach (var node in Nodes) + { -#line 38 "..\..\NodePage.cshtml" - Write(node.Address); + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"); + + #line 40 "..\..\Pages\NodePage.cshtml" + Write(node.Tags); + + #line default + #line hidden +WriteLiteral("\r\n \r\n \r\n"); -#line default -#line hidden - WriteLiteral(" \r\n
    "); + + #line 24 "..\..\Pages\NodePage.cshtml" + Write(Strings.Common_Id); -#line 35 "..\..\NodePage.cshtml" - Write(CurrentNodeId == node.Id ? "active" : null); + + #line default + #line hidden +WriteLiteral(""); -#line default -#line hidden - WriteLiteral("\">\r\n "); + + #line 25 "..\..\Pages\NodePage.cshtml" + Write(Strings.NodePage_Table_NodeName); + + #line default + #line hidden +WriteLiteral("\r\n "); -#line 36 "..\..\NodePage.cshtml" - Write(node.Id); + + #line 26 "..\..\Pages\NodePage.cshtml" + Write(Strings.NodePage_Table_IP); + + #line default + #line hidden +WriteLiteral(""); -#line default -#line hidden - WriteLiteral("\r\n "); + + #line 27 "..\..\Pages\NodePage.cshtml" + Write(Strings.NodePage_Table_Port); + + #line default + #line hidden +WriteLiteral("\r\n Tags"); -#line 37 "..\..\NodePage.cshtml" - Write(node.Name); + + #line 29 "..\..\Pages\NodePage.cshtml" + Write(Strings.NodePage_Switch); -#line default -#line hidden - WriteLiteral("\r\n "); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n "); -#line 45 "..\..\NodePage.cshtml" - } + + #line 42 "..\..\Pages\NodePage.cshtml" + Write(Html.NodeSwitchLink(node.Id)); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n
    \r\n"); + + #line 45 "..\..\Pages\NodePage.cshtml" + } + + #line default + #line hidden +WriteLiteral(" \r\n \r\n
    \r\n"); -#line 49 "..\..\NodePage.cshtml" - } + + #line 49 "..\..\Pages\NodePage.cshtml" + } -#line default -#line hidden - WriteLiteral("
    \r\n"); + + #line default + #line hidden +WriteLiteral(" \r\n"); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cs b/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cs index 2ccece2..d652c17 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cs @@ -2,21 +2,22 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; +using DotNetCore.CAP.Monitoring; namespace DotNetCore.CAP.Dashboard.Pages { - internal partial class PublishedPage + internal partial class PublishedPage : DotNetCore.CAP.Dashboard.RazorPage { public PublishedPage(string statusName) { - StatusName = statusName; + Name = statusName; } - public string StatusName { get; set; } + public string Name { get; set; } public int GetTotal(IMonitoringApi api) { - if (string.Equals(StatusName, Infrastructure.StatusName.Succeeded, + if (string.Equals(Name, nameof(Internal.StatusName.Succeeded), StringComparison.CurrentCultureIgnoreCase)) { return api.PublishedSucceededCount(); diff --git a/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cshtml b/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cshtml index d4313db..dba410f 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cshtml +++ b/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.cshtml @@ -1,10 +1,10 @@ @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@ @using System @using DotNetCore.CAP.Dashboard -@using DotNetCore.CAP.Dashboard.Monitoring @using DotNetCore.CAP.Dashboard.Pages @using DotNetCore.CAP.Dashboard.Resources @using DotNetCore.CAP.Messages +@using DotNetCore.CAP.Monitoring @inherits DotNetCore.CAP.Dashboard.RazorPage @{ Layout = new LayoutPage(Strings.PublishedMessagesPage_Title); @@ -23,7 +23,7 @@ MessageType = MessageType.Publish, Name = name, Content = content, - StatusName = StatusName, + StatusName = Name, CurrentPage = pager.CurrentPage - 1, PageSize = pager.RecordsPerPage }; @@ -84,7 +84,7 @@ @Strings.Common_Version @Strings.MessagesPage_Table_Name @Strings.MessagesPage_Table_Retries - @if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) + @if (string.Equals(Name, "Processing", StringComparison.CurrentCultureIgnoreCase)) { @Strings.MessagesPage_Table_State } @@ -110,7 +110,7 @@ @message.Retries - @if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) + @if (string.Equals(Name, "Processing", StringComparison.CurrentCultureIgnoreCase)) { @message.StatusName diff --git a/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.generated.cs index 250c6c8..8d2bee3 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/PublishedPage.generated.cs @@ -1,6 +1,4 @@ -using DotNetCore.CAP.Messages; - -#pragma warning disable 1591 +#pragma warning disable 1591 //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -13,567 +11,581 @@ namespace DotNetCore.CAP.Dashboard.Pages { - -#line 2 "..\..\PublishedPage.cshtml" + + #line 2 "..\..\Pages\PublishedPage.cshtml" using System; - -#line default -#line hidden + + #line default + #line hidden using System.Collections.Generic; using System.Linq; using System.Text; - -#line 4 "..\..\PublishedPage.cshtml" + + #line 3 "..\..\Pages\PublishedPage.cshtml" using DotNetCore.CAP.Dashboard; - -#line default -#line hidden - -#line 6 "..\..\PublishedPage.cshtml" - using DotNetCore.CAP.Dashboard.Monitoring; - -#line default -#line hidden - -#line 5 "..\..\PublishedPage.cshtml" + + #line default + #line hidden + + #line 4 "..\..\Pages\PublishedPage.cshtml" using DotNetCore.CAP.Dashboard.Pages; - -#line default -#line hidden - -#line 7 "..\..\PublishedPage.cshtml" + + #line default + #line hidden + + #line 5 "..\..\Pages\PublishedPage.cshtml" using DotNetCore.CAP.Dashboard.Resources; - -#line default -#line hidden - -#line 3 "..\..\PublishedPage.cshtml" - -#line default -#line hidden - + + #line default + #line hidden + + #line 6 "..\..\Pages\PublishedPage.cshtml" + using DotNetCore.CAP.Messages; + + #line default + #line hidden + + #line 7 "..\..\Pages\PublishedPage.cshtml" + using DotNetCore.CAP.Monitoring; + + #line default + #line hidden + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class PublishedPage : RazorPage + internal partial class PublishedPage : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { - WriteLiteral("\r\n"); - - - - - - - - - - -#line 9 "..\..\PublishedPage.cshtml" - - Layout = new LayoutPage(Strings.PublishedMessagesPage_Title); - - int from, perPage; - - int.TryParse(Query("from"), out from); - int.TryParse(Query("count"), out perPage); - string name = Query("name"); - string content = Query("content"); - - var monitor = Storage.GetMonitoringApi(); - var pager = new Pager(from, perPage, GetTotal(monitor)); - var queryDto = new MessageQueryDto - { - MessageType = MessageType.Publish, - Name = name, - Content = content, - StatusName = StatusName, - CurrentPage = pager.CurrentPage - 1, - PageSize = pager.RecordsPerPage - }; - var succeededMessages = monitor.Messages(queryDto); - - - -#line default -#line hidden - WriteLiteral("\r\n
    \r\n
    \r\n "); - - - -#line 35 "..\..\PublishedPage.cshtml" - Write(Html.MessagesSidebar(MessageType.Publish)); - - -#line default -#line hidden - WriteLiteral("\r\n
    \r\n
    \r\n

    "); - +WriteLiteral("\r\n"); -#line 38 "..\..\PublishedPage.cshtml" - Write(Strings.PublishedPage_Title); -#line default -#line hidden - WriteLiteral("

    \r\n\r\n"); -#line 40 "..\..\PublishedPage.cshtml" - if (succeededMessages.Count == 0) - { -#line default -#line hidden - WriteLiteral("
    \r\n "); + + #line 9 "..\..\Pages\PublishedPage.cshtml" + + Layout = new LayoutPage(Strings.PublishedMessagesPage_Title); + int from, perPage; + int.TryParse(Query("from"), out from); + int.TryParse(Query("count"), out perPage); + var name = Query("name"); + var content = Query("content"); -#line 43 "..\..\PublishedPage.cshtml" - Write(Strings.MessagesPage_NoMessages); + var monitor = Storage.GetMonitoringApi(); + var pager = new Pager(from, perPage, GetTotal(monitor)); + var queryDto = new MessageQueryDto + { + MessageType = MessageType.Publish, + Name = name, + Content = content, + StatusName = Name, + CurrentPage = pager.CurrentPage - 1, + PageSize = pager.RecordsPerPage + }; + var succeededMessages = monitor.Messages(queryDto); -#line default -#line hidden - WriteLiteral("\r\n
    \r\n"); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n
    \r\n "); + + #line 35 "..\..\Pages\PublishedPage.cshtml" + Write(Html.MessagesSidebar(MessageType.Publish)); -#line 45 "..\..\PublishedPage.cshtml" - } - else - { + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n
    \r\n

    "); -#line default -#line hidden - WriteLiteral("
    \r\n
    \r\n
    \r\n
    \r\n \r\n\r\n"); -#line 52 "..\..\PublishedPage.cshtml" - Write(Query(" name")); + + #line 40 "..\..\Pages\PublishedPage.cshtml" + if (succeededMessages.Count == 0) + { + + #line default + #line hidden +WriteLiteral("
    \r\n "); -#line default -#line hidden - WriteLiteral("\" placeholder=\""); + + #line 43 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.MessagesPage_NoMessages); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n"); -#line 52 "..\..\PublishedPage.cshtml" - Write(Strings.MessagesPage_Query_MessageName); + + #line 45 "..\..\Pages\PublishedPage.cshtml" + } + else + { -#line default -#line hidden - WriteLiteral("\" />\r\n
    \r\n
    \r\n " + - "
    \r\n
    -
    -
    +
    + \r\n\r\n "); + + #line 70 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.Common_RequeueMessages); + + #line default + #line hidden +WriteLiteral("\r\n \r\n\r\n "); -#line 73 "..\..\PublishedPage.cshtml" - Write(Html.PerPageSelector(pager)); + + #line 73 "..\..\Pages\PublishedPage.cshtml" + Write(Html.PerPageSelector(pager)); -#line default -#line hidden - WriteLiteral(@" -
    + + #line default + #line hidden +WriteLiteral(@" +
    -
    - - +
    +
    + - - \r\n \r\n \r\n \r\n"); - - - -#line 86 "..\..\PublishedPage.cshtml" - if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) - { - - -#line default -#line hidden - WriteLiteral(" \r\n"); - - - -#line 89 "..\..\PublishedPage.cshtml" - } - - -#line default -#line hidden - WriteLiteral(" \r\n \r\n \r\n " + - " \r\n"); - - - -#line 94 "..\..\PublishedPage.cshtml" - foreach (var message in succeededMessages) - { - - -#line default -#line hidden - WriteLiteral(" \r\n " + - " \r\n \r\n \r\n \r\n \r\n"); - - - -#line 109 "..\..\PublishedPage.cshtml" - if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) - { - - -#line default -#line hidden - WriteLiteral(" \r\n \r\n"); -#line default -#line hidden - -#line 118 "..\..\PublishedPage.cshtml" - - } - - -#line default -#line hidden - WriteLiteral(" \r\n\r\n \r\n"); + + #line 90 "..\..\Pages\PublishedPage.cshtml" + } + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n " + +" \r\n"); -#line default -#line hidden - WriteLiteral(" \r\n
    - + + "); - - - -#line 83 "..\..\PublishedPage.cshtml" - Write(Strings.Common_Id); - - -#line default -#line hidden - WriteLiteral(""); - -#line 84 "..\..\PublishedPage.cshtml" - Write(Strings.Common_Version); - - -#line default -#line hidden - WriteLiteral(""); - -#line 84 "..\..\PublishedPage.cshtml" - Write(Strings.MessagesPage_Table_Name); - - -#line default -#line hidden - WriteLiteral(""); - - - -#line 85 "..\..\PublishedPage.cshtml" - Write(Strings.MessagesPage_Table_Retries); - - -#line default -#line hidden - WriteLiteral(""); - - - -#line 88 "..\..\PublishedPage.cshtml" - Write(Strings.MessagesPage_Table_State); - - -#line default -#line hidden - WriteLiteral(""); - - - -#line 90 "..\..\PublishedPage.cshtml" - Write(Strings.MessagesPage_Table_ExpiresAt); - - -#line default -#line hidden - WriteLiteral("
    \r\n \r\n \r\n "); + + #line 83 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.Common_Id); -#line 101 "..\..\PublishedPage.cshtml" - Write(message.Id); + + #line default + #line hidden +WriteLiteral(""); -#line default -#line hidden - WriteLiteral("\r\n \r\n \r\n " + - " "); - - -#line 102 "..\..\PublishedPage.cshtml" - Write(message.Version); - - -#line default -#line hidden - WriteLiteral("\r\n \r\n " + - " "); -#line 104 "..\..\PublishedPage.cshtml" - Write(message.Name); - - -#line default -#line hidden - WriteLiteral("\r\n \r\n " + - " "); - - - -#line 107 "..\..\PublishedPage.cshtml" - Write(message.Retries); - - -#line default -#line hidden - WriteLiteral("\r\n \r\n "); - + + #line 84 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.Common_Version); + + #line default + #line hidden +WriteLiteral("\r\n "); -#line 112 "..\..\PublishedPage.cshtml" - Write(message.StatusName); - - -#line default -#line hidden - WriteLiteral("\r\n \r\n"); + + #line 85 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.MessagesPage_Table_Name); + + #line default + #line hidden +WriteLiteral(""); -#line 114 "..\..\PublishedPage.cshtml" - } + + #line 86 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.MessagesPage_Table_Retries); -#line default -#line hidden - WriteLiteral(" \r\n"); + + #line default + #line hidden +WriteLiteral("\r\n"); + + #line 87 "..\..\Pages\PublishedPage.cshtml" + if (string.Equals(Name, "Processing", StringComparison.CurrentCultureIgnoreCase)) + { -#line 116 "..\..\PublishedPage.cshtml" - if (message.ExpiresAt.HasValue) - { + + #line default + #line hidden +WriteLiteral(" "); -#line default -#line hidden + + #line 89 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.MessagesPage_Table_State); -#line 118 "..\..\PublishedPage.cshtml" - Write(Html.RelativeTime(message.ExpiresAt.Value)); + + #line default + #line hidden +WriteLiteral("
    "); -#line 123 "..\..\PublishedPage.cshtml" - } + + #line 91 "..\..\Pages\PublishedPage.cshtml" + Write(Strings.MessagesPage_Table_ExpiresAt); + + #line default + #line hidden +WriteLiteral("
    \r\n
    \r\n " + - " "); + + #line 95 "..\..\Pages\PublishedPage.cshtml" + foreach (var message in succeededMessages) + { + + #line default + #line hidden +WriteLiteral(" \r\n " + +" \r\n \r\n"); + + #line default + #line hidden +WriteLiteral("\" />\r\n \r\n \r\n
    \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    <" + - "!-- /.modal -->\r\n
    \r\n"); + + #line 127 "..\..\Pages\PublishedPage.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n <" + +"/div>\r\n "); + + + + #line 131 "..\..\Pages\PublishedPage.cshtml" + Write(Html.Paginator(pager)); + + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n"); + + #line 133 "..\..\Pages\PublishedPage.cshtml" + + + + #line default + #line hidden +WriteLiteral(@"
    +
    +
    +
    +
    + +

    Message Content

    +
    +
    +
    +
    + \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n " + +"
    \r\n
    \r\n"); -#line 150 "..\..\PublishedPage.cshtml" - } + + #line 156 "..\..\Pages\PublishedPage.cshtml" + } -#line default -#line hidden - WriteLiteral("
    \r\n

    "); + + #line default + #line hidden +WriteLiteral("
    \r\n
    "); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cs b/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cs index 9090876..f8d4249 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; +using DotNetCore.CAP.Monitoring; namespace DotNetCore.CAP.Dashboard.Pages { @@ -16,7 +17,7 @@ namespace DotNetCore.CAP.Dashboard.Pages public int GetTotal(IMonitoringApi api) { - if (string.Equals(StatusName, Infrastructure.StatusName.Succeeded, + if (string.Equals(StatusName, nameof(Internal.StatusName.Succeeded), StringComparison.CurrentCultureIgnoreCase)) { return api.ReceivedSucceededCount(); diff --git a/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cshtml b/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cshtml index fb179cf..64affa5 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cshtml +++ b/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.cshtml @@ -1,10 +1,10 @@ @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@ @using System @using DotNetCore.CAP.Dashboard -@using DotNetCore.CAP.Dashboard.Monitoring @using DotNetCore.CAP.Dashboard.Pages @using DotNetCore.CAP.Dashboard.Resources @using DotNetCore.CAP.Messages +@using DotNetCore.CAP.Monitoring @inherits DotNetCore.CAP.Dashboard.RazorPage @{ Layout = new LayoutPage(Strings.ReceivedMessagesPage_Title); diff --git a/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.generated.cs index 17365c7..7683be2 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/ReceivedPage.generated.cs @@ -1,4 +1,4 @@ -using DotNetCore.CAP.Messages; +using DotNetCore.CAP.Monitoring; #pragma warning disable 1591 //------------------------------------------------------------------------------ @@ -13,58 +13,54 @@ namespace DotNetCore.CAP.Dashboard.Pages { - -#line 2 "..\..\ReceivedPage.cshtml" + + #line 2 "..\..\Pages\ReceivedPage.cshtml" using System; - -#line default -#line hidden + + #line default + #line hidden using System.Collections.Generic; using System.Linq; using System.Text; - -#line 4 "..\..\ReceivedPage.cshtml" + + #line 3 "..\..\Pages\ReceivedPage.cshtml" using DotNetCore.CAP.Dashboard; - -#line default -#line hidden - -#line 6 "..\..\ReceivedPage.cshtml" - using DotNetCore.CAP.Dashboard.Monitoring; - -#line default -#line hidden - -#line 5 "..\..\ReceivedPage.cshtml" + + #line default + #line hidden + + #line 4 "..\..\Pages\ReceivedPage.cshtml" +#line default + #line hidden + + #line 5 "..\..\Pages\ReceivedPage.cshtml" using DotNetCore.CAP.Dashboard.Pages; - -#line default -#line hidden - -#line 7 "..\..\ReceivedPage.cshtml" + + #line default + #line hidden + + #line 6 "..\..\Pages\ReceivedPage.cshtml" using DotNetCore.CAP.Dashboard.Resources; - -#line default -#line hidden - -#line 3 "..\..\ReceivedPage.cshtml" - -#line default -#line hidden - + + #line default + #line hidden + + #line 7 "..\..\Pages\ReceivedPage.cshtml" + using DotNetCore.CAP.Messages; + + #line default + #line hidden + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class ReceivedPage : RazorPage + internal partial class ReceivedPage : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { - WriteLiteral("\r\n"); - - - +WriteLiteral("\r\n"); @@ -72,169 +68,172 @@ namespace DotNetCore.CAP.Dashboard.Pages -#line 9 "..\..\ReceivedPage.cshtml" - Layout = new LayoutPage(Strings.ReceivedMessagesPage_Title); - int from, perPage; + + #line 9 "..\..\Pages\ReceivedPage.cshtml" + + Layout = new LayoutPage(Strings.ReceivedMessagesPage_Title); - int.TryParse(Query("from"), out from); - int.TryParse(Query("count"), out perPage); - string group = Query("group"); - string name = Query("name"); - string content = Query("content"); + int from, perPage; - var monitor = Storage.GetMonitoringApi(); - var pager = new Pager(from, perPage, GetTotal(monitor)); - var queryDto = new MessageQueryDto - { - MessageType = MessageType.Subscribe, - Group = group, - Name = name, - Content = content, - StatusName = StatusName, - CurrentPage = pager.CurrentPage - 1, - PageSize = pager.RecordsPerPage - }; - var succeededMessages = monitor.Messages(queryDto); + int.TryParse(Query("from"), out from); + int.TryParse(Query("count"), out perPage); + var group = Query("group"); + var name = Query("name"); + var content = Query("content"); + var monitor = Storage.GetMonitoringApi(); + var pager = new Pager(from, perPage, GetTotal(monitor)); + var queryDto = new MessageQueryDto + { + MessageType = MessageType.Subscribe, + Group = group, + Name = name, + Content = content, + StatusName = StatusName, + CurrentPage = pager.CurrentPage - 1, + PageSize = pager.RecordsPerPage + }; + var succeededMessages = monitor.Messages(queryDto); -#line default -#line hidden - WriteLiteral("\r\n
    \r\n
    \r\n "); - - - -#line 37 "..\..\ReceivedPage.cshtml" - Write(Html.MessagesSidebar(MessageType.Subscribe)); - - -#line default -#line hidden - WriteLiteral("\r\n
    \r\n
    \r\n

    "); - - - -#line 40 "..\..\ReceivedPage.cshtml" - Write(Strings.ReceivedPage_Title); - - -#line default -#line hidden - WriteLiteral("

    \r\n\r\n"); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n
    \r\n "); + + #line 37 "..\..\Pages\ReceivedPage.cshtml" + Write(Html.MessagesSidebar(MessageType.Subscribe)); -#line 42 "..\..\ReceivedPage.cshtml" - if (succeededMessages.Count == 0) - { + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n
    \r\n

    "); -#line default -#line hidden - WriteLiteral("
    \r\n "); + + #line 40 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.ReceivedPage_Title); + + #line default + #line hidden +WriteLiteral("

    \r\n\r\n"); -#line 45 "..\..\ReceivedPage.cshtml" - Write(Strings.MessagesPage_NoMessages); + + #line 42 "..\..\Pages\ReceivedPage.cshtml" + if (succeededMessages.Count == 0) + { + + #line default + #line hidden +WriteLiteral("
    \r\n "); -#line default -#line hidden - WriteLiteral("\r\n
    \r\n"); + + #line 45 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.MessagesPage_NoMessages); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n"); -#line 47 "..\..\ReceivedPage.cshtml" - } - else - { + + #line 47 "..\..\Pages\ReceivedPage.cshtml" + } + else + { -#line default -#line hidden - WriteLiteral(@"
    + + #line default + #line hidden +WriteLiteral(@"
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n " + - " \r\n
    \r\n
    \r\n
    \r\n " + +" \r\n \r\n " + - " + + #line default + #line hidden +WriteLiteral(@"
    @@ -245,388 +244,393 @@ namespace DotNetCore.CAP.Dashboard.Pages data-url="""); + + #line 71 "..\..\Pages\ReceivedPage.cshtml" + Write(Url.To("/received/requeue")); -#line 71 "..\..\ReceivedPage.cshtml" - Write(Url.To("/received/requeue")); + + #line default + #line hidden +WriteLiteral("\"\r\n data-loading-text=\""); -#line default -#line hidden - WriteLiteral("\"\r\n data-loading-text=\""); + + #line 72 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.Common_Enqueueing); + + #line default + #line hidden +WriteLiteral("\"\r\n disabled=\"disabled\">\r\n \r\n "); -#line 72 "..\..\ReceivedPage.cshtml" - Write(Strings.Common_Enqueueing); - - -#line default -#line hidden - WriteLiteral("\"\r\n disabled=\"disabled\">\r\n \r\n "); - - - -#line 75 "..\..\ReceivedPage.cshtml" - Write(Strings.Common_ReConsume); - - -#line default -#line hidden - WriteLiteral("\r\n \r\n\r\n "); + + #line 75 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.Common_ReConsume); + + #line default + #line hidden +WriteLiteral("\r\n \r\n\r\n "); -#line 78 "..\..\ReceivedPage.cshtml" - Write(Html.PerPageSelector(pager)); + + #line 78 "..\..\Pages\ReceivedPage.cshtml" + Write(Html.PerPageSelector(pager)); - -#line default -#line hidden - WriteLiteral(@" + + #line default + #line hidden +WriteLiteral(@"
    - - - + + \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"); -#line 90 "..\..\ReceivedPage.cshtml" - Write(Strings.MessagesPage_Table_Name); + + #line 93 "..\..\Pages\ReceivedPage.cshtml" + if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) + { -#line default -#line hidden - WriteLiteral("\r\n \r\n"); -#line default -#line hidden - WriteLiteral("\r\n"); + + #line 96 "..\..\Pages\ReceivedPage.cshtml" + } + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n " + +" \r\n"); -#line default -#line hidden - WriteLiteral(" \r\n " + +" \r\n \r\n \r\n " + - " \r\n"); - - - -#line 100 "..\..\ReceivedPage.cshtml" - foreach (var message in succeededMessages) - { - - -#line default -#line hidden - WriteLiteral(" \r\n " + - " \r\n " + - " \r\n " + - " \r\n " + - "\r\n " + - "\r\n \r\n"); + + #line default + #line hidden +WriteLiteral("\' class=\"openModal\">#"); + + #line 108 "..\..\Pages\ReceivedPage.cshtml" + Write(message.Id); -#line 118 "..\..\ReceivedPage.cshtml" - if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) - { + + #line default + #line hidden +WriteLiteral("\r\n \r\n \r\n \r\n"); + + #line default + #line hidden +WriteLiteral("\r\n \r\n \r\n \r\n"); -#line 125 "..\..\ReceivedPage.cshtml" - if (message.ExpiresAt.HasValue) - { + + #line 122 "..\..\Pages\ReceivedPage.cshtml" + if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) + { + + #line default + #line hidden +WriteLiteral(" \r\n"); -#line default -#line hidden -#line 127 "..\..\ReceivedPage.cshtml" + + #line 127 "..\..\Pages\ReceivedPage.cshtml" + } - } + + #line default + #line hidden +WriteLiteral(" \r\n\r\n \r\n"); + + #line 129 "..\..\Pages\ReceivedPage.cshtml" + if (message.ExpiresAt.HasValue) + { + + + #line default + #line hidden + + #line 131 "..\..\Pages\ReceivedPage.cshtml" + Write(Html.RelativeTime(message.ExpiresAt.Value)); + + #line default + #line hidden + + #line 131 "..\..\Pages\ReceivedPage.cshtml" + + } + + #line default + #line hidden +WriteLiteral(" \r\n\r\n \r\n"); -#line 132 "..\..\ReceivedPage.cshtml" - } + + #line 136 "..\..\Pages\ReceivedPage.cshtml" + } -#line default -#line hidden - WriteLiteral(" \r\n
    - - "); +
    + + "); + + #line 88 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.Common_Id); -#line 88 "..\..\ReceivedPage.cshtml" - Write(Strings.Common_Id); + + #line default + #line hidden +WriteLiteral(""); -#line default -#line hidden - WriteLiteral(""); + + #line 89 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.Common_Version); -#line 88 "..\..\ReceivedPage.cshtml" - Write(Strings.Common_Version); + + #line default + #line hidden +WriteLiteral(""); -#line default -#line hidden - WriteLiteral(""); + + #line 90 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.MessagesPage_Table_Group); + + #line default + #line hidden +WriteLiteral(""); -#line 89 "..\..\ReceivedPage.cshtml" - Write(Strings.MessagesPage_Table_Group); + + #line 91 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.MessagesPage_Table_Name); + + #line default + #line hidden +WriteLiteral(""); -#line default -#line hidden - WriteLiteral(""); + + #line 92 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.MessagesPage_Table_Retries); + + #line default + #line hidden +WriteLiteral(""); + + #line default + #line hidden +WriteLiteral(" "); + + #line 95 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.MessagesPage_Table_State); -#line 91 "..\..\ReceivedPage.cshtml" - Write(Strings.MessagesPage_Table_Retries); + + #line default + #line hidden +WriteLiteral(""); -#line 92 "..\..\ReceivedPage.cshtml" - if (string.Equals(StatusName, "Processing", StringComparison.CurrentCultureIgnoreCase)) - { + + #line 97 "..\..\Pages\ReceivedPage.cshtml" + Write(Strings.MessagesPage_Table_ExpiresAt); + + #line default + #line hidden +WriteLiteral("
    "); + + #line 101 "..\..\Pages\ReceivedPage.cshtml" + foreach (var message in succeededMessages) + { + + #line default + #line hidden +WriteLiteral("
    \r\n \r\n"); - - - -#line 95 "..\..\ReceivedPage.cshtml" - } - - -#line default -#line hidden - WriteLiteral(" "); - - - -#line 96 "..\..\ReceivedPage.cshtml" - Write(Strings.MessagesPage_Table_ExpiresAt); - - -#line default -#line hidden - WriteLiteral("
    \r\n \r\n \r\n \r\n \r\n "); - - - -#line 111 "..\..\ReceivedPage.cshtml" - Write(message.Version); - -#line default -#line hidden - WriteLiteral("\r\n \r\n "); - - -#line 110 "..\..\ReceivedPage.cshtml" - Write(message.Group); - - -#line default -#line hidden - WriteLiteral("\r\n \r\n "); + + #line default + #line hidden +WriteLiteral("\"/>\r\n \r\n \r\n "); - - - -#line 116 "..\..\ReceivedPage.cshtml" - Write(message.Retries); - - -#line default -#line hidden - WriteLiteral("\r\n " + +"\r\n "); -#line default -#line hidden - WriteLiteral(" \r\n " + - " "); - + + #line 111 "..\..\Pages\ReceivedPage.cshtml" + Write(message.Version); + + #line default + #line hidden +WriteLiteral("\r\n \r\n "); -#line 121 "..\..\ReceivedPage.cshtml" - Write(message.StatusName); + + #line 114 "..\..\Pages\ReceivedPage.cshtml" + Write(message.Group); -#line default -#line hidden - WriteLiteral("\r\n \r\n " + +" "); + + #line 117 "..\..\Pages\ReceivedPage.cshtml" + Write(message.Name); -#line 123 "..\..\ReceivedPage.cshtml" - } + + #line default + #line hidden +WriteLiteral("\r\n \r\n " + +" "); -#line default -#line hidden - WriteLiteral(" \r\n"); + + #line 120 "..\..\Pages\ReceivedPage.cshtml" + Write(message.Retries); + + #line default + #line hidden +WriteLiteral("\r\n \r\n " + +" "); -#line default -#line hidden -#line 127 "..\..\ReceivedPage.cshtml" - Write(Html.RelativeTime(message.ExpiresAt.Value)); + + #line 125 "..\..\Pages\ReceivedPage.cshtml" + Write(message.StatusName); + + #line default + #line hidden +WriteLiteral("\r\n \r\n"); -#line default -#line hidden - WriteLiteral("
    \r\n <" + - "/div>\r\n "); + + #line default + #line hidden +WriteLiteral(" \r\n \r\n <" + +"/div>\r\n "); + + #line 140 "..\..\Pages\ReceivedPage.cshtml" + Write(Html.Paginator(pager)); -#line 136 "..\..\ReceivedPage.cshtml" - Write(Html.Paginator(pager)); + + #line default + #line hidden +WriteLiteral("\r\n
    \r\n"); -#line default -#line hidden - WriteLiteral("\r\n
    \r\n"); + + #line 142 "..\..\Pages\ReceivedPage.cshtml" - -#line 138 "..\..\ReceivedPage.cshtml" - - - -#line default -#line hidden - WriteLiteral(@"
    + + #line default + #line hidden +WriteLiteral(@"
    - +

    Message Content

    -
    +
    \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n " + +"
    \r\n
    \r\n"); -#line default -#line hidden - WriteLiteral("\r\n \r\n
    \r\n
    \r\n
    \r\n " + - "
    \r\n
    \r\n"); - - - -#line 159 "..\..\ReceivedPage.cshtml" - } - + + #line 165 "..\..\Pages\ReceivedPage.cshtml" + } -#line default -#line hidden - WriteLiteral("
    \r\n
    "); + + #line default + #line hidden +WriteLiteral("
    \r\n"); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/SubscriberPage.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/SubscriberPage.generated.cs index ebec86b..a16d03a 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/SubscriberPage.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/SubscriberPage.generated.cs @@ -16,36 +16,30 @@ namespace DotNetCore.CAP.Dashboard.Pages 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" + #line 2 "..\..\Pages\SubscriberPage.cshtml" using DotNetCore.CAP.Dashboard.Pages; #line default #line hidden - #line 5 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 3 "..\..\Pages\SubscriberPage.cshtml" using DotNetCore.CAP.Dashboard.Resources; #line default #line hidden - #line 2 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 4 "..\..\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 + internal partial class SubscriberPage : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { @@ -56,9 +50,8 @@ WriteLiteral("\r\n"); - - #line 7 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 6 "..\..\Pages\SubscriberPage.cshtml" Layout = new LayoutPage(Strings.SubscribersPage_Title); @@ -74,7 +67,7 @@ WriteLiteral("\r\n
    \r\n
    \r\n - #line 16 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 15 "..\..\Pages\SubscriberPage.cshtml" Write(Strings.SubscribersPage_Title); @@ -84,7 +77,7 @@ WriteLiteral("\r\n\r\n"); - #line 18 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 17 "..\..\Pages\SubscriberPage.cshtml" if (subscribers.Count == 0) { @@ -95,7 +88,7 @@ WriteLiteral("
    \r\n - #line 21 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 20 "..\..\Pages\SubscriberPage.cshtml" Write(Strings.SubscribersPage_NoSubscribers); @@ -105,7 +98,7 @@ WriteLiteral("\r\n
    \r\n"); - #line 23 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 22 "..\..\Pages\SubscriberPage.cshtml" } else { @@ -114,77 +107,70 @@ WriteLiteral("\r\n
    \r\n"); #line default #line hidden WriteLiteral("
    \r\n \r\n \r\n \r\n " + -" \r\n \r\n " + +" \r\n \r\n \r\n \r\n \r\n \r\n \r\n " + -" \r\n"); +WriteLiteral("\r\n \r\n \r\n " + +" \r\n"); - #line 38 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - foreach (var subscriber in subscribers) + #line 37 "..\..\Pages\SubscriberPage.cshtml" + foreach (var subscriber in subscribers) + { + var i = 0; + var rowCount = subscriber.Value.Count; + foreach (var column in subscriber.Value) { - var i = 0; - var rowCount = subscriber.Value.Count; - - - #line default - #line hidden - - #line 42 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - foreach (var column in subscriber.Value) - { #line default #line hidden -WriteLiteral(" \r\n"); +WriteLiteral(" \r\n"); - #line 45 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - if (i == 0) - { + #line 44 "..\..\Pages\SubscriberPage.cshtml" + if (i == 0) + { #line default #line hidden -WriteLiteral(" \r\n"); - #line 48 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - } + #line 47 "..\..\Pages\SubscriberPage.cshtml" + } #line default #line hidden -WriteLiteral(" \r\n \r\n \r\n " + -" \r\n"); - +WriteLiteral("\r\n \r\n " + +" \r\n \r\n " + +" \r\n"); - #line 59 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - i++; - } + #line 58 "..\..\Pages\SubscriberPage.cshtml" + i++; } + } #line default @@ -261,7 +246,7 @@ WriteLiteral(" \r\n
    "); +"ubscribe-table\">\r\n
    "); - #line 30 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - Write(Strings.Common_Group); + #line 29 "..\..\Pages\SubscriberPage.cshtml" + Write(Strings.Common_Group); #line default #line hidden -WriteLiteral("\r\n " + -" "); +WriteLiteral("\r\n "); - #line 32 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - Write(Strings.Common_Name); + #line 31 "..\..\Pages\SubscriberPage.cshtml" + Write(Strings.Common_Name); #line default #line hidden -WriteLiteral("\r\n "); +WriteLiteral("\r\n "); - #line 34 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - Write(Strings.Common_Method); + #line 33 "..\..\Pages\SubscriberPage.cshtml" + Write(Strings.Common_Method); #line default #line hidden -WriteLiteral("
    "); - #line 47 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - Write(subscriber.Key); + #line 46 "..\..\Pages\SubscriberPage.cshtml" + Write(subscriber.Key); #line default @@ -203,56 +189,55 @@ WriteLiteral(""); +WriteLiteral(" "); - #line 49 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - Write(column.Attribute.Name); + #line 48 "..\..\Pages\SubscriberPage.cshtml" + Write(column.Attribute.Name); #line default #line hidden -WriteLiteral("\r\n " + -" "); +WriteLiteral("\r\n " + +""); - #line 51 "..\..\Dashboard\Pages\SubscriberPage.cshtml" - Write(column.ImplTypeInfo.Name); + #line 50 "..\..\Pages\SubscriberPage.cshtml" + Write(column.ImplTypeInfo.Name); #line default #line hidden -WriteLiteral(":\r\n
    \r" + -"\n \r\n " + -"
    ");
    +WriteLiteral(":\r\n                                    
    \r\n " + +" \r\n " + +"
    ");
     
     
                 
    -            #line 54 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
    -                                                Write(Html.MethodEscaped(column.MethodInfo));
    +            #line 53 "..\..\Pages\SubscriberPage.cshtml"
    +                                            Write(Html.MethodEscaped(column.MethodInfo));
     
                 
                 #line default
                 #line hidden
    -WriteLiteral("
    \r\n
    \r\n " + -"
    \r\n
    \r\n - #line 65 "..\..\Dashboard\Pages\SubscriberPage.cshtml" + #line 64 "..\..\Pages\SubscriberPage.cshtml" } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.cshtml b/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.cshtml index eacc619..96e1f2a 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.cshtml +++ b/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.cshtml @@ -1,17 +1,18 @@ @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ -@using DotNetCore.CAP.Dashboard @using DotNetCore.CAP.Dashboard.Resources -@inherits RazorPage + +@inherits DotNetCore.CAP.Dashboard.RazorPage @{ - var metric = DashboardMetric.Func(this); + + var metric = Metric.Func(this); var className = metric == null ? "metric-null" : metric.Style.ToClassName(); var highlighted = metric != null && metric.Highlighted ? "highlighted" : null; }
    -
    +
    @(metric?.Value)
    - @(Strings.ResourceManager.GetString(DashboardMetric.Title) ?? DashboardMetric.Title) + @(Strings.ResourceManager.GetString(Metric.Title) ?? Metric.Title)
    \ No newline at end of file diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.generated.cs index e29de0b..d6f3c3f 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_BlockMetric.generated.cs @@ -16,37 +16,33 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_BlockMetric.cshtml" - using DotNetCore.CAP.Dashboard; - - #line default - #line hidden - - #line 3 "..\..\Dashboard\Pages\_BlockMetric.cshtml" + #line 2 "..\..\Pages\_BlockMetric.cshtml" using DotNetCore.CAP.Dashboard.Resources; #line default #line hidden [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class BlockMetric : RazorPage + internal partial class BlockMetric : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { WriteLiteral("\r\n"); +WriteLiteral("\r\n"); - #line 5 "..\..\Dashboard\Pages\_BlockMetric.cshtml" + #line 5 "..\..\Pages\_BlockMetric.cshtml" - var metric = DashboardMetric.Func(this); + + var metric = Metric.Func(this); var className = metric == null ? "metric-null" : metric.Style.ToClassName(); var highlighted = metric != null && metric.Highlighted ? "highlighted" : null; @@ -58,7 +54,7 @@ WriteLiteral("
    \r\n
    \r\n "); - #line 12 "..\..\Dashboard\Pages\_BlockMetric.cshtml" + #line 13 "..\..\Pages\_BlockMetric.cshtml" Write(metric?.Value); @@ -98,8 +94,8 @@ WriteLiteral("\r\n
    \r\n
    \r\n - #line 15 "..\..\Dashboard\Pages\_BlockMetric.cshtml" - Write(Strings.ResourceManager.GetString(DashboardMetric.Title) ?? DashboardMetric.Title); + #line 16 "..\..\Pages\_BlockMetric.cshtml" + Write(Strings.ResourceManager.GetString(Metric.Title) ?? Metric.Title); #line default diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_Breadcrumbs.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_Breadcrumbs.generated.cs index ce63c17..cc77018 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_Breadcrumbs.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_Breadcrumbs.generated.cs @@ -16,51 +16,45 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" - using DotNetCore.CAP.Dashboard; - - #line default - #line hidden - [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class Breadcrumbs : RazorPage + internal partial class Breadcrumbs : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { WriteLiteral("\r\n"); - -WriteLiteral("\r\n
      \r\n
    1. \r\n
    2. \r\n
    3. \r\n"); +WriteLiteral("\">\r\n \r\n \r\n " + +" \r\n"); - #line 7 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + #line 10 "..\..\Pages\_Breadcrumbs.cshtml" foreach (var item in Items) { #line default #line hidden -WriteLiteral("
    4. \r\n "); - #line 9 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + #line 13 "..\..\Pages\_Breadcrumbs.cshtml" Write(item.Key); #line default #line hidden -WriteLiteral("
    5. \r\n"); +WriteLiteral("\r\n \r\n"); - #line 10 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + #line 15 "..\..\Pages\_Breadcrumbs.cshtml" } @@ -90,7 +84,7 @@ WriteLiteral("
    6. "); - #line 11 "..\..\Dashboard\Pages\_Breadcrumbs.cshtml" + #line 16 "..\..\Pages\_Breadcrumbs.cshtml" Write(Title); diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_InlineMetric.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_InlineMetric.generated.cs index 1f9fcd3..74c8c4f 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_InlineMetric.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_InlineMetric.generated.cs @@ -16,7 +16,7 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_InlineMetric.cshtml" + #line 2 "..\..\Pages\_InlineMetric.cshtml" using DotNetCore.CAP.Dashboard; #line default @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - protected override void Execute() + public override void Execute() { @@ -37,7 +37,7 @@ WriteLiteral("\r\n"); - #line 4 "..\..\Dashboard\Pages\_InlineMetric.cshtml" + #line 4 "..\..\Pages\_InlineMetric.cshtml" var metric = DashboardMetric.Func(this); var className = metric == null ? "metric-null" : metric.Style.ToClassName(); @@ -51,7 +51,7 @@ WriteLiteral(""); - #line 9 "..\..\Dashboard\Pages\_InlineMetric.cshtml" + #line 9 "..\..\Pages\_InlineMetric.cshtml" Write(metric?.Value); diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_Navigation.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_Navigation.generated.cs index 273d9eb..25b5ed3 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_Navigation.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_Navigation.generated.cs @@ -16,18 +16,18 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_Navigation.cshtml" + #line 2 "..\..\Pages\_Navigation.cshtml" using DotNetCore.CAP.Dashboard; #line default #line hidden [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class Navigation : RazorPage + internal partial class Navigation : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { @@ -37,7 +37,7 @@ WriteLiteral("\r\n"); - #line 4 "..\..\Dashboard\Pages\_Navigation.cshtml" + #line 4 "..\..\Pages\_Navigation.cshtml" if (NavigationMenu.Items.Count > 0) { @@ -48,12 +48,15 @@ WriteLiteral(" \r\n"); - #line 25 "..\..\Dashboard\Pages\_Navigation.cshtml" + #line 28 "..\..\Pages\_Navigation.cshtml" } #line default diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_Paginator.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_Paginator.generated.cs index 21fdf9c..c7d9e79 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_Paginator.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_Paginator.generated.cs @@ -16,24 +16,24 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 2 "..\..\Pages\_Paginator.cshtml" using DotNetCore.CAP.Dashboard; #line default #line hidden - #line 3 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 3 "..\..\Pages\_Paginator.cshtml" using DotNetCore.CAP.Dashboard.Resources; #line default #line hidden [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class Paginator : RazorPage + internal partial class Paginator : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { @@ -41,14 +41,12 @@ WriteLiteral("\r\n"); -WriteLiteral("\r\n"); - WriteLiteral("
      \r\n"); - #line 7 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 6 "..\..\Pages\_Paginator.cshtml" if (_pager.TotalPageCount > 1) { @@ -59,7 +57,7 @@ WriteLiteral("
      \r\n"); - #line 10 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 9 "..\..\Pages\_Paginator.cshtml" foreach (var page in _pager.PagerItems) { switch (page.Type) @@ -73,7 +71,7 @@ WriteLiteral(" \r\n "); - #line 16 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 15 "..\..\Pages\_Paginator.cshtml" Write(page.PageIndex); #line default #line hidden -WriteLiteral(" \r\n \r\n"); +WriteLiteral("\r\n \r\n"); - #line 18 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 17 "..\..\Pages\_Paginator.cshtml" break; case Pager.ItemType.NextPage: @@ -114,7 +112,7 @@ WriteLiteral(" \r\n "); - #line 21 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 20 "..\..\Pages\_Paginator.cshtml" Write(Strings.Paginator_Next); @@ -144,7 +142,7 @@ WriteLiteral("\r\n \r\n"); - #line 23 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 22 "..\..\Pages\_Paginator.cshtml" break; case Pager.ItemType.PrevPage: @@ -155,7 +153,7 @@ WriteLiteral(" \r\n "); - #line 26 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 25 "..\..\Pages\_Paginator.cshtml" Write(Strings.Paginator_Prev); @@ -185,7 +183,7 @@ WriteLiteral("\r\n \r\n"); - #line 28 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 27 "..\..\Pages\_Paginator.cshtml" break; case Pager.ItemType.MorePage: @@ -197,7 +195,7 @@ WriteLiteral("
      \r\n"); - #line 38 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 37 "..\..\Pages\_Paginator.cshtml" } @@ -223,7 +221,7 @@ WriteLiteral("\r\n
      \r\n "); - #line 41 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 40 "..\..\Pages\_Paginator.cshtml" Write(Strings.Paginator_TotalItems); @@ -233,13 +231,13 @@ WriteLiteral(": "); - #line 41 "..\..\Dashboard\Pages\_Paginator.cshtml" + #line 40 "..\..\Pages\_Paginator.cshtml" Write(_pager.TotalRecordCount); #line default #line hidden -WriteLiteral("\r\n
      \r\n
      \r\n"); +WriteLiteral("\r\n
    \r\n
    "); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_PerPageSelector.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_PerPageSelector.generated.cs index 931ab0d..ed07c62 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_PerPageSelector.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_PerPageSelector.generated.cs @@ -16,7 +16,7 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_PerPageSelector.cshtml" + #line 2 "..\..\Pages\_PerPageSelector.cshtml" using DotNetCore.CAP.Dashboard.Resources; #line default @@ -27,7 +27,7 @@ namespace DotNetCore.CAP.Dashboard.Pages { #line hidden - protected override void Execute() + public override void Execute() { @@ -35,69 +35,69 @@ WriteLiteral("\r\n"); -WriteLiteral("\r\n
    \r\n"); +WriteLiteral("\r\n\r\n
    \r\n
    \r\n "); +WriteLiteral("
    \r\n
    \r\n
    \r\n "); - #line 14 "..\..\Dashboard\Pages\_PerPageSelector.cshtml" - Write(Strings.PerPageSelector_ItemsPerPage); + #line 15 "..\..\Pages\_PerPageSelector.cshtml" +Write(Strings.PerPageSelector_ItemsPerPage); #line default #line hidden -WriteLiteral(":\r\n
    \r\n"); +WriteLiteral(":\r\n
    "); } diff --git a/src/DotNetCore.CAP.Dashboard/Pages/_SidebarMenu.generated.cs b/src/DotNetCore.CAP.Dashboard/Pages/_SidebarMenu.generated.cs index ca8e4ce..52577bd 100644 --- a/src/DotNetCore.CAP.Dashboard/Pages/_SidebarMenu.generated.cs +++ b/src/DotNetCore.CAP.Dashboard/Pages/_SidebarMenu.generated.cs @@ -16,18 +16,12 @@ namespace DotNetCore.CAP.Dashboard.Pages using System.Linq; using System.Text; - #line 2 "..\..\Dashboard\Pages\_SidebarMenu.cshtml" - using DotNetCore.CAP.Dashboard; - - #line default - #line hidden - [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] - internal partial class SidebarMenu : RazorPage + internal partial class SidebarMenu : DotNetCore.CAP.Dashboard.RazorPage { #line hidden - protected override void Execute() + public override void Execute() { @@ -35,9 +29,8 @@ WriteLiteral("\r\n"); - - #line 4 "..\..\Dashboard\Pages\_SidebarMenu.cshtml" + #line 3 "..\..\Pages\_SidebarMenu.cshtml" if (Items.Any()) { @@ -48,7 +41,7 @@ WriteLiteral(" \r\n"); - #line 21 "..\..\Dashboard\Pages\_SidebarMenu.cshtml" + #line 20 "..\..\Pages\_SidebarMenu.cshtml" } - #line default #line hidden diff --git a/src/DotNetCore.CAP.Dashboard/RazorPage.cs b/src/DotNetCore.CAP.Dashboard/RazorPage.cs index 616441d..acdf72a 100644 --- a/src/DotNetCore.CAP.Dashboard/RazorPage.cs +++ b/src/DotNetCore.CAP.Dashboard/RazorPage.cs @@ -5,9 +5,10 @@ using System; using System.Diagnostics; using System.Net; using System.Text; -using DotNetCore.CAP.Dashboard.Monitoring; +using DotNetCore.CAP.Dashboard.NodeDiscovery; using DotNetCore.CAP.Internal; -using DotNetCore.CAP.NodeDiscovery; +using DotNetCore.CAP.Monitoring; +using DotNetCore.CAP.Persistence; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP.Dashboard @@ -28,7 +29,7 @@ namespace DotNetCore.CAP.Dashboard protected HtmlHelper Html { get; } public UrlHelper Url { get; private set; } - protected IStorage Storage { get; set; } + protected IDataStorage Storage { get; set; } protected string AppPath { get; set; } protected string NodeName { get; set; } @@ -55,7 +56,7 @@ namespace DotNetCore.CAP.Dashboard public string RequestPath => Request.Path; /// - protected abstract void Execute(); + public abstract void Execute(); protected string Query(string key) { @@ -95,8 +96,7 @@ namespace DotNetCore.CAP.Dashboard _statisticsLazy = new Lazy(() => { - var monitoring = Storage.GetMonitoringApi(); - var dto = monitoring.GetStatistics(); + var dto = Storage.GetMonitoringApi().GetStatistics(); SetServersCount(dto); diff --git a/src/DotNetCore.CAP.MySql/MySqlDataStorage.cs b/src/DotNetCore.CAP.MySql/MySqlDataStorage.cs index f629203..e3b119d 100644 --- a/src/DotNetCore.CAP.MySql/MySqlDataStorage.cs +++ b/src/DotNetCore.CAP.MySql/MySqlDataStorage.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Dapper; using DotNetCore.CAP.Internal; using DotNetCore.CAP.Messages; +using DotNetCore.CAP.Monitoring; using DotNetCore.CAP.Persistence; using DotNetCore.CAP.Serialization; using Microsoft.EntityFrameworkCore.Storage; @@ -65,6 +66,7 @@ namespace DotNetCore.CAP.MySql { DbId = content.GetId(), Origin = content, + Content = StringSerializer.Serialize(content), Added = DateTime.Now, ExpiresAt = null, Retries = 0 @@ -74,7 +76,7 @@ namespace DotNetCore.CAP.MySql { Id = message.DbId, Name = name, - Content = StringSerializer.Serialize(message.Origin), + message.Content, message.Retries, message.Added, message.ExpiresAt, @@ -138,7 +140,7 @@ namespace DotNetCore.CAP.MySql var content = StringSerializer.Serialize(mdMessage.Origin); using (var connection = new MySqlConnection(_options.Value.ConnectionString)) { - + connection.Execute(sql, new { Id = mdMessage.DbId, @@ -212,24 +214,9 @@ namespace DotNetCore.CAP.MySql return result; } - //public Task GetPublishedMessageAsync(long id) - //{ - // var sql = $@"SELECT * FROM `{_prefix}.published` WHERE `Id`={id};"; - - // using (var connection = new MySqlConnection(Options.ConnectionString)) - // { - // return await connection.QueryFirstOrDefaultAsync(sql); - // } - //} - - //public Task GetReceivedMessageAsync(long id) - //{ - // var sql = - // $@"SELECT * FROM `{_prefix}.received` WHERE Id={id};"; - // using (var connection = new MySqlConnection(Options.ConnectionString)) - // { - // return await connection.QueryFirstOrDefaultAsync(sql); - // } - //} + public IMonitoringApi GetMonitoringApi() + { + return new MySqlMonitoringApi(_options); + } } } diff --git a/src/DotNetCore.CAP/Internal/Helper.cs b/src/DotNetCore.CAP/Internal/Helper.cs index a1084e2..078c740 100644 --- a/src/DotNetCore.CAP/Internal/Helper.cs +++ b/src/DotNetCore.CAP/Internal/Helper.cs @@ -9,6 +9,14 @@ namespace DotNetCore.CAP.Internal { public static class Helper { + private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local); + + public static long ToTimestamp(DateTime value) + { + var elapsedTime = value - Epoch; + return (long)elapsedTime.TotalSeconds; + } + public static bool IsController(TypeInfo typeInfo) { if (!typeInfo.IsClass) diff --git a/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs b/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs index f1ca395..ee12b00 100644 --- a/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs +++ b/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs @@ -8,7 +8,7 @@ using System.Linq; namespace DotNetCore.CAP.Internal { - internal class MethodMatcherCache + public class MethodMatcherCache { private readonly IConsumerServiceSelector _selector; diff --git a/src/DotNetCore.CAP/Persistence/IDataStorage.cs b/src/DotNetCore.CAP/Persistence/IDataStorage.cs index 9bdec2a..f7b9e42 100644 --- a/src/DotNetCore.CAP/Persistence/IDataStorage.cs +++ b/src/DotNetCore.CAP/Persistence/IDataStorage.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Internal; using DotNetCore.CAP.Messages; +using DotNetCore.CAP.Monitoring; namespace DotNetCore.CAP.Persistence { @@ -13,16 +14,21 @@ namespace DotNetCore.CAP.Persistence Task ChangeReceiveStateAsync(MediumMessage message, StatusName state); - Task StoreMessageAsync(string name, Message content, object dbTransaction = null, CancellationToken cancellationToken = default); + Task StoreMessageAsync(string name, Message content, object dbTransaction = null, + CancellationToken cancellationToken = default); Task StoreReceivedExceptionMessageAsync(string name, string group, string content); Task StoreReceivedMessageAsync(string name, string group, Message content); - Task DeleteExpiresAsync(string table, DateTime timeout, int batchCount = 1000, CancellationToken token = default); + Task DeleteExpiresAsync(string table, DateTime timeout, int batchCount = 1000, + CancellationToken token = default); Task> GetPublishedMessagesOfNeedRetry(); Task> GetReceivedMessagesOfNeedRetry(); + + //dashboard api + IMonitoringApi GetMonitoringApi(); } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Persistence/MediumMessage.cs b/src/DotNetCore.CAP/Persistence/MediumMessage.cs index 638f27d..f5ff86f 100644 --- a/src/DotNetCore.CAP/Persistence/MediumMessage.cs +++ b/src/DotNetCore.CAP/Persistence/MediumMessage.cs @@ -9,6 +9,8 @@ namespace DotNetCore.CAP.Persistence public Message Origin { get; set; } + public string Content { get; set; } + public DateTime Added { get; set; } public DateTime? ExpiresAt { get; set; }