96 lines
3.3 KiB
PowerShell
96 lines
3.3 KiB
PowerShell
workflow MissingTransactions {
|
|
$servers = Get-Item "C:\users\m.nielsen\documents\thales\missingtransactions\*" | Where-Object -FilterScript { $_.Attributes -icontains 'directory' }
|
|
|
|
|
|
foreach ($s in $servers) {
|
|
$dates = Get-Item -Path "$($s.FullName)\OutgoingNotProcessed\*"
|
|
|
|
foreach -parallel -throttlelimit 4 ($d in $dates) {
|
|
|
|
InlineScript {
|
|
$date = $using:d
|
|
$server = $using:s
|
|
|
|
|
|
try {
|
|
|
|
$files = Get-ChildItem -Recurse "$($date.FullName)\rejk-p-mdl003v\dcp_ud" -File
|
|
|
|
Write-Verbose "$($server.Name) - $($date.Name) - Csv Import"
|
|
$csv = Import-Csv "$($server.FullName)\OutgoingHistory\$($date.Name)\fsv_histooutgoing.txt" -Header ('box name ; file name ; date of arrival ; number of retries ; date of last send info ; date of ack ; row of sending ; current date' -split ' ; ') -Delimiter ';'
|
|
|
|
$dateFormatted = [datetime]::ParseExact($date.Name,'yyyyMMdd', [cultureinfo]::InvariantCulture)
|
|
|
|
$filecount = 0
|
|
foreach ($file in $files) {
|
|
try {
|
|
Write-Verbose "$($server.Name) - $($date.Name) - $($file.Name)"
|
|
|
|
$filename = $file.Name
|
|
|
|
$result = foreach($entry in $csv) {
|
|
if($entry.'file name' -match $filename) {
|
|
$entry
|
|
}
|
|
}
|
|
|
|
foreach($entry in $result) {
|
|
if($entry.'date of ack' -ne $null) {
|
|
|
|
Write-Verbose "$($server.Name) - $($date.Name) - $($file.Name) - It's a match"
|
|
|
|
$foundInSql = 0
|
|
[pscustomobject]@{
|
|
Filename = $filename
|
|
DateOfAck = $($entry.'date of ack')
|
|
FoundInSQL = $foundInSql
|
|
Server = $server.name
|
|
Date = $date.Name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch {
|
|
Write-Warning "File $($file.Name) failed: $_"
|
|
}
|
|
}
|
|
}
|
|
catch {
|
|
Write-Warning "Date $($date.Name) failed: $_"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$result = MissingTransactions -Verbose
|
|
|
|
|
|
$result | Export-Csv csv.csv -Delimiter ';' -NoTypeInformation
|
|
|
|
$csv = import-csv csv.csv -Delimiter ';'
|
|
|
|
$count = 0
|
|
$csv2 = foreach($entry in $csv) {
|
|
$count++
|
|
Write-progress -Activity "Finding nonacked" -Status "$count / $($csv.Count)"
|
|
|
|
$matches = foreach($c in $csv) {
|
|
if($c.filename -eq $entry.filename) {
|
|
$c
|
|
}
|
|
}
|
|
|
|
$isack = $false
|
|
|
|
foreach($m in $matches) {
|
|
if($m.dateofack -ne 'never positif ack ') {
|
|
$isack = $true
|
|
break
|
|
}
|
|
}
|
|
|
|
if(-not $isack) {
|
|
$entry
|
|
}
|
|
} |