Ejemplo n.º 1
0
        private void ResolveTimeType(TimeUnit timeUnit, JobConfiguration configuration)
        {
            switch (configuration.TimeType)
            {
            case JobTimeTypeEnum.Seconds:
                timeUnit.Seconds();
                break;

            case JobTimeTypeEnum.Minutes:
                timeUnit.Minutes();
                break;

            case JobTimeTypeEnum.Hours:
                timeUnit.Hours();
                break;

            case JobTimeTypeEnum.Days:
                var dayUnit = timeUnit.Days();
                if (configuration.AtHour.HasValue && configuration.AtMinutes.HasValue)
                {
                    dayUnit.At(configuration.AtHour.Value, configuration.AtMinutes.Value);
                }
                break;

            default:
                throw new Exception($"Unexpected job time type - {configuration.TimeType}");
            }
        }
Ejemplo n.º 2
0
        private static object Period(this TimeUnit timeUnit, Period period)
        {
            switch (period)
            {
            case Attributes.Period.Day:
                return(timeUnit.Days());

            case Attributes.Period.Second:
                return(timeUnit.Seconds());

            case Attributes.Period.Minute:
                return(timeUnit.Minutes());

            case Attributes.Period.Hour:
                return(timeUnit.Hours());

            case Attributes.Period.Month:
                return(timeUnit.Months());

            case Attributes.Period.Milliseconds:
                return(timeUnit.Milliseconds());

            case Attributes.Period.Years:
                return(timeUnit.Years());

            case Attributes.Period.Weekdays:
                return(timeUnit.Weekdays());

            default:
                throw new ArgumentOutOfRangeException(nameof(period), period, null);
            }
        }