From bf478ff76e616f5b24d244a9e6200ecfc6070696 Mon Sep 17 00:00:00 2001 From: Jack Ma Date: Mon, 15 Jun 2015 11:31:04 -0700 Subject: [PATCH 1/2] Add warning when user doesn't specify enddatetime for slice commands --- .../DataSlices/DataSliceContextBaseCmdlet.cs | 17 +--------------- .../GetAzureDataFactorySliceCommand.cs | 20 +++++++++++++++++++ .../SetAzureDataFactorySliceStatusCommand.cs | 20 +++++++++++++++++++ .../Properties/Resources.resx | 6 ++++++ 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/DataSliceContextBaseCmdlet.cs b/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/DataSliceContextBaseCmdlet.cs index bc7034f66ea6..983b33beb216 100644 --- a/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/DataSliceContextBaseCmdlet.cs +++ b/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/DataSliceContextBaseCmdlet.cs @@ -20,7 +20,7 @@ namespace Microsoft.Azure.Commands.DataFactories { public abstract class DataSliceContextBaseCmdlet : DataFactoryBaseCmdlet { - private DateTime _endDateTime; + protected DateTime _endDateTime; [Parameter(ParameterSetName = ByFactoryObject, Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The data factory object.")] @@ -38,20 +38,5 @@ public abstract class DataSliceContextBaseCmdlet : DataFactoryBaseCmdlet [Parameter(Position = 3, Mandatory = true, HelpMessage = "The data slice range start time.")] public DateTime StartDateTime { get; set; } - - [Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")] - public DateTime EndDateTime - { - get - { - return _endDateTime == default(DateTime) - ? StartDateTime + Constants.DefaultSliceActivePeriodDuration - : _endDateTime; - } - set - { - _endDateTime = value; - } - } } } \ No newline at end of file diff --git a/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/GetAzureDataFactorySliceCommand.cs b/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/GetAzureDataFactorySliceCommand.cs index b4128dbb37a4..c66130de9032 100644 --- a/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/GetAzureDataFactorySliceCommand.cs +++ b/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/GetAzureDataFactorySliceCommand.cs @@ -14,6 +14,7 @@ using Microsoft.Azure.Commands.DataFactories.Models; using Microsoft.Azure.Commands.DataFactories.Properties; +using System; using System.Collections; using System.Collections.Generic; using System.Globalization; @@ -25,6 +26,25 @@ namespace Microsoft.Azure.Commands.DataFactories [Cmdlet(VerbsCommon.Get, Constants.DataSlice, DefaultParameterSetName = ByFactoryName), OutputType(typeof(List))] public class GetAzureDataFactorySliceCommand : DataSliceContextBaseCmdlet { + [Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")] + public DateTime EndDateTime + { + get + { + if (_endDateTime == default(DateTime)) + { + WriteWarning(Resources.EndDateTimeNotSpecifiedForGetSlice); + return StartDateTime + Constants.DefaultSliceActivePeriodDuration; + } + + return _endDateTime; + } + set + { + _endDateTime = value; + } + } + [EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)] public override void ExecuteCmdlet() { diff --git a/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/SetAzureDataFactorySliceStatusCommand.cs b/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/SetAzureDataFactorySliceStatusCommand.cs index 9d1126b15d66..9061f9a472b4 100644 --- a/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/SetAzureDataFactorySliceStatusCommand.cs +++ b/src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/SetAzureDataFactorySliceStatusCommand.cs @@ -14,6 +14,7 @@ using Microsoft.Azure.Commands.DataFactories.Properties; using Microsoft.Azure.Management.DataFactories.Models; +using System; using System.Collections; using System.Globalization; using System.Management.Automation; @@ -26,6 +27,25 @@ public class SetAzureDataFactorySliceStatusCommand : DataSliceContextBaseCmdlet { private string _updateType = "Individual"; + [Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")] + public DateTime EndDateTime + { + get + { + if (_endDateTime == default(DateTime)) + { + WriteWarning(Resources.EndDateTimeNotSpecifiedForSetSliceStatus); + return StartDateTime + Constants.DefaultSliceActivePeriodDuration; + } + + return _endDateTime; + } + set + { + _endDateTime = value; + } + } + [Parameter(Position = 5, Mandatory = true, HelpMessage = "The data slice status.")] [ValidateSet( DataSliceStatus.NotSpecified, diff --git a/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.resx b/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.resx index 7cce188ed19b..708211898133 100644 --- a/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.resx +++ b/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.resx @@ -255,4 +255,10 @@ Are you sure you want to continue? {0} For data factory naming restrictions, please see http://msdn.microsoft.com/en-us/library/dn835027.aspx + + EndDateTime is not specified and is set to 48 hours from StartDateTime (by default). Please use -EndDateTime parameter in Get-AzureDataFactorySlice command if you want to specify EndDateTime. + + + EndDateTime is not specified and is set to 48 hours from StartDateTime (by default). Please use -EndDateTime parameter in Set-AzureDataFactorySliceStatus command if you want to specify EndDateTime. + \ No newline at end of file From 4bdae8f2874270434434a4f1bcbfbe1bf1430c2d Mon Sep 17 00:00:00 2001 From: Jack Ma Date: Mon, 15 Jun 2015 11:51:51 -0700 Subject: [PATCH 2/2] Add change for designer --- .../Properties/Resources.Designer.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.Designer.cs b/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.Designer.cs index 7ab9411adafc..6a80eaa0de94 100644 --- a/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.Designer.cs +++ b/src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -170,6 +170,24 @@ internal static string DownloadLogCompleted { } } + /// + /// Looks up a localized string similar to EndDateTime is not specified and is set to 48 hours from StartDateTime (by default). Please use -EndDateTime parameter in Get-AzureDataFactorySlice command if you want to specify EndDateTime.. + /// + internal static string EndDateTimeNotSpecifiedForGetSlice { + get { + return ResourceManager.GetString("EndDateTimeNotSpecifiedForGetSlice", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to EndDateTime is not specified and is set to 48 hours from StartDateTime (by default). Please use -EndDateTime parameter in Set-AzureDataFactorySliceStatus command if you want to specify EndDateTime.. + /// + internal static string EndDateTimeNotSpecifiedForSetSliceStatus { + get { + return ResourceManager.GetString("EndDateTimeNotSpecifiedForSetSliceStatus", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} name provided using -Name switch: '{1}' in cmdlet doesn't match with {0} name: '{2}' in JSON file. {0} will be created with name: '{1}'. ///