diff --git a/scripts/KANBAN-Rational-Druck/KANBAN-Rational-Druck.ps1 b/scripts/KANBAN-Rational-Druck/KANBAN-Rational-Druck.ps1 index 5ecfb8a..8298391 100644 --- a/scripts/KANBAN-Rational-Druck/KANBAN-Rational-Druck.ps1 +++ b/scripts/KANBAN-Rational-Druck/KANBAN-Rational-Druck.ps1 @@ -11,11 +11,11 @@ param( .DESCRIPTION Ablauf: 1. Optional Self-Update aus dem Public-Repo - 2. AZ_GITHUB_TOKEN prüfen + 2. AZ_GITHUB_TOKEN pruefen 3. Private Konfiguration aus dem Private-Repo laden 4. Genau eine Datei aus Input-Ordner lesen 5. Dateiname ohne Endung als Belegnummer verwenden - 6. SQL-Abfrage ausführen + 6. SQL-Abfrage ausfuehren 7. Ergebnis an n8n senden 8. Logging in Datei @@ -90,7 +90,7 @@ function Test-AzGithubToken { if ([string]::IsNullOrWhiteSpace($env:AZ_GITHUB_TOKEN)) { - throw "❌ Umgebungsvariable AZ_GITHUB_TOKEN ist nicht gesetzt." + throw "ERROR: Umgebungsvariable AZ_GITHUB_TOKEN ist nicht gesetzt." } } @@ -103,17 +103,17 @@ function Start-SelfUpdateIfNeeded if ($SkipSelfUpdateCheck) { - Write-ConsoleLog "Self-Update-Prüfung wurde übersprungen (Restart nach Update)." "INFO" + Write-ConsoleLog "Self-Update-Pruefung wurde uebersprungen (Restart nach Update)." "INFO" return } $localScriptPath = $PSCommandPath if ([string]::IsNullOrWhiteSpace($localScriptPath)) { - throw "❌ Lokaler Skriptpfad konnte nicht ermittelt werden." + throw "ERROR: Lokaler Skriptpfad konnte nicht ermittelt werden." } - Write-ConsoleLog "Prüfe auf neue Public-Version aus Git..." "INFO" + Write-ConsoleLog "Pruefe auf neue Public-Version aus Git..." "INFO" try { @@ -132,11 +132,11 @@ function Start-SelfUpdateIfNeeded if ($localHash -eq $remoteHash) { - Write-ConsoleLog "✓ Public-Skript ist bereits aktuell." "SUCCESS" + Write-ConsoleLog "OK: Public-Skript ist bereits aktuell." "SUCCESS" return } - Write-ConsoleLog "⚠ Neue Public-Version gefunden. Aktualisiere lokales Skript..." "WARN" + Write-ConsoleLog "WARN: Neue Public-Version gefunden. Aktualisiere lokales Skript..." "WARN" $tempUpdatedScript = Join-Path $env:TEMP ("{0}-{1}.ps1" -f $script:ScriptName, [guid]::NewGuid().ToString()) Set-Content -Path $tempUpdatedScript -Value $remoteContent -Encoding UTF8 @@ -144,7 +144,7 @@ function Start-SelfUpdateIfNeeded Copy-Item -Path $tempUpdatedScript -Destination $localScriptPath -Force Remove-Item -Path $tempUpdatedScript -Force -ErrorAction SilentlyContinue - Write-ConsoleLog "✓ Lokales Public-Skript wurde aktualisiert." "SUCCESS" + Write-ConsoleLog "OK: Lokales Public-Skript wurde aktualisiert." "SUCCESS" Write-ConsoleLog "Starte aktualisierte Version neu..." "INFO" $argumentList = @( @@ -155,11 +155,11 @@ function Start-SelfUpdateIfNeeded Start-Process -FilePath 'powershell.exe' -ArgumentList $argumentList | Out-Null - Write-ConsoleLog "Aktuelle Instanz wird beendet, damit die neue Version ausgeführt wird." "INFO" + Write-ConsoleLog "Aktuelle Instanz wird beendet, damit die neue Version ausgefuehrt wird." "INFO" exit 0 } catch { - throw "❌ Fehler bei der Self-Update-Prüfung des Public-Skripts: $($_.Exception.Message)" + throw "ERROR: Fehler bei der Self-Update-Pruefung des Public-Skripts: $($_.Exception.Message)" } } @@ -197,7 +197,7 @@ function Get-PrivateConfig return $script:PrivateConfig } catch { - throw "❌ Fehler beim Laden der privaten Konfiguration: $($_.Exception.Message)" + throw "ERROR: Fehler beim Laden der privaten Konfiguration: $($_.Exception.Message)" } } @@ -224,7 +224,7 @@ function Test-RequiredConfig { if (-not $Config.ContainsKey($key) -or [string]::IsNullOrWhiteSpace([string]$Config[$key])) { - throw "❌ Fehlende Konfiguration: '$key'" + throw "ERROR: Fehlende Konfiguration: '$key'" } } } @@ -238,19 +238,19 @@ function Get-SingleInputFile if (-not (Test-Path -Path $InputFolder)) { - throw "❌ Input-Ordner existiert nicht: $InputFolder" + throw "ERROR: Input-Ordner existiert nicht: $InputFolder" } $files = Get-ChildItem -Path $InputFolder -File if ($files.Count -eq 0) { - throw "❌ Keine Datei im Input-Ordner gefunden: $InputFolder" + throw "ERROR: Keine Datei im Input-Ordner gefunden: $InputFolder" } if ($files.Count -gt 1) { - throw "❌ Es wurden mehrere Dateien gefunden. Erwartet wird genau eine Datei im Ordner: $InputFolder" + throw "ERROR: Es wurden mehrere Dateien gefunden. Erwartet wird genau eine Datei im Ordner: $InputFolder" } return $files[0] @@ -297,7 +297,7 @@ function Invoke-SqlTopOneQuery if ($dataTable.Rows.Count -eq 0) { - Write-Log "⚠ Kein SQL-Datensatz gefunden." "WARN" + Write-Log "WARN: Kein SQL-Datensatz gefunden." "WARN" return $null } @@ -316,17 +316,18 @@ function Invoke-SqlTopOneQuery } } - Write-Log "✓ SQL-Datensatz erfolgreich gelesen." "SUCCESS" + Write-Log "OK: SQL-Datensatz erfolgreich gelesen." "SUCCESS" return [pscustomobject]$result } catch { - throw "❌ Fehler bei SQL-Abfrage: $($_.Exception.Message)" + throw "ERROR: Fehler bei SQL-Abfrage: $($_.Exception.Message)" } finally { if ($connection.State -ne [System.Data.ConnectionState]::Closed) { $connection.Close() } + $connection.Dispose() } } @@ -347,10 +348,10 @@ function Send-N8nWebhook { $json = $Payload | ConvertTo-Json -Depth 10 $null = Invoke-RestMethod -Uri $WebhookUrl -Method Post -ContentType 'application/json' -Body $json - Write-Log "✓ Webhook erfolgreich gesendet." "SUCCESS" + Write-Log "OK: Webhook erfolgreich gesendet." "SUCCESS" } catch { - throw "❌ Fehler beim Senden des Webhooks: $($_.Exception.Message)" + throw "ERROR: Fehler beim Senden des Webhooks: $($_.Exception.Message)" } } @@ -374,7 +375,7 @@ try $script:LogFilePath = Join-Path $config.LogFolder ("KANBAN-Rational-Druck_{0}.log" -f (Get-Date -Format 'yyyy-MM-dd')) - Write-Log "Starte Skriptausführung KANBAN-Rational-Druck..." "INFO" + Write-Log "Starte Skriptausfuehrung KANBAN-Rational-Druck..." "INFO" $inputFile = Get-SingleInputFile -InputFolder $config.InputFolder @@ -426,7 +427,7 @@ try Send-N8nWebhook -WebhookUrl $config.WebhookUrl -Payload $payload - Write-Log "Skriptausführung abgeschlossen." "SUCCESS" + Write-Log "Skriptausfuehrung abgeschlossen." "SUCCESS" } catch { try @@ -445,7 +446,7 @@ try Write-Log $_.Exception.Message "ERROR" } catch { - Write-Host "❌ Kritischer Fehler: $($_.Exception.Message)" + Write-Host "ERROR: Kritischer Fehler: $($_.Exception.Message)" } exit 1