public override GameObject SetUpPrefab(Transform parent) { GameObject productPrefab = base.SetUpPrefab(parent); Image foodImage = productPrefab.transform.GetChild(4).GetComponent <Image>(); Button toEat = productPrefab.transform.GetChild(2).GetComponent <Button>(); Button toPut = productPrefab.transform.GetChild(3).GetComponent <Button>(); Text foodName = productPrefab.transform.GetChild(7).GetComponent <Text>(); Text foodPrice = productPrefab.transform.GetChild(6).GetComponent <Text>(); if (LevelAccess > PlayerData.Singleton.CurrentLevel || CoinPrice > PlayerData.Singleton.CoinAmount) { toEat.interactable = false; toPut.interactable = false; } foodImage.sprite = FoodImage; toEat.onClick.AddListener(ToEat); toPut.onClick.AddListener(ToPut); foodName.text = Name; foodPrice.text = CoinPrice.ToString(); return(productPrefab); }
public override GameObject SetUpPrefab(Transform parent) { if (!PlayerData.Singleton.IsProductBought(Name)) { productPrefab = base.SetUpPrefab(parent); Button toPutOn = productPrefab.transform.GetChild(0).GetComponent <Button>(); Text furnitureName = productPrefab.transform.GetChild(1).GetComponent <Text>(); Text furniturePrice = productPrefab.transform.GetChild(2).GetComponent <Text>(); if (LevelAccess > PlayerData.Singleton.CurrentLevel || CoinPrice > PlayerData.Singleton.CoinAmount) { toPutOn.interactable = false; } toPutOn.onClick.AddListener(ToPutOn); furnitureName.text = Name; furniturePrice.text = CoinPrice.ToString(); return(productPrefab); } else { return(null); } }
public void Update(CoinPrice pr) { Guard.ArgumentNotNull(pr, "CoinPrice"); pr.utime = DateTime.Now; _coinPriceRepository.Update(pr); }
private async void button2_Click(object sender, EventArgs e) { var price = new CoinPrice(); price = await binanceAPI.PriceRequest(pairName.Text.ToUpper()); this.CoinPrices.Text = price.Symbol + " Price: $" + price.Price; }
// This overload of PopulateFromJson populates the Price and Market Cap elements of a single // CoinInformation object, as deserialized from CryptoCompare.com API's pricemulti call public static void PopulateFromJson(this CoinInformation coinInformation, CoinPrice priceRec) { try { coinInformation.Price = priceRec.USD; coinInformation.MarketCap = Convert.ToDouble(coinInformation.TotalCoinsMined) * coinInformation.Price; } catch (FormatException e) { coinInformation.Price = 0.0; coinInformation.MarketCap = 0.0; } catch (OverflowException e) { coinInformation.Price = 0.0; coinInformation.MarketCap = 0.0; } }
private async Task <decimal> SaveAskPrice(int coinId, decimal askPrice) { decimal oldAskPrice = 0.00m; var coinPrice = await _context.CoinPrices.Where(c => c.CoinId == coinId).SingleOrDefaultAsync(); if (coinPrice != null) { oldAskPrice = coinPrice.AskPrice; coinPrice.AskPrice = askPrice; } else { coinPrice = new CoinPrice { CoinId = coinId, AskPrice = askPrice }; _context.CoinPrices.Add(coinPrice); } await _context.SaveChangesAsync(); return(oldAskPrice); }
private void FlushTokenPrice(decimal cny, string tokens) { var dlist = _blockCcApiService.GetTokenPriceUsd(tokens); foreach (var item in dlist) { var pr = _coinPriceService.GetBySymbol(item.name, AoteNiuConst.HUOBI); if (pr == null) { string contract = string.Empty; if (item.name == AoteNiuConst.BLOCK_CHAIN_TOKEN_PRICE_FCS) { //contract = _walletService.GetFcsContract(); } else if (item.name == AoteNiuConst.BLOCK_CHAIN_TOKEN_PRICE_ETH) { contract = AoteNiuConst.BLOCK_CHAIN_SYSTEM_CONTRACT_ETH; } pr = new CoinPrice { //ctype = BTChat_BlockChain_Type.Ethereum, address = contract, platform = AoteNiuConst.HUOBI, symbol = item.name, price_usd = item.price_usd, price = item.price * cny, ctime = DateTime.Now }; } else { pr.price = item.price * cny; pr.price_usd = item.price_usd; pr.price_btc = item.price_btc; } _coinPriceService.Update(pr); } }
private void FlushHuobiPrice(string key, string full, string address) { try { // get coin price from huobi var priceUrl = $"https://api.huobi.pro/market/trade?symbol={key}usdt"; var request = (HttpWebRequest)WebRequest.Create(priceUrl); request.Method = "GET"; request.Accept = "*/*"; request.ContentType = "application/json"; request.Timeout = 2000; int times = AoteNiuConst.HTTP_REQUEST_TRY_TIMES; while (times-- >= 0) { try { var rsp = (HttpWebResponse)request.GetResponse(); if (rsp.StatusCode != HttpStatusCode.OK) { _log.Error($"FlushHuobiPrice rsp.StatusCode != HttpStatusCode.OK"); return; } HuobiPriceModel price_data; using (var reader = new StreamReader(rsp.GetResponseStream())) { price_data = JsonConvert.DeserializeObject <HuobiPriceModel>(reader.ReadToEnd()) as HuobiPriceModel; if (null == price_data) { _log.Error($"FlushHuobiPrice price_data null"); return; } } if (null == price_data.tick.data) { _log.Error($"FlushHuobiPrice price_data.data null"); return; } decimal price = price_data.tick.data[0].price; var pr = _coinPriceService.GetBySymbol(key, AoteNiuConst.HUOBI); if (null == pr) { pr = new CoinPrice { address = address, platform = AoteNiuConst.HUOBI, symbol = key, full = full, price_usd = price, price = price * _PriceCNY, ctime = DateTime.Now }; } else { pr.price = price * _PriceCNY; pr.price_usd = price; } _coinPriceService.Update(pr); } catch (WebException ex) { _log.Error(ex.ToString()); Thread.Sleep(1000); continue; } break; } if (times < 0) { _log.Error($"FlushHuobiPrice: {key} failed !!!"); return; } } catch (Exception ex) { _log.Error(ex.ToString()); return; } }