private ItemOrdersHistogram GetPrice(int appid, string hashName) { var itemPageInfo = MarketInfoCache.Get(appid, hashName); if (itemPageInfo == null) { itemPageInfo = this.MarketClient.ItemPage(appid, hashName); MarketInfoCache.Cache(appid, hashName, itemPageInfo); } var attempts = 0; while (attempts < 3) { try { var histogram = this.MarketClient.ItemOrdersHistogramAsync(itemPageInfo.NameId).Result; return(histogram); } catch (Exception ex) { Logger.Log.Debug($"Error on getting price - {appid}-{hashName} - {ex.Message}", ex); if (++attempts == 3) { break; } } } return(null); }
private void MarketIdCacheClearButtonClick(object sender, EventArgs e) { try { if (!ConfirmationClearCacheWindow()) { return; } MarketInfoCache.Clear(); SetCacheCount(this.MarketIdCacheCountLable, GetCachedMarketIdsCount()); } catch (Exception ex) { Logger.Critical(ex); } }
public async Task <double?> GetCurrentPrice(int appid, string hashName) { var itemPageInfo = MarketInfoCache.Get(appid, hashName); if (itemPageInfo == null) { itemPageInfo = this.MarketClient.ItemPage(appid, hashName); MarketInfoCache.Cache(appid, hashName, itemPageInfo); } var attempts = 0; double?price = null; while (attempts < 3) { try { var histogram = await this.MarketClient.ItemOrdersHistogramAsync( itemPageInfo.NameId, "RU", ELanguage.Russian, 5); price = histogram.MinSellPrice; break; } catch (Exception ex) { if (++attempts == 3) { Logger.Warning($"Error on getting current price of {hashName}", ex); } } } return(price); }
private static int GetCachedMarketIdsCount() { return(MarketInfoCache.Get().Count); }