Add operation executor

This commit is contained in:
2025-10-25 20:30:49 +09:00
parent 59470b49d1
commit 891d462af1
19 changed files with 144 additions and 52 deletions

View File

@ -13,7 +13,7 @@
<Tabs>
<RadzenTabsItem Text="Пароль">
<div style="max-width: 420px">
<RadzenTemplateForm TItem="PasswordInputModel" Data=@PasswordInput Method="post" Submit="@ChangePassword">
<RadzenTemplateForm TItem="PasswordInputModel" Data=@PasswordInput Method="post" Submit="@ChangePasswordAsync">
<RadzenAlert AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" Visible="@hasError">
@errorMessage
</RadzenAlert>
@ -78,7 +78,7 @@
[SupplyParameterFromForm]
PasswordInputModel PasswordInput { get; set; } = new();
async Task ChangePassword()
async Task ChangePasswordAsync()
{
hasError = false;
hasSuccess = false;
@ -87,7 +87,7 @@
{
busyOverlay.Show();
await IdentityService.ChangePassword(PasswordInput.OldPassword, PasswordInput.NewPassword);
await IdentityService.ChangePasswordAsync(PasswordInput.OldPassword, PasswordInput.NewPassword);
hasSuccess = true;
}

View File

@ -24,7 +24,7 @@
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="6">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem">
<RadzenButton Icon="add_circle_outline" Text="Создать" Click="@AddUser" ButtonStyle="ButtonStyle.Primary" />
<RadzenButton Icon="add_circle_outline" Text="Создать" Click="@AddUserAsync" ButtonStyle="ButtonStyle.Primary" />
</RadzenStack>
</RadzenColumn>
</RadzenRow>
@ -33,7 +33,7 @@
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
@errorMessage
</RadzenAlert>
<RadzenDataGrid TItem="AppUserWithRole" Data="@usersWithRoles" RowSelect="@EditUser" IsLoading="@isLoading" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true">
<RadzenDataGrid TItem="AppUserWithRole" Data="@usersWithRoles" RowSelect="@EditUserAsync" IsLoading="@isLoading" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true">
<Columns>
<RadzenDataGridColumn TItem="AppUserWithRole" Property="User.UserName" Title="Логин" />
<RadzenDataGridColumn TItem="AppUserWithRole" Property="Role.Name" Title="Роль" />
@ -41,7 +41,7 @@
<Template Context="userWithRole">
@if (userWithRole.User.Id != currentUserId)
{
<RadzenButton Click="@(() => DeleteUser(userWithRole))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" />
<RadzenButton Click="@(() => DeleteUserAsync(userWithRole))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" />
}
</Template>
</RadzenDataGridColumn>
@ -74,7 +74,7 @@
if (state.User.IsInRole(AppRole.ADMINISTRATOR_TYPE))
{
currentUserId = state.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
usersWithRoles = await UsersService.GetUsersWithRole();
usersWithRoles = await UsersService.GetUsersWithRoleAsync();
}
isLoading = false;
@ -83,7 +83,7 @@
}
}
async Task AddUser()
async Task AddUserAsync()
{
var success = await DialogService.OpenAsync<AddUser>(
"Создание пользователя",
@ -98,11 +98,11 @@
if (success)
{
await UpdateGrid();
await UpdateGridAsync();
}
}
async Task EditUser(AppUserWithRole userWithRole)
async Task EditUserAsync(AppUserWithRole userWithRole)
{
var success = await DialogService.OpenAsync<EditUser>(
"Редактирование пользователя",
@ -122,11 +122,11 @@
if (success)
{
await UpdateGrid();
await UpdateGridAsync();
}
}
async Task DeleteUser(AppUserWithRole userWithRole)
async Task DeleteUserAsync(AppUserWithRole userWithRole)
{
try
{
@ -141,10 +141,10 @@
{
isLoading = true;
var result = await UsersService.DeleteUser(userWithRole.User.Id);
var result = await UsersService.DeleteUserAsync(userWithRole.User.Id);
if (result.Succeeded)
{
await UpdateGrid();
await UpdateGridAsync();
}
else
{
@ -162,12 +162,12 @@
}
}
async Task UpdateGrid()
async Task UpdateGridAsync()
{
isLoading = true;
hasError = false;
usersWithRoles = await UsersService.GetUsersWithRole();
usersWithRoles = await UsersService.GetUsersWithRoleAsync();
isLoading = false;
}

View File

@ -29,7 +29,7 @@
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="6">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem">
<RadzenButton Icon="sync" Text="@syncText" Disabled="@(state != CommonPageState.Idle)" Click="@SyncRegistries" ButtonStyle="ButtonStyle.Primary" />
<RadzenButton Icon="sync" Text="@syncText" Disabled="@(state != CommonPageState.Idle)" Click="@SyncRegistriesAsync" ButtonStyle="ButtonStyle.Primary" />
</RadzenStack>
</RadzenColumn>
</RadzenRow>
@ -38,14 +38,14 @@
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
@errorMessage
</RadzenAlert>
<RadzenDataGrid TItem="Registry" Data="@registries" RowSelect="@ViewRegistry" IsLoading="@(state != CommonPageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true">
<RadzenDataGrid TItem="Registry" Data="@registries" RowSelect="@ViewRegistryAsync" IsLoading="@(state != CommonPageState.Idle)" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true">
<Columns>
<RadzenDataGridColumn TItem="Registry" Property="Number" Title="Номер" />
<RadzenDataGridColumn TItem="Registry" Property="Name" Title="Название" />
<RadzenDataGridColumn TItem="Registry" Filterable="false" Sortable="false" TextAlign="TextAlign.Center" Width="70px">
<Template Context="registry">
<RadzenButton Click="@(() => EditRegistry(registry))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Primary" Icon="edit" Size="ButtonSize.Small" />
<RadzenButton Click="@(() => SyncRegistry(registry))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Primary" Icon="sync" Size="ButtonSize.Small" />
<RadzenButton Click="@(() => EditRegistryAsync(registry))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Primary" Icon="edit" Size="ButtonSize.Small" />
<RadzenButton Click="@(() => SyncRegistryAsync(registry))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Primary" Icon="sync" Size="ButtonSize.Small" />
</Template>
</RadzenDataGridColumn>
</Columns>
@ -83,14 +83,14 @@
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
if (state.User.IsInRole(AppRole.ADMINISTRATOR_TYPE) || state.User.IsInRole(AppRole.OPERATOR_TYPE))
{
var operationInProgress = await OperationService.HasActiveOperation(Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements);
var operationInProgress = await OperationService.HasActiveOperationAsync(Operation.OperationType.NsiCommon_15_7_0_1_ExportAllRegistryElements);
if (operationInProgress)
{
finalState = CommonPageState.OperationWaiting;
}
else
{
registries = await RegistryService.GetAllRegistries(true);
registries = await RegistryService.GetAllRegistriesAsync(true);
}
OperationExecutionState.OnOperationStarted += OnOperationStarted;
@ -100,34 +100,34 @@
}
}
async Task SyncRegistries()
async Task SyncRegistriesAsync()
{
if (state == CommonPageState.OperationWaiting) return;
ChangeState(CommonPageState.OperationWaiting);
if (await OperationService.HasActiveOperation(Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements))
if (await OperationService.HasActiveOperationAsync(Operation.OperationType.NsiCommon_15_7_0_1_ExportAllRegistryElements))
{
ChangeState(CommonPageState.Idle);
}
else
{
var operation = await OperationService.InitiateOperation(Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements, "");
var operation = await OperationService.InitiateOperationAsync(Operation.OperationType.NsiCommon_15_7_0_1_ExportAllRegistryElements, "");
OperationExecutionState.EnqueueOperation(operation);
}
}
async Task ViewRegistry(Registry userWithRole)
async Task ViewRegistryAsync(Registry userWithRole)
{
// TODO
}
async Task EditRegistry(Registry registry)
async Task EditRegistryAsync(Registry registry)
{
// TODO
}
async Task SyncRegistry(Registry registry)
async Task SyncRegistryAsync(Registry registry)
{
// TODO
}
@ -163,7 +163,7 @@
void OnOperationStarted(Operation operation)
{
if (operation.Type == Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements)
if (operation.Type == Operation.OperationType.NsiCommon_15_7_0_1_ExportAllRegistryElements)
{
InvokeAsync(() => ChangeState(CommonPageState.OperationWaiting));
}

View File

@ -29,7 +29,7 @@
<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()) Disabled=@inputDisabled Text="Экспорт НСИ 1" ButtonStyle="ButtonStyle.Primary" />
<RadzenButton Click="@OnNsiExportItem1ClickAsync" Disabled=@inputDisabled Text="Экспорт НСИ 1" ButtonStyle="ButtonStyle.Primary" />
</RadzenStack>
</RadzenStack>
</RadzenCard>
@ -92,7 +92,7 @@
}
}
async Task OnNsiExportItem1Click()
async Task OnNsiExportItem1ClickAsync()
{
try
{