Ejemplo n.º 1
0
        private static string GetDaysOfMonth(IRepeatableActivity schedule)
        {
            IEnumerable <int> daysOfMonth = schedule.DaysOfMounth;

            if (daysOfMonth == null || !daysOfMonth.Any())
            {
                return(UNDEFINED);
            }

            return(Separate(daysOfMonth));
        }
Ejemplo n.º 2
0
        private static string GetDaysOfWeek(IRepeatableActivity schedule)
        {
            IEnumerable <int> daysOfWeek = schedule.DaysOfWeek;

            if (daysOfWeek == null || !daysOfWeek.Any())
            {
                return(UNDEFINED);
            }

            return(Separate(daysOfWeek));
        }
Ejemplo n.º 3
0
        public static string GetCronExpression(this IRepeatableActivity schedule)
        {
            string seconds     = GetSeconds(schedule);
            string minutes     = GetMinutes(schedule);
            string hours       = GetHours(schedule);
            string daysOfMonth = GetDaysOfMonth(schedule);
            string monthes     = GetMonths(schedule);
            string daysOfWeek  = GetDaysOfWeek(schedule);
            string years       = GetYears(schedule);

            if (monthes == "" || years == "")
            {
                if (schedule.StartTime <= DateTime.Now)
                {
                    return(TriggerInThePast);
                }

                return($"{seconds} {minutes} {hours} {schedule.StartTime.Day} {schedule.StartTime.Month} {UNDEFINED} {schedule.StartTime.Year}");
            }

            return($"{seconds} {minutes} {hours} {daysOfMonth} {monthes} {daysOfWeek} {years}");
        }
Ejemplo n.º 4
0
 private static string GetYears(IRepeatableActivity schedule)
 {
     return(Separate(schedule.Years));
 }
Ejemplo n.º 5
0
 private static string GetMonths(IRepeatableActivity schedule)
 {
     return(Separate(schedule.Monthes));
 }
Ejemplo n.º 6
0
 private static string GetHours(IRepeatableActivity schedule)
 {
     return(schedule.StartTime.Hour.ToString());
 }
Ejemplo n.º 7
0
 private static string GetMinutes(IRepeatableActivity schedule)
 {
     return(schedule.StartTime.Minute.ToString());
 }
Ejemplo n.º 8
0
 private static string GetSeconds(IRepeatableActivity schedule)
 {
     return(schedule.StartTime.Second.ToString());
 }