private void изменитьToolStripMenuItem_Click(object sender, EventArgs e) { int index = dataGridView1.CurrentCell.RowIndex; Program.Dat neww = Program.Data[index]; neww.Price = Convert.ToDouble(dataGridView1.Rows[index].Cells[3].Value.ToString()); dataGridView1.Rows.RemoveAt(index); Program.Data.RemoveAt(index); Program.Data.Add(neww); string json = JsonConvert.SerializeObject(Program.Data); File.WriteAllText("data.txt", json); RefreshGrid(); MessageBox.Show("Успешно изменено!"); }
private void button1_Click(object sender, EventArgs e) { Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; var item = new Program.Dat { Id = unixTimestamp, Name = textBox2.Text, //Factory = comboBox1.Text, Price = Convert.ToDouble(textBox3.Text.Replace(".", ",")) }; Program.DataLoot.Add(item); RefreshGrid(); string json = JsonConvert.SerializeObject(Program.DataLoot); File.WriteAllText("dataLootFarm.txt", json); }
private void button1_Click(object sender, EventArgs e) { Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string tms = textBox2.Text.Replace(" ", ""); var item = new Program.Dat { Id = unixTimestamp, Name = tms, Factory = "", Price = Convert.ToDouble(textBox3.Text.Replace(".", ",")) }; // DialogResult result = MessageBox.Show("Вы добавляете СТАНДАРТНЫЙ предмет","", MessageBoxButtons.YesNo, MessageBoxIcon.Question); Program.Data.Add(item); RefreshGrid(); string json = JsonConvert.SerializeObject(Program.Data); File.WriteAllText("data.txt", json); MessageBox.Show("Добавил!"); }
private void button1_Click(object sender, EventArgs e) { try { string factory = ""; Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if (!checkBox1.Checked) { string tms = textBox2.Text.Split('(')[1].Replace(")", "").Replace("(", "").Replace(" ", ""); switch (tms) { case "MinimalWear": factory = "MW"; break; case "FactoryNew": factory = "FN"; break; case "Field-Tested": factory = "FT"; break; case "Battle-Scarred": factory = "BS"; break; case "Well-Worn": factory = "WW"; break; } var item = new Program.Dat { Id = unixTimestamp, Name = textBox2.Text.Split('(')[0], Factory = factory, Price = Convert.ToDouble(textBox3.Text.Replace(".", ",")) }; DialogResult result = MessageBox.Show("Вы добавляете СТАНДАРТНЫЙ предмет", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) //Если нажал нет { MessageBox.Show("Не добавил!"); } if (result == DialogResult.Yes) //Если нажал Да { Program.Data.Add(item); RefreshGrid(); string json = JsonConvert.SerializeObject(Program.Data); File.WriteAllText("data.txt", json); MessageBox.Show("Добавил!"); } } else { var item = new Program.Dat { Id = unixTimestamp, Name = textBox2.Text, Factory = factory, Price = Convert.ToDouble(textBox3.Text.Replace(".", ",")) }; DialogResult result = MessageBox.Show("Вы добавляете СТИКЕР или ДРУГОЙ предмет", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) //Если нажал нет { MessageBox.Show("Не добавил!"); } if (result == DialogResult.Yes) //Если нажал Да { Program.Data.Add(item); RefreshGrid(); string json = JsonConvert.SerializeObject(Program.Data); File.WriteAllText("data.txt", json); MessageBox.Show("Добавил!"); } } } catch (Exception ex) { } }
private void WorkWithData(string Name, double price, double percent) { try { string factory = ""; if (Name.Contains("(Well-Worn)") == true || Name.Contains("(Field-Tested)") == true || Name.Contains("(Battle-Scarred)") == true || Name.Contains("(Minimal Wear)") == true || Name.Contains("(Factory New)") == true) { string tms = Name.Split('(')[1].Replace(")", "").Replace("(", "").Replace(" ", ""); switch (tms) { case "MinimalWear": factory = "MW"; break; case "FactoryNew": factory = "FN"; break; case "Field-Tested": factory = "FT"; break; case "Battle-Scarred": factory = "BS"; break; case "Well-Worn": factory = "WW"; break; } var item = new Program.Dat { Name = Name.Split('(')[0], Factory = factory, Price = price + price * addPercent / 100, AutoAddItem = true, count = countMax, SiteName = siteName }; var itemFind = Program.Data.Find(N => (N.Name == item.Name && N.Factory == item.Factory)); if (itemFind.Name == null && percent > minPercent) { Program.Data.Add(item); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Добавил Предмет:{Name} с ценой: {price} (учет х%:{item.Price}) -- процент:{percent}%"); } else { if (itemFind.Price != item.Price && percent > minPercent && itemFind.AutoAddItem == true) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Factory == itemFind.Factory && N.Price == itemFind.Price)); Thread.Sleep(3000); Program.Data.RemoveAt(index); Program.Data.Add(item); Program.MessageForEditData.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Изменил Предмет:{Name} с ценой: {itemFind.Price} на новую цену:{item.Price}-- процент:{percent}"); } else if (percent < minPercent && itemFind.AutoAddItem == true && itemFind.SiteName == siteName) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Factory == itemFind.Factory && N.Price == itemFind.Price)); Program.Data.RemoveAt(index); Program.MessageForEditData.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Удалил Предмет:{Name} с ценой: {price} (учет х%:{item.Price}) -- процент:{percent}%"); } } } else { var item = new Program.Dat { Name = Name, Factory = factory, Price = price + price * addPercent / 100, AutoAddItem = true, count = countMax, SiteName = siteName }; var itemFind = Program.Data.Find(N => (N.Name == item.Name && N.Factory == item.Factory)); if (itemFind.Name == null && percent > minPercent) { Program.Data.Add(item); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Добавил Предмет:{Name} с ценой: {price} (учет х%:{item.Price})-- процент:{percent}%"); } else { if (itemFind.Price != item.Price && percent > minPercent && itemFind.AutoAddItem == true) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Factory == itemFind.Factory && N.Price == itemFind.Price)); Thread.Sleep(3000); Program.Data.RemoveAt(index); Program.Data.Add(item); Program.MessageForEditData.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Изменил Предмет:{Name} с ценой: {itemFind.Price} на новую цену:{item.Price}-- процент:{percent}"); } else if (percent < minPercent && itemFind.AutoAddItem == true && itemFind.SiteName == siteName) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Factory == itemFind.Factory && N.Price == itemFind.Price)); Program.Data.RemoveAt(index); Program.MessageForEditData.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Удалил Предмет:{Name} с ценой: {price} (учет х%:{item.Price}) -- процент:{percent}%"); } } } } catch (Exception ex) { Program.MessAutoRefresh.Enqueue($"Ошибка 4{ex.Message}"); } }
private void WorkWithData(string Name, double price, double percent) { try { if (Name.Contains("(Well-Worn)") == true || Name.Contains("(Field-Tested)") == true || Name.Contains("(Battle-Scarred)") == true || Name.Contains("(Minimal Wear)") == true || Name.Contains("(Factory New)") == true) { var item = new Program.Dat { Name = Name, Factory = "", Price = price + price * (addPercent / 100), AutoAddItem = true, count = countMax, SiteName = siteName }; var itemFind = Program.Data.Find(N => (N.Name == item.Name)); if (itemFind.Name == null && percent > minPercent) { Program.Data.Add(item); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Добавил Предмет:{Name} с ценой: {price} (учет х%:{item.Price}) -- процент:{percent}%"); } else { if (itemFind.Price != item.Price && percent > minPercent && itemFind.AutoAddItem == true) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Price == itemFind.Price)); Thread.Sleep(3000); Program.Data.RemoveAt(index); Program.Data.Add(item); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Изменил Предмет:{Name} с ценой: {itemFind.Price} на новую цену:{item.Price}-- процент:{percent}"); } else if (percent < minPercent && itemFind.AutoAddItem == true && itemFind.SiteName == siteName) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Price == itemFind.Price)); Program.Data.RemoveAt(index); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Удалил Предмет:{Name} с ценой: {price} (учет х%:{item.Price}) -- процент:{percent}%"); } } } else { var item = new Program.Dat { Name = Name, Factory = "", Price = price + price * (addPercent / 100), AutoAddItem = true, count = countMax, SiteName = siteName }; var itemFind = Program.Data.Find(N => (N.Name == item.Name)); if (itemFind.Name == null && percent > minPercent) { Program.Data.Add(item); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Добавил Предмет:{Name} с ценой: {price} (учет х%:{item.Price})-- процент:{percent}%"); } else { if (itemFind.Price != item.Price && percent > minPercent && itemFind.AutoAddItem == true) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Price == itemFind.Price)); Thread.Sleep(3000); Program.Data.RemoveAt(index); Program.Data.Add(item); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Изменил Предмет:{Name} с ценой: {itemFind.Price} на новую цену:{item.Price}-- процент:{percent}"); } else if (percent < minPercent && itemFind.AutoAddItem == true && itemFind.SiteName == siteName) { var index = Program.Data.FindIndex(N => (N.Name == itemFind.Name && N.Price == itemFind.Price)); Program.Data.RemoveAt(index); Program.MessAutoRefresh.Enqueue($"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") }|Удалил Предмет:{Name} с ценой: {price} (учет х%:{item.Price}) -- процент:{percent}%"); } } } } catch (Exception ex) { Program.MessAutoRefresh.Enqueue($"Ошибка 4{ex.Message}"); } }
private bool ClickItem(dynamic json) { try { var da = json; var aa = da.Event.Value; foreach (var item in da.data) { var b = item.b[0].Value; var id = item.id[0].Value; var m = item.m.Value; var p = item.p.Value; var f = item.f.First.Value; string ee = "0"; string s = "0"; if (item.e != null) { try { ee = item.e.Value; } catch (Exception ex) { Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка1 :" + ex.Message); } } if (item.s != null) { try { s = item.s.Count.ToString(); } catch (Exception ex) { Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка1 :" + ex.Message); } } string factory = ""; switch (ee) { case "MW": factory = " (Minimal Wear)"; break; case "FN": factory = " (Factory New)"; break; case "FT": factory = " (Field-Tested)"; break; case "BS": factory = " (Battle-Scarred)"; break; case "WW": factory = " (Well-Worn)"; break; } foreach (var name in Program.Data) { if (m.Replace(" ", "") == (name.Name).Replace(" ", "") && ee == name.Factory) { Program.MessageForSendItems.Enqueue("|_____________________________________________________________|"); Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "| Нашел предмет :" + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price); if (p <= name.Price) { if (name.count > 0) { // Program.MessTelegram.Enqueue("БОТ[CsMoney]" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Подошел предмет:" + m + "|Цена:" + p); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "| Оправил Запрос |Предмет:" + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price); if (Program.BrowesrQuery == false) { Post(handler, 1, b.ToString(), id.ToString(), p.ToString().Replace(",", ".")); } else { string ff = ""; if (f.ToString() != "0") { ff = "\\\"" + f.ToString() + "\\\""; } else { ff = f.ToString(); } IJavaScriptExecutor js = driver as IJavaScriptExecutor; string ss1 = "function test() {var xhr = new XMLHttpRequest();" + // "var body = \"{\\\"steamid\\\":\\\"" + b.ToString() + "\\\",\\\"peopleItems\\\":[],\\\"botItems\\\":[\\\"" + id.ToString() + "\\\"],\\\"onWallet\\\":-" + p.ToString().Replace(",", ".") + ",\\\"gid\\\":\\\"" + "\\\"}\";" + "var body = \"{\\\"peopleItems\\\":[],\\\"botItems\\\":[{\\\"assetid\\\":\\\"" + id.ToString() + "\\\",\\\"local_price\\\":\\\"" + p.ToString().Replace(",", ".") + "\\\",\\\"price\\\":" + p.ToString().Replace(",", ".") + ",\\\"float\\\":" + ff + ",\\\"stickers_count\\\":" + s.ToString() + ",\\\"market_hash_name\\\":\\\"" + m.ToString() + factory + "" + "\\\",\\\"bot\\\":\\\"" + b.ToString() + "\\\"}],\\\"onWallet\\\":-" + p.ToString().Replace(",", ".") + "}\";" + " xhr.open(\"POST\", 'https://cs.money/send_offer', false); " + "xhr.setRequestHeader('Content-Type', 'application/json');" + " xhr.setRequestHeader('accept', '*/*');" + " xhr.send(body);return xhr.status+'|'+xhr.responseText; } return test();"; var title = js.ExecuteScript(ss1); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Результат отправленного обмена:" + title.ToString()); } Program.OfferSend++; Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Завершил Запрос"); Program.Dat NewItem = new Program.Dat() { Id = name.Id, Name = name.Name, Factory = name.Factory, Price = name.Price, AutoAddItem = name.AutoAddItem, SiteName = name.SiteName, count = name.count - 1 }; Program.Data.Remove(name); Program.Data.Add(NewItem); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Осталось количество предметов" + NewItem.count.ToString()); if (Program.autoConfirm == true) { TradingBot tradeBot = new TradingBot(cook, cookAll, apiKey); } // TradingBot tradeBot = new TradingBot(cook, apiKey); Thread.Sleep(2000); } else { Program.DontOfferSend++; Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Не удалось запустить запрос, максимальное количество предметов:" + m); } return(true);//main-trade-button } else { Program.DontOfferSend++; Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Цена не подошла " + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price); SetListBadPrice(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "cs.money", m.ToString() + " [" + ee + "]", name.Price.ToString(), p.ToString()); } } } } } catch (Exception ex) { Program.MessageFailed.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка2 :" + ex.Message); } return(false); }
private void Work() { try { while (true) { try { pp++; Random rr = new Random(); int sl = rr.Next(100, 500); Thread.Sleep(sl); var items = Get(); if (items != null) { List <Data> list = new List <Data>(); int k = 0; foreach (var item in items.rgInventory) { Data d = new Data { _classid = item.First.classid.ToString(), _id = item.First.id.ToString(), _instanceid = item.First.instanceid.ToString() }; list.Add(d); } foreach (var item in items.rgDescriptions) { foreach (var it in Program.Data) { string factory = ""; switch (it.Factory) { case "MW": factory = "(MinimalWear)"; break; case "FN": factory = "(FactoryNew)"; break; case "FT": factory = "(Field-Tested)"; break; case "BS": factory = "(Battle-Scarred)"; break; case "WW": factory = "(Well-Worn)"; break; } string FullName = it.Name + factory; if (item.First.market_hash_name.Value.ToString().Replace(" ", "") == FullName.Replace(" ", "")) { Program.MessageForSendItems.Enqueue("|_____________________________________________________________|"); try { Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Нашел предмет {item.First.market_hash_name.Value.ToString()}"); string id = list.Find(N => (N._classid == item.First.classid.Value.ToString()))._id; var linkView = item.First.actions.First["link"].Value.ToString().Replace("%owner_steamid%", BotId).Replace("%assetid%", id); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Получил ID {id}"); double price = Program.DataMoney.Find(N => (N.Name.Replace(" ", "") == FullName.Replace(" ", ""))).Price; Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Получил Price {price}"); if (price <= it.Price) { if (it.count > 0) { //DataStruct.GoodItems.Enqueue(it); PropertyItemsFloat PIF = GetFloat(linkView); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Получил Float {PIF.floatt}"); IJavaScriptExecutor js = Program._driver as IJavaScriptExecutor; string ss1 = "function test() {var xhr = new XMLHttpRequest();" + // "var body = \"{\\\"steamid\\\":\\\"" + b.ToString() + "\\\",\\\"peopleItems\\\":[],\\\"botItems\\\":[\\\"" + id.ToString() + "\\\"],\\\"onWallet\\\":-" + p.ToString().Replace(",", ".") + ",\\\"gid\\\":\\\"" + "\\\"}\";" + "var body = \"{\\\"peopleItems\\\":[],\\\"botItems\\\":[{\\\"assetid\\\":\\\"" + id + "\\\",\\\"local_price\\\":\\\"" + price.ToString().Replace(",", ".") + "\\\",\\\"price\\\":" + price.ToString().Replace(",", ".") + ",\\\"float\\\":\\\"" + Math.Round(Convert.ToDouble(PIF.floatt), 8).ToString().Replace(",", ".") + "\\\",\\\"stickers_count\\\":" + PIF.stickerCount + ",\\\"market_hash_name\\\":\\\"" + item.First.market_hash_name.Value.ToString() + "" + "\\\",\\\"bot\\\":\\\"" + BotId + "\\\"}],\\\"onWallet\\\":-" + price.ToString().Replace(",", ".") + "}\";" + " xhr.open(\"POST\", 'https://cs.money/send_offer', false); " + "xhr.setRequestHeader('Content-Type', 'application/json');" + " xhr.setRequestHeader('accept', '*/*');" + " xhr.send(body);return xhr.status+'|'+xhr.responseText; } return test();"; ArgumentsChek.Value = ss1;//передаем строку запроса на дочерние программы через событие var title = js.ExecuteScript(ss1); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Результат отправленного обмена:" + title.ToString()); Program.OfferSend++; Program.Dat NewItem = new Program.Dat() { Id = it.Id, Name = it.Name, Factory = it.Factory, Price = it.Price, AutoAddItem = it.AutoAddItem, SiteName = it.SiteName, count = it.count - 1 }; Program.Data.Remove(it); Program.Data.Add(NewItem); Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Осталось количество предметов" + NewItem.count.ToString()); } else { Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Лимит на взятие предметов исчерпан!"); } } else { Program.DontOfferSend++; Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Цена не подошла PriceMoney:{price.ToString()}-PriceData:{it.Price.ToString()}"); } } catch (Exception ex) { Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}Work1|" + ex.Message); } Program.MessageForSendItems.Enqueue("|_____________________________________________________________|"); // Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Результат отправленного обмена:" + title.ToString()); } } k++; } Program.Mess.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}|Количсетво предметов:{-" + k + "-}"); } else { Program.Mess.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:" + BotId + "|" + "|null"); } } catch (Exception ex) { Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}Work1|" + ex.Message); //Types.LogInfo er = new Types.LogInfo() { Id = ID, Error = "Work1|"+ex.Message, Timeerror = DateTime.Now.ToString("HH:mm:ss:fff") }; //Program.MessLog.Enqueue(er); } } } catch (Exception ex) { Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}Work2|" + ex.Message); //Types.LogInfo er = new Types.LogInfo() { Id = ID, Error = "Work2|" + ex.Message, Timeerror = DateTime.Now.ToString("HH:mm:ss:fff") }; //Program.MessLog.Enqueue(er); } }