File: UtilityHelper.ps1

package info (click to toggle)
azure-devops-cli-extension 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,384 kB
  • sloc: python: 160,782; xml: 198; makefile: 56; sh: 51
file content (48 lines) | stat: -rw-r--r-- 2,148 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#---------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

function GetWorkItems {
    param(
        [string]$wiqlQuery, 
        [string]$organization
    )
    $workItems = az.cmd boards query --wiql $wiqlQuery --org $organization -o json | ConvertFrom-Json
    return $workItems
}


function HTMLContentWitsWithChangedDate {
    param (
        $witsParam,
        [string]$trackingData = ""
    )

    $sb = [System.Text.StringBuilder]::new()
    
    if ($witsParam) {
        [void]$sb.AppendLine( "<html><head><style>table, th, td {border: 1px solid black; font-family:verdana;font-size:12;}</style></head><body  style=`"font-family:verdana;font-size:11`">" )
        $ageColumnName = "Days Inactive"
        [void]$sb.AppendLine( "<table><tr><th>ID</th><th>Work Item Type</th><th>Title</th><th>State</th><th>$($ageColumnName)</th></tr>" )

        foreach ($wit in $witsParam) {
            [String]$witId = $wit.fields | Select-Object -ExpandProperty System.Id
            [String]$witType = $wit.fields | Select-Object -ExpandProperty System.WorkItemType
            [String]$witTitle = $wit.fields | Select-Object -ExpandProperty System.Title
            [String]$witState = $wit.fields | Select-Object -ExpandProperty System.State
            [String]$witChangedDate = $wit.fields | Select-Object -ExpandProperty System.ChangedDate

            $howOld = GetAge $witChangedDate
            
            [String]$witUrl = $wit.url.Replace("_apis/wit/workItems", "_workitems/edit")
            [string]$finalUrl = $witUrl + $trackingData
            [void]$sb.AppendLine( "<tr><td><a href=$finalUrl>$witId</a></td><td>$witType</td><td>$witTitle</td><td>$witState</td><td align=`"right`">$howOld</td></tr>" )
        }

        [void]$sb.AppendLine( "</table>" );
        [void]$sb.AppendLine( "</body></html>" )
    }
    
    return $sb.ToString()
}