Start operation implementation
This commit is contained in:
@ -1,18 +1,22 @@
|
||||
@page "/registry/common"
|
||||
|
||||
@using System.IdentityModel.Claims
|
||||
@using Hcs.WebApp.BackgroundServices
|
||||
@using Hcs.WebApp.Components.Dialogs
|
||||
@using Hcs.WebApp.Services
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@attribute [Authorize]
|
||||
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject OperationService OperationService
|
||||
@inject RegistryService RegistryService
|
||||
@inject DialogService DialogService
|
||||
@inject OperationExecutionState OperationExecutionState
|
||||
|
||||
<PageTitle>Общие справочники подсистемы НСИ</PageTitle>
|
||||
|
||||
@ -74,7 +78,6 @@
|
||||
if (firstRender)
|
||||
{
|
||||
ChangeState(CommonPageState.Init);
|
||||
StateHasChanged();
|
||||
|
||||
var finalState = CommonPageState.Idle;
|
||||
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
@ -89,16 +92,29 @@
|
||||
{
|
||||
registries = await RegistryService.GetAllRegistries(true);
|
||||
}
|
||||
|
||||
OperationExecutionState.OnOperationStarted += OnOperationStarted;
|
||||
}
|
||||
|
||||
ChangeState(finalState);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
async Task SyncRegistries()
|
||||
{
|
||||
// TODO
|
||||
if (state == CommonPageState.OperationWaiting) return;
|
||||
|
||||
ChangeState(CommonPageState.OperationWaiting);
|
||||
|
||||
if (await OperationService.HasActiveOperation(Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements))
|
||||
{
|
||||
ChangeState(CommonPageState.Idle);
|
||||
}
|
||||
else
|
||||
{
|
||||
var operation = await OperationService.InitiateOperation(Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements, "");
|
||||
OperationExecutionState.EnqueueOperation(operation);
|
||||
}
|
||||
}
|
||||
|
||||
async Task ViewRegistry(Registry userWithRole)
|
||||
@ -118,9 +134,12 @@
|
||||
|
||||
void ChangeState(CommonPageState state)
|
||||
{
|
||||
if (this.state == state) return;
|
||||
|
||||
this.state = state;
|
||||
|
||||
SetSyncText();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void SetSyncText()
|
||||
@ -141,4 +160,17 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnOperationStarted(Operation operation)
|
||||
{
|
||||
if (operation.Type == Operation.OperationType.Nsi_15_7_0_1_ExportAllRegistryElements)
|
||||
{
|
||||
InvokeAsync(() => ChangeState(CommonPageState.OperationWaiting));
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
OperationExecutionState.OnOperationStarted -= OnOperationStarted;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user