Skip to content

Commit 4134b10

Browse files
committed
fixed merged conflicts
2 parents a8e0179 + c74ccb1 commit 4134b10

File tree

8 files changed

+80
-19
lines changed

8 files changed

+80
-19
lines changed

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ImportAzureAutomationRunbook.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public class ImportAzureAutomationRunbook : AzureAutomationBaseCmdlet
6161
/// Gets or sets the runbook version type
6262
/// </summary>
6363
[Parameter(Mandatory = true, HelpMessage = "Runbook definition type.")]
64-
[ValidateSet(Constants.RunbookType.Graph, Constants.RunbookType.PowerShell, Constants.RunbookType.PowerShellWorkflow, IgnoreCase = true)]
64+
[ValidateSet(Constants.RunbookType.Graph,
65+
Constants.RunbookType.GraphPowerShell,
66+
Constants.RunbookType.GraphPowerShellWorkflow,
67+
Constants.RunbookType.PowerShell,
68+
Constants.RunbookType.PowerShellWorkflow,
69+
IgnoreCase = true)]
6570
[ValidateNotNullOrEmpty]
6671
public string Type { get; set; }
6772

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationRunbook.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ public class NewAzureAutomationRunbook : AzureAutomationBaseCmdlet
5353
/// Gets or sets the runbook version type
5454
/// </summary>
5555
[Parameter(Mandatory = true, HelpMessage = "Runbook definition type.")]
56-
[ValidateSet(Constants.RunbookType.Graph, Constants.RunbookType.PowerShell, Constants.RunbookType.PowerShellWorkflow, IgnoreCase = true)]
56+
[ValidateSet(Constants.RunbookType.Graph,
57+
Constants.RunbookType.GraphPowerShell,
58+
Constants.RunbookType.GraphPowerShellWorkflow,
59+
Constants.RunbookType.PowerShell,
60+
Constants.RunbookType.PowerShellWorkflow,
61+
IgnoreCase = true)]
5762
[ValidateNotNullOrEmpty]
5863
public string Type { get; set; }
5964

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationSchedule.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public NewAzureAutomationSchedule()
128128
[ValidateRange(1, byte.MaxValue)]
129129
public byte MonthInterval { get; set; }
130130

131+
/// <summary>
132+
/// Gets or sets the schedule time zone.
133+
/// </summary>
134+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The schedule time zone.")]
135+
public string TimeZone { get; set; }
136+
131137
/// <summary>
132138
/// Execute this cmdlet.
133139
/// </summary>
@@ -139,7 +145,8 @@ protected override void AutomationProcessRecord()
139145
Name = this.Name,
140146
StartTime = this.StartTime,
141147
Description = this.Description,
142-
ExpiryTime = this.ExpiryTime
148+
ExpiryTime = this.ExpiryTime,
149+
TimeZone = this.TimeZone,
143150
};
144151

145152
switch (this.ParameterSetName)

src/ResourceManager/Automation/Commands.Automation/Common/AutomationClient.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ public Schedule CreateSchedule(string resourceGroupName, string automationAccoun
336336
Description = schedule.Description,
337337
Interval = schedule.Interval,
338338
Frequency = schedule.Frequency.ToString(),
339-
AdvancedSchedule = schedule.GetAdvancedSchedule()
339+
AdvancedSchedule = schedule.GetAdvancedSchedule(),
340+
TimeZone = schedule.TimeZone,
340341
}
341342
};
342343

