16
16
using System . Collections . Generic ;
17
17
using System . Linq ;
18
18
using Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
19
+ using Microsoft . Azure . Commands . RecoveryServices . Backup . Helpers ;
19
20
using Microsoft . Azure . Commands . RecoveryServices . Backup . Properties ;
20
21
using ServiceClientModel = Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
21
22
@@ -34,7 +35,7 @@ public partial class PolicyHelpers
34
35
/// Helper function to convert ps long term retention policy from service response.
35
36
/// </summary>
36
37
public static LongTermRetentionPolicy GetPSLongTermRetentionPolicy (
37
- ServiceClientModel . LongTermRetentionPolicy serviceClientRetPolicy )
38
+ ServiceClientModel . LongTermRetentionPolicy serviceClientRetPolicy , string timeZone )
38
39
{
39
40
if ( serviceClientRetPolicy == null )
40
41
{
@@ -46,25 +47,25 @@ public static LongTermRetentionPolicy GetPSLongTermRetentionPolicy(
46
47
if ( serviceClientRetPolicy . DailySchedule != null )
47
48
{
48
49
ltrPolicy . IsDailyScheduleEnabled = true ;
49
- ltrPolicy . DailySchedule = GetPSLTRDailySchedule ( serviceClientRetPolicy . DailySchedule ) ;
50
+ ltrPolicy . DailySchedule = GetPSLTRDailySchedule ( serviceClientRetPolicy . DailySchedule , timeZone ) ;
50
51
}
51
52
52
53
if ( serviceClientRetPolicy . WeeklySchedule != null )
53
54
{
54
55
ltrPolicy . IsWeeklyScheduleEnabled = true ;
55
- ltrPolicy . WeeklySchedule = GetPSLTRWeeklySchedule ( serviceClientRetPolicy . WeeklySchedule ) ;
56
+ ltrPolicy . WeeklySchedule = GetPSLTRWeeklySchedule ( serviceClientRetPolicy . WeeklySchedule , timeZone ) ;
56
57
}
57
58
58
59
if ( serviceClientRetPolicy . MonthlySchedule != null )
59
60
{
60
61
ltrPolicy . IsMonthlyScheduleEnabled = true ;
61
- ltrPolicy . MonthlySchedule = GetPSLTRMonthlySchedule ( serviceClientRetPolicy . MonthlySchedule ) ;
62
+ ltrPolicy . MonthlySchedule = GetPSLTRMonthlySchedule ( serviceClientRetPolicy . MonthlySchedule , timeZone ) ;
62
63
}
63
64
64
65
if ( serviceClientRetPolicy . YearlySchedule != null )
65
66
{
66
67
ltrPolicy . IsYearlyScheduleEnabled = true ;
67
- ltrPolicy . YearlySchedule = GetPSLTRYearlySchedule ( serviceClientRetPolicy . YearlySchedule ) ;
68
+ ltrPolicy . YearlySchedule = GetPSLTRYearlySchedule ( serviceClientRetPolicy . YearlySchedule , timeZone ) ;
68
69
}
69
70
70
71
// safe side validate
@@ -74,7 +75,7 @@ public static LongTermRetentionPolicy GetPSLongTermRetentionPolicy(
74
75
}
75
76
76
77
public static SimpleRetentionPolicy GetPSSimpleRetentionPolicy (
77
- ServiceClientModel . SimpleRetentionPolicy hydraRetPolicy )
78
+ ServiceClientModel . SimpleRetentionPolicy hydraRetPolicy , string timeZone )
78
79
{
79
80
if ( hydraRetPolicy == null )
80
81
{
@@ -231,7 +232,8 @@ private static int GetRetentionDurationInYears(ServiceClientModel.RetentionDurat
231
232
return yearsCount ;
232
233
}
233
234
234
- private static DailyRetentionSchedule GetPSLTRDailySchedule ( ServiceClientModel . DailyRetentionSchedule serviceClientDaily )
235
+ private static DailyRetentionSchedule GetPSLTRDailySchedule ( ServiceClientModel . DailyRetentionSchedule serviceClientDaily ,
236
+ string timeZone )
235
237
{
236
238
if ( serviceClientDaily == null )
237
239
{
@@ -241,12 +243,13 @@ private static DailyRetentionSchedule GetPSLTRDailySchedule(ServiceClientModel.D
241
243
DailyRetentionSchedule psDaily = new DailyRetentionSchedule ( ) ;
242
244
243
245
psDaily . DurationCountInDays = GetRetentionDurationInDays ( serviceClientDaily . RetentionDuration ) ;
244
- psDaily . RetentionTimes = ParseDateTimesToUTC ( serviceClientDaily . RetentionTimes ) ;
246
+ psDaily . RetentionTimes = ParseDateTimesToUTC ( serviceClientDaily . RetentionTimes , timeZone ) ;
245
247
246
248
return psDaily ;
247
249
}
248
250
249
- private static WeeklyRetentionSchedule GetPSLTRWeeklySchedule ( ServiceClientModel . WeeklyRetentionSchedule serviceClientWeekly )
251
+ private static WeeklyRetentionSchedule GetPSLTRWeeklySchedule ( ServiceClientModel . WeeklyRetentionSchedule serviceClientWeekly ,
252
+ string timeZone )
250
253
{
251
254
if ( serviceClientWeekly == null )
252
255
{
@@ -256,15 +259,16 @@ private static WeeklyRetentionSchedule GetPSLTRWeeklySchedule(ServiceClientModel
256
259
WeeklyRetentionSchedule psWeekly = new WeeklyRetentionSchedule ( ) ;
257
260
258
261
psWeekly . DurationCountInWeeks = GetRetentionDurationInWeeks ( serviceClientWeekly . RetentionDuration ) ;
259
- psWeekly . RetentionTimes = ParseDateTimesToUTC ( serviceClientWeekly . RetentionTimes ) ;
262
+ psWeekly . RetentionTimes = ParseDateTimesToUTC ( serviceClientWeekly . RetentionTimes , timeZone ) ;
260
263
psWeekly . DaysOfTheWeek =
261
264
HelperUtils . EnumListConverter < ServiceClientModel . DayOfWeek ? , DayOfWeek > (
262
265
serviceClientWeekly . DaysOfTheWeek ) ;
263
266
264
267
return psWeekly ;
265
268
}
266
269
267
- private static MonthlyRetentionSchedule GetPSLTRMonthlySchedule ( ServiceClientModel . MonthlyRetentionSchedule serviceClientMonthly )
270
+ private static MonthlyRetentionSchedule GetPSLTRMonthlySchedule ( ServiceClientModel . MonthlyRetentionSchedule serviceClientMonthly ,
271
+ string timeZone )
268
272
{
269
273
if ( serviceClientMonthly == null )
270
274
{
@@ -274,7 +278,7 @@ private static MonthlyRetentionSchedule GetPSLTRMonthlySchedule(ServiceClientMod
274
278
MonthlyRetentionSchedule psMonthly = new MonthlyRetentionSchedule ( ) ;
275
279
276
280
psMonthly . DurationCountInMonths = GetRetentionDurationInMonths ( serviceClientMonthly . RetentionDuration ) ;
277
- psMonthly . RetentionTimes = ParseDateTimesToUTC ( serviceClientMonthly . RetentionTimes ) ;
281
+ psMonthly . RetentionTimes = ParseDateTimesToUTC ( serviceClientMonthly . RetentionTimes , timeZone ) ;
278
282
psMonthly . RetentionScheduleFormatType =
279
283
serviceClientMonthly . RetentionScheduleFormatType . ToEnum < RetentionScheduleFormat > ( ) ;
280
284
psMonthly . RetentionScheduleDaily = GetPSLTRDailyRetentionFormat ( serviceClientMonthly . RetentionScheduleDaily ) ;
@@ -283,7 +287,8 @@ private static MonthlyRetentionSchedule GetPSLTRMonthlySchedule(ServiceClientMod
283
287
return psMonthly ;
284
288
}
285
289
286
- private static YearlyRetentionSchedule GetPSLTRYearlySchedule ( ServiceClientModel . YearlyRetentionSchedule serviceClientYearly )
290
+ private static YearlyRetentionSchedule GetPSLTRYearlySchedule ( ServiceClientModel . YearlyRetentionSchedule serviceClientYearly ,
291
+ string timeZone )
287
292
{
288
293
if ( serviceClientYearly == null )
289
294
{
@@ -293,7 +298,7 @@ private static YearlyRetentionSchedule GetPSLTRYearlySchedule(ServiceClientModel
293
298
YearlyRetentionSchedule psYearly = new YearlyRetentionSchedule ( ) ;
294
299
295
300
psYearly . DurationCountInYears = GetRetentionDurationInYears ( serviceClientYearly . RetentionDuration ) ;
296
- psYearly . RetentionTimes = ParseDateTimesToUTC ( serviceClientYearly . RetentionTimes ) ;
301
+ psYearly . RetentionTimes = ParseDateTimesToUTC ( serviceClientYearly . RetentionTimes , timeZone ) ;
297
302
psYearly . RetentionScheduleFormatType =
298
303
serviceClientYearly . RetentionScheduleFormatType . ToEnum < RetentionScheduleFormat > ( ) ;
299
304
psYearly . RetentionScheduleDaily = GetPSLTRDailyRetentionFormat ( serviceClientYearly . RetentionScheduleDaily ) ;
@@ -378,10 +383,9 @@ public static ServiceClientModel.SimpleRetentionPolicy
378
383
ServiceClientModel . SimpleRetentionPolicy simpleRetPolicy =
379
384
new ServiceClientModel . SimpleRetentionPolicy ( ) ;
380
385
381
- string durationType = psRetPolicy . RetentionDurationType . ToString ( ) ;
382
386
simpleRetPolicy . RetentionDuration = new ServiceClientModel . RetentionDuration ( ) ;
383
387
simpleRetPolicy . RetentionDuration . DurationType =
384
- durationType . ToEnum < ServiceClientModel . RetentionDurationType > ( ) ;
388
+ ServiceClientHelpers . GetServiceClientRetentionDurationType ( psRetPolicy . RetentionDurationType ) ;
385
389
simpleRetPolicy . RetentionDuration . Count = psRetPolicy . RetentionCount ;
386
390
387
391
return simpleRetPolicy ;
@@ -496,8 +500,8 @@ private static ServiceClientModel.MonthlyRetentionSchedule GetServiceClientLTRMo
496
500
psMonthly . RetentionTimes ) ;
497
501
498
502
serviceClientMonthly . RetentionScheduleFormatType =
499
- psMonthly . RetentionScheduleFormatType
500
- . ToEnum < ServiceClientModel . RetentionScheduleFormat > ( ) ;
503
+ ServiceClientHelpers . GetServiceClientRetentionScheduleFormat (
504
+ psMonthly . RetentionScheduleFormatType ) ;
501
505
502
506
if ( psMonthly . RetentionScheduleFormatType == RetentionScheduleFormat . Daily )
503
507
{
@@ -529,8 +533,8 @@ private static ServiceClientModel.YearlyRetentionSchedule GetServiceClientLTRYea
529
533
psYearly . RetentionTimes ) ;
530
534
531
535
serviceClientYearly . RetentionScheduleFormatType =
532
- psYearly . RetentionScheduleFormatType
533
- . ToEnum < ServiceClientModel . RetentionScheduleFormat > ( ) ;
536
+ ServiceClientHelpers . GetServiceClientRetentionScheduleFormat (
537
+ psYearly . RetentionScheduleFormatType ) ;
534
538
535
539
if ( psYearly . RetentionScheduleFormatType == RetentionScheduleFormat . Daily )
536
540
{
0 commit comments