Example #1
0
        protected internal static BackupSchedule FromBackupScheduleView(BackupRestoreView.BackupSchedule backupScheduleView)
        {
            BackupSchedule backupSchedule = null;

            if (backupScheduleView.ScheduleKind == Enums.BackupScheduleType.FrequencyBased)
            {
                backupSchedule =
                    FrequencyBasedBackupSchedule.FromFrequencyBasedBackupScheduleView(
                        (BackupRestoreView.FrequencyBasedBackupSchedule)backupScheduleView);
            }
            else if (backupScheduleView.ScheduleKind == BackupScheduleType.TimeBased)
            {
                backupSchedule =
                    TimeBasedBackupSchedule.FromTimeBasedBackupScheduleView(
                        (BackupRestoreView.TimeBasedBackupSchedule)backupScheduleView);
            }
            return(backupSchedule);
        }
        internal static FrequencyBasedBackupSchedule FromFrequencyBasedBackupScheduleView(
            BackupRestoreView.FrequencyBasedBackupSchedule frequencyBasedBackupScheduleView)
        {
            //from TimeSpan to BackupScheduleInterval.
            TimeSpan timespan = frequencyBasedBackupScheduleView.Interval;
            BackupScheduleInterval intervalType;
            int interval;

            if (timespan > TimeSpan.FromDays(maximumTimeIntervalInDays))
            {
                throw new ArgumentException(StringResources.InvalidBackupInterval);
            }

            if (timespan.Minutes != 0)
            {
                intervalType = BackupScheduleInterval.Minutes;
                interval     = (int)timespan.TotalMinutes;
            }
            else if (timespan.TotalHours != 0)
            {
                intervalType = BackupScheduleInterval.Hours;
                interval     = (int)timespan.TotalHours;
            }
            else
            {
                throw new ArgumentException(StringResources.InvalidInterval);
            }

            var frequencyBasedBackupSchedule = new FrequencyBasedBackupSchedule
            {
                IntervalType = intervalType,
                Interval     = interval
            };

            return(frequencyBasedBackupSchedule);
        }
 public FrequencyBasedBackupSchedule(FrequencyBasedBackupSchedule other)
     : this()
 {
     this.Interval     = other.Interval;
     this.IntervalType = other.IntervalType;
 }