Last active
August 25, 2023 13:40
-
-
Save igoravl/f36247a4a39fa0282a8bb26aa00f3661 to your computer and use it in GitHub Desktop.
Ordena arquivos COBOL do Mercantil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MBStringComparer : System.Collections.IComparer { | |
[int] Compare([object] $x, [object] $y) { | |
if($x.Contains('/')) | |
{ | |
$x = $x.Substring($x.LastIndexOf('/') + 1) | |
} | |
if($y.Contains('/')) | |
{ | |
$y = $y.Substring($y.LastIndexOf('/') + 1) | |
} | |
$order = "LNTSOP" | |
$char1 = $x[3] | |
$char2 = $y[3] | |
$index1 = $order.IndexOf($char1) | |
$index2 = $order.IndexOf($char2) | |
if ($index1 -eq $index2) { | |
return [string]::Compare($x, $y) | |
} | |
else { | |
return $index1 - $index2 | |
} | |
} | |
} | |
[Array]::Sort($alterados, [MBStringComparer]::new()) | |
foreach ($arquivo in $alterados) { | |
Write-Output "Preparando [$arquivo] para compilação" | |
$pasta = Split-Path $arquivo -Parent | |
switch ($pasta) { | |
'bms' { | |
Write-Warning 'Programas BMS estão sendo ignorados neste momento.' | |
} | |
'cobol' { | |
Write-Output "[$arquivo] será compilado como COBOL" | |
$comandos += @" | |
/usr/lpp/IBM/dbb/bin/groovyz /var/builder/dbb-zappbuild/build.groovy | |
--sourceDir $sandboxpath | |
--workDir $logpath | |
--hlq $pdssistema | |
--application $sistema | |
--verbose | |
--userBuild $sistema/$arquivo | |
"@ -replace "`r", '' -replace "`n", '' | |
} | |
'copybook' { | |
` | |
Write-Warning 'Copybooks não são compilados.' | |
} | |
'easytrieve' { | |
Write-Output "[$arquivo] será compilado como Easytrieve" | |
foreach ($arquivo in $alterados) { | |
$comandos += @" | |
/usr/lpp/IBM/dbb/bin/groovyz /var/builder/dbb-zappbuild/buildeasy.groovy | |
--sourceDir $sandb | |
--sourceDir $sandboxpath | |
--workDir $logpath | |
--hlq $pdssistema | |
--application $sistema | |
--verbose | |
--userBuild $sistema/$arquivo | |
"@ -replace "`r", '' -replace "`n", '' | |
} | |
} | |
'plano' { | |
Write-Warning 'Planos não são compilados.' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment