Example #1
0
        public override async Task ProcessInScope(IServiceProvider serviceProvider)
        {
            Console.WriteLine($"Processing starts here at {DateTime.UtcNow:F}");
            await _csvDownloaderJob.DownloadFilesToBlobStorage();

            var provisionalResults = await _resultsAggregator.GetResults(ResultsType.Provisional);

            var partialResults = await _resultsAggregator.GetResults(ResultsType.Partial);

            var finalResults = await _resultsAggregator.GetResults(ResultsType.Final);

            await _hubContext.Clients.All.SendCoreAsync("results-updated", new[] { provisionalResults, partialResults, finalResults });
        }
Example #2
0
        private async Task SendUpdatedResults()
        {
            _logger.LogInformation($"Sending updated results");
            var provisionalResults = await _resultsAggregator.GetResults(ResultsType.Provisional);

            await _hubContext.Clients.All.SendAsync("results-updated", provisionalResults);
        }
        public async Task <ActionResult <LiveResultsResponse> > GetLatestResults([FromQuery] ResultsType type, string location)
        {
            try
            {
                var key    = $"results-{type.ConvertEnumToString()}-{location}";
                var result = await _appCache.GetOrAddAsync(
                    key, () => _resultsAggregator.GetResults(type, location), DateTimeOffset.Now.AddMinutes(5));

                if (result.IsFailure)
                {
                    _appCache.Remove(key);
                    _logger.LogError(result.Error);
                    return(BadRequest(result.Error));
                }
                return(result.Value);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception encountered while retrieving results");
                throw;
            }
        }
 public async Task <ElectionResultsData> GetLatestResults([FromQuery] ResultsType type)
 {
     return(await _resultsAggregator.GetResults(type));
 }