public void AddNotificationMessage(HotItem item, String message) { NotificationModel m = new NotificationModel(item, null, message, item.TransactionTimeLocal, NotificationType.Undefined); m.AsTransaction(); AddBuyNotification(m); }
void item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { HotItem item = (HotItem)sender; if (item != null) { if (chartItems.ContainsKey(item.DataId)) { var items = chartItems[item.DataId]; switch (e.PropertyName) { case "SellPrice": var proxy = item.CreateProxy(); items.AppendAsync(MainWindowViewModel.Dispatcher, proxy); //items.SetYMapping(y => y.SellPrice); //items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime)); break; case "BuyPrice": break; default: break; } } } }
public NotificationEventArgs(int id, HotItem item, NotifierRule rule, NotificationType type) { this.Id = id; this.Item = item; this.Rule = rule; this.NotificationType = type; }
public HotItem ParseItemListing(HotItem item, JObject json) { if (item == null) { item = new HotItem(); } try { try { item.BuyPrice = json["result"]["max_offer_unit_price"].ToObject <int>(); } catch { } try { item.SellPrice = json["result"]["min_sale_unit_price"].ToObject <int>(); } catch { } item.BuyVolume = json["result"]["offer_availability"].ToObject <int>(); item.SaleVolume = json["result"]["sale_availability"].ToObject <int>(); } catch { } return(item); }
public HotItem ParseItem(HotItem item, JObject json) { if (item == null) { item = new HotItem(); } try { try { item.Name = json["result"]["name"].ToObject <String>(); } catch { } try { item.ImgUri = json["result"]["img"].ToObject <String>(); } catch { } } catch { } return(item); }
public IList <HotItem> ParseTrendBuy(JToken json) { var items = new List <HotItem>(); foreach (var token in json) { var item = new HotItem(token["data_id"].ToObject <int>()) { SellPriceMoveCurrent = token["sell_price"].ToObject <float>(), BuyPriceMoveCurrent = token["buy_price"].ToObject <float>(), SellCountMove = token["sell_count"].ToObject <double>(), BuyCountMove = token["buy_count"].ToObject <double>(), DateTimeTrend = token["datetime"].ToObject <DateTime>(), SellPriceMove = token["sell_price_move"].ToObject <float>(), BuyPriceMove = token["buy_price_move"].ToObject <float>(), SellCountMovePercent = token["sell_count_move"].ToObject <float>(), BuyCountMovePercent = token["buy_count_move"].ToObject <float>(), }; items.Add(item); } return(items); }
public HotDataItem(HotItem apiItem) { BoardGameName = apiItem.Name; BoardGameId = apiItem.BoardGameId; Rank = apiItem.Rank; ThumbnailPath = apiItem.BoardGameId.ToString() + "_th.jpg"; YearPublished = apiItem.YearPublished; }
public void ApplyItemValues(HotItem item) { if (item != null) { Name = item.Name; Quantitiy = item.Quantity; Image = item.Image; } }
public void ViewRecipe(object param) { HotItem item = (HotItem)param; if (item != null && item.IsRecipeItem) { _mainViewModel.RecipeViewModel.ViewRecipe(item); } }
public void Register(HotItem item, ObservableDataSource <ItemProxy> items) { items.SetYMapping(y => y.SellPrice); items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime)); ChartPlotter.AddLineGraph(items, 2.0, item.Name + " S"); chartItems.Add(item.DataId, items); item.PropertyChanged += item_PropertyChanged; }
public void ViewRecipe(HotItem item) { Task.Factory.StartNew(() => { int itemId = HotItemController.DataIdToRecipeId(item.DataId); if (itemId > 0) { Recipe recipe = HotItemController.RecipeDB.Find(x => x.CreatedItemId == itemId); Add(recipe); } }); }
public SearchResult ParseSearch(SearchResult sr, JObject json) { if (sr == null) { sr = new SearchResult(); } try { sr.Count = json["count"].ToObject <int>(); int page = json["page"].ToObject <int>(); if (page == 0) { page++; } page--;// Yeah that makes sense \o/ sr.Offset = page * ItemsPerPage + 1; sr.Total = json["total"].ToObject <int>(); JToken token = json["results"]; for (int i = 0; i < token.Count(); i++) { int dataId = token[i]["data_id"].ToObject <int>(); string name = token[i]["name"].ToObject <String>(); string imgUri = token[i]["img"].ToObject <String>(); HotItem item = new HotItem(dataId) { Name = name, SellPrice = token[i]["min_sale_unit_price"].ToObject <int>(), BuyPrice = token[i]["max_offer_unit_price"].ToObject <int>(), BuyVolume = token[i]["offer_availability"].ToObject <long>(), SaleVolume = token[i]["sale_availability"].ToObject <long>(), DateTimeStamp = token[i]["price_last_changed"].ToObject <String>(), Rarity = token[i]["rarity"].ToObject <int>(), ImgUri = imgUri, Quantity = token[i]["sale_availability"].ToObject <int>(), Level = token[i]["restriction_level"].ToObject <int>() }; sr.Items.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } return(sr); }
public NotificationModel(HotItem item, NotifierRule rule, String message, DateTime timeStamp, NotificationType notificationType) { this.DataId = item.DataId; this.NotificationType = notificationType; this.TimeStamp = timeStamp; this.Message = message; this.Item = item; if (this.Item != null) { this.BuyMoney = item.BuyMoney; this.SellMoney = item.SellMoney; } this.Rule = rule; ApplyItemValues(item); // TODO: Refactoring, someday NotifierRule and NotificationModel must be merged together }
private async void UpdateHotItem() { //initalizing last week date DateTime td = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek); //sets td to the beginning of the week DateTime lastWeekStart = new DateTime(td.Year, td.Month, td.Day, 0, 0, 0).AddDays(-7); //Checking if hotItem are still up to date if (RealmManager.All <HotItem>().FirstOrDefault() != null) { //getting last time hot items have been updated DateTime lastUpdated = DateTime.Parse(RealmManager.All <HotItem>().FirstOrDefault().createdAt); if (DateTime.Compare(lastWeekStart, lastUpdated) == 0) { //return; } } RealmManager.RemoveAll <OrderList>(); RealmManager.RemoveAll <MenuItemList>(); List <MenuItem> somelist = new List <MenuItem>(); //finding each distinct category and adding it await GetOrdersRequest.SendGetOrdersRequest(); await GetMenuItemsRequest.SendGetMenuItemsRequest(); //creating a list of every menu item id for each order including duplicates List <OrderItem> menuItemIds = new List <OrderItem>(); //creating a dictionary to keep track of the count of each menuItem Dictionary <String, Dictionary <MenuItem, int> > menuItemCounter = new Dictionary <String, Dictionary <MenuItem, int> >(); foreach (Order o in RealmManager.All <OrderList>().FirstOrDefault().orders) { //this will ignore all uncompleted orders if (o.time_completed == null) { continue; } DateTime orderTime = DateTime.ParseExact(o.time_completed.Replace('T', ' ').TrimEnd('Z'), "yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture); //Makes it easier for keying the revenue map by WEEK orderTime = orderTime.AddDays(-(int)orderTime.DayOfWeek); orderTime = new DateTime(orderTime.Year, orderTime.Month, orderTime.Day, 0, 0, 0); //only added menuItems from orders for the current month if (DateTime.Compare(lastWeekStart, orderTime) == 0) { foreach (OrderItem oi in o.menuItems) { menuItemIds.Add(oi); //add next menuitem id } } } List <MenuItem> tempList = RealmManager.All <MenuItem>().ToList(); //updating menuItem map to see how often each was ordered foreach (OrderItem o in menuItemIds) { MenuItem tempMenuItem = tempList.Find(x => x._id == o._id); if (tempMenuItem == null) { continue; } if (menuItemCounter.ContainsKey(tempMenuItem.category)) { try { menuItemCounter[tempMenuItem.category][tempMenuItem] = menuItemCounter[tempMenuItem.category][tempMenuItem] + 1; } catch { menuItemCounter[tempMenuItem.category].Add(tempMenuItem, 1); } } else { menuItemCounter[tempMenuItem.category] = new Dictionary <MenuItem, int> { { tempMenuItem, 1 } }; } } foreach (string key in menuItemCounter.Keys) { KeyValuePair <MenuItem, int> topMenuItem; //finding the top menuItem for each category topMenuItem = menuItemCounter[key].Aggregate((x, y) => x.Value > y.Value ? x : y); //grabbing what was the top menuItem in the category from the previous week HotItem tempItem = RealmManager.Find <HotItem>(topMenuItem.Key.category); //if hotitem is in realm yet if (tempItem == null) { //creating new hotitem object HotItem tempHotItem = new HotItem(); tempHotItem.category = topMenuItem.Key.category; tempHotItem.createdAt = lastWeekStart.ToString(); tempHotItem._id = topMenuItem.Key._id; //getting menuItem object from list using hotItem MenuItem tempMenuItem = tempList.Find(x => x._id == topMenuItem.Key._id); RealmManager.Write(() => tempMenuItem.isHot = true); //updating database var response = await UpdateHotItemRequest.SendUpdateMenuItemRequest(tempMenuItem); //updaing realm RealmManager.AddOrUpdate <HotItem>(tempHotItem); if (!response) { ContentDialog responseAlert = new ContentDialog { Title = "Unsuccessful", Content = "Hot Item has not been updated successfully", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } } else { //if the hot item is infact new if (tempItem._id != topMenuItem.Key._id) { //finding old hotitem menuItem object MenuItem oldMenuItem = tempList.Find(x => x._id == tempItem._id); RealmManager.Write(() => oldMenuItem.isHot = false); //updating old hotItem in database var Firstresponse = await UpdateHotItemRequest.SendUpdateMenuItemRequest(oldMenuItem); if (!Firstresponse) { ContentDialog responseAlert = new ContentDialog { Title = "Unsuccessful", Content = "Original hot item has not been updated successfully", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } //finding new menuItem object using new hotItem MenuItem newMenuItem = tempList.Find(x => x._id == topMenuItem.Key._id); RealmManager.Write(() => newMenuItem.isHot = true); var Secondresponse = await UpdateHotItemRequest.SendUpdateMenuItemRequest(newMenuItem); //updating hot item in realm to match new hot Item RealmManager.Write(() => { tempItem._id = topMenuItem.Key._id; tempItem.createdAt = lastWeekStart.ToString(); }); if (!Secondresponse) { ContentDialog responseAlert = new ContentDialog { Title = "Unsuccessful", Content = "Hot Item has not been updated successfully", CloseButtonText = "Ok" }; ContentDialogResult result = await responseAlert.ShowAsync(); } } } } ContentDialog responseAlertCheck = new ContentDialog { Title = "Successful", Content = "Hot Items have been updated successfully", CloseButtonText = "Ok" }; ContentDialogResult resultCheck = await responseAlertCheck.ShowAsync(); }
public ItemContext(ContextType contextType, HotItem item) { this.ContextType = contextType; this.Item = item; }
static void Main(string[] args) { //2. Zadatak Console.WriteLine("Ovo je 2. zadatak."); Dataset newDataset = new Dataset("csv.txt"); Analyzer3rdParty newAnalyzer = new Analyzer3rdParty(); Adapter newAdapter = new Adapter(newAnalyzer); double[] averageRows = newAdapter.CalculateAveragePerRow(newDataset); Console.WriteLine("Prosjek redaka:"); for (int i = 0; i < averageRows.Length; i++) { Console.WriteLine(averageRows[i]); } double[] averageColumns = newAdapter.CalculateAveragePerColumn(newDataset); Console.WriteLine("Prosjek stupaca:"); for (int i = 0; i < averageColumns.Length; i++) { Console.WriteLine(averageColumns[i]); } //3. Zadatak Console.WriteLine("Ovo je 3. zadatak."); List <IRentable> BooksAndMovies = new List <IRentable>(); Book bookExample = new Book("Ana Karenjina"); Video videoExample = new Video("Rat i mir"); BooksAndMovies.Add(bookExample); BooksAndMovies.Add(videoExample); RentingConsolePrinter printerExample = new RentingConsolePrinter(); printerExample.PrintTotalPrice(BooksAndMovies); printerExample.DisplayItems(BooksAndMovies); //4. Zadatak Console.WriteLine("Ovo je 4. zadatak."); HotItem newestBook = new HotItem(new Book("Stranac")); HotItem newestVideo = new HotItem(new Video("Parazit")); BooksAndMovies.Add(newestBook); BooksAndMovies.Add(newestVideo); printerExample.PrintTotalPrice(BooksAndMovies); printerExample.DisplayItems(BooksAndMovies); /* Cijena liste sa samo prva dva elementa bila je 13.98. Dodavanje jos * elementa cijena bi trebala biti 27.96. Međutim, dodani asortiman * pripada HitItem-ima pa je cijena veća -> 31.94. Također uz naslove * stoji naznaka da artikl pripada Trendingu.*/ //5. Zadatak Console.WriteLine("Ovo je 5. zadatak."); List <IRentable> flashSale = new List <IRentable>(); for (int i = 0; i < 4; i++) { flashSale.Add(new DiscountedItem(BooksAndMovies[i], 20)); } printerExample.PrintTotalPrice(flashSale); printerExample.DisplayItems(flashSale); //6. zadatak Console.WriteLine("Ovo je 6. zadatak."); string myMail = "*****@*****.**"; string myPass = "******"; EmailValidator mailValidator = new EmailValidator(); PasswordValidator passValidator = new PasswordValidator(8); if (mailValidator.IsValidAddress(myMail)) { Console.WriteLine("Vasa eMail adresa" + myMail + "je ispravna."); } else { Console.WriteLine("Vasa eMail adresa " + myMail + " nije ispravna."); } if (passValidator.IsValidPassword(myPass)) { Console.WriteLine("Vasa lozinka je ispravna."); } else { Console.WriteLine("Vasa lozinka nije ispravna."); } //7. Zadatak Console.WriteLine("Ovo je 7. zadatak."); //UserEntry.ReadUserFromConsole(); RegistrationValidator finalValidator = new RegistrationValidator(); UserEntry entry = UserEntry.ReadUserFromConsole(); while (!(finalValidator.IsUserEntryValid(entry))) { entry = UserEntry.ReadUserFromConsole(); } }
public PriceChangedEventArgs(int id, HotItem item) { this.Id = id; this.Item = item; }
private void AddItemInternal(HotItem item) { HotItemController.Add(item); }
private void RemoveInternal(HotItem item) { HotItemController.Remove(item); }
public HotItem ParseItem(HotItem item, JObject json) { throw new NotImplementedException(); }
void transactionScraper_Finished(object sender, ScrapeFinishedEventArgs e) { var result = new SearchResult(e.Value, e.Arg.ToString(), e.Uri, JsonResultType.Transactions, e.TransactionType); for (int i = 0; i < Items.Count; i++) { for (int j = 0; j < result.Items.Count; j++) { if (Items[i].DataId == result.Items[j].DataId) { result.Items[j].Notify = Items[i].Notify; } } } MainWindowViewModel.Dispatcher.BeginInvoke(new Action(() => { for (int i = 0; i < result.Items.Count; i++) { result.Items[i].IsExpanded = false; var item = Items.FirstOrDefault(x => x.DataId == result.Items[i].DataId); if (item == null) { Items.Add(result.Items[i]); } else { bool replace = false; for (int j = 0; j < result.Items[i].Items.Count; j++) { //var innerItem = item.Items.FirstOrDefault(x => x.ListingId == result.Items[i].Items[j].ListingId); int count = result.Items[i].Items.Sum(x => x.Quantity); int oldCount = item.Items.Sum(x => x.Quantity); if (count != oldCount) { // var child = result.Items[i].Items[j]; // item.Items.Add(child); // item.GroupItem(child, item.Items); replace = true; } } if (replace) { result.Items[i].IsExpanded = item.IsExpanded; result.Items[i].IsGroup = item.IsGroup; result.Items[i].Notify = item.Notify; // Did i miss something ?? Items.Remove(item); Items.Add(result.Items[i]); } } } for (int i = 0; i < Items.Count; i++) { HotItem item = Items[i]; var rs = result.Items.FirstOrDefault(x => x.ListingId == item.ListingId); if (rs == null) { item.Notify = false; Items.Remove(item); i--; } } })); //Items = new ObservableCollection<HotItem>(result.Items); if (HotItemController.Config.IsTransactionNotificationEnabled) { FindBoughtAndSoldItems(TransactionType, Items.ToList()); } }