ETidalgo
7/5/2018 - 7:14 PM

Xml


$file = "D:\dev\eCargo\Reports\Source\eCargo Reports.rptproj"
$iDoc = [xml](get-content $file)

$removeNode = $iDoc.SelectSingleNode("//ProjectItem[Name='Lodestar Accruals Report Summary.rdl']")
$removeNode.ParentNode.RemoveChild($removeNode) 

$iDoc.Save($file)

gci "D:\Vault\LegacyEventQueuePayloads\chh_delvry01\*.xml" | % { 
    $fileName = $_.FullName
    $delvDoc = [xml](get-content "$fileName")
    $lprNode = (select-xml -xpath "//E1EDL20[./E1EDL21/LPRIO='04']" -xml $delvDoc )
    $sprNode = (select-xml -xpath "//E1EDL20[./E1EDL24/SPART='32']" -xml $delvDoc ) 
    $status = ""
    if ($lprNode -ne $null) {
        $status = "/LPRIO='04'"
        if ($sprNode -ne $null) {
            $status += " SPART='32'"
        } else {
            $status += " No Priority"
        }
        write-host $fileName
        write-host $status
    }
} 
$oiDoc = [xml](get-content "C:\Users\ernest\eCargo\Tasks\EC-2659 Modify OI interface to support new DELVRY07 format\DELVRY 80433969 .xml" )

## Using []
## Get the all LGORT nodes under the first E1EDL24 node
select-xml -XPath "//E1EDL24[1]/LGORT" -Xml $oidoc |  % { $_.Node } 

## Get the first LGORT node under each E1EDL24 node
select-xml -XPath "//E1EDL24/LGORT[1]" -Xml $oidoc |  % { $_.Node } 

## environments.xml
$node = $environmentXNode.SelectNodes("//MachineName[text()='etidosapp']/parent::Server")
$ipaddress = $environmentXNode.SelectSingleNode("//MachineName[text()='etidosapp']/parent::Server/IpAddress")

$ipaddress."#text" = '10.50.56.100'

# sample
$lookup = @{ etidosapp = '10.50.56.113' ; etidosdata = '10.50.56.114' } 

$environmentXNode.SelectNodes("//Server") | % { $_; $_.MachineName ; $ip = $_.SelectSingleNode("IpAddress") ; $ip."#text" = $lookup[$_.MachineName] ; $ip."#text" } 
$xmlFile = ""
$xml = [xml](gc $xmlFile)
$xml.Save("file")
## Shouldn't you have something here by now?

function Get-VmIpv4Address ($VmName) {
  get-vmnetworkadapter -vmname "$VmName"  | % { $_.IpAddresses } | ? { $_ -notmatch ":" } | select -first 1
}

function Update-VMIpAddresses {
	param([string]$EnvironmentFilename)

	function UpdateMachineIpAddress($serverNode) {
		$machineName = $serverNode.MachineName
		$ipNode = $serverNode.SelectSingleNode("IpAddress")
		$ipAddress = (Get-VmIpv4Address $ipNode.MachineName)
		$ipNode."#text" = $ipAddress
	}
	$environmentFile = gci $EnvironmentFilename
	$environmentXNode = [xml](gc $environmentFile)
	$environmentXNode.SelectNodes("//Server") | % { UpdateMachineIpAddress $_ }
	$environmentXNode.Save($environmentFile)

	## Update vm .hosts files
	## Update host .hosts file
}
$xml = [xml](gc "D:\Tasks\AC-1743 XRays uploader problem\20201014-Update uploader config\UploaderConfig.xml")
$allPatientIds = $xml.MapperWorkerData.exProXraysConfigs.ExProXraysConfig | select -ExpandProperty externalPatientID
$patientIdsToUpload = gc "D:\Tasks\AC-1743 XRays uploader problem\20201014-Update uploader config\BoxHillPatientWithNoXrays.csv" | ConvertFrom-Csv | select -ExpandProperty ExternalPatientID
$patientsWithXrays = Compare-Object $allPatientIds $patientIdsToUpload | ? { $_.SideIndicator -eq '<=' } | select -ExpandProperty InputObject 
$patientsWithXrays | sc "D:\Tasks\AC-1743 XRays uploader problem\20201014-Update uploader config\PatientsWithXRays.txt" 
$patientsToRemove = gc "D:\Tasks\AC-1743 XRays uploader problem\20201014-Update uploader config\PatientsWithXRays.txt"
$patientsToRemove | % { $xpath = "/MapperWorkerData/exProXraysConfigs/ExProXraysConfig[externalPatientID='$_']" ; $node = $xml.SelectSingleNode($xpath) ; $node.ParentNode.RemoveChild($node) | out-null } 
$xml.Save("D:\Tasks\AC-1743 XRays uploader problem\20201014-Update uploader config\UploaderConfig-Updated.xml")

$patientsNotFound = Compare-Object $allPatientIds $patientIdsToUpload | ? { $_.SideIndicator -eq '=>' }