public async Task <SteamProfile> Get(string userName) { SteamManager.SteamAPIKey = "1E17298A1D3EEC9E33720A02FEAD5232"; var steamId = await SteamManager.GetSteamIDByName(userName); if (steamId != 0) { var profile = await SteamManager.GetSteamProfileByID(steamId); if (profile != null) { await SteamManager.LoadGamesForProfile(profile); } return(profile); } return(default(SteamProfile)); }
/// <summary> /// Processes the queue message. /// </summary> /// <param name="appIdList">The asin list.</param> public static async Task ProcessQueueMessage([QueueTrigger("SteamQueue")] IList <int> appIdList) { Args.IsNotNull(() => appIdList); var userName = ConfigurationManager.AppSettings["SteamUserName"]; SteamManager.SteamAPIKey = ConfigurationManager.AppSettings["SteamApiKey"]; var steamId = await SteamManager.GetSteamIDByName(userName); if (steamId != 0) { var profile = await SteamManager.GetSteamProfileByID(steamId); if (profile != null) { await SteamManager.LoadGamesForProfile(profile); } } }
public SteamUser(string username) { Name = username; var task = new Task <Task>(async() => { Id = await SteamManager.GetSteamIDByName(Name); Program.Log.Information("{@Name} = {@Id}", Name, Id); await LoadGames(); }); try { task.Start(); task.Result.Wait(); } catch (Exception ex) { throw; } }
private async void AddUser(object sender, RoutedEventArgs e) { var name = HelperFunctions.FindChild <TextBox>(this, "UserName").Text; HelperFunctions.FindChild <TextBox>(this, "UserName").Text = ""; if (allGames == null) { allGames = await SteamManager.GetFullAppDictionary(); } long steamID; if (name.IsDigitsOnly() && name.Length == 17) { long.TryParse(name, out steamID); } else { steamID = await SteamManager.GetSteamIDByName(name); } if (steamID != 0) { var profile = await SteamManager.GetSteamProfileByID(steamID); if (profile != null) { await SteamManager.LoadGamesForProfile(profile); if (profile.Games.Count == 0) { } else if (games.Count == 0) { foreach (var game in profile.Games) { games.Add(game); } } else { games = games.Join(profile.Games.ToList(), la => la.App, lb => lb.App, (la, lb) => la).ToList(); } DataContext = null; var gameStringList = games.Select(game => game.App.Name + "\n").ToList(); gameStringList.Sort(); var gameString = gameStringList.Aggregate("", (current, str) => current + str); DataContext = gameString; profiles.Add(profile); foreach (var steamProfile in profiles.Where(steamProfile => !HelperFunctions.FindChild <TextBox>(this, "Users").Text.Contains(steamProfile.PersonaName))) { HelperFunctions.FindChild <TextBox>(this, "Users").Text += steamProfile.PersonaName + "\n"; } } else { MessageBox.Show(this, "No profile found for the id " + steamID); } } else { MessageBox.Show(this, "No Steam ID found for user " + name); } }