@@ -89,7 +89,8 @@ public static SimpleRetentionPolicy GetPSSimpleRetentionPolicy(
89
89
{
90
90
simplePolicy . RetentionDurationType = EnumUtils . GetEnum < RetentionDurationType > (
91
91
hydraRetPolicy . RetentionDuration . DurationType ) ;
92
- simplePolicy . RetentionCount = hydraRetPolicy . RetentionDuration . Count ;
92
+ simplePolicy . RetentionCount = hydraRetPolicy . RetentionDuration . Count . HasValue ?
93
+ ( int ) hydraRetPolicy . RetentionDuration . Count : default ( int ) ;
93
94
}
94
95
95
96
simplePolicy . Validate ( ) ;
@@ -107,19 +108,22 @@ private static int GetRetentionDurationInDays(ServiceClientModel.RetentionDurati
107
108
switch ( retentionDuration . DurationType )
108
109
{
109
110
case ServiceClientModel . RetentionDurationType . Days :
110
- daysCount = retentionDuration . Count ;
111
+ daysCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count ) ;
111
112
break ;
112
113
113
114
case ServiceClientModel . RetentionDurationType . Weeks :
114
- daysCount = retentionDuration . Count * PolicyConstants . NumOfDaysInWeek ;
115
+ daysCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
116
+ * PolicyConstants . NumOfDaysInWeek ;
115
117
break ;
116
118
117
119
case ServiceClientModel . RetentionDurationType . Months :
118
- daysCount = retentionDuration . Count * PolicyConstants . NumOfDaysInMonth ;
120
+ daysCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
121
+ * PolicyConstants . NumOfDaysInMonth ;
119
122
break ;
120
123
121
124
case ServiceClientModel . RetentionDurationType . Years :
122
- daysCount = retentionDuration . Count * PolicyConstants . NumOfDaysInYear ;
125
+ daysCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
126
+ * PolicyConstants . NumOfDaysInYear ;
123
127
break ;
124
128
125
129
default :
@@ -137,19 +141,22 @@ private static int GetRetentionDurationInWeeks(ServiceClientModel.RetentionDurat
137
141
switch ( retentionDuration . DurationType )
138
142
{
139
143
case ServiceClientModel . RetentionDurationType . Days :
140
- weeksCount = retentionDuration . Count / PolicyConstants . NumOfDaysInWeek ;
144
+ weeksCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
145
+ / PolicyConstants . NumOfDaysInWeek ;
141
146
break ;
142
147
143
148
case ServiceClientModel . RetentionDurationType . Weeks :
144
- weeksCount = retentionDuration . Count ;
149
+ weeksCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count ) ;
145
150
break ;
146
151
147
152
case ServiceClientModel . RetentionDurationType . Months :
148
- weeksCount = retentionDuration . Count * PolicyConstants . NumOfWeeksInMonth ;
153
+ weeksCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
154
+ * PolicyConstants . NumOfWeeksInMonth ;
149
155
break ;
150
156
151
157
case ServiceClientModel . RetentionDurationType . Years :
152
- weeksCount = retentionDuration . Count * PolicyConstants . NumOfWeeksInYear ;
158
+ weeksCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
159
+ * PolicyConstants . NumOfWeeksInYear ;
153
160
break ;
154
161
155
162
default :
@@ -167,19 +174,22 @@ private static int GetRetentionDurationInMonths(ServiceClientModel.RetentionDura
167
174
switch ( retentionDuration . DurationType )
168
175
{
169
176
case ServiceClientModel . RetentionDurationType . Days :
170
- monthsCount = retentionDuration . Count / PolicyConstants . NumOfDaysInMonth ;
177
+ monthsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
178
+ / PolicyConstants . NumOfDaysInMonth ;
171
179
break ;
172
180
173
181
case ServiceClientModel . RetentionDurationType . Weeks :
174
- monthsCount = retentionDuration . Count / PolicyConstants . NumOfWeeksInMonth ;
182
+ monthsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
183
+ / PolicyConstants . NumOfWeeksInMonth ;
175
184
break ;
176
185
177
186
case ServiceClientModel . RetentionDurationType . Months :
178
- monthsCount = retentionDuration . Count ;
187
+ monthsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count ) ;
179
188
break ;
180
189
181
190
case ServiceClientModel . RetentionDurationType . Years :
182
- monthsCount = retentionDuration . Count * PolicyConstants . NumOfMonthsInYear ;
191
+ monthsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
192
+ * PolicyConstants . NumOfMonthsInYear ;
183
193
break ;
184
194
185
195
default :
@@ -197,19 +207,22 @@ private static int GetRetentionDurationInYears(ServiceClientModel.RetentionDurat
197
207
switch ( retentionDuration . DurationType )
198
208
{
199
209
case ServiceClientModel . RetentionDurationType . Days :
200
- yearsCount = retentionDuration . Count / PolicyConstants . NumOfDaysInYear ;
210
+ yearsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
211
+ / PolicyConstants . NumOfDaysInYear ;
201
212
break ;
202
213
203
214
case ServiceClientModel . RetentionDurationType . Weeks :
204
- yearsCount = retentionDuration . Count / PolicyConstants . NumOfWeeksInYear ;
215
+ yearsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
216
+ / PolicyConstants . NumOfWeeksInYear ;
205
217
break ;
206
218
207
219
case ServiceClientModel . RetentionDurationType . Months :
208
- yearsCount = retentionDuration . Count / PolicyConstants . NumOfMonthsInYear ;
220
+ yearsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count )
221
+ / PolicyConstants . NumOfMonthsInYear ;
209
222
break ;
210
223
211
224
case ServiceClientModel . RetentionDurationType . Years :
212
- yearsCount = retentionDuration . Count ;
225
+ yearsCount = GetIntegerFromNullableIntgerValue ( retentionDuration . Count ) ;
213
226
break ;
214
227
215
228
default :
@@ -308,8 +321,9 @@ private static DailyRetentionFormat GetPSLTRDailyRetentionFormat(
308
321
{
309
322
Day psDay = new Day ( )
310
323
{
311
- Date = serviceClientDay . Date ,
312
- IsLast = serviceClientDay . IsLast
324
+ Date = GetIntegerFromNullableIntgerValue ( serviceClientDay . Date ) ,
325
+ IsLast = serviceClientDay . IsLast . HasValue ?
326
+ ( bool ) serviceClientDay . IsLast : default ( bool )
313
327
} ;
314
328
315
329
psFormat . DaysOfTheMonth . Add ( psDay ) ;
@@ -428,7 +442,8 @@ private static ServiceClientModel.DailyRetentionSchedule GetServiceClientLTRDail
428
442
DurationType = ServiceClientModel . RetentionDurationType . Days
429
443
} ;
430
444
431
- serviceClientDaily . RetentionTimes = psDaily . RetentionTimes ;
445
+ serviceClientDaily . RetentionTimes = GetNullableDateTimeListFromDateTimeList
446
+ ( psDaily . RetentionTimes ) ;
432
447
433
448
return serviceClientDaily ;
434
449
}
@@ -447,7 +462,8 @@ private static ServiceClientModel.WeeklyRetentionSchedule GetServiceClientLTRWee
447
462
Count = psWeekly . DurationCountInWeeks ,
448
463
DurationType = ServiceClientModel . RetentionDurationType . Weeks
449
464
} ;
450
- serviceClientWeekly . RetentionTimes = psWeekly . RetentionTimes ;
465
+ serviceClientWeekly . RetentionTimes = GetNullableDateTimeListFromDateTimeList (
466
+ psWeekly . RetentionTimes ) ;
451
467
serviceClientWeekly . DaysOfTheWeek = HelperUtils . GetStringListFromEnumList < DayOfWeek > ( psWeekly . DaysOfTheWeek ) ;
452
468
453
469
return serviceClientWeekly ;
@@ -467,7 +483,8 @@ private static ServiceClientModel.MonthlyRetentionSchedule GetServiceClientLTRMo
467
483
Count = psMonthly . DurationCountInMonths ,
468
484
DurationType = ServiceClientModel . RetentionDurationType . Months
469
485
} ;
470
- serviceClientMonthly . RetentionTimes = psMonthly . RetentionTimes ;
486
+ serviceClientMonthly . RetentionTimes = GetNullableDateTimeListFromDateTimeList (
487
+ psMonthly . RetentionTimes ) ;
471
488
472
489
serviceClientMonthly . RetentionScheduleFormatType = psMonthly . RetentionScheduleFormatType . ToString ( ) ;
473
490
if ( psMonthly . RetentionScheduleFormatType == RetentionScheduleFormat . Daily )
@@ -496,7 +513,8 @@ private static ServiceClientModel.YearlyRetentionSchedule GetServiceClientLTRYea
496
513
Count = psYearly . DurationCountInYears ,
497
514
DurationType = ServiceClientModel . RetentionDurationType . Years
498
515
} ;
499
- serviceClientYearly . RetentionTimes = psYearly . RetentionTimes ;
516
+ serviceClientYearly . RetentionTimes = GetNullableDateTimeListFromDateTimeList (
517
+ psYearly . RetentionTimes ) ;
500
518
501
519
serviceClientYearly . RetentionScheduleFormatType = psYearly . RetentionScheduleFormatType . ToString ( ) ;
502
520
if ( psYearly . RetentionScheduleFormatType == RetentionScheduleFormat . Daily )
@@ -565,5 +583,10 @@ private static ServiceClientModel.WeeklyRetentionFormat GetServiceClientLTRWeekl
565
583
#endregion
566
584
567
585
#endregion
586
+
587
+ private static int GetIntegerFromNullableIntgerValue ( int ? value )
588
+ {
589
+ return ( value . HasValue ? ( int ) value : default ( int ) ) ;
590
+ }
568
591
}
569
592
}
0 commit comments