Remove test page

This commit is contained in:
2025-11-16 11:19:13 +09:00
parent 00fbba1401
commit 75ba19839e
4 changed files with 0 additions and 248 deletions

View File

@ -41,9 +41,6 @@
</AuthorizeView> </AuthorizeView>
<AuthorizeView Roles="@AppRole.ADMINISTRATOR_TYPE"> <AuthorizeView Roles="@AppRole.ADMINISTRATOR_TYPE">
<Authorized> <Authorized>
<RadzenPanelMenuItem Text="Тестирование" Icon="simulation">
<RadzenPanelMenuItem Path="/test/export" Text="Экспорт" />
</RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="Администрирование" Icon="admin_panel_settings"> <RadzenPanelMenuItem Text="Администрирование" Icon="admin_panel_settings">
<RadzenPanelMenuItem Path="/management/users" Text="Пользователи" /> <RadzenPanelMenuItem Path="/management/users" Text="Пользователи" />
</RadzenPanelMenuItem> </RadzenPanelMenuItem>

View File

@ -1,142 +0,0 @@
@page "/test/export"
@using Hcs.Broker
@using Hcs.Broker.Logger
@using Hcs.Broker.MessageCapturer
@using Hcs.Service.Async.Nsi
@using Hcs.WebApp.Config
@using Hcs.WebApp.Services
@using Hcs.WebApp.Utils
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize]
@implements IDisposable
@inject NavigationManager NavigationManager
@inject IConfiguration Configuration
@inject IClientProvider ClientProvider
<PageTitle>Тестирование экспорта</PageTitle>
<AuthorizedContent Roles="@AppRole.ADMINISTRATOR_TYPE">
<Content>
<RadzenSplitter Orientation="Orientation.Vertical" Style="height: 100%; border: 1px solid rgba(0,0,0,.08);">
<RadzenSplitterPane Size="200px">
<div style="height: 100%;overflow: auto;">
<RadzenCardGroup Responsive="true">
<RadzenCard Variant="Variant.Filled">
<RadzenStack JustifyContent="JustifyContent.SpaceBetween" Gap="1rem">
<RadzenStack Orientation="Orientation.Vertical" AlignItems="AlignItems.Start" JustifyContent="JustifyContent.Normal">
<RadzenText TextStyle="TextStyle.H6">Сервис nsi</RadzenText>
<RadzenButton Click="@OnNsiExportItem1ClickAsync" Disabled=@inputDisabled Text="Экспорт НСИ 1" ButtonStyle="ButtonStyle.Primary" />
</RadzenStack>
</RadzenStack>
</RadzenCard>
</RadzenCardGroup>
</div>
</RadzenSplitterPane>
<RadzenSplitterPane>
<RadzenTabs RenderMode="TabRenderMode.Client" Style="height: 100%;">
<Tabs>
<RadzenTabsItem Text="Запрос">
<RadzenTextArea @ref=@messageTextArea Value=@messageBody Disabled="true" ReadOnly="true" Style="resize: none; white-space: pre; overflow-wrap: normal; overflow-x: auto;" class="rz-w-stretch" />
</RadzenTabsItem>
<RadzenTabsItem Text="Результат">
<RadzenTextArea @ref=@responseTextArea Value=@responseBody Disabled="true" ReadOnly="true" Style="resize: none; white-space: pre; overflow-wrap: normal; overflow-x: auto;" class="rz-w-stretch" />
</RadzenTabsItem>
</Tabs>
</RadzenTabs>
</RadzenSplitterPane>
<RadzenSplitterPane Size="auto" Resizable="false">
<EventConsole @ref=@console />
</RadzenSplitterPane>
</RadzenSplitter>
</Content>
</AuthorizedContent>
@code {
EventConsole console = default!;
bool inputDisabled = false;
RadzenTextArea messageTextArea;
RadzenTextArea responseTextArea;
string messageBody;
string responseBody;
IClient client;
ActionLogger logger = new ActionLogger();
FileMessageCapturer messageCapturer;
bool catchMessageBody;
public void Dispose()
{
if (messageCapturer != null)
{
messageCapturer.OnFileWritten -= OnFileWritten;
}
}
void OnLog(string log)
{
console.Log(log);
}
void OnFileWritten(string fileName)
{
if (catchMessageBody)
{
catchMessageBody = false;
messageBody = XmlBeautifier.Beautify(File.ReadAllText(fileName));
messageTextArea.Rows = messageBody.Count(c => c.Equals('\n')) + 2;
}
}
async Task OnNsiExportItem1ClickAsync()
{
try
{
TryInitializeClient();
StartExport();
await client.Nsi.ExportDataProviderNsiItemAsync(exportDataProviderNsiItemRequestRegistryNumber.Item1);
EndExport();
}
catch
{
NavigationManager.NavigateTo("/error");
}
}
void TryInitializeClient()
{
if (client == null)
{
logger.OnWriteLine += OnLog;
messageCapturer = new FileMessageCapturer("test/export", logger);
messageCapturer.OnFileWritten += OnFileWritten;
var config = Configuration.GetSection("BrokerConfig").Get<BrokerConfig>();
client = ClientProvider.CreateClient(config, logger, messageCapturer);
}
}
void StartExport()
{
inputDisabled = true;
messageBody = string.Empty;
responseBody = string.Empty;
catchMessageBody = true;
console.Clear();
}
void EndExport()
{
inputDisabled = false;
responseBody = XmlBeautifier.Beautify(File.ReadAllText(messageCapturer.LastFileName));
responseTextArea.Rows = responseBody.Count(c => c.Equals('\n')) + 2;
}
}

