Skip to content

Commit c1e2e1f

Browse files
committed
Fixing the followin PR comments:
1. See how other projects have their version and assembly info defined 2. This csproj is used only by StorSimple projects, please merge it into the commands project 3. Move all of the business logic into a conveniece client layer 4. This logic seems duplicated, please refactor
1 parent 290228b commit c1e2e1f

21 files changed

+181
-364
lines changed

src/AzurePowershell.sln

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2013
3-
VisualStudioVersion = 12.0.21005.1
3+
VisualStudioVersion = 12.0.30723.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}"
66
ProjectSection(SolutionItems) = preProject
@@ -151,8 +151,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RecoveryServices",
151151
EndProject
152152
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RecoveryServices.Test", "ServiceManagement\RecoveryServices\Commands.RecoveryServices.Test\Commands.RecoveryServices.Test.csproj", "{A415F75B-EB6A-49A6-934E-5BA71B83D6EB}"
153153
EndProject
154-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple.Library", "Commands.StorSimple.Library\Commands.StorSimple.Library.csproj", "{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}"
155-
EndProject
156154
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple", "ServiceManagement\StorSimple\Commands.StorSimple\Commands.StorSimple.csproj", "{11524D98-6C40-4091-A8E1-86463FEE607C}"
157155
EndProject
158156
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple.Test", "ServiceManagement\StorSimple\Commands.StorSimple.Test\Commands.StorSimple.Test.csproj", "{0FA676D5-1349-4086-B33F-65EC2CB7DA41}"
@@ -371,10 +369,6 @@ Global
371369
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
372370
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
373371
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB}.Release|Any CPU.Build.0 = Release|Any CPU
374-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
375-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Debug|Any CPU.Build.0 = Debug|Any CPU
376-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Release|Any CPU.ActiveCfg = Release|Any CPU
377-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Release|Any CPU.Build.0 = Release|Any CPU
378372
{11524D98-6C40-4091-A8E1-86463FEE607C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
379373
{11524D98-6C40-4091-A8E1-86463FEE607C}.Debug|Any CPU.Build.0 = Debug|Any CPU
380374
{11524D98-6C40-4091-A8E1-86463FEE607C}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -396,6 +390,7 @@ Global
396390
HideSolutionNode = FALSE
397391
EndGlobalSection
398392
GlobalSection(NestedProjects) = preSolution
393+
{B7FD03F6-98BC-4F54-9A14-0455E579FCD4} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
399394
{37455286-D8A7-4E0C-8B4D-C517D20C641A} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
400395
{D6F470A6-7395-4B8B-9D29-44DF0EC8F624} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
401396
{A3965B66-5A3E-4B8C-9574-28E5958D4828} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
@@ -406,7 +401,6 @@ Global
406401
{4BC0E3D3-6EDD-43AA-8F15-DCFED8ACC93D} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
407402
{9D5A40CA-5594-4F5C-8230-7ADF7CC0558E} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
408403
{3B48A77B-5956-4A62-9081-92BA04B02B27} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
409-
{B7FD03F6-98BC-4F54-9A14-0455E579FCD4} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
410404
{4C2FE49A-09E1-4979-AD46-CD64FD04C8F7} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
411405
{374D4000-DEDE-4995-9B63-E3B9FE0C4D29} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
412406
{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}

src/Commands.StorSimple.Library/Commands.StorSimple.Library.csproj

Lines changed: 0 additions & 64 deletions
This file was deleted.
-160 Bytes
Binary file not shown.

src/Commands.StorSimple.Library/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/ServiceManagement/StorSimple/Commands.StorSimple.Test/Properties/AssemblyInfo.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,18 @@
1919
// General Information about an assembly is controlled through the following
2020
// set of attributes. Change these attribute values to modify the information
2121
// associated with an assembly.
22-
[assembly: AssemblyTitle("Microsoft Azure Powershell")]
23-
[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)]
24-
[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)]
22+
[assembly: AssemblyTitle("Microsoft.WindowsAzure.Commands.StorSimple.Test")]
23+
[assembly: AssemblyDescription("")]
24+
[assembly: AssemblyConfiguration("")]
25+
[assembly: AssemblyCompany("")]
26+
[assembly: AssemblyProduct("Microsoft.WindowsAzure.Commands.StorSimple.Test")]
2527
[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)]
28+
[assembly: AssemblyTrademark("")]
29+
[assembly: AssemblyCulture("")]
2630

27-
// Setting ComVisible to false makes the types in this assembly not visible
28-
// to COM components. If you need to access a type in this assembly from
29-
// COM, set the ComVisible attribute to true on that type.
3031
[assembly: ComVisible(false)]
3132

32-
// The following GUID is for the ID of the typelib if this project is exposed to COM
3333
[assembly: Guid("d1c35c6d-1778-4d39-92c8-0bf709cc5b23")]
3434

