public void GetQuicklookPath_ValidRequest_ValidResponse() { QuicklookResponse res = api.GetQuicklookPath("Jita", "Amarr", 34, validOptions); QuicklookResult entry = res.Result; QuicklookOrder order = entry.BuyOrders.First(); Assert.AreEqual(TypeId, entry.TypeId); Assert.AreEqual("Tritanium", entry.TypeName); Assert.AreEqual(HourLimit, entry.HourLimit); Assert.AreEqual(MinQty, entry.MinQuantity); Assert.AreNotEqual(0, order.MinVolume); Assert.AreNotEqual(0, order.OrderId); Assert.AreNotEqual(0, order.VolRemaining); Assert.AreNotEqual(0, order.Price); Assert.AreNotEqual(0, order.SecurityRating); Assert.AreNotEqual(0, order.StationId); Assert.AreNotEqual("", order.StationName); Assert.AreNotEqual("", order.Expires); Assert.AreNotEqual("", order.ReportedTime); }
private QuicklookResult GetOrders(string typeId) { XML_JSON xML_JSON = new XML_JSON(); Param param = new Param(); param.typeid = typeId; // param.usesystem = "30000142"; try { string xml = EVEApi.QuickLook(param); string json = xML_JSON.XML2Json(xml, "evec_api/quicklook"); QuicklookResult result = Newtonsoft.Json.JsonConvert.DeserializeObject <QuicklookResult>(json); return(result); } catch { return(null); } }
private Way GetWay(QuicklookResult result) { Way way = new Way(); if (null != result.quicklook.sell_orders && result.quicklook.sell_orders.order.Count > 0 && null != result.quicklook.buy_orders && result.quicklook.buy_orders.order.Count > 0 ) { //1.查找卖价低于买价 差价最高的 List <OrderItem> sell_orders = result.quicklook.sell_orders.order; List <OrderItem> buy_orders = result.quicklook.buy_orders.order; decimal pricevalue = 0; foreach (var sell in sell_orders) { decimal sellPrice = Convert.ToDecimal(sell.price); foreach (var buy in buy_orders) { decimal buyPrice = Convert.ToDecimal(buy.price); decimal value = buyPrice - sellPrice; if (value > 0 && value > pricevalue && Convert.ToDecimal(sell.vol_remain) > 30 && Convert.ToDecimal(buy.vol_remain) > 30) { way.name = result.quicklook.quicklook; way.buy = buy; way.sell = sell; way.priceValue = value; pricevalue = value; way.routeConut = setRouteCount(sell.station_name, buy.station_name); } } } } if (null != way && way.priceValue > 0) { bestWay.Add(way); } return(way); }
private void button1_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); sw.Start(); bestWay.Clear(); int count = Convert.ToInt32(txtThreadNum.Text); this.progressBar1.Maximum = goodsDt.Rows.Count; this.progressBar1.Step = 1; this.progressBar1.Value = 0; ThreadPool.QueueUserWorkItem((object obj) => { List <Goods> list = (List <Goods>)List_DataTable_Helper.DataTableToListModel <Goods> .ConvertToModel(goodsDt); MultipleThread.RunTask <Goods>(list, d => { string typeId = d.typeID; QuicklookResult result = GetOrders(typeId); if (null != result) { Way way = GetWay(result); /*if (null != way && way.priceValue > 0) * { * AddItemToListBox(this.listBox1, $"物品名称:{way.name};起点:{way.sell.station_name};价格:{way.sell.price};数量:{way.sell.vol_remain};终点:{way.buy.station_name};价格:{way.buy.price};数量:{way.buy.vol_remain};差价{way.priceValue}"); * AddItemToListBox(this.listBox1, "==================================================="); * }*/ } this.Invoke(new Action(() => { this.progressBar1.PerformStep(); })); }, count); bestWay.Sort((a, b) => { var sortIndex = Convert.ToInt32(b.priceValue - a.priceValue); return(sortIndex); }); this.Invoke(new Action(() => { this.listBox1.Items.Clear(); })); foreach (var way in bestWay) { if (way.priceValue > 0) { AddItemToListBox(this.listBox1, $"物品名称:{way.name};起点:{way.sell.station_name};价格:{way.sell.price};数量:{way.sell.vol_remain};终点:{way.buy.station_name};价格:{way.buy.price};数量:{way.buy.vol_remain};差价{way.priceValue};跳跃:{way.routeConut}"); AddItemToListBox(this.listBox1, "==================================================="); } } sw.Stop(); TimeSpan ts2 = sw.Elapsed; this.Invoke(new Action(() => { this.label3.Text = ts2.TotalSeconds + "秒"; })); MessageBox.Show("OK"); }); /* ThreadPool.QueueUserWorkItem((object obj) => * { * foreach (DataRow row in dt.Rows) * { * string typeId = row["typeID"].ToString(); * QuicklookResult result = GetOrders(typeId); * if (null != result) * { * Way way=GetWay(result); * if (null != way && way.priceValue > 0) * { * AddItemToListBox(this.listBox1, $"物品名称:{way.name};起点:{way.sell.station_name};价格:{way.sell.price};数量:{way.sell.vol_remain};终点:{way.buy.station_name};价格:{way.buy.price};数量:{way.buy.vol_remain};差价{way.priceValue}"); * AddItemToListBox(this.listBox1, "==================================================="); * } * } * this.Invoke(new Action(() => { ++this.progressBar1.Step; * this.label3.Text = $"{this.progressBar1.Maximum - this.progressBar1.Step}"; * })); * } * bestWay.Sort((a,b) => { var sortIndex=Convert.ToInt32(b.priceValue - a.priceValue);return sortIndex; }); * this.Invoke(new Action(() => { * this.listBox1.Items.Clear(); * })); * foreach (var way in bestWay) * { * if (way.priceValue > 0) * { * AddItemToListBox(this.listBox1, $"物品名称:{way.name};起点:{way.sell.station_name};价格:{way.sell.price};数量:{way.sell.vol_remain};终点:{way.buy.station_name};价格:{way.buy.price};数量:{way.buy.vol_remain};差价{way.priceValue}"); * AddItemToListBox(this.listBox1, "==================================================="); * } * * } * MessageBox.Show("OK"); * });*/ }