src/Private/Report/PPT/Build-MCSMediumImpactSlide.ps1
|
function Build-MCSMediumImpactSlide { Param($Presentation,$MediumRecommendation,$Debug) if ($Debug.IsPresent) { $DebugPreference = "Continue" } else { $DebugPreference = "SilentlyContinue" } $FirstSlide = 15 $TableID = 3 $CurrentSlide = $Presentation.Slides | Where-Object { $_.SlideIndex -eq $FirstSlide } $row = 2 $Counter = 1 $RecomNumber = 1 foreach ($Medium in $MediumRecommendation) { $RecomName = $Medium.Recommendation $Implication = $Medium.Implication Write-Debug ((get-date -Format 'yyyy-MM-dd HH:mm:ss') + ' - Editing Medium Impact Slide - Adding Recommendation: ' + $RecomName) if ($Counter -lt 6) { ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(1).Shape.TextFrame.TextRange.Text = [string]$RecomNumber ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(2).Shape.TextFrame.TextRange.Text = [string]$RecomName ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(3).Shape.TextFrame.TextRange.Text = [string]$Implication $row ++ $Counter ++ $RecomNumber ++ start-sleep -Milliseconds 100 } else { Write-Debug ((get-date -Format 'yyyy-MM-dd HH:mm:ss') + ' - Editing Medium Impact Slide - Adding new Slide..') $Counter = 1 $Presentation.slides[$FirstSlide].Duplicate() | Out-Null $FirstSlide ++ $NextSlide = $Presentation.Slides | Where-Object { $_.SlideIndex -eq $FirstSlide } Start-Sleep -Seconds 1 Write-Debug ((get-date -Format 'yyyy-MM-dd HH:mm:ss') + ' - Editing Medium Impact Slide - Cleaning table of new slide..') $rowTemp = 2 while ($rowTemp -lt 7) { $cell = 1 while ($cell -lt 4) { ($NextSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($rowTemp).Cells($cell).Shape.TextFrame.TextRange.Text = '' $cell ++ } $rowTemp ++ } $CurrentSlide = $NextSlide $row = 2 ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(1).Shape.TextFrame.TextRange.Text = [string]$RecomNumber ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(2).Shape.TextFrame.TextRange.Text = [string]$RecomName ($CurrentSlide.Shapes | Where-Object { $_.Id -eq $TableID }).Table.Rows($row).Cells(3).Shape.TextFrame.TextRange.Text = [string]$Implication $row ++ $Counter ++ $RecomNumber ++ start-sleep -Milliseconds 100 } } } |