private void updateInformation_Tick(object sender, EventArgs e) { if (items.Count == 0) { return; } for (int i = 0; i < items.Count; i++) { try { XmlDocument doc = new XmlDocument(); doc.Load("http://open.api.ebay.com/shopping?callname=GetSingleItem&responseencoding=XML&appid=GregoryM-mailer-PRD-a45ed6035-97c14545&siteid=0&version=967&ItemID=" + items[i].ItemNumber); XmlNodeList nodes = doc.GetElementsByTagName("GetSingleItemResponse"); XmlElement ele = (XmlElement)nodes[0]; string endTime = ele.GetElementsByTagName("EndTime")[0].InnerText; string[] components1 = endTime.Split('T'); string[] date = components1[0].Split('-'); string[] time = components1[1].Split(':'); time[2] = time[2].Substring(0, time[2].IndexOf('.')); DateTime endTimeDt = new DateTime(int.Parse(date[0]), int.Parse(date[1]), int.Parse(date[2]), int.Parse(time[0]), int.Parse(time[1]), int.Parse(time[2])); endTimeDt = endTimeDt.AddHours(-8); endTimeDt = endTimeDt.AddSeconds(0); ItemInformation newInfo = new ItemInformation(); newInfo.Name = ele.GetElementsByTagName("Title")[0].InnerText; newInfo.ItemNumber = items[i].ItemNumber; newInfo.Price = ele.GetElementsByTagName("ConvertedCurrentPrice")[0].InnerText; newInfo.EndTime = endTimeDt; newInfo.Bid = items[i].Bid; items[i] = newInfo; items = items.OrderBy(o => o.EndTime).ToList(); } catch (Exception ex) { Log(ex.Message); } } }
private void addItem_Click(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); doc.Load("http://open.api.ebay.com/shopping?callname=GetSingleItem&responseencoding=XML&appid=GregoryM-mailer-PRD-a45ed6035-97c14545&siteid=0&version=967&ItemID=" + itemNumber.Text); XmlNodeList nodes = doc.GetElementsByTagName("GetSingleItemResponse"); XmlElement ele = (XmlElement)nodes[0]; string endTime = ele.GetElementsByTagName("EndTime")[0].InnerText; string[] components1 = endTime.Split('T'); string[] date = components1[0].Split('-'); string[] time = components1[1].Split(':'); time[2] = time[2].Substring(0, time[2].IndexOf('.')); DateTime endTimeDt = new DateTime(int.Parse(date[0]), int.Parse(date[1]), int.Parse(date[2]), int.Parse(time[0]), int.Parse(time[1]), int.Parse(time[2])); endTimeDt = endTimeDt.AddHours(-8); endTimeDt = endTimeDt.AddSeconds(0); DateTime testingDt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).AddSeconds(10); ItemInformation info = new ItemInformation(); info.Name = ele.GetElementsByTagName("Title")[0].InnerText; info.ItemNumber = itemNumber.Text; info.Price = ele.GetElementsByTagName("ConvertedCurrentPrice")[0].InnerText; info.EndTime = endTimeDt; info.Bid = maxBid.Text; items.Add(info); itemNumber.Text = ""; maxBid.Text = ""; Log("Added item number " + info.ItemNumber); }
private void checkAuction_Tick(object sender, EventArgs e) { if (items.Count == 0) { return; } closestItem = items[0]; endingTime = closestItem.EndTime; if (endingTime.Year == 9999) { return; } List <ItemInformation> endingAuctions = new List <ItemInformation>(); endingAuctions.Add(items[0]); int mills = (int)numericUpDown1.Value; for (int i = 1; i < items.Count; i++) { if ((items[i].EndTime - endingTime).TotalSeconds < 1.6) { mills += (int)numericUpDown1.Value; endingAuctions.Add(items[i]); } } timeCutoff = mills; TimeSpan timeLeft = endingTime - DateTime.Now; string timeLeftStr = timeLeft.Days + "d " + timeLeft.Hours + "h " + timeLeft.Minutes + "m " + timeLeft.Seconds + "s"; try { if (endingAuctions.Count > 1) { Invoke(new Action(() => { label1.Text = "Next Upcoming Auction: " + endingAuctions.Count + " auctions in " + timeLeftStr; })); } else { Invoke(new Action(() => { label1.Text = "Next Upcoming Auction: " + closestItem.ItemNumber + " in " + timeLeftStr; })); } } catch (Exception ex) { Log(ex.Message); } if (timeLeft.TotalMinutes < 10) { label1.ForeColor = Color.Red; } else { label1.ForeColor = Color.Black; } for (int i = 0; i < endingAuctions.Count; i++) { ItemInformation item = endingAuctions[i]; TimeSpan timeLeft2 = item.EndTime - DateTime.Now; if (timeLeft2.TotalMilliseconds < timeCutoff) { DateTime start = DateTime.Now; Log("Sent bid request for " + item.ItemNumber); Invoke(new Action(() => { label1.ForeColor = Color.Black; })); Invoke(new Action(() => { label1.Text = "Next Upcoming Auction: "; })); DateTime dt = new DateTime(9999, 12, 31, 23, 59, 59); timeLeft = dt - dt.AddSeconds(-1); items.Remove(item); if (finishedIDs.Contains(item.ItemNumber)) { return; } try { finishedIDs.Add(item.ItemNumber); if (double.Parse(item.Price) < double.Parse(item.Bid)) { string finalPrice = item.Bid; ProcessStartInfo startInfo = new ProcessStartInfo("chrome", "https://offer.ebay.com/ws/eBayISAPI.dll?MfcISAPICommand=MakeBid&uiid=1859999246&co_partnerid=2&fb=2&item=" + item.ItemNumber + "&maxbid=" + (double.Parse(item.Bid)) + "&Ctn=Continue"); startInfo.WindowStyle = ProcessWindowStyle.Maximized; Process.Start(startInfo); Thread.Sleep(1500); Cursor.Position = buttonCoordinates; LeftMouseClick(buttonCoordinates.X, buttonCoordinates.Y); Log("Confirmed bid for item " + item.ItemNumber); } else { //Logs failure of auctions whose current prices exceeded bid Log("Bid amount " + String.Format(item.Bid, "C") + " exceeded requested bid of " + item.Price + " on item number " + itemNumber.Text); } } catch { Log("Exception"); } } } //numericUpDown1.Value = 2500; timeCutoff = 0; endingAuctions.Clear(); }
private void BidOnItem(ItemInformation item) { }