Пример #1
0
        public void Apply(TriggerBuilder builder, TriggerPropertiesViewModel model)
        {
            builder.WithDailyTimeIntervalSchedule(x =>
            {
                if (!string.IsNullOrEmpty(TimeZone))
                {
                    x.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(TimeZone));
                }

                if (!RepeatForever)
                {
                    x.WithRepeatCount(RepeatCount.Value);
                }

                x.WithInterval(RepeatInterval.Value, RepeatUnit);
                x.StartingDailyAt(StartTime.Value.ToTimeOfDay());
                x.EndingDailyAt(EndTime.Value.ToTimeOfDay());
                x.OnDaysOfTheWeek(DaysOfWeek.GetSelected().ToArray());

                switch (model.MisfireInstruction)
                {
                case InstructionNotSet:
                    break;

                case IgnoreMisfirePolicy:
                    x.WithMisfireHandlingInstructionIgnoreMisfires();
                    break;

                case DailyTimeIntervalTrigger.DoNothing:
                    x.WithMisfireHandlingInstructionDoNothing();
                    break;

                case DailyTimeIntervalTrigger.FireOnceNow:
                    x.WithMisfireHandlingInstructionFireAndProceed();
                    break;

                default:
                    throw new ArgumentException("Invalid value: " + model.MisfireInstruction, nameof(model.MisfireInstruction));
                }
            });
        }