From 16800674bdfe9b83b90d357910de371b59f05662 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Wed, 11 Jul 2018 00:10:01 +0800 Subject: [PATCH] Fixed dashboard message page re-requeue and re-executed operate bug. (#158) --- .../Dashboard/DashboardRoutes.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs b/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs index 312da57..9a51faa 100644 --- a/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs +++ b/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs @@ -3,7 +3,7 @@ using System.Reflection; using DotNetCore.CAP.Dashboard.Pages; -using DotNetCore.CAP.Infrastructure; +using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP.Dashboard { @@ -83,24 +83,34 @@ namespace DotNetCore.CAP.Dashboard Routes.AddJsonResult("/published/message/(?.+)", x => { var id = int.Parse(x.UriMatch.Groups["Id"].Value); - var message = x.Storage.GetConnection().GetPublishedMessageAsync(id).GetAwaiter().GetResult(); + var message = x.Storage.GetConnection().GetPublishedMessageAsync(id) + .GetAwaiter().GetResult(); return message.Content; }); Routes.AddJsonResult("/received/message/(?.+)", x => { var id = int.Parse(x.UriMatch.Groups["Id"].Value); - var message = x.Storage.GetConnection().GetReceivedMessageAsync(id).GetAwaiter().GetResult(); + var message = x.Storage.GetConnection().GetReceivedMessageAsync(id) + .GetAwaiter().GetResult(); return message.Content; }); Routes.AddPublishBatchCommand( "/published/requeue", (client, messageId) => - client.Storage.GetConnection().ChangePublishedState(messageId, StatusName.Scheduled)); + { + var msg = client.Storage.GetConnection().GetPublishedMessageAsync(messageId) + .GetAwaiter().GetResult(); + client.RequestServices.GetService().EnqueueToPublish(msg); + }); Routes.AddPublishBatchCommand( "/received/requeue", (client, messageId) => - client.Storage.GetConnection().ChangeReceivedState(messageId, StatusName.Scheduled)); + { + var msg = client.Storage.GetConnection().GetReceivedMessageAsync(messageId) + .GetAwaiter().GetResult(); + client.RequestServices.GetService().EnqueueToExecute(msg); + }); Routes.AddRazorPage( "/published/(?.+)",