21
21
using Microsoft . Rest . Azure . OData ;
22
22
using System ;
23
23
using System . Collections . Generic ;
24
- using System . IO ;
25
24
using System . Linq ;
26
25
using System . Management . Automation ;
27
26
using ServiceClientModel = Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
@@ -127,6 +126,16 @@ public override void ExecuteCmdlet()
127
126
TimeSpan timeSpan = DateTime . UtcNow - new DateTime ( 1970 , 1 , 1 ) ;
128
127
int offset = ( int ) timeSpan . TotalSeconds ;
129
128
string targetDb = "" ;
129
+
130
+ if ( TargetItem != null )
131
+ {
132
+ if ( ! string . Equals ( ( ( AzureWorkloadProtectableItem ) TargetItem ) . ProtectableItemType ,
133
+ ProtectableItemType . SQLInstance . ToString ( ) ) )
134
+ {
135
+ throw new ArgumentException ( string . Format ( Resources . AzureWorkloadRestoreProtectableItemException ) ) ;
136
+ }
137
+ }
138
+
130
139
if ( ParameterSetName == RpParameterSet )
131
140
{
132
141
Dictionary < UriEnums , string > keyValueDict = HelperUtils . ParseUri ( RecoveryPoint . Id ) ;
@@ -145,12 +154,6 @@ public override void ExecuteCmdlet()
145
154
}
146
155
else if ( AlternateWorkloadRestore . IsPresent && Item == null )
147
156
{
148
- if ( string . Compare ( ( ( AzureWorkloadProtectableItem ) TargetItem ) . ProtectableItemType ,
149
- ProtectableItemType . SQLInstance . ToString ( ) ) != 0 )
150
- {
151
- throw new ArgumentException ( string . Format ( Resources . AzureWorkloadRestoreProtectableItemException ) ) ;
152
- }
153
-
154
157
azureWorkloadRecoveryConfig . RestoredDBName =
155
158
GetRestoredDBName ( RecoveryPoint . ItemName , currentTime ) ;
156
159
azureWorkloadRecoveryConfig . OverwriteWLIfpresent = "No" ;
@@ -199,12 +202,6 @@ public override void ExecuteCmdlet()
199
202
}
200
203
else if ( Item != null && TargetItem != null )
201
204
{
202
- if ( string . Compare ( ( ( AzureWorkloadProtectableItem ) TargetItem ) . ProtectableItemType ,
203
- ProtectableItemType . SQLDataBase . ToString ( ) ) == 0 )
204
- {
205
- throw new ArgumentException ( string . Format ( Resources . AzureWorkloadRestoreProtectableItemException ) ) ;
206
- }
207
-
208
205
azureWorkloadRecoveryConfig . RestoredDBName =
209
206
GetRestoredDBName ( Item . Name , currentTime ) ;
210
207
azureWorkloadRecoveryConfig . OverwriteWLIfpresent = "No" ;
0 commit comments