public DotaAssistansService() { webInterfaceFactory = new SteamWebInterfaceFactory(ConfigurationManager.AppSettings["steamWebApi"]); dotaEconInterface = webInterfaceFactory.CreateSteamWebInterface <DOTA2Econ>(new HttpClient()); GetHeroes(); GetItems(); }
public SteamCommandProcessor(string steamWebApiKey) { webInterfaceFactory = new SteamWebInterfaceFactory(steamWebApiKey); steamUserInterface = webInterfaceFactory.CreateSteamWebInterface <SteamUser>(httpClient); steamUserStatsInterface = webInterfaceFactory.CreateSteamWebInterface <SteamUserStats>(httpClient); steamIdContainer = webInterfaceFactory.CreateSteamWebInterface <SteamId>(httpClient); dota2EconInterface = webInterfaceFactory.CreateSteamWebInterface <DOTA2Econ>(httpClient); playerServiceInterface = webInterfaceFactory.CreateSteamWebInterface <PlayerService>(httpClient); steamNewsInterface = webInterfaceFactory.CreateSteamWebInterface <SteamNews>(httpClient); }
public async Task Run( [TimerTrigger("0 * * * * Sun", RunOnStartup = true)] TimerInfo myTimer, ExecutionContext context, ILogger log) { this.log = log; log.LogInformation($"Starting {nameof(CosmeticItemIconFunction)} function."); var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) // <- This gives you access to your application settings in your local development environment .AddEnvironmentVariables() // <- This is what actually gets you the application settings in Azure .Build(); string blobStorageConnectionString = config["BlobStorageConnectionString"]; blobServiceClient = new BlobServiceClient(blobStorageConnectionString); string steamWebApiKey = config["SteamWebApiKey"]; var steamWebInterfaceFactory = new SteamWebInterfaceFactory(steamWebApiKey); dota2Econ = steamWebInterfaceFactory.CreateSteamWebInterface <DOTA2Econ>(); log.LogInformation("Downloading latest schema file from blob storage."); // Get latest Dota 2 game schema (cosmetic items) var schema = await GetSchemaAsync(blobStorageConnectionString); log.LogInformation($"Starting to process {schema.Items.Count} items."); // For each item in schema HttpClient httpClient = new HttpClient(); foreach (var item in schema.Items) { // Get item icon from Steam Web API if (!string.IsNullOrWhiteSpace(item.ImageInventoryPath)) { log.LogInformation($"Starting to process {item.Name}"); string uploadFileName = $"{item.DefIndex}.jpg"; var blobContainerClient = blobServiceClient.GetBlobContainerClient(cosmeticItemIconStorageContainerName); var blobClient = blobContainerClient.GetBlockBlobClient(uploadFileName); try { if (!await blobClient.ExistsAsync()) { log.LogInformation($"Calling {nameof(GetItemIconFromSteamAsync)} for {item.ImageInventoryPath}."); var iconPng = await GetItemIconFromSteamAsync(httpClient, item.ImageInventoryPath); log.LogInformation($"Converting from JPG --> PNG."); var iconJpg = ConvertPngToJpg(iconPng); log.LogInformation($"Calling {nameof(UploadItemIconToBlobStorageAsync)} for {uploadFileName}."); await UploadItemIconToBlobStorageAsync(uploadFileName, iconJpg); await Task.Delay(TimeSpan.FromSeconds(5)); } else { log.LogInformation($"{uploadFileName} already exists in blob storage. Skipping."); await Task.Delay(TimeSpan.FromMilliseconds(500)); } } catch (Exception ex) { log.LogError(ex, ex.Message); await Task.Delay(TimeSpan.FromSeconds(5)); } } } log.LogInformation("Done."); }
public DOTA2EconTests() { steamInterface = factory.CreateSteamWebInterface <DOTA2Econ>(new HttpClient()); }