@@ -454,7 +455,7 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
454455
var rdcprop = new RunbookCreateOrUpdateDraftProperties()
455456
{
456457
Description = description,
457-
RunbookType = String.IsNullOrWhiteSpace(type) ? RunbookTypeEnum.Script : (0 == string.Compare(type, Constants.RunbookType.PowerShellWorkflow, StringComparison.OrdinalIgnoreCase)) ? RunbookTypeEnum.Script : type,
458+
RunbookType = String.IsNullOrWhiteSpace(type) ? RunbookTypeEnum.Script : type,
458459
LogProgress = logProgress.HasValue && logProgress.Value,
459460
LogVerbose = logVerbose.HasValue && logVerbose.Value,
460461
Draft = new RunbookDraft(),
@@ -476,7 +477,6 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
476477

477478
public Runbook ImportRunbook(string resourceGroupName, string automationAccountName, string runbookPath, string description, IDictionary tags, string type, bool? logProgress, bool? logVerbose, bool published, bool overwrite, string name)
478479
{
479-
480480
var fileExtension = Path.GetExtension(runbookPath);
481481

482482
if (0 !=
@@ -492,14 +492,12 @@ public Runbook ImportRunbook(string resourceGroupName, string automationAccountN
492492

493493
// if graph runbook make sure type is not null and has right value
494494
if (0 == string.Compare(fileExtension, Constants.SupportedFileExtensions.Graph, StringComparison.OrdinalIgnoreCase)
495-
&& string.IsNullOrWhiteSpace(type)
496-
&& (0 != string.Compare(type, Constants.RunbookType.Graph,StringComparison.OrdinalIgnoreCase)))
495+
&& (string.IsNullOrWhiteSpace(type) || !IsGraphRunbook(type)))
497496
{
498497
throw new ResourceCommonException(typeof(Runbook),
499498
string.Format(CultureInfo.CurrentCulture, Resources.InvalidRunbookTypeForExtension, fileExtension));
500499
}
501500

502-
503501
var runbookName = Path.GetFileNameWithoutExtension(runbookPath);
504502

505503
if (String.IsNullOrWhiteSpace(name) == false)
@@ -1786,7 +1784,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
17861784
outputFolderFullPath = this.ValidateAndGetFullPath(outputFolder);
17871785
}
17881786

1789-
var fileExtension = (0 == string.Compare(runbookType, Constants.RunbookType.Graph, StringComparison.OrdinalIgnoreCase)) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript;
1787+
var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript;
17901788

17911789
var outputFilePath = outputFolderFullPath + "\\" + runbookName + fileExtension;
17921790

@@ -1803,6 +1801,13 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
18031801
return new DirectoryInfo(runbookName + fileExtension);
18041802
}
18051803

1804+
private static bool IsGraphRunbook(string runbookType)
1805+
{
1806+
return (string.Equals(runbookType, Constants.RunbookType.Graph, StringComparison.OrdinalIgnoreCase) ||
1807+
string.Equals(runbookType, Constants.RunbookType.GraphPowerShell, StringComparison.OrdinalIgnoreCase) ||
1808+
string.Equals(runbookType, Constants.RunbookType.GraphPowerShellWorkflow, StringComparison.OrdinalIgnoreCase));
1809+
}
1810+
18061811
#endregion
18071812
}
18081813
}

src/ResourceManager/Automation/Commands.Automation/Common/Constants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public static class RunbookType
8181
public const string PowerShellWorkflow = "PowerShellWorkflow";
8282

8383
public const string Graph = "Graph";
84+
85+
public const string GraphPowerShell = "GraphPowerShell";
86+
87+
public const string GraphPowerShellWorkflow = "GraphPowerShellWorkflow";
8488
}
8589

8690
public static class SupportedFileExtensions

