public override void Validate()
        {
            base.Validate();

            if (DurationCountInYears <= 0 || DurationCountInYears > PolicyConstants.MaxAllowedRetentionDurationCount)
            {
                throw new ArgumentException(Resources.RetentionDurationCountInvalidException);
            }

            if (MonthsOfYear == null || MonthsOfYear.Count == 0 || MonthsOfYear.Count != MonthsOfYear.Distinct().Count())
            {
                throw new ArgumentException(Resources.YearlyScheduleMonthsOfYearException);
            }

            if (RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
            {
                if (RetentionScheduleDaily == null)
                {
                    throw new ArgumentException(Resources.MonthlyYearlyRetentionDailySchedulePolicyNULLException);
                }

                RetentionScheduleDaily.Validate();
            }

            if (RetentionScheduleFormatType == RetentionScheduleFormat.Weekly)
            {
                if (RetentionScheduleWeekly == null)
                {
                    throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException);
                }

                RetentionScheduleWeekly.Validate();
            }
        }
예제 #2
0
        public override void Validate()
        {
            base.Validate();

            int MinDurationCountInYears = 1, MaxDurationCountInYears = PolicyConstants.MaxAllowedRetentionDurationCountYearly;

            if (BackupManagementType == Management.RecoveryServices.Backup.Models.BackupManagementType.AzureStorage)
            {
                MinDurationCountInYears = PolicyConstants.AfsYearlyRetentionMin;
                MaxDurationCountInYears = PolicyConstants.AfsYearlyRetentionMax;
            }
            if (DurationCountInYears < MinDurationCountInYears || DurationCountInYears > MaxDurationCountInYears)
            {
                throw new ArgumentException(Resources.RetentionDurationCountInvalidException);
            }

            if (MonthsOfYear == null || MonthsOfYear.Count == 0 || MonthsOfYear.Count != MonthsOfYear.Distinct().Count())
            {
                throw new ArgumentException(Resources.YearlyScheduleMonthsOfYearException);
            }

            if (RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
            {
                if (RetentionScheduleDaily == null)
                {
                    throw new ArgumentException(Resources.MonthlyYearlyRetentionDailySchedulePolicyNULLException);
                }

                RetentionScheduleDaily.Validate();
            }

            if (RetentionScheduleFormatType == RetentionScheduleFormat.Weekly)
            {
                if (RetentionScheduleWeekly == null)
                {
                    throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException);
                }

                RetentionScheduleWeekly.Validate();
            }
        }
        public override void Validate(ScheduleRunType ScheduleRunFrequency = 0)
        {
            base.Validate(ScheduleRunFrequency);

            int MinDurationCountInMonths = 1, MaxDurationCountInMonths = PolicyConstants.MaxAllowedRetentionDurationCountMonthly;

            if (BackupManagementType == Management.RecoveryServices.Backup.Models.BackupManagementType.AzureStorage)
            {
                MinDurationCountInMonths = PolicyConstants.AfsMonthlyRetentionMin;
                MaxDurationCountInMonths = PolicyConstants.AfsMonthlyRetentionMax;
            }

            if (DurationCountInMonths < MinDurationCountInMonths || DurationCountInMonths > MaxDurationCountInMonths)
            {
                throw new ArgumentException(Resources.RetentionDurationCountInvalidException);
            }

            if (RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
            {
                if (RetentionScheduleDaily == null)
                {
                    throw new ArgumentException(Resources.MonthlyYearlyRetentionDailySchedulePolicyNULLException);
                }

                RetentionScheduleDaily.Validate();
            }

            if (RetentionScheduleFormatType == RetentionScheduleFormat.Weekly)
            {
                if (RetentionScheduleWeekly == null)
                {
                    throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException);
                }

                RetentionScheduleWeekly.Validate();
            }
        }