public RandomCashBoxSimulator(ILogger <RandomCashBoxSimulator> logger, IHubContext <OrdersHub, IOrdersHub> ordersHub) { _logger = logger; _logger.LogInformation("Beginning dish population...."); var scraperDataKFCFileNames = Directory.GetFiles($"{Directory.GetCurrentDirectory()}\\ScrapersData\\KFC\\"); foreach (string scrapedFileName in scraperDataKFCFileNames) { Dish[] deserializedDishes = DishDeserializer.DeserializeDishFile(scrapedFileName); foreach (var deserializedDish in deserializedDishes) { //Generating random estimated cooking time //Can't generated random decimal so using tricks deserializedDish.EstimatedCookingTime = _random.Next( Decimal.ToInt32(MIN_ESTIMATED_COOKING_TIME) * 100, Decimal.ToInt32(MAX_ESTIMATED_COOKING_TIME) * 100 + 1 ) / 100; } _dishesPool.AddDishes(deserializedDishes); } _logger.LogInformation("Populated Dishes..."); _ordersHub = ordersHub; }
public static void Main(string[] args) { KFCScraper scraper = new KFCScraper(); scraper.MyScrape("/ScrapersData/KFC/"); var scraperDataKFC = Directory.GetFiles(Directory.GetCurrentDirectory() + "/ScrapersData/KFC/"); DishesPool dishesPool = DishesPool.GetInstance(); foreach (var scrapedFile in scraperDataKFC) { dishesPool.AddDishes(DataWorker.DeserialiseToDishes(scrapedFile)); } CreateHostBuilder(args).Build().Run(); }