public override void Validate()
        {
            //Currently only one scheduled run time is allowed
            //Validate that the schedule runtime is in multiples of 30 Mins
            if (ScheduleRunTimes == null || ScheduleRunTimes.Count != 1 ||
                ScheduleRunTimes[0].Minute % 30 != 0 ||
                ScheduleRunTimes[0].Second != 0 ||
                ScheduleRunTimes[0].Millisecond != 0)
            {
                throw new ArgumentException(Resources.InvalidScheduleTimeInScheduleException);
            }

            if (ScheduleRunTimes[0].Kind != DateTimeKind.Utc)
            {
                throw new ArgumentException(Resources.ScheduleTimeNotInUTCTimeZoneException);
            }

            if (ScheduleRunFrequency == ScheduleRunType.Weekly)
            {
                if (ScheduleRunDays == null || ScheduleRunDays.Count == 0 ||
                    ScheduleRunDays.Count != ScheduleRunDays.Distinct().Count())
                {
                    throw new ArgumentException(Resources.InvalidScheduleRunDaysInScheduleException);
                }
            }
        }
Exemple #2
0
        public override void Validate()
        {
            //Currently only one scheduled run time is allowed
            //Validate that the schedule runtime is in multiples of 30 Mins
            if (ScheduleRunFrequency != ScheduleRunType.Hourly)
            {
                if (ScheduleInterval != null || ScheduleWindowStartTime != null || ScheduleWindowDuration != null)
                {
                    throw new ArgumentException(Resources.HourlyScheduleNotNull);
                }

                if (ScheduleRunTimes == null || ScheduleRunTimes.Count != 1 ||
                    ScheduleRunTimes[0].Minute % 30 != 0 ||
                    ScheduleRunTimes[0].Second != 0 ||
                    ScheduleRunTimes[0].Millisecond != 0)
                {
                    throw new ArgumentException(Resources.InvalidScheduleTimeInScheduleException);
                }

                if (ScheduleRunTimes[0].Kind != DateTimeKind.Utc)
                {
                    throw new ArgumentException(Resources.ScheduleTimeNotInUTCTimeZoneException);
                }

                if (ScheduleRunFrequency == ScheduleRunType.Weekly)
                {
                    if (ScheduleRunDays == null || ScheduleRunDays.Count == 0 ||
                        ScheduleRunDays.Count != ScheduleRunDays.Distinct().Count())
                    {
                        throw new ArgumentException(Resources.InvalidScheduleRunDaysInScheduleException);
                    }
                }
            }
            else
            {
                if (ScheduleInterval == null || ScheduleWindowStartTime == null || ScheduleWindowDuration == null || ScheduleRunTimeZone == null)
                {
                    throw new ArgumentException(String.Format(Resources.HourlyScheduleNullValueException));
                }

                if (ScheduleRunDays != null || ScheduleRunTimes != null)
                {
                    throw new ArgumentException(Resources.NonHourlyAttributesNotNull);
                }

                if (ScheduleWindowDuration < ScheduleInterval)
                {
                    throw new ArgumentException(String.Format(Resources.WindowDurationLessThanInterval));
                }

                if (((DateTime)ScheduleWindowStartTime).Kind != DateTimeKind.Utc)
                {
                    throw new ArgumentException(Resources.WindowStartTimeNotInUTC);
                }

                DateTime windowStartTime = (DateTime)ScheduleWindowStartTime;

                // If ScheduleWindowDuration is greator than (23:30 - ScheduleWindowStartTime) then throw exception
                // if non-UTC times are allowed then this exception needs to change
                if (windowStartTime.Minute % 30 != 0 || windowStartTime.Second != 0 || windowStartTime.Millisecond != 0)
                {
                    throw new ArgumentException(Resources.InvalidScheduleTimeInScheduleException);
                }
            }
        }
Exemple #3
0
        public override void Validate()
        {
            //Currently only one scheduled run time is allowed
            //Validate that the schedule runtime is in multiples of 30 Mins
            if (ScheduleRunFrequency != ScheduleRunType.Hourly)
            {
                if (ScheduleRunTimes == null || ScheduleRunTimes.Count != 1 ||
                    ScheduleRunTimes[0].Minute % 30 != 0 ||
                    ScheduleRunTimes[0].Second != 0 ||
                    ScheduleRunTimes[0].Millisecond != 0)
                {
                    throw new ArgumentException(Resources.InvalidScheduleTimeInScheduleException);
                }

                if (ScheduleRunTimes[0].Kind != DateTimeKind.Utc)
                {
                    throw new ArgumentException(Resources.ScheduleTimeNotInUTCTimeZoneException);
                }

                if (ScheduleRunFrequency == ScheduleRunType.Weekly)
                {
                    if (ScheduleRunDays == null || ScheduleRunDays.Count == 0 ||
                        ScheduleRunDays.Count != ScheduleRunDays.Distinct().Count())
                    {
                        throw new ArgumentException(Resources.InvalidScheduleRunDaysInScheduleException);
                    }
                }
            }
            else
            {
                if (ScheduleInterval == null || ScheduleWindowStartTime == null || ScheduleWindowDuration == null || ScheduleRunTimeZone == null)
                {
                    throw new ArgumentException(String.Format(Resources.HourlyScheduleNullValueException));
                }

                List <int> AllowedScheduleIntervals = new List <int> {
                    4, 6, 8, 12
                };
                if (!(AllowedScheduleIntervals.Contains((int)ScheduleInterval)))
                {
                    throw new ArgumentException(String.Format(Resources.InvalidScheduleInterval, string.Join(",", AllowedScheduleIntervals.ToArray())));
                }

                if ((ScheduleWindowDuration < ScheduleInterval) || (ScheduleWindowDuration < PolicyConstants.AfsHourlyWindowDurationMin) ||
                    (ScheduleWindowDuration > PolicyConstants.AfsHourlyWindowDurationMax))
                {
                    throw new ArgumentException(String.Format(Resources.InvalidScheduleWindowDuration, PolicyConstants.AfsHourlyWindowDurationMin, PolicyConstants.AfsHourlyWindowDurationMax));
                }

                DateTime windowStartTime  = (DateTime)ScheduleWindowStartTime;
                DateTime minimumStartTime = new DateTime(windowStartTime.Year, windowStartTime.Month, windowStartTime.Day, 00, 00, 00, 00, DateTimeKind.Utc);
                DateTime maximumStartTime = new DateTime(windowStartTime.Year, windowStartTime.Month, windowStartTime.Day, 19, 30, 00, 00, DateTimeKind.Utc);

                // final backup time can be 23:30:00
                DateTime finalBackupTime = new DateTime(windowStartTime.Year, windowStartTime.Month, windowStartTime.Day, 23, 30, 00, 00, DateTimeKind.Utc);
                TimeSpan diff            = finalBackupTime - windowStartTime;

                //validate window start time
                if (ScheduleWindowStartTime > maximumStartTime || ScheduleWindowStartTime < minimumStartTime)
                {
                    throw new ArgumentException(String.Format(Resources.ScheduleWindowStartTimeOutOfRange));
                }

                if (diff.TotalHours < ScheduleWindowDuration)
                {
                    throw new ArgumentException(String.Format(Resources.InvalidLastBackupTime));
                }

                // if non-UTC times are allowed then this exception needs to change
                if (windowStartTime.Minute % 30 != 0 || windowStartTime.Second != 0 || windowStartTime.Millisecond != 0)
                {
                    throw new ArgumentException(Resources.InvalidScheduleTimeInScheduleException);
                }
            }
        }