private void CheckPrice(out PriceDate pd, out string prefix, out string suffix) { pd = null; prefix = suffix = ""; try { string response = HelpFunctions.LoadPage(ITEM_JSON_LINK); if (response == "" || response == "[]") { SetToolTipUpdate($"{DateTime.Now} empty json"); } else { MarketResponse resp = JsonConvert.DeserializeObject <MarketResponse>(response); if (resp != null && resp.success) { if (resp.sog != null && resp.sog.Count > 0) { prefix = resp.price_prefix; suffix = resp.price_suffix; pd = new PriceDate(double.Parse(resp.sog[0][0], CultureInfo.InvariantCulture), DateTime.Now); SetToolTipUpdate($"{DateTime.Now} success updated"); } } else { SetToolTipUpdate($"{DateTime.Now} error json"); } } } catch (Exception ex) { Logger.Write($"CheckPrice error: {ex.Message} / {ITEM_ID} / {ITEM_NAME}"); } }
public async Task InitItem() { PriceDate res = await CheckPriceAsync(); if (res != null) { textblockValues.startPrice = res.price; textblockValues.Price = res.price.ToString(); } t_Tick(this, null); t.Enabled = true; }
public async void t_Tick(object source, ElapsedEventArgs e) { try { PriceDate res = await CheckPriceAsync(); if (res != null) { lPrices.Insert(0, res); } UpdatePrices(); } catch (Exception ex) { Logger.Write($"t_Tick error: {ex.Message} / {ITEM_ID} / {ITEM_NAME}"); } }