View File

@ -1,74 +0,0 @@
@using System.Text.Json
@using System.Diagnostics.CodeAnalysis
@inject IJSRuntime JSRuntime
<RadzenCard Variant="Variant.Filled">
<RadzenStack Orientation="Orientation.Vertical" Gap="0.5rem" @attributes=@Attributes>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.SpaceBetween">
<RadzenText TextStyle="TextStyle.Subtitle1" TagName="TagName.P" class="rz-m-0">Логи</RadzenText>
<RadzenButton Click=@OnClearClick Text="Очистить" ButtonStyle="ButtonStyle.Base" Variant="Variant.Flat" Size="ButtonSize.Small" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Vertical" Gap="0" ID="event-console" class="rz-pt-1" Style="border-top: var(--rz-grid-cell-border); min-height: 2rem; max-height: 6rem; overflow: auto;">
@foreach (var message in messages)
{
<RadzenAlert ShowIcon="false" Variant="Variant.Flat" AlertStyle="message.AlertStyle" Size="AlertSize.ExtraSmall" Shade="Shade.Lighter" AllowClose="false" Style="font-size: 0.75rem;">
<span style="opacity: 0.6;">@message.Date.ToString("HH:mm:ss.ff")</span> @message.Text
</RadzenAlert>
}
</RadzenStack>
</RadzenStack>
</RadzenCard>
@code {
class Message
{
public DateTime Date { get; set; }
[AllowNull]
public string Text { get; set; }
public AlertStyle AlertStyle { get; set; }
}
[Parameter(CaptureUnmatchedValues = true)]
[AllowNull]
public IDictionary<string, object> Attributes { get; set; }
IList<Message> messages = new List<Message>();
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
{
await JSRuntime.InvokeVoidAsync("eval", $"document.getElementById('event-console').scrollTop = document.getElementById('event-console').scrollHeight");
}
}
void OnClearClick()
{
Clear();
}
public void Clear()
{
messages.Clear();
InvokeAsync(StateHasChanged);
}
public void Log(string message, AlertStyle alertStyle = AlertStyle.Info)
{
messages.Add(new Message
{
Date = DateTime.Now,
Text = message,
AlertStyle = alertStyle
});
InvokeAsync(StateHasChanged);
}
public void Log(object value)
{
Log(JsonSerializer.Serialize(value));
}
}

View File

@ -1,29 +0,0 @@
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace Hcs.WebApp.Utils
{
internal static class XmlBeautifier
{
internal static string Beautify(string xml)
{
var stringBuilder = new StringBuilder();
var settings = new XmlWriterSettings
{
OmitXmlDeclaration = true,
Indent = true,
NewLineOnAttributes = true
};
using (var xmlWriter = XmlWriter.Create(stringBuilder, settings))
{
var element = XElement.Parse(xml);
element.Save(xmlWriter);
}
return stringBuilder.ToString();
}
}
}