1111using System . Linq ;
1212using OfficeDevPnP . Core . Framework . Provisioning . Providers ;
1313using SharePointPnP . PowerShell . Commands . Components ;
14+ using System . Collections . Generic ;
1415
1516namespace SharePointPnP . PowerShell . Commands . Provisioning
1617{
@@ -119,7 +120,7 @@ protected override void ExecuteCmdlet()
119120 {
120121 Path = System . IO . Path . Combine ( SessionState . Path . CurrentFileSystemLocation . Path , Path ) ;
121122 }
122- if ( ! System . IO . File . Exists ( Path ) )
123+ if ( ! System . IO . File . Exists ( Path ) )
123124 {
124125 throw new FileNotFoundException ( $ "File not found") ;
125126 }
@@ -278,30 +279,45 @@ protected override void ExecuteCmdlet()
278279 WriteProgress ( progressRecord ) ;
279280 } ;
280281
282+ var warningsShown = new List < string > ( ) ;
283+
281284 applyingInformation . MessagesDelegate = ( message , type ) =>
282285 {
283286 switch ( type )
284287 {
285288 case ProvisioningMessageType . Warning :
286- {
287- WriteWarning ( message ) ;
288- break ;
289- }
289+ {
290+ if ( ! warningsShown . Contains ( message ) )
291+ {
292+ WriteWarning ( message ) ;
293+ warningsShown . Add ( message ) ;
294+ }
295+ break ;
296+ }
290297 case ProvisioningMessageType . Progress :
291- {
292- var activity = message ;
293- if ( message . IndexOf ( "|" ) > - 1 )
294298 {
295- var messageSplitted = message . Split ( '|' ) ;
296- if ( messageSplitted . Length == 4 )
299+ var activity = message ;
300+ if ( message . IndexOf ( "|" ) > - 1 )
297301 {
298- var current = double . Parse ( messageSplitted [ 2 ] ) ;
299- var total = double . Parse ( messageSplitted [ 3 ] ) ;
300- subProgressRecord . RecordType = ProgressRecordType . Processing ;
301- subProgressRecord . Activity = messageSplitted [ 0 ] ;
302- subProgressRecord . StatusDescription = messageSplitted [ 1 ] ;
303- subProgressRecord . PercentComplete = Convert . ToInt32 ( ( 100 / total ) * current ) ;
304- WriteProgress ( subProgressRecord ) ;
302+ var messageSplitted = message . Split ( '|' ) ;
303+ if ( messageSplitted . Length == 4 )
304+ {
305+ var current = double . Parse ( messageSplitted [ 2 ] ) ;
306+ var total = double . Parse ( messageSplitted [ 3 ] ) ;
307+ subProgressRecord . RecordType = ProgressRecordType . Processing ;
308+ subProgressRecord . Activity = messageSplitted [ 0 ] ;
309+ subProgressRecord . StatusDescription = messageSplitted [ 1 ] ;
310+ subProgressRecord . PercentComplete = Convert . ToInt32 ( ( 100 / total ) * current ) ;
311+ WriteProgress ( subProgressRecord ) ;
312+ }
313+ else
314+ {
315+ subProgressRecord . Activity = "Processing" ;
316+ subProgressRecord . RecordType = ProgressRecordType . Processing ;
317+ subProgressRecord . StatusDescription = activity ;
318+ subProgressRecord . PercentComplete = 0 ;
319+ WriteProgress ( subProgressRecord ) ;
320+ }
305321 }
306322 else
307323 {
@@ -311,23 +327,14 @@ protected override void ExecuteCmdlet()
311327 subProgressRecord . PercentComplete = 0 ;
312328 WriteProgress ( subProgressRecord ) ;
313329 }
330+ break ;
314331 }
315- else
316- {
317- subProgressRecord . Activity = "Processing" ;
318- subProgressRecord . RecordType = ProgressRecordType . Processing ;
319- subProgressRecord . StatusDescription = activity ;
320- subProgressRecord . PercentComplete = 0 ;
321- WriteProgress ( subProgressRecord ) ;
322- }
323- break ;
324- }
325332 case ProvisioningMessageType . Completed :
326- {
333+ {
327334
328- WriteProgress ( new ProgressRecord ( 1 , message , " " ) { RecordType = ProgressRecordType . Completed } ) ;
329- break ;
330- }
335+ WriteProgress ( new ProgressRecord ( 1 , message , " " ) { RecordType = ProgressRecordType . Completed } ) ;
336+ break ;
337+ }
331338 }
332339 } ;
333340
0 commit comments