@@ -57,18 +57,8 @@ public Schedule(string resourceGroupName, string automationAccountName, Azure.Ma
57
57
this . NextRun = AdjustOffset ( schedule . Properties . NextRun , schedule . Properties . NextRunOffsetMinutes ) ;
58
58
this . Interval = schedule . Properties . Interval ?? this . Interval ;
59
59
this . Frequency = ( ScheduleFrequency ) Enum . Parse ( typeof ( ScheduleFrequency ) , schedule . Properties . Frequency , true ) ;
60
- this . DaysOfWeekWeeklySchedule = schedule . Properties . AdvancedSchedule == null
61
- ? null
62
- : schedule . Properties . AdvancedSchedule . WeekDays ;
63
- this . DaysOfMonth = schedule . Properties . AdvancedSchedule == null
64
- ? null
65
- : this . GetDaysOfMonth ( schedule . Properties . AdvancedSchedule . MonthDays ) ;
66
- this . DayOfWeekMonthlySchedule = this . IsMonthlyOccurrenceNull ( schedule . Properties . AdvancedSchedule )
67
- ? null
68
- : schedule . Properties . AdvancedSchedule . MonthlyOccurrences . First ( ) . Day ;
69
- this . DayOfWeekOccurrence = this . IsMonthlyOccurrenceNull ( schedule . Properties . AdvancedSchedule )
70
- ? null
71
- : this . GetDayOfWeekOccurrence ( schedule . Properties . AdvancedSchedule . MonthlyOccurrences . First ( ) . Occurrence ) ;
60
+ this . WeeklyScheduleOptions = this . CreateWeeklyScheduleOptions ( schedule ) ;
61
+ this . MonthlyScheduleOptions = this . CreateMonthlyScheduleOptions ( schedule ) ;
72
62
this . TimeZone = schedule . Properties . TimeZone ;
73
63
}
74
64
@@ -112,24 +102,14 @@ public Schedule()
112
102
public ScheduleFrequency Frequency { get ; set ; }
113
103
114
104
/// <summary>
115
- /// Gets or sets the schedule days of the week.
116
- /// </summary>
117
- public IList < string > DaysOfWeekWeeklySchedule { get ; set ; }
118
-
119
- /// <summary>
120
- /// Gets or sets the schedule days of the month.
105
+ /// Gets or sets the monthly schedule options.
121
106
/// </summary>
122
- public IList < DaysOfMonth > DaysOfMonth { get ; set ; }
107
+ public MonthlyScheduleOptions MonthlyScheduleOptions { get ; set ; }
123
108
124
109
/// <summary>
125
- /// Gets or sets the schedule day of the week .
110
+ /// Gets or sets the weekly schedule options .
126
111
/// </summary>
127
- public string DayOfWeekMonthlySchedule { get ; set ; }
128
-
129
- /// <summary>
130
- /// Gets or sets the schedule day of the week occurrence.
131
- /// </summary>
132
- public string DayOfWeekOccurrence { get ; set ; }
112
+ public WeeklyScheduleOptions WeeklyScheduleOptions { get ; set ; }
133
113
134
114
/// <summary>
135
115
/// The create advanced schedule.
@@ -146,23 +126,32 @@ public AdvancedSchedule GetAdvancedSchedule()
146
126
147
127
var advancedSchedule = new AdvancedSchedule ( )
148
128
{
149
- WeekDays = this . DaysOfWeekWeeklySchedule ,
150
- MonthDays = this . DaysOfMonth == null ? null : this . DaysOfMonth . Select ( v => Convert . ToInt32 ( v ) ) . ToList ( ) ,
151
- MonthlyOccurrences = string . IsNullOrWhiteSpace ( this . DayOfWeekMonthlySchedule ) && this . DayOfWeekOccurrence == null
129
+ WeekDays = this . WeeklyScheduleOptions == null ? null : this . WeeklyScheduleOptions . DaysOfWeek ,
130
+ MonthDays = ( this . MonthlyScheduleOptions == null || this . MonthlyScheduleOptions . DaysOfMonth == null ) ? null : this . MonthlyScheduleOptions . DaysOfMonth . Select ( v => Convert . ToInt32 ( v ) ) . ToList ( ) ,
131
+ MonthlyOccurrences = ( this . MonthlyScheduleOptions == null || this . MonthlyScheduleOptions . DayOfWeek == null )
152
132
? null
153
133
: new AdvancedScheduleMonthlyOccurrence [ ]
154
134
{
155
135
new AdvancedScheduleMonthlyOccurrence ( )
156
136
{
157
- Day = this . DayOfWeekMonthlySchedule ,
158
- Occurrence = this . GetDayOfWeekOccurrence ( this . DayOfWeekOccurrence )
137
+ Day = this . MonthlyScheduleOptions . DayOfWeek . Day ,
138
+ Occurrence = this . GetDayOfWeekOccurrence ( this . MonthlyScheduleOptions . DayOfWeek . Occurrence )
159
139
}
160
140
}
161
141
} ;
162
142
163
143
return advancedSchedule ;
164
144
}
165
145
146
+ /// <summary>
147
+ /// Gets or sets the schedule time zone.
148
+ /// </summary>
149
+ public string TimeZone { get ; set ; }
150
+
151
+ #endregion Public Properties
152
+
153
+ #region Private Methods
154
+
166
155
/// <summary>
167
156
/// The is null or empty list.
168
157
/// </summary>
@@ -204,10 +193,8 @@ private bool IsMonthlyOccurrenceNull(Azure.Management.Automation.Models.Advanced
204
193
/// </returns>
205
194
private bool AdvancedScheduleIsNull ( Schedule schedule )
206
195
{
207
- return ( schedule . DaysOfWeekWeeklySchedule == null
208
- && schedule . DaysOfMonth == null
209
- && string . IsNullOrWhiteSpace ( schedule . DayOfWeekMonthlySchedule )
210
- && schedule . DayOfWeekOccurrence == null ) ;
196
+ return schedule . WeeklyScheduleOptions == null
197
+ && schedule . MonthlyScheduleOptions == null ;
211
198
}
212
199
213
200
/// <summary>
@@ -229,6 +216,53 @@ private bool AdvancedScheduleIsNull(Schedule schedule)
229
216
return Convert . ToInt32 ( Enum . Parse ( typeof ( DayOfWeekOccurrence ) , dayOfWeekOccurrence ) ) ;
230
217
}
231
218
219
+ /// <summary>
220
+ /// The create weekly schedule options.
221
+ /// </summary>
222
+ /// <param name="schedule">
223
+ /// The schedule.
224
+ /// </param>
225
+ /// <returns>
226
+ /// The <see cref="WeeklyScheduleOptions"/>.
227
+ /// </returns>
228
+ private WeeklyScheduleOptions CreateWeeklyScheduleOptions ( Microsoft . Azure . Management . Automation . Models . Schedule schedule )
229
+ {
230
+ return schedule . Properties . AdvancedSchedule == null
231
+ ? null
232
+ : new WeeklyScheduleOptions ( )
233
+ {
234
+ DaysOfWeek = schedule . Properties . AdvancedSchedule . WeekDays
235
+ } ;
236
+ }
237
+
238
+ /// <summary>
239
+ /// The create monthly schedule options.
240
+ /// </summary>
241
+ /// <param name="schedule">
242
+ /// The schedule.
243
+ /// </param>
244
+ /// <returns>
245
+ /// The <see cref="MonthlyScheduleOptions"/>.
246
+ /// </returns>
247
+ private MonthlyScheduleOptions CreateMonthlyScheduleOptions (
248
+ Microsoft . Azure . Management . Automation . Models . Schedule schedule )
249
+ {
250
+ return schedule . Properties . AdvancedSchedule == null
251
+ || ( schedule . Properties . AdvancedSchedule . MonthDays == null && schedule . Properties . AdvancedSchedule . MonthlyOccurrences == null )
252
+ ? null
253
+ : new MonthlyScheduleOptions ( )
254
+ {
255
+ DaysOfMonth = this . GetDaysOfMonth ( schedule . Properties . AdvancedSchedule . MonthDays ) ,
256
+ DayOfWeek = this . IsMonthlyOccurrenceNull ( schedule . Properties . AdvancedSchedule )
257
+ ? null
258
+ : new DayOfWeek ( )
259
+ {
260
+ Day = schedule . Properties . AdvancedSchedule . MonthlyOccurrences . First ( ) . Day ,
261
+ Occurrence = this . GetDayOfWeekOccurrence ( schedule . Properties . AdvancedSchedule . MonthlyOccurrences . First ( ) . Occurrence )
262
+ }
263
+ } ;
264
+ }
265
+
232
266
/// <summary>
233
267
/// The get day of week occurrence.
234
268
/// </summary>
@@ -258,14 +292,6 @@ private IList<DaysOfMonth> GetDaysOfMonth(IList<int> daysOfMonth)
258
292
{
259
293
return daysOfMonth . Select ( value => ( DaysOfMonth ) value ) . ToList ( ) ;
260
294
}
261
- /// <summary>
262
- /// Gets or sets the schedule time zone.
263
- /// </summary>
264
- public string TimeZone { get ; set ; }
265
-
266
- #endregion Public Properties
267
-
268
- #region Private Methods
269
295
270
296
private static DateTimeOffset ? AdjustOffset ( DateTimeOffset ? dateTimeOffset , double offsetMinutes )
271
297
{
0 commit comments