// /// <summary> /// Проверяем, есть ли предметы в уведомлениях, которые нужно добавить в покупки /// </summary> public void CheckNotifications() { try { int i = 0; var ans = CLIENT1.GetNotifications(cfg.key); if (ans != null && ans.success) { foreach (var itm in ans.Notifications) { var haveInItems = Items.Find(item => item.id == itm.i_classid + "_" + itm.i_instanceid); if (haveInItems == null) { AddItem("https://market.csgo.com/item/" + itm.i_classid + "-" + itm.i_instanceid, Convert.ToInt32(itm.n_val) / 100, PriceCheck.Notification); i++; } } if (i != 0) { WriteMessage($"Добавлено {i} предметов", MessageType.Info); } } } catch { } }
/// <summary> /// Обновление цен /// </summary> void CorrectPrice() { try { double Averange, MinPrice, Discount, Cost; Discount = 1 - Convert.ToDouble(cfg.discount / 100); foreach (Itm I in Items) { //Если предмет добавлен с уведомлений, то его цену прверяем в списке уведомлений if (I.priceCheck == PriceCheck.Notification) { var ans = CLIENT1.GetNotifications(cfg.key); if (ans != null && ans.success) { var item = ans.Notifications.Find(fi => fi.i_classid + "_" + fi.i_instanceid == I.id); if (item != null) { I.price = Convert.ToInt32(item.n_val) / 100.0; } } } else { //проверяем остальные вещи Thread.Sleep(cfg.Itimer); // new System.Action(() => Console.Write("\r{0}/{1} ", ++count, Items.Count)).BeginInvoke(null, null); MinPrice = Convert.ToDouble(CLIENT.GetMinPrice(I, cfg.key)); if (MinPrice == -1) { MinPrice = Convert.ToDouble(CLIENT.GetMinPrice(I, cfg.key)); if (MinPrice == -1) { continue; } } Averange = Convert.ToDouble(CLIENT.GetAverangePrice(I, cfg.key)); if (Averange < MinPrice) { Cost = Averange; } else { Cost = MinPrice; } //если у предмета выставлена персональная прибыль, то используем ее, а не общую double profit; if (I.profit != 0) { profit = I.profit; } else { profit = cfg.price; } if (Cost > 20000) { I.price = Math.Round((Cost * Discount - profit * 2) / 100.0, 2); continue; } if (Cost > 10000) { I.price = Math.Round((Cost * Discount - profit) / 100.0, 2); continue; } else { I.price = Math.Round((Cost * Discount - profit) / 100.0, 2); continue; } } } WriteMessage("Обновлены цены", MessageType.Info); } catch (Exception ex) { WriteMessage(string.Format("[CorrectPrice] {0}", ex.Message), MessageType.Error); } }