Skip to content

Instantly share code, notes, and snippets.

@igoravl
Last active August 25, 2023 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igoravl/f36247a4a39fa0282a8bb26aa00f3661 to your computer and use it in GitHub Desktop.
Save igoravl/f36247a4a39fa0282a8bb26aa00f3661 to your computer and use it in GitHub Desktop.
Ordena arquivos COBOL do Mercantil
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