Add export test page
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<RadzenComponents @rendermode="InteractiveServer" />
|
||||
|
||||
<RadzenLayout Style="grid-template-areas: 'rz-sidebar rz-header' 'rz-sidebar rz-body'">
|
||||
@ -11,13 +13,14 @@
|
||||
</RadzenHeader>
|
||||
<RadzenSidebar @bind-Expanded="@sidebarExpanded">
|
||||
<RadzenPanelMenu>
|
||||
<RadzenPanelMenuItem Text="Главная" Icon="home" />
|
||||
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/"))" Text="Главная" Icon="home" />
|
||||
<RadzenPanelMenuItem Text="Тестирование" Icon="simulation">
|
||||
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/test/export"))" Text="Экспорт" Icon="arrow_outward" />
|
||||
</RadzenPanelMenuItem>
|
||||
</RadzenPanelMenu>
|
||||
</RadzenSidebar>
|
||||
<RadzenBody>
|
||||
<div class="rz-p-4">
|
||||
@Body
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
Произошла непредвиденная ошибка
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
|
||||
<PageTitle>Ошибка</PageTitle>
|
||||
|
||||
<h1 class="text-danger">Ошибка</h1>
|
||||
<h2 class="text-danger">При выполнении запроса возникла ошибка</h2>
|
||||
|
||||
@if (ShowRequestId)
|
||||
|
||||
@ -1,12 +1,3 @@
|
||||
@page "/"
|
||||
|
||||
<PageTitle>Главная</PageTitle>
|
||||
|
||||
<RadzenButton Click="@ButtonClicked" Text="Нажми меня"></RadzenButton>
|
||||
|
||||
@code {
|
||||
void ButtonClicked()
|
||||
{
|
||||
Console.WriteLine("Кнопка нажата");
|
||||
}
|
||||
}
|
||||
|
||||
74
Hcs.WebApp/Components/Pages/Test/Export.razor
Normal file
74
Hcs.WebApp/Components/Pages/Test/Export.razor
Normal file
@ -0,0 +1,74 @@
|
||||
@page "/test/export"
|
||||
|
||||
@using Hcs.Client
|
||||
@using Hcs.Client.Logger
|
||||
@using Hcs.Client.MessageCapturer
|
||||
@using Hcs.Service.Async.Nsi
|
||||
@using Hcs.WebApp.Components.Shared
|
||||
|
||||
<PageTitle>Тестирование экспорта</PageTitle>
|
||||
|
||||
<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=@(() => OnNsiExportItem1Click()) Text="Экспорт НСИ 1" ButtonStyle="ButtonStyle.Primary" />
|
||||
</RadzenStack>
|
||||
</RadzenStack>
|
||||
</RadzenCard>
|
||||
</RadzenCardGroup>
|
||||
</div>
|
||||
</RadzenSplitterPane>
|
||||
<RadzenSplitterPane>
|
||||
<RadzenTabs RenderMode="TabRenderMode.Client" Style="height: 100%;">
|
||||
<Tabs>
|
||||
<RadzenTabsItem Text="Запрос">
|
||||
</RadzenTabsItem>
|
||||
<RadzenTabsItem Text="Результат">
|
||||
</RadzenTabsItem>
|
||||
</Tabs>
|
||||
</RadzenTabs>
|
||||
</RadzenSplitterPane>
|
||||
<RadzenSplitterPane Size="auto" Resizable="false">
|
||||
<EventConsole @ref=@console />
|
||||
</RadzenSplitterPane>
|
||||
</RadzenSplitter>
|
||||
|
||||
@code {
|
||||
EventConsole console = default!;
|
||||
ActionLogger logger = new ActionLogger();
|
||||
UniClient client;
|
||||
|
||||
public Export()
|
||||
{
|
||||
logger.OnWriteLine += OnLog;
|
||||
|
||||
client = new UniClient
|
||||
{
|
||||
OrgPPAGUID = "ccd7fa02-a2bf-428a-984b-faef69ae0eb2",
|
||||
ExecutorGUID = "ccd7fa02-a2bf-428a-984b-faef69ae0eb2",
|
||||
UseTunnel = false,
|
||||
IsPPAK = false,
|
||||
Role = OrganizationRole.RSO,
|
||||
Logger = logger,
|
||||
MessageCapturer = new FileMessageCapturer(null, logger)
|
||||
};
|
||||
|
||||
var cert = client.FindCertificate(x => x.SerialNumber == "0636D2330032B3C38A4A26D765C787C248");
|
||||
client.SetSigningCertificate(cert);
|
||||
}
|
||||
|
||||
void OnLog(string log)
|
||||
{
|
||||
console.Log(log);
|
||||
}
|
||||
|
||||
void OnNsiExportItem1Click()
|
||||
{
|
||||
client.Nsi.ExportDataProviderNsiItemAsync(exportDataProviderNsiItemRequestRegistryNumber.Item1);
|
||||
}
|
||||
}
|
||||
75
Hcs.WebApp/Components/Shared/EventConsole.razor
Normal file
75
Hcs.WebApp/Components/Shared/EventConsole.razor
Normal file
@ -0,0 +1,75 @@
|
||||
@using Radzen
|
||||
@using System.Text.Json
|
||||
@using System.Diagnostics.CodeAnalysis
|
||||
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<RadzenCard Variant="Variant.Filled" class="rz-mt-4">
|
||||
<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));
|
||||
}
|
||||
}
|
||||
@ -14,4 +14,8 @@
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hcs.Client\Hcs.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user