Esempio n. 1
0
        public void TestMethod1()
        {
            string htmlString = File.ReadAllText("TestData\\Gewinnzahlen06.html");
            var    prices     = PriceScraper.ExtractPrices(htmlString);

            Assert.IsNotNull(prices);
        }
Esempio n. 2
0
        public void TestMethod19()
        {
            string     htmlString = File.ReadAllText("TestData\\Gewinnzahlen19.html");
            List <Day> days       = PriceScraper.ExtractPrices(htmlString);

            Assert.IsNotNull(days);


            Console.Write(PriceHelper.PrintDays(days, true));

            for (int i = 1; i <= 16; i++)
            {
                Day day = days.SingleOrDefault(x => x.Date == i);

                Assert.IsNotNull(day);



                Assert.IsTrue(0 < day.Prices.Count, $"Day {i} has no Prices.");

                foreach (Price p in day.Prices)
                {
                    Assert.AreEqual(p.Numbers.Count, p.IntNumbers.Count());

                    Assert.IsTrue(p.Numbers.Any(n => !string.IsNullOrEmpty(n)), $"Price '{p.Description}' of day {i} has no numbers.");
                }
            }
        }
Esempio n. 3
0
        public async Task <string[]> GetSiteInfo(string url)
        {
            url = HttpUtility.UrlDecode(url);
            string[] res = await PriceScraper.FetchData(url);

            return(res);
        }
Esempio n. 4
0
        public async Task <ActionResult> DbUpdate(string authKey)
        {
            if (authKey != MailConfig.SendPass)
            {
                return(NoContent());
            }
            var Listings = _context.TrackLists.Where(e => e.UserId != 7).ToList();

            foreach (var item in Listings)
            {
                float price = 0f;
                try
                {
                    string[] info = await PriceScraper.FetchData(item.PageUrl);

                    price = float.Parse(info[1]);
                    if (item.MaxPrice >= price)
                    {
                        MailSender.MakeEmail(item.ListedEmail, item.ItemName,
                                             info[1], item.PageUrl, item.Vendor);
                    }
                }
                catch
                {
                    RemoveItem(item.Id);
                    continue;
                }

                var nodes = _context.ListTrends.Where(e => e.TrackListId == item.Id).ToList();

                bool isMax = false;
                nodes.ForEach(e => e.DaysAgo += 1);
                if (nodes.Count == 30)
                {
                    isMax = true;
                }
                PriceRecord NewNode = new PriceRecord
                {
                    DaysAgo     = 0,
                    Price       = price,
                    ItemName    = item.ItemName,
                    TrackListId = item.Id
                };
                _context.ListTrends.Add(NewNode);
                _context.SaveChanges();

                if (isMax)
                {
                    CapList(item.Id);
                }
            }

            return(Ok());
        }