From 6cf465cf7ca0e6a51ebf4ce85d28c9bb055dce1f Mon Sep 17 00:00:00 2001 From: GyroGearl00se Date: Sun, 11 Aug 2024 04:36:09 +0200 Subject: [PATCH] - added message size - queue browser (experimental) - added delete confirmation dialog - queue browser --- .gitignore | 4 ++- Components/Layout/MainLayout.razor | 5 ++-- Components/Pages/QueueBrowser.razor | 38 ++++++++++++++++++----------- Services/QueueBrowserService.cs | 32 ++++++++++++++++++------ SolaceWebClient.csproj | 2 ++ wwwroot/app.css | 4 +++ 6 files changed, 61 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index d148e8a..44fbc74 100644 --- a/.gitignore +++ b/.gitignore @@ -363,4 +363,6 @@ MigrationBackup/ FodyWeavers.xsd trustedca/* -!trustedca/.keep \ No newline at end of file +!trustedca/.keep + +presets/presets.json \ No newline at end of file diff --git a/Components/Layout/MainLayout.razor b/Components/Layout/MainLayout.razor index f44ed6d..67c6545 100644 --- a/Components/Layout/MainLayout.razor +++ b/Components/Layout/MainLayout.razor @@ -14,6 +14,8 @@ + +
- +
\ No newline at end of file diff --git a/Components/Pages/QueueBrowser.razor b/Components/Pages/QueueBrowser.razor index 275beac..de70e23 100644 --- a/Components/Pages/QueueBrowser.razor +++ b/Components/Pages/QueueBrowser.razor @@ -7,6 +7,7 @@ @inject Blazored.Toast.Services.IToastService toastService @inject NavigationManager Navigation @inject PresetService PresetService +@inject IMessageService MessageService Queue Browser @@ -104,6 +105,7 @@ +
@@ -195,24 +197,32 @@ private async Task DeleteMessage(long adMessageId) { - try + if (await MessageService.Confirm("Are you sure you want to delete message with ID: " + adMessageId + " ?", "Confirmation")) { - isDeleting = true; - deletingMessageId = adMessageId.ToString(); - await QueueBrowserService.DeleteMessage(host, vpnName, username, password, queueName, sslVerify, adMessageId); - toastService.ShowSuccess("Deleting message with ID: " + deletingMessageId); - await BrowseQueueAsync(); + try + { + isDeleting = true; + deletingMessageId = adMessageId.ToString(); + await QueueBrowserService.DeleteMessage(host, vpnName, username, password, queueName, sslVerify, adMessageId); + toastService.ShowSuccess("Deleting message with ID: " + deletingMessageId); + await BrowseQueueAsync(); + } + catch (SolaceSystems.Solclient.Messaging.OperationErrorException ex) + { + toastService.ShowError($"Error deleting Message: {ex.ErrorInfo}"); + } + finally + { + await Task.Delay(2000); + isDeleting = false; + deletingMessageId = ""; + } } - catch (SolaceSystems.Solclient.Messaging.OperationErrorException ex) + else { - toastService.ShowError($"Error deleting Message: {ex.ErrorInfo}"); - } - finally - { - await Task.Delay(2000); - isDeleting = false; - deletingMessageId = ""; + Console.WriteLine("Cancel Clicked"); } + } protected override async Task OnInitializedAsync() diff --git a/Services/QueueBrowserService.cs b/Services/QueueBrowserService.cs index e48bfe9..1cf6353 100644 --- a/Services/QueueBrowserService.cs +++ b/Services/QueueBrowserService.cs @@ -22,6 +22,7 @@ public class MessageDetails public string FormattedDateTime { get; set; } public Dictionary UserProperties { get; set; } public string DeliveryMode { get; set; } + public int Size { get; set; } } public class QueueBrowserService @@ -100,7 +101,7 @@ public async Task> BrowseQueueAsync(string host, string vpn if (message.SenderTimestamp == -1) { - formattedDateTime = "N/A"; + formattedDateTime = ""; } else { DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(message.SenderTimestamp); @@ -143,20 +144,37 @@ public async Task> BrowseQueueAsync(string host, string vpn messageContent = ""; } } + Console.WriteLine($"Message ID: {message.ADMessageId}"); + int messageSize = 0; + if (message.BinaryAttachment != null) + { + byte[] binaryAttachment = message.BinaryAttachment; + messageSize = binaryAttachment.Length; + } + else if (message.XmlContent != null) + { + messageSize = message.XmlContent.Length; + } + else if (SDTUtils.GetText(message) != null) + { + messageSize = SDTUtils.GetText(message).Length; + } + Console.WriteLine($"################# Message size: {messageSize.ToString("N0")} bytes"); messages.Add(new MessageDetails { - DestinationName = message.Destination.Name != null ? message.Destination.Name : "N/A", - ApplicationMessageType = message.ApplicationMessageType != null ? message.ApplicationMessageType : "N/A", - ApplicationMessageId = message.ApplicationMessageId != null ? message.ApplicationMessageId : "N/A", - SenderId = message.SenderId != null ? message.SenderId : "N/A", + DestinationName = message.Destination.Name != null ? message.Destination.Name : "", + ApplicationMessageType = message.ApplicationMessageType != null ? message.ApplicationMessageType : "", + ApplicationMessageId = message.ApplicationMessageId != null ? message.ApplicationMessageId : "", + SenderId = message.SenderId != null ? message.SenderId : "", MessageContent = messageContent, MessageContentXML = message.XmlContent != null ? System.Text.Encoding.ASCII.GetString(message.XmlContent) : "", - CorrelationId = message.CorrelationId != null ? message.CorrelationId : "N/A", + CorrelationId = message.CorrelationId != null ? message.CorrelationId : "", ADMessageId = message.ADMessageId != 0 ? message.ADMessageId : 0, FormattedDateTime = formattedDateTime, UserProperties = keyValuePairs, - DeliveryMode = message.DeliveryMode.ToString() + DeliveryMode = message.DeliveryMode.ToString(), + Size = messageSize }); messageCount++; } diff --git a/SolaceWebClient.csproj b/SolaceWebClient.csproj index 8bfbd55..cadcf5c 100644 --- a/SolaceWebClient.csproj +++ b/SolaceWebClient.csproj @@ -11,6 +11,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/wwwroot/app.css b/wwwroot/app.css index 9312e84..5a38e43 100644 --- a/wwwroot/app.css +++ b/wwwroot/app.css @@ -197,4 +197,8 @@ h1:focus { .checkbox-container { margin-left: 10px; white-space: nowrap; +} + +.modal-content { + background-color: #303030; } \ No newline at end of file