# Copyright © 2012, Microsoft Corporation. All rights reserved. # Format-DiagReport # Format-DiagChart # Set-DiagPID # StrArrayTo-ObjArray function Format-DiagReport ([string]$Style, [System.Xml.XmlDocument]$xml) { $xmlBase = $xml.PSBase $xmlNode = $xmlBase.SelectSingleNode("//Objects") [System.Xml.XmlAttribute]$attrib = $xmlBase.CreateAttribute("style") if ($style.length -gt 0) { switch ($Style) { "column" { $xmlNode.setattribute("style", "$style") $headerItems = @() $xmlNode.SelectNodes("//Property") | ForEach-Object { if ($headeritems -contains $_.name) { } else { $headeritems += $_.name } } $headerNode = $xmlBase.CreateElement("Header") $xmlNode.appendchild($headernode) > $null $headeritems | ForEach-Object { $prop = $xmlBase.CreateElement("Property") $prop.setattribute("Name", "$_") $headerNode.appendchild($prop) > $null } } "literal" { $xmlnode.setattribute("style", "$style") } default { $xmlnode.setattribute("style", "unsupported") } } } $xmlBase.outerxml } function Format-DiagChart ($object, $PropNameField, $PropValueField, $PropMaxValueField, $absolute, $Title, $style) { $xmlStrings $minVal = 0 $maxVal = 0 #get min and max values if ($absolute -eq 1) { for ($i = 0; $i -lt $object.length; $i++) { if ($object[$i]."$PropMaxValueField" -gt $maxVal) { $maxVal = $object[$i]."$PropMaxValueField" } if ($object[$I]."$PropMaxValueField" -lt $minVal) { $minVal = $object[$i]."$PropMaxValueField" } } } #Add each item to chart for ($i = 0; $i -lt $object.length; $i++) { if ($absolute -ne 1) { $maxval = 0 $minval = 0 if ($object[$i]."$PropMaxValueField" -gt $maxVal) { $maxVal = $object[$i]."$PropMaxValueField" } if ($object[$I]."$PropMaxValueField" -lt $minVal) { $minVal = $object[$i]."$PropMaxValueField" } } $itemSize = [math]::round(($object[$i]."$PropValueField" / $maxval) * 100,1) if ($itemSize -le 0) { $itemSize = 0 } $itemValue = $object[$i]."$PropValueField" $itemName = $object[$i]."$PropNameField" $xmlStrings = $xmlStrings + "" } $xmlstrings = $xmlstrings.insert(0, "") $xmlstrings = $xmlstrings + "" $xmlstrings } # Place ProductID in Debug Report function Set-DiagPID([string]$ProductName, [string]$ProductID) { $PIDObject = "" | Select-Object ProductName # Return object $PIDObject.ProductName = $ProductName add-member -inputobject $PIDObject -membertype noteproperty -name ProductID -value $ProductID (convertto-xml -InputObject $PIDObject) | update-diagreport -id OAS_DATAPOINT_ID -name "OAS_DATAPOINT" -description "OAS Data Point for OAS submission" -verbosity debug } function StrArrayTo-ObjArray([Array]$strArray, [string]$PropertyName='Name') { $Output = @() foreach($item in $strArray) { $TableEntry = New-Object psobject Add-Member -inputobject $TableEntry -membertype NoteProperty -Name $PropertyName -Value $item $Output += $TableEntry } return $Output }