private static Tuple <DateTime, ItemOffers> DownloadOffers(Item item) { var url = "http://warframe.market/api/get_orders/firstPart/secondPart"; var itemType = item.item_type; var itemName = item.item_name; if (itemName.Contains(" ")) { itemName = itemName.Replace(" ", "%20"); } url = url.Replace("firstPart", itemType); url = url.Replace("secondPart", itemName); string contents; restart: try { using (var wc = new WebClient()) contents = wc.DownloadString(url); } catch (Exception e) { Console.WriteLine($"Error: {e}"); goto restart; } return(new Tuple <DateTime, ItemOffers>(DateTime.UtcNow, ItemOffers.FromJson(contents))); }
public CatalogPage(int Id, int ParentId, string Enabled, string Caption, string PageLink, int Icon, int MinRank , string Template, string PageStrings1, string PageStrings2, string CaptionEn, string CaptionBr, string PageStrings2En, string PageStrings2Br, Dictionary <int, CatalogItem> Items) { this.Id = Id; this.ParentId = ParentId; this.Enabled = Enabled.ToLower() == "1" ? true : false; this.Caption = Caption; this.CaptionEn = CaptionEn; this.CaptionBr = CaptionBr; this.PageLink = PageLink; this.Icon = Icon; this.MinimumRank = MinRank; this.Template = Template; foreach (string Str in PageStrings1.Split('|')) { if (this.PageStrings1 == null) { this.PageStrings1 = new List <string>(); } this.PageStrings1.Add(Str); } foreach (string Str in PageStrings2.Split('|')) { if (this.PageStrings2 == null) { this.PageStrings2 = new List <string>(); } this.PageStrings2.Add(Str); } foreach (string Str in PageStrings2En.Split('|')) { if (this.PageStrings2En == null) { this.PageStrings2En = new List <string>(); } this.PageStrings2En.Add(Str); } foreach (string Str in PageStrings2Br.Split('|')) { if (this.PageStrings2Br == null) { this.PageStrings2Br = new List <string>(); } this.PageStrings2Br.Add(Str); } this.Items = Items; this.ItemOffers = new Dictionary <int, CatalogItem>(); if (Template == "default_3x3") { foreach (CatalogItem item in this.Items.Values) { if (item.IsLimited) { continue; } if (!ItemOffers.ContainsKey(item.Id)) { ItemOffers.Add(item.Id, item); } } } }