Skip to content

Commit

Permalink
- added message size - queue browser (experimental)
Browse files Browse the repository at this point in the history
- added delete confirmation dialog - queue browser
  • Loading branch information
GyroGearl00se committed Aug 11, 2024
1 parent cc18aaa commit 6cf465c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,6 @@ MigrationBackup/
FodyWeavers.xsd

trustedca/*
!trustedca/.keep
!trustedca/.keep

presets/presets.json
5 changes: 3 additions & 2 deletions Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
</CloseButtonContent>
</BlazoredToasts>

<MessageProvider/>

<div class="page">
<div class="sidebar">
<NavMenu />
Expand All @@ -35,5 +37,4 @@
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

</div>
38 changes: 24 additions & 14 deletions Components/Pages/QueueBrowser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@inject Blazored.Toast.Services.IToastService toastService
@inject NavigationManager Navigation
@inject PresetService PresetService
@inject IMessageService MessageService

<Layout>
<Title>Queue Browser</Title>
Expand Down Expand Up @@ -104,6 +105,7 @@
<DataGridColumn TItem="MessageDetails" Field="ApplicationMessageType" Caption="Message Type" />
<DataGridColumn TItem="MessageDetails" Field="CorrelationId" Caption="Correlation ID" />
<DataGridColumn TItem="MessageDetails" Field="DeliveryMode" Caption="Delivery Mode" />
<DataGridNumericColumn TItem="MessageDetails" DisplayFormat="{0:N0}" Field="Size" Caption="Size in bytes (experimental)" />
</DataGridColumns>
<RowOverlayTemplate>
<Div>
Expand Down Expand Up @@ -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()
Expand Down
32 changes: 25 additions & 7 deletions Services/QueueBrowserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MessageDetails
public string FormattedDateTime { get; set; }
public Dictionary<string, object> UserProperties { get; set; }
public string DeliveryMode { get; set; }
public int Size { get; set; }
}

public class QueueBrowserService
Expand Down Expand Up @@ -100,7 +101,7 @@ public async Task<List<MessageDetails>> BrowseQueueAsync(string host, string vpn

if (message.SenderTimestamp == -1)
{
formattedDateTime = "N/A";
formattedDateTime = "";
} else
{
DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(message.SenderTimestamp);
Expand Down Expand Up @@ -143,20 +144,37 @@ public async Task<List<MessageDetails>> 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++;
}
Expand Down
2 changes: 2 additions & 0 deletions SolaceWebClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<ItemGroup>
<Content Remove="presets\example.json" />
<Content Remove="presets\presets.json" />
</ItemGroup>

<ItemGroup>
Expand All @@ -35,6 +36,7 @@
</ItemGroup>

<ItemGroup>
<None Include="presets\presets.json" />
<None Include="presets\example.json" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions wwwroot/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,8 @@ h1:focus {
.checkbox-container {
margin-left: 10px;
white-space: nowrap;
}

.modal-content {
background-color: #303030;
}

0 comments on commit 6cf465c

Please sign in to comment.