public async Task <bool> WouldReceiveTelegram(string nationName) { XmlDocument result = await _apiService.GetWouldReceiveTelegramAsync(nationName); if (result != null) { XmlNodeList canRecruitNodeList = result.GetElementsByTagName("TGCANRECRUIT"); return(canRecruitNodeList[0].InnerText == "1"); } else { var id = LogEventIdProvider.GetEventIdByType(LoggingEvent.WouldReceiveTelegram); _logger.LogWarning(id, LogMessageBuilder.Build(id, $"Result of GetWouldReceiveTelegramAsync '{nationName}' were null")); return(false); } }
public async Task <int> WouldReceiveTelegramAsync(Nation nation, EventId id) { try { await _dumpDataService.WaitForDataAvailabilityAsync(); if (nation.StatusTime < DumpDataService.LastDumpUpdateTimeUtc) { var exists = await _dumpDataService.DoesNationExistInDumpAsync(nation.Name); if (!exists) { _logger.LogDebug(id, LogMessageBuilder.Build(id, $"Nation {nation.Name} probably CTEd according to Dump. Skipped.")); return(0); } } XmlDocument result = await _apiService.GetWouldReceiveTelegramAsync(nation.Name); if (result != null) { XmlNodeList canRecruitNodeList = result.GetElementsByTagName("TGCANRECRUIT"); return(canRecruitNodeList[0].InnerText == "1" ? 1 : 0); } else { _logger.LogDebug(id, LogMessageBuilder.Build(id, $" WouldReceive -> '{nation.Name}' => null. Skipped.")); return(0); } } catch (Exception ex) { _logger.LogError(id, ex, LogMessageBuilder.Build(id, $"GetWouldReceiveTelegramAsync '{nation.Name}' failed.")); return(2); } }