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

@ -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));
}