Пример #1
0
        public async Task <IEnumerable <JobSchedule> > GetJobSchedules()
        {
            var fireTimes = await _repository.GetAllNotificationsFireTimes();

            var schedules = fireTimes.Select(f =>
                                             // new JobSchedule(typeof(NotificationJob),
                                             //     calculateCronExpresion(f))
                                             new JobSchedule
            {
                Cron     = calculateCronExpresion(f),
                FireTime = f
            }
                                             );
            // delete, if cronn count is more > 1
            var jobSchedules      = schedules as JobSchedule[] ?? schedules.ToArray();
            var distinctSchedules = jobSchedules.DistinctBy(s => s.Cron).ToArray();

            return(distinctSchedules);
        }