src/ResourceManager/Automation/Commands.Automation/Model/Schedule.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,18 @@ public class Schedule : BaseProperties
4444
public Schedule(string resourceGroupName, string automationAccountName, Azure.Management.Automation.Models.Schedule schedule)
4545
{
4646
Requires.Argument("schedule", schedule).NotNull();
47+
4748
this.ResourceGroupName = resourceGroupName;
4849
this.AutomationAccountName = automationAccountName;
4950
this.Name = schedule.Name;
5051
this.Description = schedule.Properties.Description;
51-
this.StartTime = schedule.Properties.StartTime.ToLocalTime();
52-
this.ExpiryTime = schedule.Properties.ExpiryTime.ToLocalTime();
52+
this.StartTime = AdjustOffset(schedule.Properties.StartTime, schedule.Properties.StartTimeOffsetMinutes);
53+
this.ExpiryTime = AdjustOffset(schedule.Properties.ExpiryTime, schedule.Properties.ExpiryTimeOffsetMinutes);
5354
this.CreationTime = schedule.Properties.CreationTime.ToLocalTime();
5455
this.LastModifiedTime = schedule.Properties.LastModifiedTime.ToLocalTime();
5556
this.IsEnabled = schedule.Properties.IsEnabled;
56-
this.NextRun = schedule.Properties.NextRun.HasValue
57-
? schedule.Properties.NextRun.Value.ToLocalTime()
58-
: this.NextRun;
59-
this.Interval = schedule.Properties.Interval.HasValue ? schedule.Properties.Interval.Value : this.Interval;
57+
this.NextRun = AdjustOffset(schedule.Properties.NextRun, schedule.Properties.NextRunOffsetMinutes);
58+
this.Interval = schedule.Properties.Interval ?? this.Interval;
6059
this.Frequency = (ScheduleFrequency)Enum.Parse(typeof(ScheduleFrequency), schedule.Properties.Frequency, true);
6160
this.DaysOfWeekWeeklySchedule = schedule.Properties.AdvancedSchedule == null
6261
? null
@@ -70,10 +69,13 @@ public Schedule(string resourceGroupName, string automationAccountName, Azure.Ma
7069
this.DayOfWeekOccurrence = this.IsMonthlyOccurrenceNull(schedule.Properties.AdvancedSchedule)
7170
? null
7271
: this.GetDayOfWeekOccurrence(schedule.Properties.AdvancedSchedule.MonthlyOccurrences.First().Occurrence);
72+
this.TimeZone = schedule.Properties.TimeZone;
7373
}
7474

75+
#region Public Properties
76+
7577
/// <summary>
76-
/// Initializes a new instance of the <see cref="HourlySchedule"/> class.
78+
/// Initializes a new instance of the <see cref="Schedule"/> class.
7779
/// </summary>
7880
public Schedule()
7981
{
@@ -110,6 +112,7 @@ public Schedule()
110112
public ScheduleFrequency Frequency { get; set; }
111113

112114
/// <summary>
115+
<<<<<<< HEAD
113116
/// Gets or sets the schedule days of the week.
114117
/// </summary>
115118
public IList<string> DaysOfWeekWeeklySchedule { get; set; }
@@ -256,5 +259,31 @@ private IList<DaysOfMonth> GetDaysOfMonth(IList<int> daysOfMonth)
256259
{
257260
return daysOfMonth.Select(value => (DaysOfMonth)value).ToList();
258261
}
262+
=======
263+
/// Gets or sets the schedule time zone.
264+
/// </summary>
265+
public string TimeZone { get; set; }
266+
267+
#endregion Public Properties
268+
269+
#region Private Methods
270+
271+
private static DateTimeOffset? AdjustOffset(DateTimeOffset? dateTimeOffset, double offsetMinutes)
272+
{
273+
if (dateTimeOffset.HasValue)
274+
{
275+
return AdjustOffset(dateTimeOffset.Value, offsetMinutes);
276+
}
277+
278+
return null;
279+
}
280+
281+
private static DateTimeOffset AdjustOffset(DateTimeOffset dateTimeOffset, double offsetMinutes)
282+
{
283+
var timeSpan = TimeSpan.FromMinutes(offsetMinutes);
284+
return dateTimeOffset.ToOffset(timeSpan);
285+
}
286+
287+
#endregion Private Methods
259288
}
260289
}

src/ResourceManager/Automation/Commands.Automation/Model/ScheduleFrequency.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public enum ScheduleFrequency
1212
Day,
1313
Hour,
1414
Week,
15-
Month
15+
Month,
1616
}
1717
}

src/ServiceManagement/Automation/Commands.Automation/Model/Schedule.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ public Schedule(string automationAccountName, WindowsAzure.Management.Automation
4545
: this.NextRun;
4646
this.Interval = schedule.Properties.Interval.HasValue ? schedule.Properties.Interval.Value : this.Interval;
4747
this.Frequency = (ScheduleFrequency)Enum.Parse(typeof(ScheduleFrequency), schedule.Properties.Frequency, true);
48+
this.TimeZone = schedule.Properties.TimeZone;
4849
}
4950

5051
/// <summary>
51-
/// Initializes a new instance of the <see cref="HourlySchedule"/> class.
52+
/// Initializes a new instance of the <see cref="Schedule"/> class.
5253
/// </summary>
5354
public Schedule()
5455
{
@@ -108,5 +109,10 @@ public Schedule()
108109
/// Gets or sets the schedule frequency.
109110
/// </summary>
110111
public ScheduleFrequency Frequency { get; set; }
112+
113+
/// <summary>
114+
/// Gets or sets the schedule time zone.
115+
/// </summary>
116+
public string TimeZone { get; set; }
111117
}
112118
}

0 commit comments

Comments
 (0)