public static IEnumerable <ClientRating> CaclucatedAndSave(DateTime date)
        {
            var ratings = ReadRating(date);

            if (ratings.Length > 0)
            {
                return(ratings);
            }

            var calculator = new RatingCalculator(date, date.LastDayOfMonth());

            ratings = calculator.Ratings().ToArray();
            Save(date, ratings);
            return(ratings);
        }
Beispiel #2
0
        public void Work(CancellationToken token)
        {
            Date = DateTime.Today;
            var ratings = RatingCalculator.CaclucatedAndSave(Date.AddMonths(-1).FirstDayOfMonth());

            var costCalculator = new CostCalculator(token)
            {
                CostThreshold = Config.CostThreshold
            };
            var offers       = costCalculator.Offers(ratings, Config.ThreadCount);
            var averageCosts = costCalculator.Calculate(offers);

            log.DebugFormat("Начинаю сохранять средние цены");
            var inserted = costCalculator.Save(Date, averageCosts);

            log.DebugFormat("Закончил сохранять средние цены, всего {0}", inserted);
        }