//public static string GetPricesAsString(string searchNumber, string htmlString) //{ // List<Price> prices = PriceScraper.ExtractPrices(htmlString); // return PrintPrices(prices, searchNumber); //} public static string GetPricesAsString(ICollection <string> searchNumbers, string htmlString) { List <Day> days = PriceScraper.ExtractPrices(htmlString); string strReturn = PrintIsWinnerOrLoser(searchNumbers, days); return(string.Concat(strReturn, PrintDays(days))); }
public override void OnReceive(Context context, Intent intent) { var preferences = context.GetSharedPreferences("myPrefs", FileCreationMode.Private); var numbers = preferences.GetStringSet("keyNumbers", new HashSet <string>()).ToList(); // string number = intent.GetStringExtra("number"); // Toast.MakeText(context, "Leo Winner scheduler searching for number " + number, ToastLength.Long).Show(); var html = Task.Run(MainActivity.LoadStringFromUrl).Result; List <Day> days = PriceScraper.ExtractPrices(html); string searchResult = PriceHelper.PrintIsWinnerOrLoser(numbers, days); MakeNotification(context, searchResult); }
//private static string PrintPrices(List<Price> prices, string searchNumber) //{ // string pricesString = "Detected the following prices:\n"; // string stringWinner = string.Empty; // for (int day = 24; day >= 1; day--) // { // if (prices.Any(x => x.Day == day)) // { // pricesString += "Prices of day " + day + "\n"; // } // foreach (var p in prices.Where(x => x.Day == day)) // { // pricesString += p.ToString() + "\n"; // if (p.Numbers.Any(x => x.Equals(searchNumber))) // { // stringWinner += " \n******* WINNNER *******\n\n"; // stringWinner += " Your price: " + p.Description; // } // } // } // if (stringWinner == String.Empty) // { // stringWinner = searchNumber + ": - Better luck next time :)"; // } // else // { // // Toast.MakeText(this, stringWinner, ToastLength.Short).Show(); // } // return stringWinner + "\n\n" + pricesString; //} // return string.Empty if no price found public static string GetPriceOfNUmber(string number, string htmlString) { List <Day> days = PriceScraper.ExtractPrices(htmlString); List <Price> winners = new List <Price>(); foreach (Day d in days) { winners.AddRange(d.GetWinningPrices(number)); } if (winners.Any()) { return(string.Join("\n", winners.Select(x => x.Description))); } return(string.Empty); }