35-
// Version information for an assembly consists of the following four values:
36-
//
37-
// Major Version
38-
// Minor Version
39-
// Build Number
40-
// Revision
41-
//
42-
// You can specify all the values or you can default the Build and Revision Numbers
43-
// by using the '*' as shown below:
44-
// [assembly: AssemblyVersion("1.0.*")]
4535
[assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)]
4636
[assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)]
47-
[assembly: CLSCompliant(false)]

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupPolicy/GetAzureStorSimpleDeviceBackupPolicy.cs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,13 @@ public override void ExecuteCmdlet()
5151
{
5252
BackupPolicyListResponse backupPolicyList = null;
5353
backupPolicyList = StorSimpleClient.GetAllBackupPolicies(deviceId);
54-
backupPolicyList.BackupPolicies = CorrectLastBackupForNewPolicy(backupPolicyList.BackupPolicies);
5554
WriteObject(backupPolicyList.BackupPolicies);
5655
WriteVerbose(string.Format(Resources.BackupPolicyGet_StatusMessage, backupPolicyList.BackupPolicies.Count, backupPolicyList.BackupPolicies.Count > 1 ? "ies" : "y"));
5756
}
5857
else
5958
{
6059
GetBackupPolicyDetailsResponse backupPolicyDetail = null;
6160
backupPolicyDetail = StorSimpleClient.GetBackupPolicyByName(deviceId, BackupPolicyName);
62-
backupPolicyDetail.BackupPolicyDetails = CorrectLastBackupForNewPolicyDetail(backupPolicyDetail.BackupPolicyDetails);
6361
if (string.IsNullOrEmpty(backupPolicyDetail.BackupPolicyDetails.InstanceId))
6462
WriteVerbose(string.Format(Resources.NoBackupPolicyWithGivenNameFound,BackupPolicyName,DeviceName));
6563
else
@@ -87,53 +85,5 @@ private bool ProcessParameters()
8785
}
8886
return true;
8987
}
90-
91-
/// <summary>
92-
/// for a new backuppolicy for which no backup has yet been taken,service returns last backup time as 1/1/2010 which is misleading
93-
/// we are setting it to null
94-
/// </summary>
95-
/// <param name="backupPolicyList"></param>
96-
/// <returns></returns>
97-
private IList<BackupPolicy> CorrectLastBackupForNewPolicy(IList<BackupPolicy> backupPolicyList)
98-
{
99-
if (backupPolicyList != null)
100-
{
101-
for (int i = 0; i < backupPolicyList.Count; ++i)
102-
{
103-
if (backupPolicyList[i].LastBackup.Value.Year == 2010
104-
&& backupPolicyList[i].LastBackup.Value.Month == 1
105-
&& backupPolicyList[i].LastBackup.Value.Day == 1)
106-
{
107-
//this means that for this policy no backup has yet been taken
108-
//so the service returns 1/1/2010 which is incorrect. hence we are correcting it here
109-
backupPolicyList[i].LastBackup = null;
110-
}
111-
}
112-
}
113-
return backupPolicyList;
114-
}
115-
116-
/// <summary>
117-
/// for a new backuppolicy for which no backup has yet been taken,service returns last backup time as 1/1/2010 which is misleading
118-
/// we are setting it to null
119-
/// </summary>
120-
/// <param name="backupPolicyList"></param>
121-
/// <returns></returns>
122-
private BackupPolicyDetails CorrectLastBackupForNewPolicyDetail(BackupPolicyDetails backupPolicyDetail)
123-
{
124-
if (backupPolicyDetail != null && backupPolicyDetail.LastBackup != null)
125-
{
126-
if (backupPolicyDetail.LastBackup.Value.Year == 2010
127-
&& backupPolicyDetail.LastBackup.Value.Month == 1
128-
&& backupPolicyDetail.LastBackup.Value.Day == 1)
129-
{
130-
//this means that for this policy no backup has yet been taken
131-
//so the service returns 1/1/2010 which is incorrect. hence we are correcting it here
132-
backupPolicyDetail.LastBackup = null;
133-
}
134-
135-
}
136-
return backupPolicyDetail;
137-
}
138-
}
13988
}
89+
}

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupPolicy/NewAzureStorSimpleDeviceBackupScheduleAddConfig.cs

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,61 +52,19 @@ public class NewAzureStorSimpleDeviceBackupScheduleAddConfig : StorSimpleCmdletB
5252
[Parameter(Position = 5, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.HelpMessageBackupEnabledDesc)]
5353
public bool Enabled { get; set; }
5454

