public OreOptimizer(SDEEntities sde) { this._sde = sde; this.Prices = new Dictionary <ore, double>(); try { string types = ""; foreach (ore ore in _sde.ores) { types += ore.typeID + ","; } types = types.Substring(0, types.Length - 1); string json; using (WebClient wc = new WebClient()) { string url = "https://market.fuzzwork.co.uk/aggregates/?station=60003760&types=" + types; json = wc.DownloadString(url); } JObject jsonObj = JObject.Parse(json); foreach (ore ore in _sde.ores) { ore.name = ore.name.TrimEnd(); double price = (double)jsonObj[ore.typeID.ToString()]["sell"]["min"]; int vol = (int)double.Parse((string)jsonObj[ore.typeID.ToString()]["sell"]["volume"]); if (price < 100 || vol < 20) { continue; } Prices.Add(ore, price); } } catch (Exception except) { Console.WriteLine("Could not update prices"); //TODO use cached prices (need to cache prices 1st) } }
public static ItemList getMatsFor(invType type) { var db = new SDEEntities(); return(new ItemList(db.GetMats(type.typeID, 1).ToList())); }