private static CSMMonthlyRetentionSchedule ConvertToGetCSMMonthlyRetentionObject(AzureBackupMonthlyRetentionPolicy retentionPolicy, IList<DateTime> RetentionTimes) { CSMMonthlyRetentionSchedule csmMonthlyRetention = new CSMMonthlyRetentionSchedule(); if (retentionPolicy.RetentionFormat == RetentionFormat.Daily) { csmMonthlyRetention.RetentionScheduleType = RetentionScheduleFormat.Daily; csmMonthlyRetention.RetentionScheduleDaily = new CSMDailyRetentionFormat(); csmMonthlyRetention.RetentionScheduleDaily.DaysOfTheMonth = ConvertToCSMDayList(retentionPolicy.DaysOfMonth); } else if (retentionPolicy.RetentionFormat == RetentionFormat.Weekly) { csmMonthlyRetention.RetentionScheduleWeekly = new CSMWeeklyRetentionFormat(); csmMonthlyRetention.RetentionScheduleType = RetentionScheduleFormat.Weekly; csmMonthlyRetention.RetentionScheduleWeekly.DaysOfTheWeek = retentionPolicy.DaysOfWeek; csmMonthlyRetention.RetentionScheduleWeekly.WeeksOfTheMonth = retentionPolicy.WeekNumber; } csmMonthlyRetention.CSMRetentionDuration = new CSMRetentionDuration(); csmMonthlyRetention.CSMRetentionDuration.Count = retentionPolicy.Retention; csmMonthlyRetention.CSMRetentionDuration.DurationType = RetentionDurationType.Months; csmMonthlyRetention.RetentionTimes = RetentionTimes; return csmMonthlyRetention; }
private static AzureBackupMonthlyRetentionPolicy ConvertToPowershellMonthlyRetentionObject(CSMMonthlyRetentionSchedule MonthlySchedule) { if (MonthlySchedule == null) return null; AzureBackupMonthlyRetentionPolicy monthlyRetention = null; RetentionFormat retentionFormat = (RetentionFormat)Enum.Parse(typeof(RetentionFormat), MonthlySchedule.RetentionScheduleType.ToString(), true); if (retentionFormat == RetentionFormat.Daily) { List<string> dayList = ConvertToPowershellDayList(MonthlySchedule.RetentionScheduleDaily.DaysOfTheMonth); monthlyRetention = new AzureBackupMonthlyRetentionPolicy("Monthly", MonthlySchedule.CSMRetentionDuration.Count, retentionFormat, dayList, null, null); } else if (retentionFormat == RetentionFormat.Weekly) { List<WeekNumber> weekNumberList = ConvertToPowershellWeekNumberList(MonthlySchedule.RetentionScheduleWeekly); List<DayOfWeek> dayOfWeekList = ConvertToPowershellWeekDaysList(MonthlySchedule.RetentionScheduleWeekly); monthlyRetention = new AzureBackupMonthlyRetentionPolicy("Monthly", MonthlySchedule.CSMRetentionDuration.Count, retentionFormat, null, weekNumberList, dayOfWeekList); } monthlyRetention.RetentionTimes = MonthlySchedule.RetentionTimes; return monthlyRetention; }