private async Task UpdateData() { try { if (LastDumpUpdateTimeUtc == DateTime.UnixEpoch) { await InitialUpdate(); } else { await _apiService.WaitForAction(NationStatesApiRequestType.DownloadDumps, TimeSpan.FromMinutes(30), tokenSource.Token); if (!tokenSource.Token.IsCancellationRequested) { IsUpdating = true; _logger.LogInformation(defaultEventId, GetLogMessage("--- Updating NATION and REGION collections from dumps ---")); await DowloadAndReadDumpsAsync(); } } _logger.LogInformation(defaultEventId, GetLogMessage("--- Dump Data Update Finished ---")); } catch (Exception ex) { _logger.LogCritical(defaultEventId, ex, GetLogMessage("A critical error occurred while processing of Dump Update")); } finally { IsUpdating = false; } }
private async Task GetNewNationsAsync() { var id = LogEventIdProvider.GetEventIdByType(LoggingEvent.GetNewNations); while (IsRecruiting) { try { await _apiService.WaitForAction(NationStatesApiRequestType.GetNewNations); PoolStatus = "Filling up with new nations"; var result = await _apiService.GetNewNationsAsync(id); await AddNationToPendingAsync(id, result, false); PoolStatus = "Waiting for new nations"; } catch (Exception ex) { _logger.LogError(id, ex, LogMessageBuilder.Build(id, "An error occured.")); } await Task.Delay(300000); } }