Esempio n. 1
0
 public static DailyTimeIntervalScheduleBuilder DailyTriggerOnce(this DailyTimeIntervalScheduleBuilder builder,
                                                                 TimeOfDay fireTime,
                                                                 IEnumerable <DayOfWeek> onDaysOfWeek = null)
 {
     builder.StartingDailyAt(fireTime)
     .EndingDailyAfterCount(1)
     .OnDaysOfTheWeekIfAny(onDaysOfWeek);
     return(builder);
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
 public static DailyTimeIntervalScheduleBuilder DailyTriggerReccuring(this DailyTimeIntervalScheduleBuilder builder,
                                                                      int interval,
                                                                      IntervalUnit unit,
                                                                      TimeOfDay startTimeOfDay,
                                                                      TimeOfDay endTimeOfDay,
                                                                      IEnumerable <DayOfWeek> onDaysOfWeek = null)
 {
     builder.StartingDailyAt(startTimeOfDay)
     .EndingDailyAt(endTimeOfDay)
     .WithInterval(interval, unit)
     .OnDaysOfTheWeekIfAny(onDaysOfWeek);
     return(builder);
 }
        private static DailyTimeIntervalScheduleBuilder zCreateDailyTimeIntervalSchedule(DailyRepeatableSchedule schedule)
        {
            DailyTimeIntervalScheduleBuilder sb = DailyTimeIntervalScheduleBuilder.Create();

            switch (schedule.MissedScheduleMode)
            {
            case MissedScheduleMode.RunImmediately:
                sb = sb.WithMisfireHandlingInstructionFireAndProceed();
                break;

            case MissedScheduleMode.RunAtNextScheduledTime:
                sb = sb.WithMisfireHandlingInstructionDoNothing();
                break;

            default:
                throw new NotImplementedException();
            }
            if (schedule.RepeatsDailyOnInterval)
            {
                sb = sb.StartingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(
                                            schedule.DailyRepetitionStartTimeUtc.Hour,
                                            schedule.DailyRepetitionStartTimeUtc.Minute,
                                            schedule.DailyRepetitionStartTimeUtc.Second))
                     .WithIntervalInSeconds((int)schedule.DailyRepetitionInterval.TotalSeconds)
                     .EndingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(
                                        schedule.DailyRepetitionEndTimeUtc.Hour,
                                        schedule.DailyRepetitionEndTimeUtc.Minute,
                                        schedule.DailyRepetitionEndTimeUtc.Second));
            }
            else
            {
                sb = sb.StartingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(
                                            schedule.StartTimeUtc.Hour,
                                            schedule.StartTimeUtc.Minute,
                                            schedule.StartTimeUtc.Second))
                     .WithIntervalInHours(24);
            }
            return(sb);
        }
        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 (daysOfWeekStr != null)
            {
                ISet <DayOfWeek> daysOfWeek = new HashSet <DayOfWeek>();
                string[]         nums       = daysOfWeekStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (nums.Length > 0)
                {
                    foreach (String num in nums)
                    {
                        daysOfWeek.Add((DayOfWeek)Int32.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 = Int32.Parse(nums[0]);
                    int min  = Int32.Parse(nums[1]);
                    int sec  = Int32.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 = Int32.Parse(nums[3]);
                    int min  = Int32.Parse(nums[4]);
                    int sec  = Int32.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));
        }