protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOperableTrigger trigger)
        {
            CalendarIntervalTriggerImpl calTrig = (CalendarIntervalTriggerImpl) trigger;

            SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();

            props.Int1 = (calTrig.RepeatInterval);
            props.String1 = (calTrig.RepeatIntervalUnit.ToString());
            props.Int2 = (calTrig.TimesTriggered);

            return props;
        }
        protected override TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties props)
        {
            CalendarIntervalScheduleBuilder sb = CalendarIntervalScheduleBuilder.Create()
                .WithInterval(
                    props.Int1,
                    (IntervalUnit) Enum.Parse(typeof(IntervalUnit), props.String1, true));

            int timesTriggered = props.Int2;

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

            return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues);
        }
        protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOperableTrigger trigger)
        {
            CalendarIntervalTriggerImpl calTrig = (CalendarIntervalTriggerImpl) trigger;

            SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();

            props.Int1 = calTrig.RepeatInterval;
            props.String1 = calTrig.RepeatIntervalUnit.ToString();
            props.Int2 = calTrig.TimesTriggered;
            props.String2 = calTrig.TimeZone.Id;
            props.Boolean1 = calTrig.PreserveHourOfDayAcrossDaylightSavings;
            props.Boolean2 = calTrig.SkipDayIfHourDoesNotExist;

            return props;
        }
        protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOperableTrigger trigger)
        {
            DailyTimeIntervalTriggerImpl dailyTrigger = (DailyTimeIntervalTriggerImpl) trigger;
            SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();

            props.Int1 = dailyTrigger.RepeatInterval;
            props.String1 = dailyTrigger.RepeatIntervalUnit.ToString();
            props.Int2 = dailyTrigger.TimesTriggered;

            ISet<DayOfWeek> days = dailyTrigger.DaysOfWeek;
            string daysStr = string.Join(",", days.Cast<int>().Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray());
            props.String2 = daysStr;

            StringBuilder timeOfDayBuffer = new StringBuilder();
            TimeOfDay startTimeOfDay = dailyTrigger.StartTimeOfDay;
            if (startTimeOfDay != null)
            {
                timeOfDayBuffer.Append(startTimeOfDay.Hour).Append(",");
                timeOfDayBuffer.Append(startTimeOfDay.Minute).Append(",");
                timeOfDayBuffer.Append(startTimeOfDay.Second).Append(",");
            }
            else
            {
                timeOfDayBuffer.Append(",,,");
            }

            TimeOfDay endTimeOfDay = dailyTrigger.EndTimeOfDay;
            if (endTimeOfDay != null)
            {
                timeOfDayBuffer.Append(endTimeOfDay.Hour).Append(",");
                timeOfDayBuffer.Append(endTimeOfDay.Minute).Append(",");
                timeOfDayBuffer.Append(endTimeOfDay.Second);
            }
            else
            {
                timeOfDayBuffer.Append(",,,");
            }
            props.String3 = timeOfDayBuffer.ToString();
            props.Long1 = dailyTrigger.RepeatCount;
            return props;
        }
        protected override TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties props)
        {
            TimeZoneInfo tz = null; // if we use null, that's ok as system default tz will be used
            string tzId = props.String2;
            if (tzId != null && tzId.Trim().Length != 0) // there could be null entries from previously released versions
            {
                tz = TimeZoneInfo.FindSystemTimeZoneById(tzId);
            }

            CalendarIntervalScheduleBuilder sb = CalendarIntervalScheduleBuilder.Create()
                .WithInterval(props.Int1, (IntervalUnit) Enum.Parse(typeof(IntervalUnit), props.String1, true))
                .InTimeZone(tz)
                .PreserveHourOfDayAcrossDaylightSavings(props.Boolean1)
                .SkipDayIfHourDoesNotExist(props.Boolean2);

            int timesTriggered = props.Int2;

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

            return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues);
        }
        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) 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);
        }
 protected abstract TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties properties);
        public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
        {
            using (IDbCommand cmd = adoUtil.PrepareCommand(conn, AdoJobStoreUtil.ReplaceTablePrefix(SelectSimplePropsTrigger, tablePrefix, schedNameLiteral)))
            {
                adoUtil.AddCommandParameter(cmd, "@", triggerKey.Name);
                adoUtil.AddCommandParameter(cmd, "@", triggerKey.Group);

                using (IDataReader rs = cmd.ExecuteReader())
                {
                    if (rs.Read())
                    {
                        SimplePropertiesTriggerProperties properties = new SimplePropertiesTriggerProperties();

                        properties.String1 = (rs.GetString(ColumnStrProp1));
                        properties.String2 = (rs.GetString(ColumnStrProp2));
                        properties.String3 = (rs.GetString(ColumnStrProp3));
                        properties.Int1 = (rs.GetInt32(ColumnIntProp1));
                        properties.Int2 = (rs.GetInt32(ColumnIntProp2));
                        properties.Long1 = (rs.GetInt32(ColumnLongProp1));
                        properties.Long2 = (rs.GetInt32(ColumnLongProp2));
                        properties.Decimal1 = (rs.GetDecimal(ColumnDecProp1));
                        properties.Decimal2 = (rs.GetDecimal(ColumnDecProp2));
                        properties.Boolean1 = (rs.GetBoolean(ColumnBoolProp1));
                        properties.Boolean2 = (rs.GetBoolean(ColumnBoolProp2));

                        return GetTriggerPropertyBundle(properties);
                    }
                }
            }

            throw new InvalidOperationException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlSelectSimpleTrigger, tablePrefix, schedNameLiteral));
        }
示例#9
0
 protected abstract TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties properties);
        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)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));
        }