private async Task SetButtonStates(CancellationToken cancellationToken) { var period = await _periodService.ReturnPeriod(CollectionType, cancellationToken); var periodClosed = period.PeriodClosed; string stateString = await _periodEndService.GetPathItemStatesAsync(period.Year.Value, period.Period, CollectionType, cancellationToken); var state = _stateService.GetMainState(stateString); var startEnabled = periodClosed && !state.PeriodEndStarted; if (PeriodEndState.CurrentAction != Constants.Action_StartPeriodEndButton) { await _hubContext.Clients.All.SendAsync(Constants.Action_StartPeriodEndButton, startEnabled, cancellationToken); } if (PeriodEndState.CurrentAction != Constants.Action_MCAReportsButton) { var mcaEnabled = periodClosed && !startEnabled && !state.McaReportsPublished && state.McaReportsReady; await _hubContext.Clients.All.SendAsync(Constants.Action_MCAReportsButton, mcaEnabled, cancellationToken); } if (PeriodEndState.CurrentAction != Constants.Action_ProviderReportsButton) { var providerEnabled = periodClosed && !state.ProviderReportsPublished && state.ProviderReportsReady; await _hubContext.Clients.All.SendAsync(Constants.Action_ProviderReportsButton, providerEnabled, cancellationToken); } if (PeriodEndState.CurrentAction != Constants.Action_PeriodClosedButton) { var closeEnabled = periodClosed && !state.PeriodEndFinished && state.McaReportsPublished && state.ProviderReportsPublished; await _hubContext.Clients.All.SendAsync(Constants.Action_PeriodClosedButton, closeEnabled, cancellationToken); } }
protected override async Task DoWork(CancellationToken cancellationToken) { try { // Get state JSON. string pathItemStates = await _periodEndService.GetPathItemStatesAsync(null, null, CollectionTypes.ILR, cancellationToken); // Send JSON to clients. await _periodEndHub.SendMessage(pathItemStates, cancellationToken); } catch (Exception ex) { _logger.LogError($"Failed to {nameof(DoWork)} in {nameof(PeriodEndTimedHostedService)}", ex); } }
private async Task <PeriodEndViewModel> ShowPath(int collectionYear, int period) { var pathItemStates = await _periodEndService.GetPathItemStatesAsync(collectionYear, period, CollectionTypes.ILR); var state = _stateService.GetMainState(pathItemStates); var pathModel = new PeriodEndViewModel { Period = period, Year = collectionYear, Paths = state.Paths, CollectionClosed = state.CollectionClosed, PeriodEndStarted = state.PeriodEndStarted, McaReportsReady = state.McaReportsReady, McaReportsPublished = state.McaReportsPublished, ProviderReportsReady = state.ProviderReportsReady, ProviderReportsPublished = state.ProviderReportsPublished, PeriodEndFinished = state.PeriodEndFinished, ReferenceDataJobsPaused = state.ReferenceDataJobsPaused }; return(pathModel); }