//void HotItemController_SellNotification(object sender, NotificationEventArgs e) //{ // AddNotification(BuyNotifications, new NotificationModel(e.Item, null, e.Rule, e.Rule.SelectedRuleType.ToString(), DateTime.Now)); // Currently we add Sell notifications to the buy list too //} private void Disable(NotificationModel model) { if (model.Rule != null) { model.Rule.Disable(); } //if (model.RuleBuy != null) //{ // model.RuleBuy.Disable(); //} }
public void AddBuyNotification(NotificationModel item) { AddNotification(BuyNotifications, item); }
public void TimeoutRule(NotificationModel item) { if (!item.IsGemNotification && item.Item.Notify) { item.Item.AcceptTime = DateTime.Now; item.Item.TimeOut = new TimeSpan(0, item.TimeoutMinutes, 0); } else { if (item.Rule != null) { item.Rule.IsActive = false; item.Rule.AcceptTime = DateTime.Now; item.Rule.TimeOut = new TimeSpan(0, item.TimeoutMinutes, 0); } //if (item.Rule != null) //{ // item.Rule.IsActive = false; // item.Rule.AcceptTime = DateTime.Now; // item.Rule.TimeOut = new TimeSpan(0, item.TimeoutMinutes, 0); //} } BuyNotifications.Remove(item); if (BuyNotifications.Count <= 0) { CloseRequest(); } }
//public void AddSellNotification(NotificationModel item) //{ // AddNotification(SellNotifications, item); //} private void AddNotification(ObservableCollection<NotificationModel> collection, NotificationModel item) { NotificationView.Dispatcher.BeginInvoke((Action)delegate() { try { var notificationItem = collection.FirstOrDefault(x => x.DataId == item.DataId); if (notificationItem == null) { //var localItem = collection.FirstOrDefault(x => x.Item.DataId == item.Item.DataId); collection.Add(item); } else { if (item.IsMessageNotification) { collection.Add(item); } else { //notificationItem.Rule. if (notificationItem.Item != null && item.Item != null && notificationItem.Item.ListingId != item.Item.ListingId) { notificationItem.Quantitiy += item.Quantitiy; } //notificationItem. } } } catch { } ShowOnNotifiaction(); }); }
public void ClearRule(NotificationModel item) { if (item.Item != null && item.Item.Notify) { item.Item.Notify = false; } else { Disable(item); } BuyNotifications.Remove(item); if (BuyNotifications.Count <= 0) { CloseRequest(); } }
public void AddNotificationMessage(HotItem item, String message) { NotificationModel m = new NotificationModel(item, null, message, item.TransactionTimeLocal, NotificationType.Undefined); m.AsTransaction(); AddBuyNotification(m); }
//void HotItemController_SellNotification(object sender, NotificationEventArgs e) //{ // AddNotification(BuyNotifications, new NotificationModel(e.Item, null, e.Rule, e.Rule.SelectedRuleType.ToString(), DateTime.Now)); // Currently we add Sell notifications to the buy list too //} private void Disable(NotificationModel model) { if (model.RuleSell != null) { model.RuleSell.Disable(); } if (model.RuleBuy != null) { model.RuleBuy.Disable(); } }
//public void AddSellNotification(NotificationModel item) //{ // AddNotification(SellNotifications, item); //} private void AddNotification(ObservableCollection<NotificationModel> collection, NotificationModel item) { NotificationView.Dispatcher.BeginInvoke((Action)delegate() { try { int count = collection.Count(x => x.DataId == item.DataId); //var localItem = collection.FirstOrDefault(x => x.Item.DataId == item.Item.DataId); if (item.IsMessageNotification || count <= 0) { collection.Add(item); } } catch { } ShowOnNotifiaction(); }); }
private void Worker(object state) { try { while (IsRunning) { RefreshTransactions(); for (int i = 0; i < BuyingViewModel.Items.Count; i++) { HotItem item = BuyingViewModel.Items[i]; if (item.Notify && DateTime.Now > item.AcceptTime + item.TimeOut) { item.Crawl(); if (item.BuyPrice > item.UnitPrice) { MainWindow.Dispatcher.BeginInvoke((Action)delegate { var model = new NotificationModel(item, new NotifierRule(item, RuleType.Higher, item.UnitPrice, ContextType.Other, null), "Higher", DateTime.Now, NotificationType.Buy); NotifiactionViewModel.AddBuyNotification(model); NotifiactionViewModel.ShowOnNotifiaction(); }); } } } for (int i = 0; i < SellingViewModel.Items.Count; i++) { HotItem item = SellingViewModel.Items[i]; if (item.Notify && DateTime.Now > item.AcceptTime + item.TimeOut) { item.Crawl(); if (item.SellPrice < item.UnitPrice) { MainWindow.Dispatcher.BeginInvoke((Action)delegate { var model = new NotificationModel(item, new NotifierRule(item, RuleType.Less, item.UnitPrice, ContextType.Other, null), "Less", DateTime.Now, NotificationType.Sell); NotifiactionViewModel.AddBuyNotification(model); NotifiactionViewModel.ShowOnNotifiaction(); }); } } } Thread.Sleep(random.Next(HotItemController.CurrentApi.WorkerTransactionTimeOut - 500, HotItemController.CurrentApi.WorkerTransactionTimeOut + 500)); } } catch (ThreadInterruptedException) { IsRunning = false; } }