Skip to content

Commit bf478ff

Browse files
committed
Add warning when user doesn't specify enddatetime for slice commands
1 parent 5bc82b7 commit bf478ff

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/DataSliceContextBaseCmdlet.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Microsoft.Azure.Commands.DataFactories
2020
{
2121
public abstract class DataSliceContextBaseCmdlet : DataFactoryBaseCmdlet
2222
{
23-
private DateTime _endDateTime;
23+
protected DateTime _endDateTime;
2424

2525
[Parameter(ParameterSetName = ByFactoryObject, Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,
2626
HelpMessage = "The data factory object.")]
@@ -38,20 +38,5 @@ public abstract class DataSliceContextBaseCmdlet : DataFactoryBaseCmdlet
3838

3939
[Parameter(Position = 3, Mandatory = true, HelpMessage = "The data slice range start time.")]
4040
public DateTime StartDateTime { get; set; }
41-
42-
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")]
43-
public DateTime EndDateTime
44-
{
45-
get
46-
{
47-
return _endDateTime == default(DateTime)
48-
? StartDateTime + Constants.DefaultSliceActivePeriodDuration
49-
: _endDateTime;
50-
}
51-
set
52-
{
53-
_endDateTime = value;
54-
}
55-
}
5641
}
5742
}

src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/GetAzureDataFactorySliceCommand.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.DataFactories.Models;
1616
using Microsoft.Azure.Commands.DataFactories.Properties;
17+
using System;
1718
using System.Collections;
1819
using System.Collections.Generic;
1920
using System.Globalization;
@@ -25,6 +26,25 @@ namespace Microsoft.Azure.Commands.DataFactories
2526
[Cmdlet(VerbsCommon.Get, Constants.DataSlice, DefaultParameterSetName = ByFactoryName), OutputType(typeof(List<PSDataSlice>))]
2627
public class GetAzureDataFactorySliceCommand : DataSliceContextBaseCmdlet
2728
{
29+
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")]
30+
public DateTime EndDateTime
31+
{
32+
get
33+
{
34+
if (_endDateTime == default(DateTime))
35+
{
36+
WriteWarning(Resources.EndDateTimeNotSpecifiedForGetSlice);
37+
return StartDateTime + Constants.DefaultSliceActivePeriodDuration;
38+
}
39+
40+
return _endDateTime;
41+
}
42+
set
43+
{
44+
_endDateTime = value;
45+
}
46+
}
47+
2848
[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
2949
public override void ExecuteCmdlet()
3050
{

src/ResourceManager/DataFactories/Commands.DataFactories/DataSlices/SetAzureDataFactorySliceStatusCommand.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.DataFactories.Properties;
1616
using Microsoft.Azure.Management.DataFactories.Models;
17+
using System;
1718
using System.Collections;
1819
using System.Globalization;
1920
using System.Management.Automation;
@@ -26,6 +27,25 @@ public class SetAzureDataFactorySliceStatusCommand : DataSliceContextBaseCmdlet
2627
{
2728
private string _updateType = "Individual";
2829

30+
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The data slice range end time.")]
31+
public DateTime EndDateTime
32+
{
33+
get
34+
{
35+
if (_endDateTime == default(DateTime))
36+
{
37+
WriteWarning(Resources.EndDateTimeNotSpecifiedForSetSliceStatus);
38+
return StartDateTime + Constants.DefaultSliceActivePeriodDuration;
39+
}
40+
41+
return _endDateTime;
42+
}
43+
set
44+
{
45+
_endDateTime = value;
46+
}
47+
}
48+
2949
[Parameter(Position = 5, Mandatory = true, HelpMessage = "The data slice status.")]
3050
[ValidateSet(
3151
DataSliceStatus.NotSpecified,

src/ResourceManager/DataFactories/Commands.DataFactories/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,10 @@ Are you sure you want to continue?</value>
255255
<value>{0}
256256
For data factory naming restrictions, please see http://msdn.microsoft.com/en-us/library/dn835027.aspx</value>
257257
</data>
258+
<data name="EndDateTimeNotSpecifiedForGetSlice" xml:space="preserve">
259+
<value>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.</value>
260+
</data>
261+
<data name="EndDateTimeNotSpecifiedForSetSliceStatus" xml:space="preserve">
262+
<value>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.</value>
263+
</data>
258264
</root>

0 commit comments

Comments
 (0)