private async Task UpdateSteamPlayerInfo() { await Task.Run(async () => { Client client = new Client(SteamAPIKey); List<string> steamIds = Players.Select(player => player.SteamID.ToString()).ToList(); var banData = await client.GetPlayerBansAsync(steamIds); await client.GetPlayerSummariesAsync(steamIds).ContinueWith((players) => { if (players.Exception == null) { var result = players.Result.Value; foreach (SteamWeb.Models.Player player in result) { var gamePlayer = Players.FirstOrDefault(p => p.SteamID.ToString() == player.SteamID.ToString()); var bans = banData.Value.FirstOrDefault(p => p.SteamId.ToString() == player.SteamID.ToString()); if (gamePlayer == null) continue; gamePlayer.UpdateSteamPlayerData(player); if (bans != null) gamePlayer.UpdateSteamBansData(bans); } } }); }); }
private async Task UpdateSteamPlayerInfo() { if (string.IsNullOrWhiteSpace(App.ModelManager.Get<UserSettings>().GeneralSettings.SteamApiKey)) return; await Task.Run(async () => { Client client = new Client(App.ModelManager.Get<UserSettings>().GeneralSettings.SteamApiKey); List<string> steamIds = Players.Select(player => player.SteamID.ToString()).ToList(); await client.GetPlayerBansAsync(steamIds).ContinueWith(async (banData) => { if (banData.Exception == null) { await client.GetPlayerSummariesAsync(steamIds).ContinueWith((players) => { if (players.Exception == null) { var result = players.Result.Value; foreach (SteamWeb.Models.Player player in result) { try { var gamePlayer = Players.FirstOrDefault(p => p.SteamID.ToString() == player.SteamID.ToString()); var bans = banData.Result.Value.FirstOrDefault(p => p.SteamId.ToString() == player.SteamID.ToString()); if (gamePlayer == null) continue; gamePlayer.UpdateSteamPlayerData(player); if (bans != null) gamePlayer.UpdateSteamBansData(bans); } catch { } } } }); } }); }); }