55-
private ScheduleStatus scheduleStatus;
56-
private DateTime StartFromDt;
57-
58-
private void ProcessParameters()
59-
{
60-
if (string.IsNullOrEmpty(StartFromDateTime))
61-
{
62-
StartFromDt = DateTime.Now;
63-
}
64-
else
65-
{
66-
bool dateTimeValid = DateTime.TryParse(StartFromDateTime, out StartFromDt);
67-
68-
if (!dateTimeValid)
69-
{
70-
throw new ArgumentException(Resources.StartFromDateForBackupNotValid);
71-
}
72-
}
73-
scheduleStatus = Enabled ? ScheduleStatus.Enabled : ScheduleStatus.Disabled;
74-
if (BackupType == "Invalid")
75-
{
76-
throw new ArgumentException(Resources.BackupTypeInvalid);
77-
}
78-
79-
if (RetentionCount < 1 || RetentionCount > 64)
80-
{
81-
throw new ArgumentException(Resources.RetentionCountRangeInvalid);
82-
}
83-
84-
if (RecurrenceType == "Invalid")
85-
{
86-
throw new ArgumentException(Resources.RecurrenceTypeInvalid);
87-
}
88-
89-
if (RecurrenceValue <= 0)
90-
{
91-
throw new ArgumentException(Resources.RecurrenceValueLessThanZero);
92-
}
93-
}
94-
9555
public override void ExecuteCmdlet()
9656
{
9757
try
9858
{
99-
ProcessParameters();
100-
10159
BackupScheduleBase newScheduleObject = new BackupScheduleBase();
10260
newScheduleObject.BackupType = (BackupType)Enum.Parse(typeof(BackupType), BackupType);
103-
newScheduleObject.Status = scheduleStatus;
61+
newScheduleObject.Status = Enabled ? ScheduleStatus.Enabled : ScheduleStatus.Disabled;
10462
newScheduleObject.RetentionCount = RetentionCount;
105-
newScheduleObject.StartTime = StartFromDt.ToString("yyyy-MM-ddTHH:mm:sszzz");
63+
newScheduleObject.StartTime = StartFromDateTime;
10664
newScheduleObject.Recurrence = new ScheduleRecurrence();
10765
newScheduleObject.Recurrence.RecurrenceType = (RecurrenceType)Enum.Parse(typeof(RecurrenceType), RecurrenceType);
10866
newScheduleObject.Recurrence.RecurrenceValue = RecurrenceValue;
109-
67+
StorSimpleClient.ValidateBackupScheduleBase(newScheduleObject);
11068
WriteObject(newScheduleObject);
11169
}
11270
catch (Exception exception)

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupPolicy/NewAzureStorSimpleDeviceBackupScheduleUpdateConfig.cs

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -57,60 +57,20 @@ public class NewAzureStorSimpleDeviceBackupScheduleUpdateConfig:StorSimpleCmdlet
5757
[Parameter(Position = 6, Mandatory = false, HelpMessage = StorSimpleCmdletHelpMessage.HelpMessageBackupEnabledDesc)]
5858
public bool Enabled { get; set; }
5959

60-
private ScheduleStatus scheduleStatus;
61-
private DateTime StartFromDt;
62-
private void ProcessParameters()
63-
{
64-
if (!string.IsNullOrEmpty(StartFromDateTime))
65-
{
66-
bool dateTimeValid = DateTime.TryParse(StartFromDateTime, out StartFromDt);
67-
68-
if (!dateTimeValid)
69-
{
70-
throw new ArgumentException(Resources.StartFromDateForBackupNotValid);
71-
}
72-
}
73-
else
74-
StartFromDt = DateTime.Now;
75-
76-
scheduleStatus = Enabled ? ScheduleStatus.Enabled : ScheduleStatus.Disabled;
77-
if (BackupType == "Invalid")
78-
{
79-
throw new ArgumentException(Resources.BackupTypeInvalid);
80-
}
81-
82-
if (RetentionCount < 1 || RetentionCount > 64)
83-
{
84-
throw new ArgumentException(Resources.RetentionCountRangeInvalid);
85-
}
86-
87-
if (RecurrenceType == "Invalid")
88-
{
89-
throw new ArgumentException(Resources.RecurrenceTypeInvalid);
90-
}
91-
92-
if (RecurrenceValue <= 0)
93-
{
94-
throw new ArgumentException(Resources.RecurrenceValueLessThanZero);
95-
}
96-
}
97-
9860
public override void ExecuteCmdlet()
9961
{
10062
try
10163
{
102-
ProcessParameters();
103-
10464
BackupScheduleUpdateRequest updateScheduleObject = new BackupScheduleUpdateRequest();
10565
updateScheduleObject.BackupType = (BackupType)Enum.Parse(typeof(BackupType), BackupType);
106-
updateScheduleObject.Status = scheduleStatus;
66+
updateScheduleObject.Status = Enabled ? ScheduleStatus.Enabled : ScheduleStatus.Disabled;
10767
updateScheduleObject.RetentionCount = RetentionCount;
108-
updateScheduleObject.StartTime = StartFromDt.ToString("yyyy-MM-ddTHH:mm:sszzz");
68+
updateScheduleObject.StartTime = StartFromDateTime;
10969
updateScheduleObject.Recurrence = new ScheduleRecurrence();
11070
updateScheduleObject.Recurrence.RecurrenceType = (RecurrenceType)Enum.Parse(typeof(RecurrenceType), RecurrenceType);
11171
updateScheduleObject.Recurrence.RecurrenceValue = RecurrenceValue;
11272
updateScheduleObject.Id = Id;
113-
73+
StorSimpleClient.ValidateBackupScheduleUpdateRequest(updateScheduleObject);
11474
WriteObject(updateScheduleObject);
11575
}
11676
catch (Exception exception)

0 commit comments

Comments
 (0)