Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Windows Time Period code to separate function #133

Closed
2 tasks done
rebelinux opened this issue Jan 9, 2024 · 0 comments · Fixed by #137
Closed
2 tasks done

Migrate Windows Time Period code to separate function #133

rebelinux opened this issue Jan 9, 2024 · 0 comments · Fixed by #137
Assignees
Labels
change request Request a new change or an improvement
Milestone

Comments

@rebelinux
Copy link
Collaborator

Description

$Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
$Hours24 = [ordered]@{
    0 = 12
    1 = 1
    2 = 2
    3 = 3
    4 = 4
    5 = 5
    6 = 6
    7 = 7
    8 = 8
    9 = 9
    10 = 10
    11 = 11
    12 = 12
    13 = 1
    14 = 2
    15 = 3
    16 = 4
    17 = 5
    18 = 6
    19 = 7
    20 = 8
    21 = 9
    22 = 10
    23 = 11
}
$ScheduleTimePeriod = $TrafficRule.ThrottlingWindowOptions -split '(.{48})' | Where-Object {$_}

foreach ($OBJ in $Hours24.GetEnumerator()) {

    $inObj = [ordered] @{
        'H' = $OBJ.Value
        'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key]
        'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key]
        'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key]
        'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key]
        'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key]
        'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key]
        'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key]
    }
    $OutObj += $inobj
}

$TableParams = @{
    Name = "Throttling Windows - $($TrafficRule.Name)"
    List = $true
    ColumnWidths = 6,4,3,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,4,4,4,4,4,4
    Key = 'H'
}
if ($Report.ShowTableCaptions) {
    $TableParams['Caption'] = "- $($TableParams.Name)"
}
if ($OutObj) {
    $OutObj2 = Table -Hashtable $OutObj @TableParams
    $OutObj2.Rows | Where-Object {$_.Sun -eq "0"} | Set-Style -Style OFF -Property "Sun"
    $OutObj2.Rows | Where-Object {$_.Mon -eq "0"} | Set-Style -Style OFF -Property "Mon"
    $OutObj2.Rows | Where-Object {$_.Tue -eq "0"} | Set-Style -Style OFF -Property "Tue"
    $OutObj2.Rows | Where-Object {$_.Wed -eq "0"} | Set-Style -Style OFF -Property "Wed"
    $OutObj2.Rows | Where-Object {$_.Thu -eq "0"} | Set-Style -Style OFF -Property "Thu"
    $OutObj2.Rows | Where-Object {$_.Fri -eq "0"} | Set-Style -Style OFF -Property "Fri"
    $OutObj2.Rows | Where-Object {$_.Sat -eq "0"} | Set-Style -Style OFF -Property "Sat"

    $OutObj2.Rows | Where-Object {$_.Sun -eq "1"} | Set-Style -Style ON -Property "Sun"
    $OutObj2.Rows | Where-Object {$_.Mon -eq "1"} | Set-Style -Style ON -Property "Mon"
    $OutObj2.Rows | Where-Object {$_.Tue -eq "1"} | Set-Style -Style ON -Property "Tue"
    $OutObj2.Rows | Where-Object {$_.Wed -eq "1"} | Set-Style -Style ON -Property "Wed"
    $OutObj2.Rows | Where-Object {$_.Thu -eq "1"} | Set-Style -Style ON -Property "Thu"
    $OutObj2.Rows | Where-Object {$_.Fri -eq "1"} | Set-Style -Style ON -Property "Fri"
    $OutObj2.Rows | Where-Object {$_.Sat -eq "1"} | Set-Style -Style ON -Property "Sat"
    $OutObj2
}

Additional Context

No response

Before submitting

  • I have read the documentation, and referred to the known issues before submitting this change request.
  • I have checked for previously opened & closed issues before submitting this change request.
@rebelinux rebelinux added the change request Request a new change or an improvement label Jan 9, 2024
@rebelinux rebelinux self-assigned this Jan 9, 2024
@rebelinux rebelinux added this to the v0.8.4 milestone Jan 9, 2024
rebelinux added a commit to rebelinux/AsBuiltReport.Veeam.VBR that referenced this issue Jan 16, 2024
@rebelinux rebelinux mentioned this issue Jan 16, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Request a new change or an improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant