Пример #1
0
        private void ConfigureScheduleBuilder(DailyTimeIntervalScheduleBuilder ScheduleBuilder)
        {
            //ScheduleBuilder = ScheduleBuilder.InTimeZone(TimeZoneInfo.Utc);
            //ScheduleBuilder = ScheduleBuilder.StartingDailyAt(new TimeOfDay(0, 0, 5));
            //ScheduleBuilder = ScheduleBuilder.WithInterval(1, IntervalUnit.Month);

            DateTimeOffset Df = DateTimeOffset.Now.AddSeconds(5.0);

            ScheduleBuilder = ScheduleBuilder.InTimeZone(TimeZoneInfo.Local);
            ScheduleBuilder = ScheduleBuilder.StartingDailyAt(new TimeOfDay(Df.Hour, Df.Minute, Df.Second));
            ScheduleBuilder = ScheduleBuilder.WithInterval(20, IntervalUnit.Second);
        }
Пример #2
0
        protected override TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties props)
        {
            int    repeatCount     = (int)props.Long1;
            int    interval        = props.Int1;
            string intervalUnitStr = props.String1;
            string daysOfWeekStr   = props.String2;
            string timeOfDayStr    = props.String3;

            IntervalUnit intervalUnit = (IntervalUnit)Enum.Parse(typeof(IntervalUnit), intervalUnitStr, true);
            DailyTimeIntervalScheduleBuilder scheduleBuilder = DailyTimeIntervalScheduleBuilder.Create()
                                                               .WithInterval(interval, intervalUnit)
                                                               .WithRepeatCount(repeatCount);

            if (!string.IsNullOrEmpty(props.TimeZoneId))
            {
                scheduleBuilder.InTimeZone(TimeZoneUtil.FindTimeZoneById(props.TimeZoneId));
            }

            if (daysOfWeekStr != null)
            {
                var      daysOfWeek = new HashSet <DayOfWeek>();
                string[] nums       = daysOfWeekStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (nums.Length > 0)
                {
                    foreach (string num in nums)
                    {
                        daysOfWeek.Add((DayOfWeek)int.Parse(num));
                    }
                    scheduleBuilder.OnDaysOfTheWeek(daysOfWeek);
                }
            }
            else
            {
                scheduleBuilder.OnDaysOfTheWeek(DailyTimeIntervalScheduleBuilder.AllDaysOfTheWeek);
            }

            if (timeOfDayStr != null)
            {
                string[]  nums = timeOfDayStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                TimeOfDay startTimeOfDay;
                if (nums.Length >= 3)
                {
                    int hour = int.Parse(nums[0]);
                    int min  = int.Parse(nums[1]);
                    int sec  = int.Parse(nums[2]);
                    startTimeOfDay = new TimeOfDay(hour, min, sec);
                }
                else
                {
                    startTimeOfDay = TimeOfDay.HourMinuteAndSecondOfDay(0, 0, 0);
                }
                scheduleBuilder.StartingDailyAt(startTimeOfDay);

                TimeOfDay endTimeOfDay;
                if (nums.Length >= 6)
                {
                    int hour = int.Parse(nums[3]);
                    int min  = int.Parse(nums[4]);
                    int sec  = int.Parse(nums[5]);
                    endTimeOfDay = new TimeOfDay(hour, min, sec);
                }
                else
                {
                    endTimeOfDay = TimeOfDay.HourMinuteAndSecondOfDay(23, 59, 59);
                }
                scheduleBuilder.EndingDailyAt(endTimeOfDay);
            }
            else
            {
                scheduleBuilder.StartingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(0, 0, 0));
                scheduleBuilder.EndingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(23, 59, 59));
            }


            int timesTriggered = props.Int2;

            string[] statePropertyNames  = { "timesTriggered" };
            object[] statePropertyValues = { timesTriggered };

            return(new TriggerPropertyBundle(scheduleBuilder, statePropertyNames, statePropertyValues));
        }