Compare commits
11
Commits
b32cc61e43
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b1c14b892 | ||
|
|
61b5b7e452 | ||
|
|
b18adab26d | ||
|
|
fe3c84a27f | ||
|
|
999f69bcb9 | ||
|
|
3b4a621cd3 | ||
|
|
3219c3f1bc | ||
|
|
4af64d8b41 | ||
|
|
1228f71765 | ||
|
|
9ce7e8d45a | ||
|
|
08626197be |
@@ -0,0 +1,72 @@
|
||||
# AI-Maintainer-Handoff
|
||||
|
||||
## Projekt und Sicherheitsziel
|
||||
|
||||
Das Repository enthält ein .NET-Framework-4.6.1-WinForms-Tool für kontrollierte BizTalk-2020-Wartungsoperationen. Änderungen müssen Dry-run, explizite Freigabe realer Aktionen, sichere Reihenfolgen und wiederherstellbare Installergrenzen erhalten. Die aktuelle Produktversion ist 2.3.4.
|
||||
|
||||
## Installerinvarianten
|
||||
|
||||
- Vor der ersten Mutation müssen Manifest, Länge, SHA-256 und Staging-Self-Test erfolgreich sein.
|
||||
- Eine laufende installierte Anwendung blockiert Update und Deinstallation.
|
||||
- Ein Update darf die aktive Vorversion erst nach erfolgreichem Staging verändern.
|
||||
- Das Backup einer bestehenden Installation wird nur atomar per `Directory.Move` erzeugt. Bei dauerhaftem Fehler bleibt die Vorversion aktiv; es gibt keinen In-place-Kopierfallback.
|
||||
- Nach ausgeschöpften Aktivierungs-Move-Retries darf eine erneut SHA-256-geprüfte Kopie nur in ein nicht vorhandenes Ziel geschrieben werden: bei einer Neuinstallation oder nachdem eine Update-Vorversion vollständig atomar ins Backup verschoben wurde.
|
||||
- Nach jeder Aktivierungsart läuft der Self-Test erneut aus dem endgültigen Installationsziel.
|
||||
- Sobald ein Zielverzeichnis teilweise angelegt sein kann, muss `activated=true` gesetzt sein, damit der Catch-Pfad es entfernt.
|
||||
- Scheitert der Ziel-Self-Test nach einem Update-Kopierfallback, muss die teilweise neue Version entfernt und das atomare Backup wieder als aktives Verzeichnis eingesetzt werden.
|
||||
- Windows-Integration wird erst nach bestandenem Ziel-Self-Test verändert und bei Folgefehlern aus dem Snapshot restauriert.
|
||||
- Startmenü-Link, Uninstaller und Uninstall-Registry sind verpflichtend; Fehler müssen weiterhin den vollständigen Rollback auslösen.
|
||||
- Der gemeinsame Desktop-Link ist optional und standardmäßig abgewählt. Snapshot, Erstellen/Entfernen, Validierung, Rollback und Uninstall müssen jeden Fehler als sichtbare Warnung isolieren und dürfen keine Kernoperation abbrechen.
|
||||
- Diagnose-Logging darf das eigentliche Setup-Ergebnis nie ersetzen.
|
||||
|
||||
Die zentrale Implementierung liegt in `src/BizTalkPlatformManagementTool.Setup/InstallerEngine.cs`. Move-Retries sind auf acht Versuche und 19,75 Sekunden Wartezeit begrenzt. Die injizierbaren `directoryMover`- und `retryDelay`-Delegates existieren ausschließlich, damit Sperrpfade ohne echte Wartezeit portabel getestet werden können.
|
||||
|
||||
## Runtime- und Recovery-Invarianten
|
||||
|
||||
- Ein isolierter WMI-, Adapter- oder Servicefehler darf keine späteren unabhängigen Planschritte verhindern.
|
||||
- Teilfehler werden vollständig pro Schritt persistiert; der Gesamtlauf bleibt sichtbar fehlgeschlagen und darf nicht als Erfolg ausgegeben werden.
|
||||
- Vor jeder Mutation wird der aktuelle Zustand geprüft. Bereits erreichte Sollzustände werden ohne Methodenaufruf als `AlreadySatisfied` erfasst.
|
||||
- Der Nachher-Snapshot wird unabhängig von Einzelfehlern versucht; sein Fehler gehört in denselben Ergebnisreport.
|
||||
- Die Runtime-WMI-Klassen liefern keine verlässliche Application-Zuordnung. `BizTalkApplicationResolver` liest deshalb die Management-DB-Position aus `MSBTS_GroupSetting` und indiziert die read-only ExplorerOM-Anwendungshierarchie. WMI bleibt Quelle für Zustand und Mutationen; ExplorerOM wird ohne Compile-time-Abhängigkeit und nur mit geprüfter Microsoft-Assemblyidentität geladen.
|
||||
- Scheitert die Katalogauflösung, bleibt die WMI-Zustandserfassung verfügbar, aber alle betroffenen Artefakte werden sichtbar unter `(Unknown Application)` gruppiert und Diagnose, Grid sowie Laufzeitlog müssen eine verwertbare Warnung ausgeben.
|
||||
- Shutdown-Kategorien gelten global über alle Anwendungen: Receive Locations, Orchestrations, Send Ports, Host Instances.
|
||||
- Zwischen der globalen Receive-Location-Phase und allen späteren Shutdown-Kategorien liegt ein persistierter Operator-Checkpoint. Ein realer Lauf darf nur nach explizitem Continue fortsetzen; Stop oder Handlerfehler markiert alle späteren Zeilen als `NotExecuted` und arbeitet fail-closed.
|
||||
- Dry-run zeigt den Checkpoint ohne Callback. Der Ergebnisreport muss Entscheidung, Zeitpunkt, OperatorStopped und NotExecutedCount dauerhaft enthalten.
|
||||
- Ein BizTalk-Application-Stop wird nicht zusätzlich ausgeführt: `Partially Started` ist während des Drains erwartbar, während Application-Stop-Optionen eine breitere, teils destruktive Semantik als das reine Setzen eines Statuswerts besitzen.
|
||||
- Restore-Kategorien gelten global über alle Anwendungen: Host Instances, Send Ports, Orchestrations, Receive Locations.
|
||||
- Emergency Restore überschreibt niemals die Eingabe-`before.json`, erzeugt eine timestamp-basierte Kopie und stellt `ENTSSO` vor Host Instances sicher.
|
||||
- Emergency Restore muss mit genau einer validen `before.json` funktionieren; Dateien eines vorherigen fehlgeschlagenen Laufs dürfen keine Voraussetzung sein.
|
||||
- Ein älterer kompatibler Snapshot, insbesondere aus 2.1.3, darf nicht allein anhand seines `ToolVersion`-Werts abgelehnt werden.
|
||||
- Alle laufzeitrelevanten Bestätigungsdialoge müssen mit dem Hauptformular als Owner angezeigt werden. Vor dem echten Drain-Checkpoint muss der Status sichtbar `ACTION REQUIRED`/pausiert melden; Dry-run muss ausdrücklich erklären, dass keine Runtime-Änderung und keine echte Drain-Entscheidung erfolgt.
|
||||
- Der echte Emergency Restore erzeugt nach Möglichkeit automatisch einen timestamp-basierten Soll/Ist-Diff aus Recovery-Quelle und Nachher-Snapshot.
|
||||
- Die zentrale best-effort Orchestrierung liegt in `OperationPlanExecutor`; die WMI-/Service-Zustandsprüfung bleibt im produktiven Runtime-Adapter.
|
||||
- Datei-Logging und optionale GUI-Logweiterleitung sind Diagnosekanäle und dürfen niemals einen fachlichen Planschritt oder dessen Fehlerbehandlung unterbrechen.
|
||||
- Ein Laufzeitlogpfad gilt erst nach erfolgreichem Create/Write/Flush/Delete-Test als verfügbar. Die Reihenfolge ProgramData, LocalAppData, EXE-`Logs`, Temp ist stabil; ein Append-Fehler muss denselben Datensatz auf dem nächsten Kandidaten erneut versuchen.
|
||||
- Fallback und Totalausfall des Dateiloggings müssen mit Pfad und Exception im Grid sichtbar sein. Jeder GUI-Start persistiert einen Verifikationsdatensatz; der WMI-freie Self-Test prüft einen vollständigen Log-Write/Read-Roundtrip.
|
||||
- Scheduler-Preflight darf nur für Receive Locations mit passendem Adaptername oder `scheduler:`-URI laufen; normale Adapter dürfen keine zusätzliche Abhängigkeit erhalten.
|
||||
- Adapter-DLLs dürfen nur aus explizit konfigurierten, per Registry erkannten oder konventionellen Produktverzeichnissen und nur nach vollständiger Assemblyidentitätsprüfung geladen werden. Der Toolprozess verändert niemals den GAC.
|
||||
- Laufzeitlogs halten 30 Kalendertage, komprimieren abgeschlossene Tage und rehydrieren maximal 10.000 neue Einträge ins Grid. Ein Archiv-/Lesefehler darf keine BizTalk-Operation beeinflussen.
|
||||
|
||||
## Versionierung
|
||||
|
||||
Bei einem Release sind mindestens diese Stellen konsistent zu ändern:
|
||||
|
||||
- `InstallerEngine.ProductVersion`
|
||||
- Setup-Titel in `MainForm`
|
||||
- beide `Properties/AssemblyInfo.cs`
|
||||
- beide `app.manifest`
|
||||
- `BizTalkOperationService.Version`
|
||||
- `CHANGELOG.md`
|
||||
|
||||
## Verifikation
|
||||
|
||||
Portable Befehle:
|
||||
|
||||
```sh
|
||||
msbuild BizTalkPlatformManagementTool.sln /t:Rebuild /p:Configuration=Release '/p:Platform=Any CPU' /m:1
|
||||
mono tests/BizTalkPlatformManagementTool.Tests/bin/Release/BizTalkPlatformManagementTool.Tests.exe
|
||||
mono src/BizTalkPlatformManagementTool/bin/Release/BizTalkPlatformManagementTool.exe --self-test
|
||||
mono src/BizTalkPlatformManagementTool.Packager/bin/Release/BizTalkPlatformManagementTool.Packager.exe . Release
|
||||
```
|
||||
|
||||
Nach der Paketierung müssen ZIP, Base64-TXT und SHA-256-Datei gegengeprüft werden. Die abschließende Freigabe braucht zusätzlich einen repräsentativen Windows-/ACC-Test von UAC, `Program Files`-ACL/EDR, Registry, Verknüpfungen, Update, Rollback und Deinstallation sowie BizTalk-Diagnose und Dry-run.
|
||||
+139
@@ -1,6 +1,145 @@
|
||||
|
||||
# Changelog
|
||||
|
||||
## [2.3.4] - 2026-08-27
|
||||
### Fixed
|
||||
- Shutdown plan review, inbound-drain and emergency-restore confirmations are now owned by the main window, preventing a modal decision from being hidden behind the application in RDP and multi-monitor sessions.
|
||||
- The shutdown status now changes from a generic preparation message to an explicit `ACTION REQUIRED` / paused state before the real inbound-drain decision.
|
||||
|
||||
### Changed
|
||||
- Dry-run and real execution are distinguished with prominent mode text, color and persistent status guidance; execution settings cannot be changed while an operation is active.
|
||||
- A shutdown Dry-run now displays an owned informational notice explaining that it changes no receive locations and therefore does not open the real drain decision dialog.
|
||||
- The prepared real-shutdown confirmation explicitly announces the second decision after the receive-location phase; closing the real checkpoint dialog is explicitly documented as a safe stop.
|
||||
|
||||
### Added
|
||||
- Regression coverage for checkpoint creation when later shutdown work exists without enabled receive locations, and for distinct Dry-run, prepared-plan and paused-checkpoint operator guidance.
|
||||
- A dedicated PROD root-cause analysis, validation runbook and plain-text handoff for shutdown-dialog visibility.
|
||||
|
||||
## [2.3.3] - 2026-08-27
|
||||
### Fixed
|
||||
- Snapshot, shutdown and restore rows no longer show every Send Port, Receive Location and Orchestration under `(Unknown Application)` when the BizTalk runtime WMI classes omit application ownership.
|
||||
|
||||
### Changed
|
||||
- Application ownership is now read from the official read-only ExplorerOM application hierarchy, while WMI remains authoritative for runtime state and mutations.
|
||||
- **Diagnose** reports visible Send Ports and the exact number with a resolved application association; incomplete catalog access remains a visible warning instead of being hidden.
|
||||
- ExplorerOM is loaded process-locally from the GAC or identity-checked BizTalk installation paths, preserving the portable build and WMI-free installer self-test.
|
||||
|
||||
### Added
|
||||
- Regression coverage for Send Port, Receive Port/Location and Orchestration mapping, case-insensitive lookup and rejection of ambiguous cross-application names.
|
||||
- A dedicated PROD root-cause analysis, validation runbook and plain-text handoff for the application-association fix.
|
||||
|
||||
## [2.3.2] - 2026-08-26
|
||||
### Added
|
||||
- A persisted, fail-closed operator drain checkpoint between the global receive-location phase and all later real shutdown phases.
|
||||
- Durable `Continue`, `Stop` or `Error` checkpoint evidence plus `NotExecuted` results for every protected downstream plan row.
|
||||
- Regression coverage for checkpoint ordering, continuation after an early receive-location failure, explicit operator stop, missing-handler fail-closed behavior and dry-run isolation.
|
||||
- A dedicated PROD runbook and plain-text handoff for drain verification and BizTalk application status semantics.
|
||||
|
||||
### Changed
|
||||
- Real shutdown now pauses with a default-No dialog that summarizes receive-location outcomes and asks the operator to verify Group Hub and enterprise monitoring before continuing.
|
||||
- A safe operator stop still attempts the partial-state snapshot and execution report and is shown as stopped rather than a completed shutdown.
|
||||
|
||||
### Security
|
||||
- The tool deliberately does not issue a broad application-level stop merely to change `Partially Started`; stronger BizTalk application stop modes can remove subscriptions, unenlist artifacts, undeploy policies or terminate running instances.
|
||||
|
||||
## [2.3.1] - 2026-08-26
|
||||
### Added
|
||||
- A real runtime-log write/read roundtrip to the WMI-free installer self-test and a durable startup verification record naming the active daily file.
|
||||
- Regression coverage for startup fallback, append-time failover without record loss and total storage failure diagnostics.
|
||||
- A dedicated PROD storage-validation runbook in Markdown and plain text.
|
||||
|
||||
### Changed
|
||||
- Runtime logging now verifies actual writes and uses the deterministic fallback order ProgramData, LocalAppData, executable-local `Logs`, then Temp.
|
||||
- **Log Folder** opens the currently verified path; fallback and total failure diagnostics include attempted paths and exceptions in the Operation Log grid.
|
||||
|
||||
### Fixed
|
||||
- Successful directory creation can no longer be mistaken for working file logging when the subsequent append is denied.
|
||||
- Runtime append failures are no longer swallowed silently; the failed record is retried on the next local candidate and a durable/visible warning is emitted.
|
||||
|
||||
## [2.3.0] - 2026-08-26
|
||||
### Added
|
||||
- Process-local, assembly-identity-checked resolution and preflight for ScheduledTask `scheduler:` receive locations, including automatic BizTalk/adapter directory and registry discovery plus an explicit configuration override.
|
||||
- Persistent Operation Log grid restoration from retained plain and GZip-compressed daily logs.
|
||||
- **Log Folder** action and a dedicated PROD validation/support runbook in Markdown and plain text.
|
||||
- Regression coverage for Scheduler plan metadata, assembly identity rejection, restart persistence, compression, 30-day retention and detailed exception diagnostics.
|
||||
|
||||
### Changed
|
||||
- Runtime logs now retain 30 calendar days and compress completed daily files instead of deleting everything older than five days.
|
||||
- Grid, result JSON and file logs now preserve exception type, HRESULT, inner exceptions, Fusion loader details and stack traces for support analysis.
|
||||
|
||||
### Fixed
|
||||
- ScheduledTask 7.0.2 receive locations can resolve `Microsoft.BizTalk.Scheduler.dll` from the installed BizTalk environment before WMI `Enable`/`Disable`, without requiring the management tool to mutate the GAC.
|
||||
|
||||
## [2.2.4] - 2026-08-24
|
||||
### Fixed
|
||||
- Permission, Windows Script Host, validation and rollback errors affecting the optional all-users desktop shortcut no longer abort installation, update or uninstallation.
|
||||
- Failure to capture or restore the optional desktop shortcut can no longer prevent restoration of mandatory registry, Start menu and uninstaller state.
|
||||
|
||||
### Changed
|
||||
- The all-users desktop shortcut is now opt-in and unchecked by default.
|
||||
- Optional desktop warnings are visible in the setup UI and durable log, while completion remains successful with an explicit warning result.
|
||||
|
||||
### Added
|
||||
- Failure-injection coverage proving that both an optional shortcut exception and a failing warning sink remain non-fatal.
|
||||
- Dedicated operator and maintainer documentation for the optional Windows-integration boundary.
|
||||
|
||||
## [2.2.3] - 2026-08-24
|
||||
### Fixed
|
||||
- A persistent Windows/EDR denial of the final staging-directory rename no longer aborts activation after an existing installation has already been atomically moved to its backup.
|
||||
- The SHA-256-verified copy fallback now covers both first installation and update activation, while refusing to overwrite an existing target or an update without a completed backup.
|
||||
|
||||
### Added
|
||||
- Regression coverage for successful update copy fallback and complete restoration of the previous version when the post-copy target self-test fails.
|
||||
- PROD incident analysis and a plain-text operator handoff for the observed 2.1.2 `SETUP-ACTIVATION` failure.
|
||||
|
||||
## [2.2.2] - 2026-08-19
|
||||
### Fixed
|
||||
- A failure in the optional GUI log sink can no longer escape step-level error handling or stop later independent shutdown/restore steps.
|
||||
|
||||
### Added
|
||||
- Failure-injection coverage for multiple consecutive unexpected exception types and a permanently failing log-display sink.
|
||||
|
||||
## [2.2.1] - 2026-08-19
|
||||
### Added
|
||||
- WMI-free **Validate State** preflight with snapshot metadata, server matching and artifact counts.
|
||||
- Direct **State...** file selection for a preserved recovery snapshot.
|
||||
- Automatic timestamped JSON/CSV/HTML target/actual diff after a real Emergency Restore.
|
||||
- Regression coverage proving that a `before.json` created by version 2.1.3 remains a valid Emergency Restore source.
|
||||
|
||||
### Changed
|
||||
- Emergency-recovery documentation now provides a dedicated operator runbook for the ACC restart and explicitly distinguishes dry-run evidence from real execution evidence.
|
||||
|
||||
## [2.2.0] - 2026-08-19
|
||||
### Added
|
||||
- State-aware **Emergency Restore** from an existing `before.json` without overwriting the recovery source.
|
||||
- Enterprise Single Sign-On (`ENTSSO`) startup as the first emergency-recovery prerequisite.
|
||||
- Durable per-step `shutdown-result.json`, `restore-result.json` and timestamped emergency result reports.
|
||||
- Regression coverage for the ACC `Microsoft.BizTalk.Scheduler` failure, best-effort continuation, already-satisfied states, emergency ordering and global cross-application ordering.
|
||||
|
||||
### Changed
|
||||
- Shutdown and restore continue with remaining independent steps after an isolated WMI or adapter failure and finish with an explicit operator-review result.
|
||||
- Runtime operations skip artifacts that already match the requested target state, making recovery from partial shutdowns idempotent.
|
||||
- Post-operation snapshots are attempted and diagnosed independently after partial execution failures.
|
||||
- Shutdown order is now global across all applications: receive locations, orchestrations, send ports, then host instances.
|
||||
- Restore order is now global across all applications: host instances, send ports, orchestrations, then receive locations.
|
||||
|
||||
### Fixed
|
||||
- An ACC shutdown no longer aborts every later step when `RV_PMP_Trigger_Schedule` fails validation because `Microsoft.BizTalk.Scheduler` or a dependency cannot be loaded.
|
||||
- A partial shutdown no longer prevents recovery evidence from being written after the first failed step.
|
||||
- Host-instance steps no longer treat the short name and FQDN of the same target server as different machines.
|
||||
|
||||
## [2.1.3] - 2026-08-11
|
||||
### Added
|
||||
- Bounded retry/backoff diagnostics for transient `Directory.Move` locks caused by the Windows loader, antivirus or endpoint protection.
|
||||
- A SHA-256-verified copy activation fallback limited to first-time installations with no existing active version.
|
||||
- Regression coverage for transient recovery, permanent new-install fallback and permanent update denial without mutation.
|
||||
- ACC incident analysis and an AI maintainer handoff document.
|
||||
|
||||
### Changed
|
||||
- Install, update, rollback and uninstall directory moves now use eight bounded attempts over at most 19.75 seconds.
|
||||
- Setup completion logs record the activation method and preservation state of both backup and staging directories.
|
||||
- Product and setup version advanced to 2.1.3.
|
||||
|
||||
## [2.1.2] - 2026-08-11
|
||||
### Added
|
||||
- Complete XML documentation for types and methods across application, setup, packager and regression projects, including parameters, generic type parameters and return values.
|
||||
|
||||
+84
-11
@@ -1,6 +1,6 @@
|
||||
# BizTalk Platform Management Tool Dokumentation
|
||||
|
||||
**Stand:** 2026-08-11
|
||||
**Stand:** 2026-08-26
|
||||
**Implementierung:** C# WinForms, .NET Framework 4.6.1
|
||||
**Archivierte PowerShell-Version:** `archive/powershell/BizTalkPlatformManagementTool.ps1`
|
||||
|
||||
@@ -20,6 +20,9 @@ Das BizTalk Platform Management Tool unterstützt kontrollierte Wartungsfenster
|
||||
- Projekt: `src/BizTalkPlatformManagementTool/BizTalkPlatformManagementTool.csproj`
|
||||
- UI: `src/BizTalkPlatformManagementTool/Ui/MainForm.cs`
|
||||
- WMI-Zugriff: `src/BizTalkPlatformManagementTool/Services/BizTalkWmiClient.cs`
|
||||
- Anwendungszuordnung: `src/BizTalkPlatformManagementTool/Services/BizTalkApplicationResolver.cs`
|
||||
- Adapter-Assemblyauflösung: `src/BizTalkPlatformManagementTool/Services/AdapterAssemblyResolver.cs`
|
||||
- Persistentes Laufzeitlogging: `src/BizTalkPlatformManagementTool/Services/OperationLogger.cs`
|
||||
- Operationslogik: `src/BizTalkPlatformManagementTool/Services/BizTalkOperationService.cs`
|
||||
- Snapshot-Validierung: `src/BizTalkPlatformManagementTool/Services/SnapshotValidator.cs`
|
||||
- Installer: `src/BizTalkPlatformManagementTool.Setup`
|
||||
@@ -35,6 +38,7 @@ Deutsche Inline-Kommentare stehen gezielt an Stellen, deren Zweck nicht allein a
|
||||
|
||||
- sichere Shutdown-/Restore-Reihenfolge und Schutz gebundener Orchestrierungen,
|
||||
- WMI-Auflösung über breite Abfrage mit clientseitigem Filter,
|
||||
- read-only Anwendungszuordnung über die ExplorerOM-Anwendungshierarchie,
|
||||
- atomare JSON-Ersetzung auf demselben Volume,
|
||||
- Neutralisierung formelartiger CSV-Werte,
|
||||
- Persistenz eines Operationsplans vor der Benutzerbestätigung,
|
||||
@@ -53,25 +57,38 @@ Selbsterklärende Zuweisungen und reine UI-Konstruktion werden nicht zeilenweise
|
||||
6. Mit **Snapshot Before** die Datei `before.json` erzeugen.
|
||||
7. Mit **Shutdown** den Plan `shutdown-plan.json` erzeugen und prüfen.
|
||||
8. **Dry run** erst deaktivieren, wenn der Plan korrekt ist.
|
||||
9. Nach der Wartung mit **Restore** aus `before.json` wiederherstellen.
|
||||
10. Mit **Snapshot After** und **Compare** die Umgebung validieren.
|
||||
9. Beim echten Shutdown nach den Receive Locations den Drain-Dialog geöffnet lassen, Group Hub und Enterprise-Monitoring prüfen und erst bei leer gelaufener Verarbeitung **Yes** wählen.
|
||||
10. Nach der Wartung mit **Restore** aus `before.json` wiederherstellen.
|
||||
11. Mit **Snapshot After** und **Compare** die Umgebung validieren.
|
||||
|
||||
Die Statusanzeige rechts im Kopfbereich bewertet die Host-Instance-Zustaende des letzten Snapshots und zeigt `Started`, `Stopped`, `Partial` oder `Unknown`. **Clear** leert die sichtbaren Ergebnis- und Log-Grids, loescht aber keine Dateien. **Close** beendet die Anwendung.
|
||||
Wenn ein echter Shutdown oder Restore nur teilweise ausgeführt wurde und lediglich die ursprüngliche `before.json` verfügbar ist, wird **Emergency Restore** verwendet. Die Quelle kann über **State...** ausgewählt und vorab über **Validate State** ohne WMI-Zugriff geprüft werden. Der Modus kopiert die Quelle unter einem timestamp-basierten Namen, überschreibt `before.json` nicht, stellt zuerst `ENTSSO` sicher und gleicht danach den gespeicherten Sollzustand zustandsbewusst ab. Der erste Lauf muss als Dry-run erfolgen.
|
||||
|
||||
Die Statusanzeige rechts im Kopfbereich bewertet die Host-Instance-Zustaende des letzten Snapshots und zeigt `Started`, `Stopped`, `Partial` oder `Unknown`. **Clear** leert die sichtbaren Ergebnis- und Log-Grids, loescht aber keine Dateien. Beim nächsten Start wird die aufbewahrte Historie erneut geladen. **Log Folder** öffnet den lokalen Ablageordner, **Close** beendet die Anwendung.
|
||||
|
||||
## Sicherheitsdesign
|
||||
|
||||
- Dry-run ist standardmäßig aktiviert.
|
||||
- Beim Start wird geprüft, ob die Anwendung mit Administratorrechten läuft. Ohne erhöhte Rechte wird eine Fehlermeldung angezeigt und die Anwendung beendet.
|
||||
- Echte Shutdown-/Restore-Aktionen verlangen erst nach Erzeugung und Speicherung des frischen Plans eine zusätzliche Bestätigung mit Zielserver, Plandatei und exakter Zahl ausführbarer Schritte.
|
||||
- Ein echter Shutdown hält nach der globalen Receive-Location-Phase an einem im Plan gespeicherten Operator-Checkpoint. Nur ein explizites **Yes** setzt Orchestrierungen, Send Ports und Host Instances fort.
|
||||
- **No** oder ein Fehler des Bestätigungsdialogs arbeitet fail-closed: spätere Planzeilen werden ohne Mutation als `NotExecuted` gespeichert; Nachher-Snapshot und Ergebnisreport werden trotzdem versucht.
|
||||
- Jede Operation schreibt Einträge in das sichtbare Operation Log.
|
||||
- Zusätzlich wird unter `%ProgramData%\BizTalkPlatformManagementTool\Logs` eine tägliche Logdatei `BizTalkPlatformManagementTool-yyyy-MM-dd.log` geschrieben. Nur wenn ProgramData nicht verfügbar ist, wird auf das EXE-Verzeichnis zurückgefallen.
|
||||
- Logdateien werden rollierend für den aktuellen Tag plus vier vorherige Tage vorgehalten.
|
||||
- Primär wird unter `%ProgramData%\BizTalkPlatformManagementTool\Logs` eine tägliche Logdatei `BizTalkPlatformManagementTool-yyyy-MM-dd.log` geschrieben. Jeder Kandidat muss einen echten Create/Write/Flush/Delete-Test bestehen. Die Fallbackreihenfolge ist LocalAppData, `Logs` unter dem EXE-Verzeichnis und Temp.
|
||||
- Jeder GUI-Start hängt einen Prüfdatensatz an die aktive Tagesdatei an. **Log Folder** öffnet diesen tatsächlich beschreibbaren Pfad; ein Fallback oder der vollständige Ausfall des Dateiloggings wird mit Pfaden und Exception im Grid angezeigt.
|
||||
- Der aktuelle Tag bleibt als `.log` lesbar. Abgeschlossene Vortage werden als `.log.gz` komprimiert; aktueller Tag plus 29 Vortage bleiben erhalten.
|
||||
- Beim Programmstart werden bis zu 10.000 der neuesten Einträge aus `.log` und `.log.gz` chronologisch in das Operation Log geladen.
|
||||
- Der Kopfbereich zeigt den zuletzt erkannten Umgebungsstatus aus den Host Instances.
|
||||
- Operationspläne werden vor Laufzeitänderungen gespeichert.
|
||||
- Jeder ausführbare Schritt prüft vor der Mutation, ob sein Sollzustand bereits erreicht ist.
|
||||
- Ein Einzelfehler stoppt nicht mehr die restlichen unabhängigen Schritte; alle Ergebnisse werden einzeln persistiert.
|
||||
- Ein Teilfehler bleibt im GUI und im Ergebnisreport ausdrücklich fehlgeschlagen und wird nicht als Gesamterfolg ausgegeben.
|
||||
- Der Nachher-Snapshot wird auch nach Einzelfehlern separat versucht; ein Snapshotfehler wird im Ergebnisreport gesichert.
|
||||
- WMI-Methodenrückgaben werden geprüft.
|
||||
- **Diagnose** meldet neben sichtbaren Send Ports auch die Zahl erfolgreich zugeordneter Anwendungen; eine Differenz erzeugt eine Warnung.
|
||||
- Wartezeiten nutzen konfigurierbare Timeout- und Polling-Werte.
|
||||
- Host Instances auf anderen Servern werden übersprungen und als Warnung protokolliert.
|
||||
- Echte Shutdown-/Restore-Schritte protokollieren WMI-Klasse, Schlüssel, Zielobjekt und Methode, damit Fehler wie WMI-Query- oder Methodenfehler eindeutig zugeordnet werden können.
|
||||
- Fehler protokollieren Typ, HRESULT, vollständige innere Exception-Kette, vorhandenes Fusion-Loaderprotokoll und Stacktrace identisch im Grid, Ergebnisreport und Laufzeitlog.
|
||||
- Restore-Pläne werden abgelehnt, wenn Snapshot-Server und ausgewählter Zielserver nicht übereinstimmen; Kurzname und FQDN desselben Hosts gelten als identisch.
|
||||
- Pro Windows-Sitzung ist nur eine Toolinstanz zulässig; das Fenster kann während einer aktiven WMI-Operation nicht geschlossen werden.
|
||||
- Die EXE enthält zusätzlich einen WMI-freien `--self-test`, den der Installer vor und nach der Aktivierung ausführt.
|
||||
@@ -79,9 +96,12 @@ Die Statusanzeige rechts im Kopfbereich bewertet die Host-Instance-Zustaende des
|
||||
## Shutdown-Reihenfolge
|
||||
|
||||
1. Receive Locations deaktivieren, die im Snapshot aktiviert waren.
|
||||
2. Orchestrations stoppen, die gestartet waren.
|
||||
3. Send Ports stoppen, die gestartet waren.
|
||||
4. Host Instances stoppen, die auf dem ausgewählten Server gestartet waren.
|
||||
2. Operator-Checkpoint: eingehenden Verkehr, Group Hub, laufende Service Instances und Enterprise-Monitoring prüfen; erst nach dem Leerfahren fortsetzen.
|
||||
3. Orchestrations stoppen, die gestartet waren.
|
||||
4. Send Ports stoppen, die gestartet waren.
|
||||
5. Host Instances stoppen, die auf dem ausgewählten Server gestartet waren.
|
||||
|
||||
`Partially Started` auf Anwendungsebene ist während der Drain-Phase erwartbar: deaktivierte Receive Locations bei noch laufenden Orchestrierungen/Send Ports entsprechen dem BizTalk-Modell „Partial Stop - Allow running instances to continue“. Das Tool setzt Anwendungen nicht zusätzlich pauschal auf `Stopped`. Ein Application-Stop ist kein reines Statusflag, sondern führt abhängig von der Auswahl weitere Mutationen bis hin zu Unenlist, Policy-Undeploy oder Instanzterminierung aus. Die artefaktgenaue Steuerung bleibt deshalb die sichere, aus `before.json` reproduzierbare Grenze.
|
||||
|
||||
## Restore-Reihenfolge
|
||||
|
||||
@@ -90,6 +110,23 @@ Die Statusanzeige rechts im Kopfbereich bewertet die Host-Instance-Zustaende des
|
||||
3. Orchestrations wiederherstellen, soweit dies sicher möglich ist.
|
||||
4. Receive Locations zuletzt wiederherstellen.
|
||||
|
||||
Die Kategorienreihenfolge gilt global über alle BizTalk-Anwendungen. Dadurch wird keine Receive Location einer alphabetisch früheren Anwendung aktiviert, bevor Send Ports und Orchestrations späterer Anwendungen behandelt wurden.
|
||||
|
||||
## Emergency Restore
|
||||
|
||||
Der Emergency Restore benötigt nur eine valide `before.json` und denselben Zielserver. Er erzeugt keine neue Vorheraufnahme und überschreibt die Recovery-Quelle nicht.
|
||||
|
||||
1. Timestamp-basierte Kopie der Eingabedatei sichern.
|
||||
2. Enterprise Single Sign-On (`ENTSSO`) auf dem Zielserver auf `Running` bringen.
|
||||
3. Zuvor gestartete Host Instances zustandsbewusst starten.
|
||||
4. Send Ports, Orchestrations und Receive Locations in global sicherer Reihenfolge auf den Snapshotzustand abgleichen.
|
||||
5. Bereits korrekte Zustände als `AlreadySatisfied` überspringen.
|
||||
6. Isolierte WMI-/Adapterfehler als `Failed` erfassen und mit dem nächsten unabhängigen Schritt fortfahren.
|
||||
7. Nachher-Snapshot unabhängig versuchen und vollständigen Ergebnisreport schreiben.
|
||||
8. Bei erfolgreichem Nachher-Snapshot automatisch einen timestamp-basierten Soll/Ist-Diff als JSON, CSV und HTML erzeugen.
|
||||
|
||||
Der Best-effort-Ansatz bedeutet nicht, dass Fehler ignoriert werden: Jeder Teilfehler erzeugt einen roten/fehlgeschlagenen Abschluss und erfordert die Prüfung des Ergebnisreports. Er verhindert lediglich, dass beispielsweise eine einzelne nicht validierbare Receive Location alle späteren Host-, Port- oder Receive-Location-Schritte blockiert.
|
||||
|
||||
## Restore-Grenzen
|
||||
|
||||
- Send Ports werden auf `Started`, `Stopped` oder `Bound` zurückgesetzt.
|
||||
@@ -97,20 +134,40 @@ Die Statusanzeige rechts im Kopfbereich bewertet die Host-Instance-Zustaende des
|
||||
- Orchestrations mit Status `Bound` bleiben unverändert und werden zur manuellen Prüfung markiert, weil ein blindes Unenlist zu `Unbound` führen kann.
|
||||
- Receive Locations werden zuletzt aktiviert, damit eingehender Verkehr erst nach Host Instances und abhängigen Artefakten wieder aufgenommen wird.
|
||||
|
||||
## ScheduledTask-Adapter
|
||||
|
||||
Beim Fremdadapter `Schedule`/ScheduledTask 7.0.2 wird `MSBTS_ReceiveLocation.Enable` beziehungsweise `.Disable` erst ausgeführt, nachdem die für die Transportdatenvalidierung erforderliche `Microsoft.BizTalk.Scheduler.dll` prozesslokal geladen werden konnte. Die Planzeile enthält dafür Adaptername und `scheduler:`-Adresse aus dem Snapshot.
|
||||
|
||||
Der Resolver sucht nur in vorhandenen, vertrauenswürdigen Installationsverzeichnissen und akzeptiert eine DLL erst nach Prüfung der Assemblyidentität. Er berücksichtigt:
|
||||
|
||||
1. `AdapterAssemblySearchPaths` aus der EXE-Konfiguration,
|
||||
2. Installations- und Assemblypfade aus beiden BizTalk-Registryansichten,
|
||||
3. lokale Verzeichnisse `Microsoft BizTalk Server*` und `BizTalk ScheduledTask Adapter*` unter Program Files (x86).
|
||||
|
||||
Die Standardkonfiguration enthält BizTalk Server 2020 und den im PROD-Screenshot bestätigten Pfad `C:\Program Files (x86)\BizTalk ScheduledTask Adapter 7.0.2`. Die Auflösung gilt nur im Toolprozess. Es werden weder GAC noch Adapterdateien verändert. Ist die erforderliche Assembly nicht auffindbar oder nicht zur angeforderten Identität passend, scheitert nur dieser Schritt mit vollständiger Pfad-, Versions- und Loaderdiagnose; der Executor arbeitet die restlichen unabhängigen Schritte weiter ab.
|
||||
|
||||
## Ausgabedateien
|
||||
|
||||
- Snapshots: `before.json`, `after.json`
|
||||
- Operationspläne: `shutdown-plan.json`, `restore-plan.json`
|
||||
- Nachher-Snapshots: `shutdown-after.json`, `restore-after.json`
|
||||
- Ergebnisreports: `shutdown-result.json`, `restore-result.json`
|
||||
- Emergency-Dateien: `emergency-source-before-*`, `emergency-restore-plan-*`, `emergency-restore-result-*`, `emergency-restore-after-*`
|
||||
- Diff: `diff.json`, `diff.csv`, `diff.html`
|
||||
- Snapshot-Reports: `*.csv`, `*.hosts.csv`, `*.html`
|
||||
- Laufzeitlogs: `%ProgramData%\BizTalkPlatformManagementTool\Logs\BizTalkPlatformManagementTool-yyyy-MM-dd.log`
|
||||
- Laufzeitlogs: primär `%ProgramData%\BizTalkPlatformManagementTool\Logs\BizTalkPlatformManagementTool-yyyy-MM-dd.log`, andernfalls der im Grid und über **Log Folder** ausgewiesene verifizierte Fallback; komprimierte Vortage `*.log.gz`
|
||||
- Installerlogs: `%ProgramData%\BizTalkPlatformManagementTool\InstallerLogs\setup-*.log`
|
||||
|
||||
## Fehleranalyse
|
||||
|
||||
`MSBTS_SendPort`, `MSBTS_ReceiveLocation` und `MSBTS_Orchestration` enthalten gemäß BizTalk-WMI-Schema keine verlässliche Application-Property. Die Anwendung liest deshalb zuerst über `MSBTS_GroupSetting` den BizTalk-Managementdatenbankserver und -namen. Danach wird `Microsoft.BizTalk.ExplorerOM.dll` ohne Compile-time-Referenz aus dem GAC oder einem identitätsgeprüften BizTalk-Installationspfad geladen. Der read-only Anwendungskatalog liefert die Hierarchie Application → Send Ports, Receive Ports/Locations und Orchestrations; die eigentlichen Zustände und alle Mutationen bleiben ausschließlich WMI-basiert.
|
||||
|
||||
Kann ExplorerOM nicht geladen werden, fehlen Management-DB-Rechte oder ist ein Name nicht eindeutig, bleibt die Zustandserfassung best-effort verfügbar. Die betroffenen Zeilen stehen dann bewusst unter `(Unknown Application)`. Das Grid und die Laufzeitdatei enthalten die vollständige Lade-/DB-/Reflection-Diagnose; **Diagnose** zeigt eine kleinere Zahl zugeordneter als sichtbarer Send Ports. Ein Dry-run darf erst nach geklärter Zuordnung freigegeben werden.
|
||||
|
||||
Bei echten Shutdown- und Restore-Aktionen wird jeder Schritt vor der Ausführung mit Artefakttyp, WMI-Klasse, Schlüsselproperty, Schlüsselwert und Methodenname protokolliert. Die Objektauflösung verwendet eine breite `SELECT * FROM <class>`-Abfrage und filtert danach im Prozess auf den Schlüsselwert. Dadurch können Host-Instance-Namen und andere BizTalk-Namen mit Sonderzeichen keine ungültige WMI-WQL-`WHERE`-Query mehr erzeugen.
|
||||
|
||||
Bei `scheduler:` erscheinen zusätzlich `ScheduledTask adapter preflight`, alle tatsächlich verwendeten Suchverzeichnisse, Prozessbitness und bei Erfolg die vollständige geladene Assemblyidentität samt Pfad. Ein Ladefehler enthält die anfordernde Assembly, HRESULT, Fusion-Details und Stacktrace. Für eine Supportanalyse sind die Tagesdatei, relevante `.log.gz`, der passende `*-result.json`, Plan, Vorher-/Nachher-Snapshot und die unveränderte EXE-Konfiguration zu sichern.
|
||||
|
||||
Snapshot- und Plan-JSON-Dateien werden als UTF-8 ohne BOM über eine temporäre Datei im Zielverzeichnis und anschließenden atomaren Austausch geschrieben. Beim Laden werden vorhandene Dateien mit UTF-8-BOM oder durch Encoding-Konvertierung sichtbar gewordenem BOM-Marker toleriert. Deserialisierte Snapshots werden normalisiert und auf leere Namen, Duplikate und fehlende Strukturen geprüft.
|
||||
|
||||
Diffs verwenden den zusammengesetzten Schlüssel aus Anwendung und Artefaktname. Gleichnamige Artefakte in verschiedenen BizTalk-Anwendungen überschreiben sich daher nicht mehr. CSV-Werte mit Präfix `=`, `+`, `-`, `@` oder Tab werden mit einem Apostroph neutralisiert, damit Tabellenkalkulationen sie nicht als Formel ausführen.
|
||||
@@ -128,7 +185,7 @@ Die Aktivierung ist transaktional aufgebaut:
|
||||
3. Kopierte Dateien nochmals per SHA-256 und die Staging-EXE per `--self-test` prüfen.
|
||||
4. Laufende Toolinstanz ausschließen.
|
||||
5. Bestehendes Verzeichnis in ein eindeutiges Backup verschieben.
|
||||
6. Staging auf demselben Volume als produktives Verzeichnis aktivieren.
|
||||
6. Staging auf demselben Volume als produktives Verzeichnis aktivieren; kurzzeitige Rename-Sperren werden mit acht begrenzten Versuchen und insgesamt höchstens 19,75 Sekunden Backoff behandelt.
|
||||
7. Aktivierte EXE erneut per `--self-test` prüfen.
|
||||
8. Erst danach Startmenü, optionale Desktop-Verknüpfung und Windows-Uninstall-Eintrag schreiben.
|
||||
9. Windows-Integration durch Rücklesen der Verknüpfungen und der wesentlichen Registrywerte verifizieren.
|
||||
@@ -136,6 +193,10 @@ Die Aktivierung ist transaktional aufgebaut:
|
||||
|
||||
Fehler vor der ersten Mutation werden als **Kein Rollback erforderlich** ausgewiesen. Ein Rollback wird nur als erfolgreich bezeichnet, wenn seine einzelnen Schritte ohne Fehler abgeschlossen wurden; ein verbliebenes Backup ohne aktives Programmverzeichnis verletzt eine zusätzlich geprüfte Invariante und wird als unvollständiger Rollback gemeldet. Bereinigungsprobleme an einem nicht mehr benötigten Backup oder Deinstallations-Quarantäneverzeichnis werden als erfolgreiche Operation mit Warnung protokolliert und zerstören die wiederherstellbaren Dateien nicht blind.
|
||||
|
||||
Wenn ausschließlich die atomare Staging-Umbenennung dauerhaft gesperrt bleibt, ist ein eng begrenzter Kopierfallback zulässig: Bei einer Neuinstallation muss das Ziel fehlen; bei einem Update muss die vollständige Vorversion bereits atomar ins Backup verschoben worden sein und das aktive Ziel fehlen. Jede Zieldatei wird erneut anhand des Manifests per SHA-256 geprüft, und der zweite Self-Test läuft weiterhin aus dem endgültigen Ziel. Der Fallback ist nie ein In-place-Update. Ein Teilfehler entfernt die Zielkopie und stellt beim Update das Backup wieder her. Jeder Retry, der Geltungsbereich und die verwendete Aktivierungsmethode stehen im Setup-Log.
|
||||
|
||||
Die Windows-Integration besitzt ab Version 2.2.4 eine explizite Kritikalitätsgrenze. Startmenü-Link, Uninstaller und Registry sind für einen wartbaren Maschinenzustand verpflichtend und bleiben Teil der Transaktion. Der gemeinsame Desktop-Link ist dagegen eine standardmäßig abgewählte Komfortfunktion. Sämtliche Zugriffe darauf – Eingangssnapshot, Erstellen/Entfernen, Rücklesevalidierung, Rollback und Uninstall – laufen innerhalb einer ausfallsicheren optionalen Exception-Grenze. Ein Fehler erzeugt UI- und Logwarnung sowie einen erfolgreichen Abschluss mit Warnstatus, aber keinen Anwendungsrollback. Auch eine fehlerhafte GUI-Warnungsweiterleitung ist isoliert.
|
||||
|
||||
Das dauerhafte Setup-Log enthält pro Lauf einen Kontextkopf mit Version, Betriebssystem, 32-/64-Bit-Kontext, CLR, Rechner, Identität und Elevation. Hinzu kommen Pfade, freier Speicher, Dateiversion/-größe/-SHA-256, vollständige Self-Test-Ausgaben mit Exitcode, Exception-Ketten mit HRESULT und Stacktrace sowie jeder Rollbackschritt. Stabile `SETUP-*`- und `UNINSTALL-*`-Fehlercodes ermöglichen die Zuordnung unabhängig vom lokalisierten Meldungstext. Die Aufbewahrung beträgt 90 Tage. Wenn ProgramData für die Diagnose nicht verfügbar ist, wird ein Temp-Fallback verwendet und sichtbar gemeldet; die Schaltfläche **Diagnoselogs öffnen** öffnet den regulären Ablageort.
|
||||
|
||||
Der Self-Test ist eine technische Installationsabnahme ohne BizTalk-WMI. Ein fachlicher Umgebungszustand wie fehlender WMI-Zugriff oder `Unknown` führt deshalb nicht zum Installer-Rollback. Nach erfolgreicher Installation bleiben **Diagnose** und ein Dry-run gegen das Zielsystem verpflichtende Abnahmeschritte.
|
||||
@@ -148,17 +209,29 @@ Das äußere ZIP erhält zusätzlich eine SHA-256-Datei und eine Certutil-kompat
|
||||
|
||||
- Atomare JSON-Aktualisierung und BOM-Kompatibilität.
|
||||
- Anwendungsbezogene Diff-Identität bei gleichnamigen Artefakten.
|
||||
- ExplorerOM-basierte Artefaktzuordnung einschließlich Receive-Port-Fallback und Ambiguitätsschutz.
|
||||
- Restore-Servergrenze und sichere Restore-Reihenfolge.
|
||||
- Neutralisierung formelartiger CSV-Werte.
|
||||
- Erkennung manipulierter Payload-Dateien.
|
||||
- Ablehnung nicht deklarierter Dateien und aus dem Payload-Verzeichnis ausbrechender Manifestpfade.
|
||||
- Staging-Fehler ohne Mutation einer bestehenden Installation.
|
||||
- Erfolgreiche Staging-Aktivierung.
|
||||
- Erholung nach einer vorübergehenden Rename-Sperre mit korrektem Backoff und Diagnoseereignissen.
|
||||
- Verifizierter Kopierfallback einer dauerhaft move-gesperrten Neuinstallation und eines bereits atomar gesicherten Updates.
|
||||
- Vollständiger Update-Rollback, wenn der Ziel-Self-Test nach dem Kopierfallback fehlschlägt.
|
||||
- Nichtfataler gemeinsamer Desktop-Link bei simuliertem ACL-Fehler, Zustandsabweichung und ausfallender Warnungsweiterleitung.
|
||||
- Begrenzter Abbruch eines dauerhaft move-gesperrten Updates ohne Veränderung der Vorversion.
|
||||
- Wiederherstellung der Vorversion, wenn der Self-Test nach Aktivierung fehlschlägt.
|
||||
- Deinstallation durch atomare Umbenennung des Programmverzeichnisses vor der bestmöglichen Bereinigung.
|
||||
- Eindeutige Fehlerphase ohne irreführende Rollbackmeldung bei einem Staging-Fehler.
|
||||
- Vollständiger Diagnosekontext mit Exception-Kette und Temp-Fallback für das Setup-Log.
|
||||
- Unabhängigkeit der Installation von Fehlern der UI-Fortschrittsanzeige.
|
||||
- Fortsetzung nach einer simulierten `Microsoft.BizTalk.Scheduler`-Exception.
|
||||
- Idempotentes Überspringen bereits erreichter Sollzustände.
|
||||
- `ENTSSO` als erster Emergency-Restore-Schritt.
|
||||
- Globale Kategorie-Reihenfolge über mehrere BizTalk-Anwendungen.
|
||||
- Kurzname/FQDN-Gleichheit für Host-Instance-Schritte.
|
||||
- Persistenz vollständiger Teilfehlerreports.
|
||||
|
||||
Der portable Build, die Tests, der Anwendungsselftest und die Paketkonsistenz sind lokal unter Mono prüfbar. Die endgültige Freigabe erfordert zusätzlich einen Windows-Test von UAC, Registry, Verknüpfungen und Setup-Rollback sowie einen repräsentativen BizTalk-2020-Test von Diagnose, Dry-run, Shutdown und Restore.
|
||||
|
||||
|
||||
+71
-4
@@ -15,6 +15,8 @@ Das Release erzeugt folgende Dateien unter `artifacts`:
|
||||
- `BizTalkPlatformManagementTool-Setup.zip.b64.txt`: Certutil-kompatible Base64-Übertragung
|
||||
- `BizTalkPlatformManagementTool-Setup.zip.sha256.txt`: SHA-256 des ZIP-Archivs
|
||||
- `BizTalkPlatformManagementTool-Setup.zip`: direkt entpackbares Installationspaket
|
||||
- `BizTalkPlatformManagementTool-2.3.4-source.zip.b64.txt`: vollständiger Quellstand als Base64-TXT
|
||||
- `BizTalkPlatformManagementTool-2.3.4-source.zip.sha256.txt`: SHA-256 des Quellarchivs
|
||||
|
||||
Auf dem Zielsystem wird die TXT-Datei so rekonstruiert und geprüft:
|
||||
|
||||
@@ -30,7 +32,7 @@ Der Hash aus `certutil` muss exakt dem Wert in der SHA-256-Datei entsprechen. Da
|
||||
|
||||
1. ZIP vollständig entpacken; `Setup.exe`, `application.manifest` und der Ordner `application` müssen nebeneinander liegen.
|
||||
2. `Setup.exe` starten und die UAC-Abfrage bestätigen.
|
||||
3. Optional die Desktop-Verknüpfung abwählen.
|
||||
3. Die standardmäßig abgewählte, optionale Desktop-Verknüpfung nur bei Bedarf für alle Benutzer aktivieren.
|
||||
4. **Installieren** wählen.
|
||||
5. Den Abschluss und den Pfad des Diagnoselogs prüfen.
|
||||
6. Die Anwendung starten, **Dry run** aktiviert lassen und zuerst **Diagnose** ausführen.
|
||||
@@ -38,11 +40,44 @@ Der Hash aus `certutil` muss exakt dem Wert in der SHA-256-Datei entsprechen. Da
|
||||
Installationsziele:
|
||||
|
||||
- Programm: `%ProgramFiles%\BizTalkPlatformManagementTool`
|
||||
- Laufzeitlogs: `%ProgramData%\BizTalkPlatformManagementTool\Logs`
|
||||
- Laufzeitlogs primär: `%ProgramData%\BizTalkPlatformManagementTool\Logs`
|
||||
- Installerlogs: `%ProgramData%\BizTalkPlatformManagementTool\InstallerLogs`
|
||||
- Uninstaller: `%ProgramData%\BizTalkPlatformManagementTool\Setup\Uninstall.exe`
|
||||
- Startmenü: `BizTalk Platform Management Tool`
|
||||
|
||||
## Laufzeitlog-Ablage prüfen
|
||||
|
||||
Der normale Laufzeitlogordner liegt nicht im Programmverzeichnis. `%ProgramData%` entspricht üblicherweise `C:\ProgramData` und ist im Explorer standardmäßig ausgeblendet. Dass unter `C:\Program Files\BizTalkPlatformManagementTool` nur EXE, Konfiguration und Installationsstatus sichtbar sind, ist daher allein noch kein Logfehler.
|
||||
|
||||
Ab Version 2.3.1 akzeptiert die Anwendung einen Ablageort erst nach einem echten Create/Write/Flush/Delete-Test. Sie prüft in dieser Reihenfolge:
|
||||
|
||||
1. `%ProgramData%\BizTalkPlatformManagementTool\Logs`
|
||||
2. `%LocalAppData%\BizTalkPlatformManagementTool\Logs`
|
||||
3. `%ProgramFiles%\BizTalkPlatformManagementTool\Logs`
|
||||
4. `%TEMP%\BizTalkPlatformManagementTool\Logs`
|
||||
|
||||
Danach wird bei jedem Programmstart die Zeile `Runtime log storage verified by startup append. Active file: ...` wirklich in die Tagesdatei geschrieben und im Grid angezeigt. **Log Folder** öffnet genau den aktiven Pfad. Bei einem Fallback nennt eine gelbe Grid-Warnung den verworfenen Pfad samt Exception. Kann kein Kandidat beschrieben werden, erscheint `RUNTIME FILE LOGGING UNAVAILABLE`; vor einer echten Wartungsoperation müssen dann Berechtigungen, Datenträger oder Sicherheitssoftware geklärt werden.
|
||||
|
||||
Der WMI-freie Installer-Self-Test schreibt und liest zusätzlich einen eigenen temporären Runtime-Logmarker. Damit wird eine Version, deren Logger grundsätzlich keine Datei erzeugen kann, bereits vor der Aktivierung abgelehnt. Die PROD-Abnahme des realen Maschinenpfads bleibt nach dem Update erforderlich.
|
||||
|
||||
## Anwendungszuordnung ab 2.3.3
|
||||
|
||||
Die Runtime-WMI-Klassen für Send Ports, Receive Locations und Orchestrierungen liefern keine verlässliche BizTalk-Anwendungszuordnung. Version 2.3.3 liest deshalb `MgmtDbServerName` und `MgmtDbName` aus `MSBTS_GroupSetting` und verwendet die lokal installierte `Microsoft.BizTalk.ExplorerOM.dll` ausschließlich read-only zum Aufbau der Application-/Artefakthierarchie. Zustandsabfrage sowie Shutdown-/Restore-Mutationen bleiben WMI-basiert.
|
||||
|
||||
Es wird keine BizTalk-DLL mit dem Paket ausgeliefert. Die Microsoft-Assembly wird aus dem GAC oder aus einem vorhandenen, identitätsgeprüften BizTalk-Installationspfad geladen. Das ausführende Konto benötigt neben WMI-Zugriff Leserechte auf den BizTalk-Anwendungskatalog in der Management-Datenbank. Nach dem Update muss **Diagnose** für PROD dieselbe Zahl bei `Send ports visible` und `application associations resolved` melden. Andernfalls zeigt das Log den Lade-, Berechtigungs- oder Zuordnungsfehler; ein realer Lauf darf erst nach Klärung freigegeben werden.
|
||||
|
||||
## Shutdown-Drain-Checkpoint ab 2.3.2
|
||||
|
||||
Ein echter Shutdown pausiert nach allen Receive Locations und vor Orchestrierungen, Send Ports und Host Instances. Der Dialog zeigt erfolgreiche, bereits deaktivierte und fehlgeschlagene Receive Locations. Er darf geöffnet bleiben, während Group Hub, laufende Service Instances, MessageBox-/Queue-Metriken und das Enterprise-Monitoring geprüft werden.
|
||||
|
||||
- **Yes** protokolliert `CheckpointDecision=Continue` und setzt den gespeicherten Plan fort.
|
||||
- **No** beendet den Lauf sicher; alle späteren Zeilen werden als `NotExecuted` gespeichert.
|
||||
- Ein fehlender oder fehlerhafter Dialog stoppt ebenfalls fail-closed und wird als Fehler protokolliert.
|
||||
- Dry-run zeigt den Checkpoint im Plan/Grid, fordert aber keine echte Entscheidung an.
|
||||
- Nach einem Stopp werden `shutdown-after.json` und `shutdown-result.json` soweit möglich trotzdem geschrieben.
|
||||
|
||||
Der Dialog behauptet nicht automatisch, die Umgebung sei leer. Diese fachliche Entscheidung bleibt bewusst beim Operator und den vorhandenen Enterprise-Monitoringquellen. `Partially Started` in der BizTalk-Konsole ist direkt nach dem Abschalten der Receive Locations erwartbar. Es wird kein pauschaler Application-Stop ergänzt, da dieser je nach Modus weitere Artefaktzustände, Subscriptions, Policies oder laufende Instanzen verändert.
|
||||
|
||||
## Update und Rollback
|
||||
|
||||
Der Installer verändert eine bestehende Installation erst nach erfolgreicher Paketprüfung:
|
||||
@@ -51,11 +86,21 @@ Der Installer verändert eine bestehende Installation erst nach erfolgreicher Pa
|
||||
2. Die neue Version wird in ein eindeutiges Staging-Verzeichnis kopiert und dort mit `--self-test` geprüft.
|
||||
3. Eine laufende Toolinstanz blockiert das Update.
|
||||
4. Die bestehende Installation wird in ein Backup-Verzeichnis verschoben.
|
||||
5. Das validierte Staging wird auf demselben Volume aktiviert.
|
||||
5. Das validierte Staging wird auf demselben Volume aktiviert. Atomare Verzeichnisverschiebungen werden bei `IOException` oder `UnauthorizedAccessException` mit begrenztem Backoff bis zu achtmal versucht (insgesamt höchstens 19,75 Sekunden Wartezeit).
|
||||
6. Die aktivierte EXE führt den Self-Test erneut aus.
|
||||
7. Erst danach werden Verknüpfungen und Windows-Uninstall-Eintrag aktualisiert.
|
||||
|
||||
Schlägt ein Schritt nach Beginn der Umschaltung fehl, entfernt das Setup die neue Version und stellt das Backup wieder her. Tritt der Fehler bereits bei Paketprüfung oder Staging auf, meldet das Setup ausdrücklich **Kein Rollback erforderlich**, weil die aktive Installation unverändert blieb. Staging und Backup werden anschließend bestmöglich bereinigt. Kann ein nicht mehr benötigtes Backup wegen einer Dateisperre nicht gelöscht werden, bleibt die erfolgreiche Installation aktiv und das Log kennzeichnet den Abschluss als `success_with_backup_cleanup_warning`.
|
||||
Kann ausschließlich die Umbenennung des geprüften Staging-Verzeichnisses dauerhaft nicht ausgeführt werden, darf der Installer nach vollständig ausgeschöpften Move-Versuchen auf eine verifizierte Kopie zurückfallen. Dabei wird jede Datei aus dem Staging nochmals gegen ihren Manifest-SHA-256 geprüft; anschließend läuft auch der zweite Self-Test aus dem endgültigen Ziel. Bei einer Neuinstallation muss das Ziel noch fehlen. Bei einem Update ist der Fallback erst zulässig, nachdem die vollständige Vorversion atomar ins Backup verschoben wurde und das Ziel ebenfalls nicht mehr existiert. Er ist damit kein In-place-Update und überschreibt keine aktive Version.
|
||||
|
||||
Scheitern Kopie, Hashprüfung oder Ziel-Self-Test, entfernt das Setup das teilweise neue Ziel und stellt beim Update das zuvor atomar erzeugte Backup wieder her. Kann bereits die Vorversion nicht atomar ins Backup verschoben werden, bleibt sie unverändert aktiv und das Update bricht ohne Kopierfallback ab.
|
||||
|
||||
Schlägt ein Schritt nach Beginn der Umschaltung fehl, entfernt das Setup die neue Version und stellt das Backup wieder her. Tritt der Fehler bereits bei Paketprüfung oder Staging auf, meldet das Setup ausdrücklich **Kein Rollback erforderlich**, weil die aktive Installation unverändert blieb. Staging und Backup werden anschließend bestmöglich bereinigt. Kann ein nicht mehr benötigtes temporäres Verzeichnis wegen einer Dateisperre nicht gelöscht werden, bleibt die erfolgreiche Installation aktiv und das Log kennzeichnet den Abschluss als `success_with_temporary_cleanup_warning`.
|
||||
|
||||
### Optionale Desktop-Verknüpfung für alle Benutzer
|
||||
|
||||
Der gemeinsame Desktop-Link unter `%PUBLIC%\Desktop` ist eine Komfortfunktion und ab Version 2.2.4 standardmäßig abgewählt. Fehlende Rechte, eine WSH-/COM-Sperre, eine abweichende Linkvalidierung oder ein Fehler beim Sichern, Entfernen beziehungsweise Wiederherstellen dieses optionalen Links dürfen Installation, Update, Rollback und Deinstallation nicht abbrechen. Das Setup zeigt eine Warnung, schreibt die vollständige Exception ins Diagnoselog und setzt die Kernoperation fort.
|
||||
|
||||
Startmenü-Link, Uninstaller unter ProgramData und Uninstall-Registry bleiben verpflichtende Windows-Integration. Scheitert einer dieser Bestandteile, wird die Installation weiterhin als fehlgeschlagen behandelt und die vorherige Version vollständig wiederhergestellt. Der Installer verändert keine ACLs und umgeht keine Sicherheitsrichtlinie; bei einem Desktop-Link-Fehler bleibt der Link lediglich im tatsächlich erreichbaren Zustand.
|
||||
|
||||
## Installer-Diagnose
|
||||
|
||||
@@ -75,6 +120,10 @@ Die Abschlussmeldung enthält einen stabilen Fehlercode und die betroffene Phase
|
||||
|
||||
Das Log enthält Betriebssystem, Prozess-/OS-Bitness, .NET-Version, Rechner, Windows-Identität und Elevation sowie Installationspfade, freien Speicher, Dateigrößen, Versionen und SHA-256. Für Self-Tests werden Laufzeit, Exitcode dezimal und hexadezimal sowie vollständiges `stdout` und `stderr` geschrieben. Bei Fehlern folgen Exception-Kette, HRESULT und Stacktrace; jeder Rollbackschritt und sein Ergebnis werden separat protokolliert. Passwörter oder Verbindungsdaten werden vom Installer nicht verarbeitet oder geloggt.
|
||||
|
||||
Bei einer gesperrten Verzeichnisverschiebung erscheinen `event=directory_move_retry` und nach einer Erholung `event=directory_move_recovered`. Ein Kopierfallback protokolliert `event=activation_fallback_started`, `event=activation_fallback_complete`, den Geltungsbereich `scope=new_install` oder `scope=update_after_backup` und im Abschluss `activation_method=verified_copy_fallback`. Kann bei einem Update bereits das Backup nicht erzeugt werden, endet es weiterhin mit `SETUP-ACTIVATION`, bevor die aktive Version verändert wurde.
|
||||
|
||||
Ein Fehler des gemeinsamen Desktop-Links erscheint als `event=optional_windows_integration_warning` mit einer Rolle wie `desktop_shortcut_snapshot`, `desktop_shortcut_create`, `desktop_shortcut_remove`, `desktop_shortcut_validate`, `desktop_shortcut_rollback_restore` oder `desktop_shortcut_uninstall_remove`. Der erfolgreiche Gesamtabschluss enthält dann `optional_desktop_shortcut_warning=True` und beispielsweise `result=success_with_optional_desktop_shortcut_warning`; er ist kein Rollback und kein fehlgeschlagenes Setup.
|
||||
|
||||
Für eine Supportanalyse bitte sichern:
|
||||
|
||||
1. Vollständige Fehlermeldung einschließlich Fehlercode und Phase.
|
||||
@@ -83,6 +132,24 @@ Für eine Supportanalyse bitte sichern:
|
||||
|
||||
Ein erfolgreicher Installer-Self-Test bestätigt Paket, Programmstart und lokale Kernfunktionen. Der fachliche BizTalk-Zustand ist bewusst kein Rollbackkriterium: WMI-Erreichbarkeit, Berechtigungen und Umgebungszustand danach separat über **Diagnose** und einen Dry-run prüfen. So wird beispielsweise ein erreichbarer Installer nicht wegen eines fachlichen `Unknown`-Zustands zurückgerollt.
|
||||
|
||||
## Emergency Restore nach einem Teilabbruch
|
||||
|
||||
Version 2.3.1 kann einen Wiederanlauf allein aus einer erhaltenen `before.json` vorbereiten und ausführen. Eine mit Version 2.1.3 erzeugte Datei ist kompatibel; zusätzliche Plan- oder Nachher-Dateien des fehlgeschlagenen Laufs sind nicht erforderlich. Auch ein Fehler der GUI-Logweiterleitung ist vom fachlichen Executor isoliert und kann die späteren Planschritte nicht abbrechen.
|
||||
|
||||
Für ScheduledTask-Receive-Locations enthält die installierte EXE-Konfiguration `AdapterAssemblySearchPaths`. Normalerweise ist keine Anpassung nötig: BizTalk- und ScheduledTask-Installationsverzeichnisse werden zusätzlich automatisch erkannt. Nur bei einem abweichenden lokalen Installationspfad darf der vorhandene Wert um diesen Pfad ergänzt werden. Die Assembly muss aus genau dieser BizTalk-/Adapterinstallation stammen; das Tool verändert den GAC nicht.
|
||||
|
||||
1. Die erhaltene `before.json` außerhalb des Arbeitsverzeichnisses zusätzlich sichern.
|
||||
2. Anwendung als Administrator starten und denselben Zielserver wählen, der im Snapshot gespeichert ist.
|
||||
3. Über **State...** die erhaltene Datei auswählen oder im Feld **State** ihren vollständigen Pfad eintragen.
|
||||
4. **Validate State** ausführen. Diese Prüfung öffnet keine WMI-Verbindung und verändert keinen Laufzeitzustand.
|
||||
5. **Dry run** aktiviert lassen und **Emergency Restore** wählen.
|
||||
6. Den timestamp-basierten `emergency-restore-plan-*` prüfen. Die bestehende `before.json` wird dabei nicht überschrieben.
|
||||
7. Dry run deaktivieren, **Emergency Restore** erneut wählen und den expliziten Dialog bestätigen.
|
||||
|
||||
Der Emergency Restore stellt zuerst sicher, dass der Windows-Dienst `ENTSSO` läuft. Danach folgen Host Instances, Send Ports, Orchestrations und zuletzt Receive Locations. Vor jeder Mutation wird der aktuelle Zustand geprüft; bereits korrekte Zustände werden als `AlreadySatisfied` protokolliert. Ein isolierter Fehler wird als `Failed` festgehalten, während alle späteren unabhängigen Schritte weiter versucht werden.
|
||||
|
||||
Jeder Lauf schreibt eine unveränderte Snapshot-Kopie sowie timestamp-basierte Plan- und Ergebnisdateien. Der echte Lauf versucht zusätzlich Nachher-Snapshot und `emergency-restore-diff-*` als JSON, CSV und HTML. Ein Ergebnis mit mindestens einem fehlgeschlagenen Schritt bleibt im GUI ausdrücklich `Failed` und verlangt Operator-Review, auch wenn alle anderen Schritte erfolgreich waren.
|
||||
|
||||
## Deinstallation
|
||||
|
||||
Die Deinstallation ist über **Apps & Features / Programme und Features** oder über den Setup-Button **Deinstallieren** möglich. Vorher muss die Anwendung geschlossen sein. Das Programmverzeichnis wird zuerst atomar aus dem aktiven Pfad in ein eindeutiges Quarantäneverzeichnis verschoben; erst danach werden Verknüpfungen und Uninstall-Eintrag entfernt und die Dateien bestmöglich gelöscht. Scheitert die Windows-Integration, werden Programmverzeichnis, Registrywerte, Verknüpfungen und vorheriger Uninstaller wiederhergestellt. Installerlogs und der supportfähige Setup-Ordner bleiben bewusst zur Fehleranalyse unter `%ProgramData%\BizTalkPlatformManagementTool` erhalten.
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
PROD-HANDOFF: APPLICATION-ZUORDNUNG - VERSION 2.3.3
|
||||
Stand: 2026-08-27
|
||||
|
||||
FEHLER
|
||||
Version 2.3.2 zeigte Send Ports, Receive Locations und Orchestrierungen unter
|
||||
"(Unknown Application)". Die Objekte und Zustaende kamen korrekt aus WMI,
|
||||
aber die erwarteten Application-Properties existieren in diesen Runtime-WMI-
|
||||
Klassen nicht.
|
||||
|
||||
FIX
|
||||
Version 2.3.3 liest MgmtDbServerName/MgmtDbName aus MSBTS_GroupSetting und
|
||||
baut ueber die lokal installierte, read-only verwendete ExplorerOM-Hierarchie
|
||||
einen Application-/Artefaktindex. WMI bleibt alleinige Quelle fuer Zustaende
|
||||
und Mutationen. Es wird keine BizTalk-DLL mitgeliefert oder in den GAC kopiert.
|
||||
|
||||
PROD-ABNAHME
|
||||
1. Setup 2.3.3 installieren; setup_version=2.3.3.0 und Ziel-Self-Test pruefen.
|
||||
2. Tool als Administrator starten; PROD-Ziel und aktiviertes Dry run pruefen.
|
||||
3. Diagnose ausfuehren. Erwartet:
|
||||
Send ports visible: N; application associations resolved: N.
|
||||
Beide Zahlen muessen identisch sein.
|
||||
4. Im Runtime-Log "BizTalk application catalog loaded through ExplorerOM"
|
||||
und plausible Application-/Artefaktzaehler pruefen.
|
||||
5. Snapshot Before erzeugen. Keine Unknown-Application-Gruppe fuer regulaere
|
||||
katalogisierte Artefakte; mehrere Ports, Receive Locations und
|
||||
Orchestrierungen gegen die BizTalk Administration Console abgleichen.
|
||||
6. Shutdown nur als Dry-run ausfuehren. Echte Application-Namen und korrekte
|
||||
globale Reihenfolge in Grid und shutdown-plan.json pruefen.
|
||||
7. Erst danach einen echten Wartungslauf freigeben.
|
||||
|
||||
STOPPKRITERIUM
|
||||
Sind sichtbare und zugeordnete Send-Port-Zahl verschieden oder bleibt Unknown
|
||||
Application sichtbar, keinen echten Shutdown starten. Tageslog, Diagnose-
|
||||
Screenshot, before.json, shutdown-plan.json, Setup-Log, Prozessidentitaet und
|
||||
vollstaendige Exceptiondiagnose sichern. ExplorerOM-Installation, Management-
|
||||
DB-Erreichbarkeit und Leserechte pruefen.
|
||||
|
||||
LOKALE VERIFIKATION
|
||||
Release-Rebuild erfolgreich; 41 Regressionstests erfolgreich; WMI-freier
|
||||
Self-Test erfolgreich; Paket/Base64/SHA-256 ueber die Release-Chain geprueft.
|
||||
|
||||
DETAILS
|
||||
docs\PROD-Application-Zuordnung-2026-08-27.md
|
||||
@@ -0,0 +1,38 @@
|
||||
PROD-RUNBOOK: LAUFZEITLOG-ABLAGE - VERSION 2.3.1
|
||||
Stand: 2026-08-26
|
||||
|
||||
EINORDNUNG
|
||||
Der Installationsordner C:\Program Files\BizTalkPlatformManagementTool ist nicht
|
||||
der primaere Logordner. Dieser liegt unter
|
||||
%ProgramData%\BizTalkPlatformManagementTool\Logs. ProgramData ist im Explorer
|
||||
normalerweise ausgeblendet. Im Program-Files-Ordner wird daher im Normalfall
|
||||
kein Log erwartet.
|
||||
|
||||
FIX IN 2.3.1
|
||||
- Echter Create/Write/Flush/Delete-Test vor Auswahl eines Logpfads.
|
||||
- Reihenfolge: ProgramData, LocalAppData, EXE-Unterordner Logs, Temp.
|
||||
- Append-Fehler: derselbe Datensatz wird im naechsten Kandidaten wiederholt.
|
||||
- Fallback/Totalausfall erscheinen mit Pfad und Exception im Grid.
|
||||
- Jeder GUI-Start schreibt einen Startup-Verifikationseintrag in Datei und Grid.
|
||||
- Der Installer-Self-Test prueft einen temporaeren Write/Read-Roundtrip.
|
||||
- 30 Kalendertage, abgeschlossene Tage GZip, maximal 10.000 Grid-Eintraege.
|
||||
|
||||
PROD-ABNAHME
|
||||
1. Setup 2.3.1 als Administrator installieren/aktualisieren.
|
||||
2. Erfolgreichen Ziel-Self-Test im Setup-Log pruefen.
|
||||
3. Tool starten, noch keine reale BizTalk-Operation ausfuehren.
|
||||
4. Gruenen Eintrag "Runtime log storage verified by startup append" pruefen.
|
||||
5. Gelbe Fallbackwarnung bzw. RUNTIME FILE LOGGING UNAVAILABLE ausschliessen.
|
||||
6. Log Folder oeffnen. Genannte Tagesdatei muss existieren und den Eintrag
|
||||
dieses Starts enthalten.
|
||||
7. Diagnose ausfuehren, Tool schliessen und neu starten.
|
||||
8. Diagnosehistorie muss im Grid und in der Tagesdatei vorhanden sein.
|
||||
9. Erst danach ScheduledTask zuerst als Dry-run und nach Planreview real testen.
|
||||
|
||||
BEI TOTALAUSFALL
|
||||
Keine reale Wartungsoperation beginnen. Vollstaendigen Grid-Eintrag, Benutzer,
|
||||
freien Speicher, Endpoint-Security-Ereignisse und ACLs der vier Kandidaten
|
||||
sichern. ACLs nicht eigenmaechtig aufweiten.
|
||||
|
||||
DETAILFASSUNG
|
||||
docs\PROD-Laufzeitlog-Ablage-2026-08-26.md
|
||||
@@ -0,0 +1,80 @@
|
||||
PROD-RUNBOOK: SCHEDULEDTASK-STEUERUNG UND PERSISTENTES LAUFZEITLOGGING
|
||||
Stand: 2026-08-26
|
||||
Zielversion: 2.3.4
|
||||
Adapter: BizTalk ScheduledTask Adapter 7.0.2
|
||||
Adapterpfad: C:\Program Files (x86)\BizTalk ScheduledTask Adapter 7.0.2
|
||||
|
||||
URSACHE
|
||||
MSBTS_ReceiveLocation.Enable/Disable validiert die Transportdaten. Der Adapter
|
||||
benoetigt dabei Microsoft.BizTalk.Scheduler.dll (beobachtet: Version 3.13.0.0).
|
||||
Die Datei liegt in der BizTalk-Installation, ist aber nicht zwingend im GAC
|
||||
aufloesbar. Version 2.3.1 laedt sie nach Assemblyidentitaetspruefung nur in den
|
||||
laufenden Toolprozess. Das Tool kopiert keine DLL und aendert den GAC nicht.
|
||||
|
||||
VORBEREITUNG
|
||||
1. before.json, Reports und vorhandene Logs extern sichern.
|
||||
2. Setup 2.3.4 als Administrator installieren/aktualisieren.
|
||||
3. setup_version=2.3.4.0 und erfolgreichen Ziel-Self-Test pruefen.
|
||||
4. Tool als Administrator starten, gruenen Startup-Log-Pruefeintrag kontrollieren,
|
||||
dann Log Folder oeffnen. Normalfall: %ProgramData%\BizTalkPlatformManagementTool\Logs.
|
||||
5. Im lokalen BizTalk-Ordner Microsoft.BizTalk.Scheduler.dll pruefen.
|
||||
6. Nur bei Sonderpfad AdapterAssemblySearchPaths in der EXE.config erweitern.
|
||||
Mehrere Pfade mit Semikolon trennen. Keine fremde/alte DLL kopieren.
|
||||
|
||||
FUNKTIONSTEST
|
||||
1. Diagnose.
|
||||
2. Snapshot Before; Scheduler-Receive-Location und scheduler:-URI pruefen.
|
||||
3. Shutdown zuerst mit Dry run; shutdown-plan.json reviewen.
|
||||
4. Dry run deaktivieren, Shutdown bestaetigen.
|
||||
5. Erwartete Logzeilen:
|
||||
ScheduledTask adapter preflight
|
||||
ProcessBitness=...; SearchDirectories=...
|
||||
ScheduledTask dependency loaded process-locally / resolved through CLR/GAC
|
||||
(oder already loaded)
|
||||
Calling MSBTS_ReceiveLocation.Disable
|
||||
Reached: Disable receive location completed
|
||||
6. shutdown-result.json: Succeeded oder AlreadySatisfied.
|
||||
7. Drain-Checkpoint: Group Hub/Monitoring leer laufen lassen, dann Yes.
|
||||
8. Restore zuerst Dry run, dann real.
|
||||
9. Calling MSBTS_ReceiveLocation.Enable und Reached pruefen.
|
||||
10. Snapshot After und Compare; Sollzustand muss wiederhergestellt sein.
|
||||
|
||||
LOGGING-TEST
|
||||
1. Lauf mit erkennbarer Uhrzeit erzeugen, Tool schliessen und neu starten.
|
||||
2. Vorherige Eintraege muessen mit Datum/Uhrzeit wieder im Grid stehen.
|
||||
3. Clear leert nur das Grid; Neustart laedt die Historie erneut.
|
||||
4. Aktueller Tag: BizTalkPlatformManagementTool-yyyy-MM-dd.log
|
||||
5. Abgeschlossene Vortage: .log.gz
|
||||
6. Aufbewahrung: aktueller Tag plus 29 Vortage.
|
||||
7. Grid: neueste maximal 10.000 Eintraege; Dateien bleiben vollstaendig.
|
||||
|
||||
HINWEIS ZUM PFAD
|
||||
ProgramData ist nicht Program Files und im Explorer normalerweise ausgeblendet.
|
||||
Unter Program Files ist im Normalfall kein Log sichtbar. Die Reihenfolge lautet:
|
||||
ProgramData, LocalAppData, EXE-Unterordner Logs, Temp. Fallback oder Totalausfall
|
||||
muss ab 2.3.1 mit Pfad und Exception im Grid erscheinen. Die Tagesdatei muss den
|
||||
bei jedem Start geschriebenen Verifikationseintrag enthalten.
|
||||
|
||||
FEHLERFALL SICHERN
|
||||
1. Aktuelle .log und relevante .log.gz aus Log Folder.
|
||||
2. shutdown-plan.json oder restore-plan.json.
|
||||
3. Passenden *-result.json-Report.
|
||||
4. before.json und vorhandenen Nachher-Snapshot.
|
||||
5. Unveraenderte BizTalkPlatformManagementTool.exe.config.
|
||||
6. Screenshot des vollstaendigen roten Grid-Eintrags.
|
||||
7. Dateiversion von Microsoft.BizTalk.Scheduler.dll.
|
||||
|
||||
Fehler enthalten Typ, HRESULT, innere Ausnahmen, Fusion-Informationen,
|
||||
Stacktrace, angeforderte/anfragende Assembly und alle Suchpfade. GAC oder DLLs
|
||||
im Fehlerfall nicht spontan veraendern; zuerst dieses Supportpaket auswerten.
|
||||
|
||||
ABNAHME
|
||||
- Scheduler-Receive-Location real deaktiviert und wieder aktiviert.
|
||||
- Normale Adapter ohne Scheduler-Preflight weiterhin funktionsfaehig.
|
||||
- Teilfehler bleibt Failed, spaetere unabhaengige Schritte laufen weiter.
|
||||
- Historie erscheint nach Neustart im Grid.
|
||||
- Vortage komprimiert, 30 Kalendertage aufbewahrt.
|
||||
- Setup/Tool/Reports zeigen 2.3.4 bzw. 2.3.4-net461.
|
||||
|
||||
Detailfassung:
|
||||
docs\PROD-ScheduledTask-und-Laufzeitlogging-2026-08-26.md
|
||||
@@ -0,0 +1,55 @@
|
||||
PROD-HANDOFF: SHUTDOWN-DIALOG-SICHTBARKEIT - VERSION 2.3.4
|
||||
Datum: 2026-08-27
|
||||
|
||||
BEFUND
|
||||
Nach der Receive-Location-Phase wurde kein sichtbarer Dialog zur Bestaetigung
|
||||
des Leerlaufens wahrgenommen.
|
||||
|
||||
URSACHEN
|
||||
1. Dry run ist standardmaessig aktiv. Er deaktiviert keine Receive Location und
|
||||
ruft deshalb bewusst keinen echten Drain-Entscheidungsdialog auf. Dieser
|
||||
Unterschied war waehrend der Ausfuehrung nicht deutlich genug sichtbar.
|
||||
2. Die bisherigen MessageBoxen hatten keinen Owner. In RDP-/Multi-Monitor-
|
||||
Sitzungen konnte ein modaler Plan- oder Drain-Dialog hinter dem Hauptfenster
|
||||
liegen, waehrend dort nur "Preparing shutdown..." sichtbar blieb.
|
||||
|
||||
SICHERHEIT
|
||||
Der persistierte OperatorCheckpoint war vorhanden. Ohne Dialog-Callback, bei
|
||||
Fehler, Nein oder Schliessen stoppt der echte Shutdown fail-closed. Spaetere
|
||||
Orchestrierungen, Send Ports und Host Instances bleiben NotExecuted.
|
||||
|
||||
FIX 2.3.4
|
||||
- Alle runtime-relevanten Bestaetigungen sind an das Hauptfenster gebunden.
|
||||
- Am echten Checkpoint steht sichtbar ACTION REQUIRED / Shutdown paused.
|
||||
- Der erste Realbetrieb-Dialog kuendigt die zweite Drain-Entscheidung an.
|
||||
- Dry run und REAL EXECUTION sind farblich und textlich eindeutig.
|
||||
- Dry run zeigt einen eigenen Hinweis: keine Mutation, keine echte Drain-
|
||||
Entscheidung.
|
||||
- Einstellungen sind waehrend einer laufenden Operation gesperrt.
|
||||
|
||||
PROD-ABNAHME
|
||||
1. Setup 2.3.4 installieren; setup_version=2.3.4.0 und Ziel-Self-Test pruefen.
|
||||
2. Dry run: Shutdown Dry Run - No Runtime Changes muss sichtbar sein; keine
|
||||
BizTalk-Mutation.
|
||||
3. shutdown-plan.json: OperatorCheckpoint muss vor jeder spaeteren Shutdown-
|
||||
Phase stehen.
|
||||
4. Freigegebenes Wartungsfenster: Dry run deaktivieren; REAL EXECUTION muss
|
||||
sichtbar sein.
|
||||
5. Ersten gespeicherten Plan bestaetigen.
|
||||
6. Nach Receive Locations: ACTION REQUIRED und owner-gebundener Drain-Dialog.
|
||||
7. Zuerst Nein testen: CheckpointDecision=Stop, alle spaeteren Zeilen
|
||||
NotExecuted.
|
||||
8. Danach kontrolliert wiederholen; Group Hub und Monitoring pruefen; erst bei
|
||||
bestaetigtem Leerlauf Ja auswaehlen.
|
||||
9. RDP minimieren/wiederherstellen und ggf. Monitorwechsel testen.
|
||||
|
||||
ALTE LAEUFE UNTERSCHEIDEN
|
||||
- DryRun=true + keine CheckpointDecision: erwartete Simulation.
|
||||
- Kein Ergebnis + UI bleibt Preparing shutdown: moeglicherweise verdeckter
|
||||
Dialog; Alt+Tab pruefen, Prozess nicht blind beenden.
|
||||
- CheckpointDecision=Stop/Error: sicher vor spaeteren Phasen gestoppt.
|
||||
- CheckpointDecision=Continue: positive Bedienerentscheidung wurde erfasst.
|
||||
|
||||
Portable Verifikation: Release-Build aller vier Projekte, 43 Regressionstests,
|
||||
Runtime-Self-Test und manifest-/hashgepruefte Paketierung. Die finale Dialog-
|
||||
und BizTalk-Pruefung erfolgt auf Windows/PROD.
|
||||
@@ -0,0 +1,42 @@
|
||||
PROD-RUNBOOK: SHUTDOWN-DRAIN-CHECKPOINT - VERSION 2.3.2
|
||||
Stand: 2026-08-26
|
||||
|
||||
ZIEL
|
||||
Nach allen Receive Locations pausiert der echte Shutdown. Erst wenn BizTalk
|
||||
sauber leer gelaufen ist, setzt ein ausdrueckliches Yes Orchestrierungen,
|
||||
Send Ports und Host Instances fort.
|
||||
|
||||
DRY-RUN
|
||||
1. Setup 2.3.2 installieren; setup_version=2.3.2.0 und Ziel-Self-Test pruefen.
|
||||
2. Diagnose, Snapshot Before und Shutdown mit aktiviertem Dry run ausfuehren.
|
||||
3. shutdown-plan.json: ReceiveLocations, OperatorCheckpoint, Orchestrations,
|
||||
SendPorts, HostInstances.
|
||||
4. Dry-run zeigt den Checkpoint, oeffnet aber keinen Entscheidungsdialog.
|
||||
|
||||
ECHTER SHUTDOWN
|
||||
1. Gesamtplan bestaetigen und Receive-Location-Ergebnisse beobachten.
|
||||
2. Dialog "Confirm BizTalk Inbound Drain" geoeffnet lassen.
|
||||
3. In Group Hub und Enterprise-Monitoring pruefen:
|
||||
- kein neuer Eingang,
|
||||
- laufende Service Instances kontrolliert gegen null,
|
||||
- keine unerwarteten Suspended/Resumable Instances,
|
||||
- MessageBox-, Queue-, Adapter- und Fremdsystemmetriken leer/stabil,
|
||||
- mehrteilige Prozesse fachlich vollstaendig.
|
||||
4. Nur bei leerer Umgebung Yes waehlen.
|
||||
5. Bei Unsicherheit, Last oder Receive-Location-Fehlern No waehlen.
|
||||
|
||||
ERGEBNIS
|
||||
Yes: Outcome=Confirmed, CheckpointDecision=Continue, Fortsetzung.
|
||||
No: Outcome=Declined, CheckpointDecision=Stop, OperatorStopped=true.
|
||||
Dialogfehler: CheckpointDecision=Error; sicherer Stopp.
|
||||
Nach No/Error sind alle spaeteren Zeilen NotExecuted. shutdown-after.json und
|
||||
shutdown-result.json werden trotzdem soweit moeglich geschrieben.
|
||||
|
||||
APPLICATION STATUS
|
||||
Partially Started direkt nach dem Abschalten der Receive Locations ist der
|
||||
erwartete Drain-Zwischenzustand. Kein zusaetzlicher Application-Stop wird
|
||||
ausgefuehrt. Dessen staerkere Modi koennen Subscriptions entfernen, Artefakte
|
||||
unenlisten, Policies undeployen oder laufende Instanzen terminieren.
|
||||
|
||||
DETAILS
|
||||
docs\PROD-Shutdown-Drain-Checkpoint-2026-08-26.md
|
||||
@@ -17,15 +17,28 @@ WinForms tool for controlled Microsoft BizTalk Server 2020 platform operations d
|
||||
- Diff between `before.json` and `after.json`
|
||||
- Controlled shutdown from the current runtime state
|
||||
- Controlled restore from `before.json`
|
||||
- State-aware emergency restore from a preserved `before.json`, including Enterprise SSO startup
|
||||
- WMI-free validation and file selection for preserved recovery snapshots, including 2.1.3 snapshots
|
||||
- Host instance handling for the selected BizTalk server
|
||||
- Dry-run mode enabled by default
|
||||
- WMI access through `root\MicrosoftBizTalkServer`
|
||||
- Correct application ownership from the read-only ExplorerOM application hierarchy, with WMI retained for runtime state and mutations
|
||||
- Startup check for administrator rights
|
||||
- Detailed operation logging in the GUI and daily rolling log files under ProgramData
|
||||
- Detailed operation logging in the GUI and daily rolling log files in a write-verified local directory
|
||||
- Automatic operation-log restoration into the grid after an application restart
|
||||
- Thirty-day runtime-log retention with GZip compression for completed daily logs
|
||||
- Process-local ScheduledTask adapter dependency resolution for `scheduler:` receive locations without modifying the GAC
|
||||
- Fail-closed operator drain checkpoint after all receive locations and before later shutdown phases
|
||||
- Owner-bound shutdown confirmations with an explicit paused/action-required status and an unambiguous Dry-run notice
|
||||
- Best-effort plan execution: one isolated WMI failure is recorded while remaining independent steps continue
|
||||
- Idempotent execution that skips artifacts already in the requested target state
|
||||
- Durable per-step result reports even when a shutdown or restore completes only partially
|
||||
- Environment status indicator based on host instance state
|
||||
- Clear and Close actions in the main toolbar
|
||||
- No compile-time dependency on BizTalk ExplorerOM assemblies
|
||||
- No compile-time dependency on BizTalk ExplorerOM assemblies; the installed Microsoft assembly is loaded process-locally with identity validation
|
||||
- Transactional Windows installer/updater with SHA-256 payload validation and rollback
|
||||
- Bounded activation retries plus a verified copy fallback for first installs and atomically backed-up updates when Windows/EDR blocks only the staging rename
|
||||
- Opt-in all-users desktop shortcut whose ACL, WSH, validation or rollback failures remain visible but cannot roll back the core installation
|
||||
- Installer diagnostics with stable phase codes, complete child-process output, exception chains and a ProgramData-to-Temp log fallback
|
||||
- WMI-free runtime self-test plus automated regression test executable
|
||||
|
||||
@@ -37,10 +50,13 @@ WinForms tool for controlled Microsoft BizTalk Server 2020 platform operations d
|
||||
4. Click **Snapshot Before**.
|
||||
5. Click **Shutdown** and review `shutdown-plan.json`.
|
||||
6. Disable **Dry run** only when the plan is correct.
|
||||
7. After maintenance, click **Restore** using the saved `before.json`.
|
||||
8. Click **Snapshot After** and **Compare**.
|
||||
7. During a real shutdown, keep the drain dialog open until Group Hub and enterprise monitoring show that in-flight processing has emptied; choose **Yes** only then.
|
||||
8. After maintenance, click **Restore** using the saved `before.json`.
|
||||
9. Click **Snapshot After** and **Compare**.
|
||||
|
||||
The environment indicator shows `Started`, `Stopped`, `Partial` or `Unknown` from the most recent snapshot. `Clear` removes the visible status and operation log grids; it does not delete files.
|
||||
If a shutdown was interrupted and only the original `before.json` remains, select that file with **State...**, run **Validate State**, keep **Dry run** enabled and click **Emergency Restore**. The recovery plan never overwrites the source snapshot, ensures the `ENTSSO` service is running first, skips already-correct runtime states and continues after isolated step failures. Disable Dry run only after reviewing the timestamped emergency plan. A real run automatically writes a timestamped target/actual diff when the post-operation snapshot succeeds.
|
||||
|
||||
The environment indicator shows `Started`, `Stopped`, `Partial` or `Unknown` from the most recent snapshot. `Clear` removes the visible status and operation log grids; it does not delete files. **Log Folder** opens the persistent local runtime-log directory.
|
||||
|
||||
The application requests administrator rights through its UAC manifest and checks them again during startup. Only one GUI instance can run per Windows session.
|
||||
|
||||
@@ -50,6 +66,7 @@ Before a real shutdown or restore, the exact fresh plan is saved and a second di
|
||||
|
||||
Shutdown:
|
||||
- Disable receive locations that were enabled.
|
||||
- Pause at the persisted inbound-drain checkpoint and require an explicit operator decision.
|
||||
- Stop orchestrations that were started.
|
||||
- Stop send ports that were started.
|
||||
- Stop host instances that were started on the selected server.
|
||||
@@ -62,21 +79,43 @@ Restore:
|
||||
|
||||
Orchestrations that were `Bound` are deliberately left unchanged during restore to avoid accidentally making them `Unbound`.
|
||||
|
||||
The drain checkpoint is part of `shutdown-plan.json`. In a real run, the status changes to **ACTION REQUIRED**, and the owned dialog remains in front of the main window. **Yes** records `CheckpointDecision=Continue`; **No**, a closed dialog or a callback error fails closed before orchestrations, send ports and host instances. All later rows are persisted as `NotExecuted`, followed by a partial-state snapshot and `shutdown-result.json`. Dry-run shows the checkpoint but never opens a decision dialog; it displays a separate notice explaining that no receive location was changed.
|
||||
|
||||
BizTalk applications displaying `Partially Started` immediately after receive locations are disabled is expected. Microsoft defines “Partial Stop - Allow running instances to continue” as disabling only receive locations so in-flight instances can finish. The tool deliberately does not issue an additional application-level stop: its stronger variants can stop or unenlist artifacts, remove subscriptions, undeploy policies or terminate instances. The existing artifact-level plan preserves exact snapshot state and controlled global ordering.
|
||||
|
||||
## Outputs
|
||||
|
||||
- `before.json`, `after.json`
|
||||
- `shutdown-plan.json`, `restore-plan.json`
|
||||
- `shutdown-after.json`, `restore-after.json`
|
||||
- `shutdown-result.json`, `restore-result.json`
|
||||
- Timestamped `emergency-source-before-*`, `emergency-restore-plan-*`, `emergency-restore-result-*`, `emergency-restore-after-*` and `emergency-restore-diff-*` files
|
||||
- `diff.json`, `diff.csv`, `diff.html`
|
||||
- Snapshot sidecars: `*.csv`, `*.hosts.csv`, `*.html`
|
||||
- Runtime logs under `%ProgramData%\BizTalkPlatformManagementTool\Logs`
|
||||
- Runtime logs primarily under `%ProgramData%\BizTalkPlatformManagementTool\Logs`
|
||||
|
||||
Log files are retained for the current day plus the previous four days. Older `BizTalkPlatformManagementTool-*.log` files are removed on startup. If ProgramData is unexpectedly unavailable, logging falls back to the executable directory.
|
||||
The current day remains a plain `BizTalkPlatformManagementTool-yyyy-MM-dd.log`. Completed daily logs are compressed to `.log.gz`; the current day plus the previous 29 calendar days are retained. Older records are removed on startup. Up to the newest 10,000 retained entries are automatically restored from plain and compressed files into the Operation Log grid after a restart.
|
||||
|
||||
At every start, the application performs an actual create/write/flush/delete probe and then appends a visible startup verification record. The ordered locations are ProgramData, the current account's LocalAppData, `Logs` below the executable directory, and Temp. **Log Folder** opens the path that really accepted the write. A fallback or complete storage failure is shown with attempted paths and exception details in the Operation Log; it is never silently ignored.
|
||||
|
||||
`C:\Program Files\BizTalkPlatformManagementTool` therefore normally contains no log file. ProgramData is a separate, normally hidden Windows directory. An install-local `Logs` subdirectory appears only when both ProgramData and LocalAppData were rejected and Program Files itself permits the fallback write.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
The BizTalk runtime WMI classes for Send Ports, Receive Locations and Orchestrations do not expose a reliable application property. The tool therefore reads `MgmtDbServerName`/`MgmtDbName` from `MSBTS_GroupSetting`, opens the installed read-only ExplorerOM application catalog and builds an application/artifact index before collecting WMI state. **Diagnose** reports both visible and application-resolved Send Port counts. A mismatch is never silently presented as a valid association: affected rows stay under `(Unknown Application)` and the Operation Log records whether ExplorerOM loading, Management database access or catalog matching failed.
|
||||
|
||||
The Operation Log shows the WMI class, key property, key value and method for real shutdown and restore steps. WMI objects are resolved with a broad `SELECT * FROM <class>` query and a client-side key filter so names containing special characters do not break the WMI query parser.
|
||||
|
||||
Execution is deliberately best-effort. A failure such as an adapter-specific validation exception is written as `Failed` in the result report, but later independent plan steps are still attempted. The GUI ends in a failed/operator-review state when any step failed; it never reports a partial execution as an unconditional success. The post-operation snapshot is attempted independently and its own failure is preserved in the same report.
|
||||
|
||||
The operator checkpoint is the explicit exception to best-effort continuation: declining it or losing the confirmation mechanism intentionally prevents every later shutdown phase. This is a safe incomplete operation, not a successful full shutdown, and remains visible in the report and grid.
|
||||
|
||||
For a ScheduledTask receive location, the operation plan retains adapter name and address. Immediately before a real `Enable` or `Disable`, the tool preloads `Microsoft.BizTalk.Scheduler.dll` from the locally installed BizTalk directory and resolves further dependencies from identity-checked BizTalk/ScheduledTask adapter directories. Conventional BizTalk 2020 and `BizTalk ScheduledTask Adapter 7.x` folders plus BizTalk registry paths are discovered automatically. An exceptional installation path can be added to the semicolon-delimited `AdapterAssemblySearchPaths` value in `BizTalkPlatformManagementTool.exe.config`. This is process-local: the tool neither copies DLLs nor changes the GAC. Never point the setting at assemblies from a different BizTalk version.
|
||||
|
||||
Error records in the grid, execution report and file log include exception type, HRESULT, complete inner-exception chain, available Fusion loader information and stack trace. For the PROD validation and support bundle, follow [ScheduledTask control and runtime logging runbook](docs/PROD-ScheduledTask-und-Laufzeitlogging-2026-08-26.md).
|
||||
|
||||
For the specific PROD finding "no logs visible below Program Files" and the version 2.3.1 storage verification, follow [PROD runtime-log storage validation](docs/PROD-Laufzeitlog-Ablage-2026-08-26.md).
|
||||
|
||||
Snapshot and plan JSON files are written as UTF-8 without BOM. Loading is tolerant of existing files that contain a UTF-8 BOM or a visible BOM marker from previous encoding conversions.
|
||||
|
||||
JSON snapshots and plans are written through a same-directory temporary file and atomic replacement. Snapshot comparison keys artifacts by application plus name, preventing collisions between equal artifact names in different applications. CSV fields that could be interpreted as spreadsheet formulas are neutralized.
|
||||
@@ -102,4 +141,14 @@ Targeted German inline comments explain non-obvious operational decisions such a
|
||||
- [Installation](Installation.md)
|
||||
- [Dokumentation](Dokumentation.md)
|
||||
- [Installer stability analysis](docs/Installer-Stabilitaetsanalyse-2026-08-11.md)
|
||||
- [ACC activation incident analysis](docs/ACC-Installer-Aktivierungsfehler-2026-08-11.md)
|
||||
- [PROD activation incident analysis and 2.2.3 fix](docs/PROD-Installer-Aktivierungsfehler-2026-08-24.md)
|
||||
- [Optional all-users desktop shortcut stability](docs/Installer-Optionale-Desktopverknuepfung-2026-08-24.md)
|
||||
- [ACC runtime shutdown incident and recovery fix](docs/ACC-Runtime-Shutdown-Exception-2026-08-19.md)
|
||||
- [PROD ScheduledTask control and runtime logging runbook](docs/PROD-ScheduledTask-und-Laufzeitlogging-2026-08-26.md)
|
||||
- [PROD runtime-log storage validation and 2.3.1 fix](docs/PROD-Laufzeitlog-Ablage-2026-08-26.md)
|
||||
- [PROD shutdown drain checkpoint and application-status analysis](docs/PROD-Shutdown-Drain-Checkpoint-2026-08-26.md)
|
||||
- [PROD application-association analysis and 2.3.3 validation](docs/PROD-Application-Zuordnung-2026-08-27.md)
|
||||
- [PROD shutdown-dialog visibility analysis and 2.3.4 validation](docs/PROD-Shutdown-Dialog-Sichtbarkeit-2026-08-27.md)
|
||||
- [AI maintainer handoff](AI-README.md)
|
||||
- [References](REFERENCES.md)
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
- MSBTS_SendPort.Status (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-sendport-status-property-wmi
|
||||
- MSBTS_SendPort (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-sendport-wmi
|
||||
- MSBTS_GroupSetting (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-groupsetting-wmi
|
||||
- BtsCatalogExplorer (ExplorerOM): https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.btscatalogexplorer?view=bts-2020
|
||||
- Application (ExplorerOM): https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.application?view=bts-2020
|
||||
- IBizTalkApplication (ExplorerOM): https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.ibiztalkapplication?view=bts-dotnet
|
||||
- BtsOrchestration (ExplorerOM): https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.btsorchestration?view=bts-2020
|
||||
- MSBTS_SendPort.Start (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-sendport-start-method-wmi
|
||||
- MSBTS_SendPort.Stop (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-sendport-stop-method-wmi
|
||||
- MSBTS_SendPort.Enlist (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-sendport-enlist-method-wmi
|
||||
@@ -14,6 +19,12 @@
|
||||
- MSBTS_ReceiveLocation (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-receivelocation-wmi
|
||||
- MSBTS_ReceiveLocation.Enable (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-receivelocation-enable-method-wmi
|
||||
- MSBTS_ReceiveLocation.Disable (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-receivelocation-disable-method-wmi
|
||||
- Microsoft.BizTalk.Scheduler.ISchedule: https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.scheduler.ischedule?view=bts-2020
|
||||
- Managed BizTalk adapter assembly deployment and resolution: https://learn.microsoft.com/en-us/biztalk/core/how-biztalk-server-instantiates-an-adapter
|
||||
- BizTalk Scheduled Task Adapter 7.0.2 release repository: https://github.com/sandroasp/BizTalk-Scheduled-Task-Adapter
|
||||
- MSBTS_HostInstance (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-hostinstance-wmi
|
||||
- MSBTS_HostInstance.Start (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-hostinstance-start-method-wmi
|
||||
- MSBTS_HostInstance.Stop (WMI): https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-hostinstance-stop-method-wmi
|
||||
- Start and stop a BizTalk application: https://learn.microsoft.com/en-us/biztalk/core/how-to-start-and-stop-a-biztalk-application
|
||||
- Stop Application dialog semantics: https://learn.microsoft.com/en-us/biztalk/core/technical-reference/stop-application-dialog-box
|
||||
- BizTalk Server shutdown sequence: https://learn.microsoft.com/en-us/biztalk/core/how-to-start-stop-pause-resume-or-restart-biztalk-server-services
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# ACC Emergency Restore aus `before.json`
|
||||
|
||||
Stand: 19.08.2026
|
||||
Ausführung: Donnerstag, 20.08.2026, oder Montag, 24.08.2026
|
||||
Zielserver: `AV23AGPWBI01`
|
||||
Benötigte Toolversion: `2.2.2`
|
||||
|
||||
## Kurzantwort
|
||||
|
||||
Ja. Die vorhandene, mit Version 2.1.3 erzeugte `before.json` kann von Version 2.2.2 direkt als Recovery-Quelle verwendet werden. Zusätzliche Dateien des abgebrochenen Shutdowns sind nicht erforderlich. Die Kompatibilität wird durch einen Regressionstest abgedeckt; die echte BizTalk-/ACC-Ausführung muss noch vor Ort bestätigt werden.
|
||||
|
||||
Für diesen Teilzustand ausschließlich **Emergency Restore** verwenden. Dieser Modus startet zuerst `ENTSSO`, arbeitet danach den gespeicherten Sollzustand idempotent ab, setzt nach Einzelfehlern fort und überschreibt die Quell-`before.json` nicht.
|
||||
|
||||
## 1. Dateien vorbereiten
|
||||
|
||||
- [ ] Originale `before.json` an einem zweiten Ort unverändert sichern.
|
||||
- [ ] Optional den Hash der Originaldatei protokollieren:
|
||||
|
||||
```bat
|
||||
certutil -hashfile before.json SHA256
|
||||
```
|
||||
|
||||
- [ ] Die Release-Datei `BizTalkPlatformManagementTool-Setup.zip.b64.txt` und die zugehörige SHA-256-Datei auf ACC übertragen.
|
||||
- [ ] Die TXT-Datei rekonstruieren und das ZIP prüfen:
|
||||
|
||||
```bat
|
||||
certutil -decode BizTalkPlatformManagementTool-Setup.zip.b64.txt BizTalkPlatformManagementTool-Setup.zip
|
||||
certutil -hashfile BizTalkPlatformManagementTool-Setup.zip SHA256
|
||||
type BizTalkPlatformManagementTool-Setup.zip.sha256.txt
|
||||
```
|
||||
|
||||
- [ ] Nur fortfahren, wenn beide ZIP-Hashes exakt gleich sind.
|
||||
- [ ] ZIP in einen neuen Ordner entpacken, die laufende Toolinstanz schließen und `Setup.exe` als Administrator starten.
|
||||
- [ ] Installation/Update auf Version `2.2.2` vollständig abschließen.
|
||||
- [ ] Ein neues, leeres Ausgabeverzeichnis anlegen, zum Beispiel `C:\BizTalk-Recovery\2026-08-20` oder `C:\BizTalk-Recovery\2026-08-24`.
|
||||
|
||||
Wichtig: Die Recovery-Quelle außerhalb dieses Ausgabeverzeichnisses lassen. Während der Recovery nicht **Snapshot Before** anklicken, damit kein neuer Teilzustand als vermeintlicher Sollzustand gespeichert wird.
|
||||
|
||||
## 2. `before.json` ohne WMI prüfen
|
||||
|
||||
- [ ] Anwendung als Administrator starten.
|
||||
- [ ] Im Feld **Server** `AV23AGPWBI01` eintragen. Kurzname und FQDN desselben Hosts werden akzeptiert.
|
||||
- [ ] Unter **Output** das neue Recovery-Ausgabeverzeichnis auswählen.
|
||||
- [ ] Über **State...** die gesicherte `before.json` auswählen.
|
||||
- [ ] **Dry run** aktiviert lassen.
|
||||
- [ ] **Validate State** anklicken.
|
||||
- [ ] Im Erfolgsdialog prüfen:
|
||||
- Snapshotversion ist erwartungsgemäß `2.1.3-net461` oder `2.1.3`.
|
||||
- Snapshotserver ist `AV23AGPWBI01` beziehungsweise dessen FQDN.
|
||||
- Erstellzeit und Anzahl von Applications, Host Instances, Receive Locations, Send Ports und Orchestrations wirken plausibel.
|
||||
|
||||
**Validate State** öffnet keine WMI-Verbindung und verändert weder BizTalk noch Windows-Dienste. Bei einer roten Fehlermeldung nicht real ausführen, sondern zuerst Pfad, JSON-Datei und Serverauswahl korrigieren.
|
||||
|
||||
## 3. Emergency-Dry-run prüfen
|
||||
|
||||
- [ ] **Dry run** bleibt aktiviert.
|
||||
- [ ] **Emergency Restore** anklicken.
|
||||
- [ ] Den erzeugten `emergency-restore-plan-<Zeitstempel>.json` öffnen.
|
||||
- [ ] Prüfen, dass der Plan zu `AV23AGPWBI01` gehört.
|
||||
- [ ] Reihenfolge prüfen:
|
||||
1. Windows-Dienst `ENTSSO`,
|
||||
2. alle Host Instances,
|
||||
3. alle Send Ports,
|
||||
4. alle Orchestrations,
|
||||
5. alle Receive Locations.
|
||||
- [ ] Prüfen, dass der Dry-run-Report `emergency-restore-result-<Zeitstempel>.json` geschrieben wurde und keine Initialisierungsfehler enthält.
|
||||
- [ ] Die timestamp-basierte Datei `emergency-source-before-<Zeitstempel>.json` als zusätzliche Recovery-Evidenz sichern.
|
||||
|
||||
Der Dry-run führt keine Zustandsänderung aus. Er bestätigt aber, dass genau die erhaltene Datei gelesen, validiert und in einen ausführbaren Emergency-Plan übersetzt werden kann.
|
||||
|
||||
## 4. Echten Wiederanlauf ausführen
|
||||
|
||||
- [ ] Sicherstellen, dass SQL Server, Netzwerk und die übrigen BizTalk-Abhängigkeiten erreichbar sind.
|
||||
- [ ] Noch einmal kontrollieren: Server, Output-Pfad und State-Datei sind korrekt.
|
||||
- [ ] **Dry run** deaktivieren.
|
||||
- [ ] **Emergency Restore** anklicken.
|
||||
- [ ] Im Bestätigungsdialog Quellpfad, Zielserver, Plandatei und Schrittzahl lesen.
|
||||
- [ ] Erst danach mit **Yes** bestätigen.
|
||||
- [ ] Anwendung bis zum Abschluss geöffnet lassen.
|
||||
|
||||
Die reale Reihenfolge ist:
|
||||
|
||||
1. `ENTSSO` auf `Running` bringen.
|
||||
2. Host Instances gemäß `before.json` abgleichen.
|
||||
3. Send Ports abgleichen.
|
||||
4. Orchestrations abgleichen; im Snapshot nur `Bound` gebliebene Orchestrations werden bewusst zur manuellen Kontrolle markiert.
|
||||
5. Receive Locations zuletzt abgleichen.
|
||||
|
||||
Vor jeder Mutation liest Version 2.2.2 den Istzustand. Ein bereits korrekter Zustand wird als `AlreadySatisfied` protokolliert und nicht erneut per WMI geändert. Ein einzelner Fehler wird als `Failed` gespeichert; alle späteren unabhängigen Schritte werden trotzdem versucht. Auch ein Fehler der optionalen GUI-Loganzeige kann die fachliche Ausführung nicht unterbrechen.
|
||||
|
||||
## 5. Ergebnis abnehmen
|
||||
|
||||
- [ ] `emergency-restore-result-<Zeitstempel>.json` prüfen.
|
||||
- [ ] Idealfall: `FailedCount` ist `0`, `InitializationError` und `PostSnapshotError` sind leer.
|
||||
- [ ] `AlreadySatisfied` ist normal und bedeutet, dass keine unnötige Mutation ausgeführt wurde.
|
||||
- [ ] `emergency-restore-after-<Zeitstempel>.json` muss nach einem echten Lauf vorhanden sein, sofern der Nachher-Snapshot gelang.
|
||||
- [ ] `emergency-restore-diff-<Zeitstempel>.json`, `.csv` und `.html` prüfen. Im vollständigen Sollzustand sind keine fachlichen Unterschiede enthalten.
|
||||
- [ ] Danach **Diagnose** ausführen und den BizTalk-Zustand zusätzlich in der BizTalk Administration Console kontrollieren.
|
||||
- [ ] Empfang, Verarbeitung und Versand mit dem für ACC vorgesehenen fachlichen Smoke-Test prüfen; Suspended Instances kontrollieren.
|
||||
- [ ] Recovery-Quelle, Plan, Ergebnis, Nachher-Snapshot, Diff und Laufzeitlog gemeinsam sichern.
|
||||
|
||||
## Sonderfall `RV_PMP_Trigger_Schedule`
|
||||
|
||||
Wenn die Receive Location noch aktiviert ist und `before.json` ebenfalls `Enabled=true` vorgibt, wird sie als `AlreadySatisfied` übersprungen. Damit wird der fehlerhafte Scheduler-WMI-Aufruf nicht erneut ausgelöst.
|
||||
|
||||
Wenn sie deaktiviert ist, obwohl `before.json` sie aktiviert erwartet, versucht das Tool die Aktivierung. Tritt der bekannte Fehler zu `Microsoft.BizTalk.Scheduler, Version=3.13.0.0` erneut auf, wird genau dieser Schritt als `Failed` protokolliert; die übrigen Receive Locations werden weiterbearbeitet. Dann:
|
||||
|
||||
- [ ] Ergebnisreport und vollständige Exception sichern.
|
||||
- [ ] Aktuellen Zustand der Receive Location in der BizTalk Administration Console prüfen.
|
||||
- [ ] Scheduler-Assembly/Abhängigkeiten auf dem Administrations-/BizTalk-Host reparieren oder den Schritt nach fachlicher Freigabe manuell ausführen.
|
||||
- [ ] PROD erst freigeben, wenn der verbleibende Einzelfehler behoben oder ausdrücklich akzeptiert und getestet ist.
|
||||
|
||||
## Wenn der Lauf erneut unterbrochen wird
|
||||
|
||||
Die ursprüngliche `before.json` bleibt unverändert. Version 2.2.2 kann mit derselben Recovery-Quelle erneut gestartet werden, weil bereits erreichte Zustände als `AlreadySatisfied` übersprungen werden. Vor dem Wiederholen immer den jüngsten Ergebnisreport sichern und prüfen, welcher Schritt tatsächlich fehlgeschlagen ist.
|
||||
|
||||
## Go/No-Go für PROD
|
||||
|
||||
ACC ist erst ein belastbarer PROD-Nachweis, wenn der echte Emergency Restore abgeschlossen wurde, der Ergebnisreport vollständig ist, der automatische Diff geprüft wurde und jeder verbliebene `Failed`-Schritt fachlich behandelt wurde. Die lokalen 27 Regressionstests und der Self-Test ersetzen diesen realen BizTalk-/Windows-Nachweis nicht.
|
||||
@@ -0,0 +1,36 @@
|
||||
# ACC-Installer-Aktivierungsfehler vom 11.08.2026
|
||||
|
||||
## Befund
|
||||
|
||||
Die Installation von Version 2.1.2 auf `AV23AGPWBI01` scheiterte in Phase 3 mit `SETUP-ACTIVATION`, `System.IO.IOException` und HRESULT `0x80070005`. Betroffen war die Verschiebung
|
||||
|
||||
`C:\Program Files\BizTalkPlatformManagementTool.staging.<guid>` → `C:\Program Files\BizTalkPlatformManagementTool`.
|
||||
|
||||
Das Log belegt gleichzeitig:
|
||||
|
||||
- Setup lief 64-Bit und erhöht (`elevated=true`).
|
||||
- Das Ziel war eine Neuinstallation (`existing_installation=False`).
|
||||
- Paketmanifest, Dateilängen und SHA-256 waren korrekt.
|
||||
- Das Staging-Verzeichnis konnte unter `Program Files` angelegt und vollständig beschrieben werden.
|
||||
- Die Staging-EXE startete und beendete ihren Self-Test erfolgreich.
|
||||
- Zwischen dem protokollierten Self-Test-Ende und dem ersten `Directory.Move` lagen nur rund 15 ms.
|
||||
|
||||
Damit sind ein beschädigtes Paket, fehlender Speicherplatz, eine laufende Altversion und ein generelles Fehlen von Schreibrechten als unmittelbare Ursache nicht plausibel. `0x80070005` beweist jedoch nicht, welcher Prozess oder welche Policy die Verschiebung blockierte. Der wahrscheinlichste Befund ist ein noch kurz gehaltenes Delete-/Rename-Handle des Windows Loaders, Virenscanners oder ACC-Endpoint-Schutzes unmittelbar nach Ausführung der neuen EXE. Eine dauerhaft auf Rename beschränkte Endpoint-Policy bleibt als zweite Möglichkeit bestehen.
|
||||
|
||||
## Fix in Version 2.1.3
|
||||
|
||||
Alle transaktionalen Verzeichnisverschiebungen verwenden jetzt höchstens acht Versuche. Nach einem `IOException` oder `UnauthorizedAccessException` wartet das Setup 250, 500, 1.000, 2.000, 3.000, 5.000 und 8.000 ms. Die gesamte zusätzliche Wartezeit ist damit auf 19,75 Sekunden begrenzt. Jeder Fehlversuch und eine spätere Erholung werden mit Exceptiontyp, HRESULT, Rolle, Versuch und Wartezeit protokolliert.
|
||||
|
||||
Bleibt bei einer reinen Neuinstallation die Staging-Umbenennung dauerhaft gesperrt, kopiert das Setup die bereits validierte Payload in das noch nicht vorhandene Installationsziel. Jede Zieldatei wird dabei erneut gegen den Manifest-SHA-256 geprüft. Danach läuft der zweite Self-Test unverändert aus dem endgültigen Ziel. Ein Teilfehler gilt als begonnene Mutation und entfernt das unvollständige Ziel per Rollback.
|
||||
|
||||
Für Updates existiert dieser Kopierfallback absichtlich nicht. Lässt sich die aktive Version nicht atomar ins Backup verschieben, bleibt sie unangetastet und das Setup bricht nach den begrenzten Versuchen mit `SETUP-ACTIVATION` ab.
|
||||
|
||||
## Erwartete ACC-Abnahme
|
||||
|
||||
1. `BizTalkPlatformManagementTool-Setup.zip.b64.txt` dekodieren und den SHA-256 des ZIP prüfen.
|
||||
2. In einen neuen Ordner entpacken und `Setup.exe` starten.
|
||||
3. Im Erfolgslog `setup_version=2.1.3.0` und `activation_method=atomic_move` oder `activation_method=verified_copy_fallback` prüfen.
|
||||
4. Anwendung starten, **Diagnose** ausführen und danach einen Dry-run erstellen.
|
||||
5. Bei erneutem Fehler das vollständige neue `setup-*.log` sichern. Die `directory_move_retry`-Ereignisse zeigen dann, ob und wie lange ACC die Operation blockiert hat.
|
||||
|
||||
Die lokale Mono-Prüfung deckt Build, 17 Regressionstests, Anwendungsselftest, Paketmanifest und Transportartefakte ab. UAC, Endpoint-Schutz, Windows-Registry, Verknüpfungen und BizTalk-WMI müssen weiterhin auf ACC geprüft werden.
|
||||
@@ -0,0 +1,103 @@
|
||||
# ACC-Runtime-Abbruch beim Shutdown vom 19.08.2026
|
||||
|
||||
## Befund
|
||||
|
||||
Der reale Shutdown auf `AV23AGPWBI01` mit Version 2.1.3 wurde bei der Receive Location `RV_PMP_Trigger_Schedule` abgebrochen. Der WMI-Aufruf `MSBTS_ReceiveLocation.Disable` meldete sinngemäß:
|
||||
|
||||
```text
|
||||
Could not validate TransportTypeData, Address or Public Address properties for Receive Location.
|
||||
Could not load file or assembly Microsoft.BizTalk.Scheduler, Version=3.13.0.0 or one of its dependencies.
|
||||
```
|
||||
|
||||
Die unmittelbar vorher erzeugte `before.json` blieb vorhanden. Weil der Executor die erste Schrittausnahme erneut warf, wurden alle späteren Planschritte und der Nachher-Snapshot nicht mehr ausgeführt. Anschließend wurden die Host Instances und Enterprise Single Sign-On manuell gestoppt. Damit entstand ein gemischter Teilzustand.
|
||||
|
||||
Die Exception belegt einen Validierungs-/Assemblyfehler des Scheduler-Adapters oder einer Abhängigkeit im BizTalk-WMI-Pfad. Sie belegt nicht, dass `before.json` beschädigt wurde. Der Snapshot wurde bereits vor jeder Laufzeitmutation atomar gespeichert und bleibt die maßgebliche Wiederherstellungsquelle.
|
||||
|
||||
## Sicherheitsproblem in Version 2.1.3
|
||||
|
||||
- Ein isolierter Adapterfehler stoppte alle späteren unabhängigen Schritte.
|
||||
- Der erste Fehler verhinderte `shutdown-after.json` und einen strukturierten Ergebnisreport.
|
||||
- Restore-Pläne beschrieben zwar den Sollzustand aus `before.json`, prüften aber vor `Start`, `Stop`, `Enable` oder `Disable` nicht allgemein, ob dieser Zustand bereits erreicht war.
|
||||
- Ein erneuter Restore nach einem Teilabbruch konnte deshalb an einer redundanten Operation erneut stoppen.
|
||||
- Die dokumentierte Kategorie-Reihenfolge war nur innerhalb einer einzelnen Anwendung umgesetzt; über mehrere Anwendungen hinweg konnten Kategorien ineinandergreifen.
|
||||
- Enterprise SSO lag außerhalb des Snapshots und wurde bei einer manuellen Abschaltung nicht automatisch als Wiederanlaufvoraussetzung behandelt.
|
||||
|
||||
## Fix in Version 2.2.0
|
||||
|
||||
### Best-effort mit klarer Fehlergrenze
|
||||
|
||||
Jeder Planschritt hat nun einen eigenen Fehlerfang. Ein Fehler erhält das Ergebnis `Failed` mit kompletter Exception-Kette; anschließend wird der nächste unabhängige Schritt versucht. Der Gesamtlauf bleibt bei mindestens einem Fehler ausdrücklich fehlgeschlagen und verlangt Operator-Review.
|
||||
|
||||
### Zustandsbewusste und idempotente Ausführung
|
||||
|
||||
Vor jeder Mutation wird der aktuelle WMI- beziehungsweise Servicezustand gelesen. Entspricht er bereits dem Ziel, wird keine Methode aufgerufen und das Ergebnis lautet `AlreadySatisfied`. Dadurch kann ein Restore sicher an einem gemischten Zustand ansetzen. Im konkreten ACC-Fall wird die weiterhin aktiv gebliebene Scheduler-Receive-Location beim Restore nicht erneut über WMI aktiviert, wenn `before.json` ebenfalls `Enabled=true` enthält.
|
||||
|
||||
### Dauerhafte Evidenz
|
||||
|
||||
Reguläre Operationen schreiben `shutdown-result.json` beziehungsweise `restore-result.json`. Jeder Report enthält Ergebnis, Zeit und Exception pro Schritt. Der Nachher-Snapshot wird auch nach Einzelfehlern separat versucht; ein Fehler dieser Aufnahme wird ebenfalls im Report gesichert.
|
||||
|
||||
### Emergency Restore nur aus `before.json`
|
||||
|
||||
Der neue Button **Emergency Restore** benötigt außer der erhaltenen `before.json` keine Datei des fehlgeschlagenen Laufs. Er:
|
||||
|
||||
1. validiert Snapshot und Zielserver,
|
||||
2. schreibt eine timestamp-basierte, unveränderte Recovery-Kopie,
|
||||
3. erzeugt und speichert einen neuen Emergency-Plan,
|
||||
4. stellt zuerst den Windows-Dienst `ENTSSO` auf `Running`,
|
||||
5. gleicht Host Instances, Send Ports, Orchestrations und Receive Locations zustandsbewusst ab,
|
||||
6. arbeitet nach isolierten Fehlern weiter,
|
||||
7. versucht einen Nachher-Snapshot und schreibt immer den vollständigen Ergebnisreport, soweit das Ausgabeverzeichnis verfügbar ist.
|
||||
|
||||
## Recovery-Ergänzungen in Version 2.2.1
|
||||
|
||||
- **State...** wählt die erhaltene `before.json` direkt aus.
|
||||
- **Validate State** prüft JSON-Struktur und Zielserver ohne WMI-Verbindung oder Laufzeitänderung und zeigt Snapshotversion, Erstellzeit sowie Artefaktzahlen an.
|
||||
- Ein 2.1.3-Snapshot wird ausdrücklich als kompatible Recovery-Quelle regressionsgetestet; `ToolVersion` ist keine Versionssperre.
|
||||
- Nach einem echten Emergency Restore wird bei erfolgreichem Nachher-Snapshot automatisch `emergency-restore-diff-*` als JSON, CSV und HTML geschrieben.
|
||||
|
||||
## Zusätzliche Exception-Grenze in Version 2.2.2
|
||||
|
||||
Ein erneuter Audit des gesamten Shutdown-Kontrollflusses bestätigte, dass WMI-Lookup, Istzustandsprüfung, Methodenaufruf, Zustandswartezeit und Objektfreigabe innerhalb der Per-Step-Exception-Grenze liegen. Zusätzlich ist nun auch die optionale GUI-Weiterleitung des Loggers vollständig isoliert: Selbst wenn die Anzeige eines Logeintrags eine Exception wirft, laufen der aktuelle fachliche Schritt und alle späteren unabhängigen Schritte weiter. Failure-Injection-Tests decken mehrere aufeinanderfolgende `InvalidOperationException`-, `IOException`- und `TimeoutException`-Fehler sowie einen dauerhaft werfenden Log-Sink ab.
|
||||
|
||||
### Globale Reihenfolge
|
||||
|
||||
Shutdown:
|
||||
|
||||
1. alle Receive Locations,
|
||||
2. alle Orchestrations,
|
||||
3. alle Send Ports,
|
||||
4. alle Host Instances.
|
||||
|
||||
Restore und Emergency Restore:
|
||||
|
||||
1. bei Emergency Restore zuerst `ENTSSO`,
|
||||
2. alle Host Instances,
|
||||
3. alle Send Ports,
|
||||
4. alle Orchestrations,
|
||||
5. alle Receive Locations.
|
||||
|
||||
Diese Reihenfolge gilt nun über alle Anwendungen hinweg.
|
||||
|
||||
## Verifikation
|
||||
|
||||
Die portable Regressionstestsuite enthält ab Version 2.2.0 unter anderem folgende Vorfallsprüfungen:
|
||||
|
||||
- simulierte `Microsoft.BizTalk.Scheduler`-Exception in einem mittleren Schritt,
|
||||
- erfolgreiche Ausführung aller späteren Schritte,
|
||||
- vollständige Persistenz des Teilfehlerreports,
|
||||
- Überspringen eines bereits erreichten Sollzustands ohne Mutation,
|
||||
- `ENTSSO` als erster Emergency-Schritt,
|
||||
- globale Shutdown-/Restore-Reihenfolge mit mehreren Anwendungen,
|
||||
- Kurzname/FQDN-Gleichheit für Host-Instance-Schritte.
|
||||
|
||||
Die lokale Suite umfasst ab Version 2.2.2 insgesamt 27 Tests einschließlich der expliziten 2.1.3-Snapshot-Kompatibilität, zusätzlicher Failure-Injection für unerwartete Exceptions und eines vollständigen Shutdown-Fortsetzungstests über Receive Location, Orchestration, Send Port und Host Instance. Die abschließende Freigabe für PROD benötigt weiterhin einen Windows-/BizTalk-Test auf ACC: echter Scheduler-Fehlerpfad, vollständige Fortsetzung, Ergebnisreport, Emergency-Dry-run und realer Wiederanlauf aus einer Kopie der vorhandenen `before.json`.
|
||||
|
||||
## PROD-Freigabekriterien
|
||||
|
||||
- Version 2.2.2 installieren und Installer-Self-Test bestätigen.
|
||||
- `Diagnose` und einen vollständigen Shutdown-Dry-run ausführen.
|
||||
- Kontrolliert nachweisen, dass eine isolierte Scheduler-Exception spätere Schritte nicht blockiert.
|
||||
- `shutdown-result.json` und Nachher-Snapshot prüfen.
|
||||
- Emergency Restore zuerst ausschließlich als Dry-run aus einer Snapshot-Kopie prüfen.
|
||||
- Realen Emergency Restore auf ACC abschließen und `FailedCount=0` oder jeden verbleibenden Einzelfehler fachlich freigeben.
|
||||
- Erst danach dasselbe Releasepaket für PROD verwenden.
|
||||
@@ -0,0 +1,56 @@
|
||||
# Optionale Desktop-Verknüpfung für alle Benutzer
|
||||
|
||||
## Befund
|
||||
|
||||
Bis Version 2.2.3 war die Option **Desktop-Verknüpfung für alle Benutzer erstellen** standardmäßig aktiviert. Der Installer verwaltet den Link über Windows Script Host im von `Environment.SpecialFolder.CommonDesktopDirectory` gelieferten gemeinsamen Desktop-Verzeichnis, üblicherweise `%PUBLIC%\Desktop`.
|
||||
|
||||
Obwohl der Link fachlich optional war, lagen alle Zugriffe innerhalb der transaktionskritischen Windows-Integrationsphase. Eine `UnauthorizedAccessException`, COM-/WSH-Exception oder Zustandsabweichung konnte daher nach bereits erfolgreicher Payload-Aktivierung einen `SETUP-WINDOWS-INTEGRATION`-Fehler und den vollständigen Rollback auslösen. Betroffen waren nicht nur das Erstellen, sondern fünf Pfade:
|
||||
|
||||
1. Lesen des vorhandenen Links für den Rollback-Snapshot.
|
||||
2. Erstellen oder Entfernen entsprechend der Setup-Auswahl.
|
||||
3. Rücklesende Validierung des gewünschten Zustands.
|
||||
4. Wiederherstellung des vorherigen Links während eines Rollbacks.
|
||||
5. Entfernen und Prüfen bei der Deinstallation.
|
||||
|
||||
Der konkrete Berechtigungsgeber kann erst anhand des vollständigen `setup-*.log`, der effektiven ACL und gegebenenfalls EDR-Ereignisse bestimmt werden. Unabhängig davon war die bisherige Kritikalität für eine reine Komfortfunktion zu hoch.
|
||||
|
||||
## Fix in Version 2.2.4
|
||||
|
||||
- Die Desktop-Option ist standardmäßig abgewählt und muss bewusst aktiviert werden.
|
||||
- Alle fünf Desktop-Pfade laufen über eine gemeinsame optionale Exception-Grenze.
|
||||
- Jeder Fehler wird mit Exceptiontyp, HRESULT, Stacktrace, Rolle und Pfad als `optional_windows_integration_warning` protokolliert.
|
||||
- Die Setup-Oberfläche zeigt eine Warnung und erklärt ausdrücklich, dass die Kerninstallation fortgesetzt wird.
|
||||
- Auch eine Exception der Warnungsweiterleitung wird isoliert und als `optional_windows_integration_report_failed` protokolliert.
|
||||
- Ein Desktop-Snapshot, der wegen fehlender Rechte nicht gelesen werden konnte, wird beim späteren Rollback nicht erfunden oder überschrieben.
|
||||
- Ein fehlgeschlagener Desktop-Zugriff bei der Deinstallation kann einen alten Link zurücklassen, verhindert aber nicht die Entfernung der Anwendung.
|
||||
|
||||
Der Installer ändert keine ACLs, übernimmt keinen Besitz und umgeht keine Sicherheitsrichtlinie. Die Sicherheitsentscheidung des Systems bleibt bestehen; lediglich die optionale Verknüpfung wird aus der Kerntransaktion entfernt.
|
||||
|
||||
## Weiterhin verpflichtende Integration
|
||||
|
||||
Diese Bestandteile bleiben transaktionskritisch:
|
||||
|
||||
- Startmenü-Verknüpfung für alle Benutzer,
|
||||
- Uninstaller unter `%ProgramData%\BizTalkPlatformManagementTool\Setup`,
|
||||
- Uninstall-Eintrag unter `HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall`.
|
||||
|
||||
Ein Fehler dieser Elemente verhindert weiterhin einen inkonsistenten Erfolg und löst bei Installation oder Update den Rollback aus.
|
||||
|
||||
## Diagnose und Abnahme
|
||||
|
||||
Bei nicht angeforderter oder erfolgreicher Desktop-Operation enthält das Log `event=optional_windows_integration_completed`. Bei einem tolerierten Fehler enthält es:
|
||||
|
||||
```text
|
||||
event=optional_windows_integration_warning role=desktop_shortcut_... path="..." exception_type=... hresult=...
|
||||
event=setup_completed result=success_with_optional_desktop_shortcut_warning optional_desktop_shortcut_warning=True
|
||||
```
|
||||
|
||||
Für die Windows-Abnahme:
|
||||
|
||||
1. Setup 2.2.4 zunächst mit abgewählter Desktop-Option installieren oder aktualisieren.
|
||||
2. `setup_version=2.2.4.0`, erfolgreichen Kernabschluss, Startmenü-Link, Uninstaller und Registry prüfen.
|
||||
3. Die Option in einem weiteren Update gezielt aktivieren. Wird der gemeinsame Desktop blockiert, muss das Setup mit Warnung erfolgreich bleiben und die Anwendung startbar sein.
|
||||
4. Danach **Diagnose** und einen Dry-run ausführen.
|
||||
5. Deinstallation separat prüfen; ein nicht löschbarer optionaler Desktop-Link darf höchstens als Warnung verbleiben.
|
||||
|
||||
Die portable Regressionstestsuite injiziert einen ACL-Fehler, eine Validierungsabweichung und einen fehlerhaften Warnungs-Sink. Reale `%PUBLIC%\Desktop`-ACLs, WSH/COM, Endpoint-Schutz und Gruppenrichtlinien bleiben auf Windows zu validieren.
|
||||
@@ -11,6 +11,8 @@ Vor Version 2.1.0 enthielt das Repository keinen Installer für die C#-Anwendung
|
||||
- Keine Mutation vor vollständig bestandenem Manifest- und Staging-Self-Test.
|
||||
- Update nur bei geschlossener produktiver Toolinstanz.
|
||||
- Staging und Backup als eindeutige Geschwister des Installationsverzeichnisses auf demselben Volume.
|
||||
- Acht begrenzte Move-Versuche mit 250, 500, 1.000, 2.000, 3.000, 5.000 und 8.000 ms Backoff zwischen den Versuchen.
|
||||
- SHA-256-verifizierter Kopierfallback für eine Neuinstallation ohne Ziel oder für eine Update-Aktivierung nach vollständig atomar gesicherter Vorversion; niemals als In-place-Update.
|
||||
- Zweiter Self-Test nach Aktivierung und vor Windows-Registrierung.
|
||||
- Automatisches Datei- und Registrierungsrollback bei Fehlern.
|
||||
- Dauerhaftes phasenbezogenes Installerlog unter ProgramData.
|
||||
@@ -18,13 +20,14 @@ Vor Version 2.1.0 enthielt das Repository keinen Installer für die C#-Anwendung
|
||||
- Stabile Fehlercodes, vollständige Self-Test-Ausgaben, Exception-Ketten, HRESULTs und einzeln protokollierte Rollbackschritte.
|
||||
- Explizite Unterscheidung zwischen Fehlern vor der ersten Mutation und tatsächlich ausgeführtem Rollback.
|
||||
- Rücklesende Verifikation von Verknüpfungen, Uninstaller und zentralen Registrywerten.
|
||||
- Explizite optionale Exception-Grenze für sämtliche Zugriffe auf den gemeinsamen Desktop-Link; Startmenü, Uninstaller und Registry bleiben transaktionskritisch.
|
||||
- Deinstallation über Windows-Uninstall-Eintrag; Diagnoseprotokolle bleiben erhalten.
|
||||
- Äußere ZIP-Prüfsumme und Certutil-kompatible Base64-TXT für kontrollierte Übertragung.
|
||||
|
||||
## Lokal verifiziert
|
||||
|
||||
- Release-Build aller Projekte mit Mono MSBuild.
|
||||
- Vierzehn Regressionstests einschließlich manipulierter/zusätzlicher/ausbrechender Payload-Pfade, Staging-Abbruch ohne Mutation, erzwungenem Fehler des zweiten Self-Tests mit Wiederherstellung der Vorversion, Deinstallation über ein Quarantäneverzeichnis, Diagnosekontext, Log-Fallback und Fehlerisolierung der UI-Ausgabe.
|
||||
- Dreißig Regressionstests einschließlich manipulierter/zusätzlicher/ausbrechender Payload-Pfade, Staging-Abbruch ohne Mutation, transienter Move-Erholung, verifiziertem Neuinstallations- und Updatefallback, begrenztem Updateabbruch, erzwungenem Fehler des zweiten Self-Tests mit Wiederherstellung der Vorversion, Deinstallation über ein Quarantäneverzeichnis, Diagnosekontext, Log-Fallback sowie Fehlerisolierung der UI- und optionalen Desktop-Ausgabe.
|
||||
- WMI-freier Self-Test der produktiven EXE.
|
||||
- Erstellung des Installationsordners, ZIPs, Base64-TXTs und der SHA-256-Datei.
|
||||
- Rückdekodierung der Base64-TXT und Bytevergleich mit dem ZIP.
|
||||
@@ -47,7 +50,7 @@ Die lokale Linux-/Mono-Verifikation kann folgende Windows-spezifische Punkte nic
|
||||
2. Startmenü- und optionale Desktop-Verknüpfung über Windows Script Host.
|
||||
3. 64-Bit-Uninstall-Eintrag und Aufruf über Apps & Features.
|
||||
4. Updateblockade bei laufender installierter GUI.
|
||||
5. Reales Rollback bei Dateisperren, Virenscannerzugriff oder Registryfehlern.
|
||||
5. Reales Rollback bei nicht durch den neuen Retry/Fallback aufgelösten Dateisperren oder Registryfehlern.
|
||||
6. ProgramData-Fehler und Temp-Log-Fallback unter realen Windows-ACLs.
|
||||
7. Diagnose und Laufzeitoperationen gegen `root\MicrosoftBizTalkServer` auf BizTalk Server 2020.
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# PROD-Analyse: `(Unknown Application)` bei Runtime-Artefakten
|
||||
|
||||
**Stand:** 2026-08-27
|
||||
|
||||
**Fehlerstand:** 2.3.2
|
||||
|
||||
**Zielversion:** 2.3.3
|
||||
|
||||
## Beobachtung und Bewertung
|
||||
|
||||
Im PROD-Shutdown-Plan wurden die gefundenen Send Ports mit korrekten Namen und Zuständen angezeigt, die Spalte **Application** enthielt jedoch durchgehend `(Unknown Application)`. Damit war der WMI-Zugriff selbst erfolgreich; fehlerhaft war die nachgelagerte Zuordnung der Artefakte zu BizTalk-Anwendungen.
|
||||
|
||||
Der Lauf wäre technisch weiterhin in der global sicheren Kategorie-Reihenfolge ausführbar gewesen, weil Send Ports über ihren gruppenweit eindeutigen WMI-Namen adressiert werden. Die Anzeige ist dennoch ein Produktfehler: Planreview und anwendungsbezogene Snapshot-/Diff-Auswertung benötigen die echte Ownership. Ein realer Lauf mit ungeklärter Zuordnung ist daher nicht freizugeben.
|
||||
|
||||
## Root Cause
|
||||
|
||||
Version 2.3.2 versuchte bei `MSBTS_SendPort`, `MSBTS_ReceiveLocation` und `MSBTS_Orchestration` Properties namens `ApplicationName`, `Application` oder `BizTalkApplication` auszulesen. Diese Properties gehören nicht zum dokumentierten Runtime-WMI-Vertrag der drei Klassen. Der Code fiel deshalb für jedes betroffene Objekt auf `(Unknown Application)` zurück.
|
||||
|
||||
Die BizTalk-Anwendung ist eine Kataloghierarchie, keine verlässliche Property dieser Runtime-WMI-Objekte. Microsoft stellt sie über `Microsoft.BizTalk.ExplorerOM` bereit: Eine Application enthält ihre Send Ports, Receive Ports samt Receive Locations und Orchestrierungen. `MSBTS_GroupSetting` liefert den Server und Namen der BizTalk Management-Datenbank, mit der `BtsCatalogExplorer` verbunden wird.
|
||||
|
||||
## Korrektur in 2.3.3
|
||||
|
||||
`BizTalkApplicationResolver` baut vor der WMI-Zustandserfassung einen read-only Index auf:
|
||||
|
||||
1. `MSBTS_GroupSetting` lesen und genau einen Management-DB-Endpunkt verlangen.
|
||||
2. Die lokal installierte `Microsoft.BizTalk.ExplorerOM.dll` über CLR/GAC oder vorhandene BizTalk-Verzeichnisse laden.
|
||||
3. Vor einem dateibasierten Fallback Simple Name und Microsoft-Public-Key-Token prüfen.
|
||||
4. Applications und deren Send Ports, Receive Ports/Locations sowie Orchestrierungen enumerieren.
|
||||
5. WMI-Artefakte case-insensitiv gegen diesen Index auflösen; bei Receive Locations dient der Parent-Receive-Port als zusätzlicher Fallback.
|
||||
6. Namen, die widersprüchlich unter mehreren Anwendungen auftauchen, nicht raten, sondern weiter als unbekannt markieren.
|
||||
|
||||
Es gibt weiterhin keine Compile-time-Referenz und keine mitgelieferte Kopie der BizTalk-DLL. Der Installer-Self-Test bleibt WMI- und BizTalk-frei. ExplorerOM wird ausschließlich gelesen; Zustände, Wait-Logik und sämtliche Shutdown-/Restore-Mutationen bleiben beim bestehenden WMI-Adapter.
|
||||
|
||||
Wenn Assembly, Management-Datenbank oder Berechtigung nicht verfügbar sind, bricht die Zustandserfassung nicht verdeckt ab. Die betroffenen Zeilen bleiben sichtbar unter `(Unknown Application)`, und Grid sowie Laufzeitlog enthalten die vollständige Ursache. **Diagnose** meldet künftig sowohl die Zahl sichtbarer Send Ports als auch die Zahl erfolgreicher Application-Zuordnungen.
|
||||
|
||||
## Lokale Verifikation
|
||||
|
||||
- Release-Rebuild aller vier .NET-Framework-4.6.1-Projekte erfolgreich.
|
||||
- 41 portable Regressionstests erfolgreich.
|
||||
- Neuer Test deckt Send Port, Receive Location, Receive-Port-Fallback, Orchestration, case-insensitive Namen und mehrdeutige Cross-Application-Namen ab.
|
||||
- WMI-freier Anwendungsselftest erfolgreich mit `2.3.3-net461`.
|
||||
- Paketmanifest, Installer-ZIP, Certutil-Base64 und SHA-256 werden durch die Release-Chain erzeugt und separat gegengeprüft.
|
||||
|
||||
Die lokale Suite kann den echten BizTalk-2020-ExplorerOM-Katalog nicht simulieren. Die abschließende Freigabe benötigt deshalb die folgende PROD-Abnahme.
|
||||
|
||||
## PROD-Abnahme nach dem Update
|
||||
|
||||
1. Setup 2.3.3 als Administrator ausführen und im Setup-Log `setup_version=2.3.3.0` sowie erfolgreichen Ziel-Self-Test prüfen.
|
||||
2. Tool starten, PROD-Zielserver kontrollieren und **Dry run** aktiviert lassen.
|
||||
3. **Diagnose** ausführen. Erwartung: `Send ports visible: N; application associations resolved: N.` mit identischen Zahlen und ohne nachfolgende Association-Warnung.
|
||||
4. Laufzeitlog über **Log Folder** öffnen und den Eintrag `BizTalk application catalog loaded through ExplorerOM` prüfen. Er muss plausible Zähler für Applications, Send Ports, Receive Ports/Locations und Orchestrations enthalten.
|
||||
5. **Snapshot Before** erzeugen und `before.json` prüfen:
|
||||
- keine `(Unknown Application)`-Gruppe für regulär katalogisierte Runtime-Artefakte,
|
||||
- stichprobenartig mehrere Send Ports aus unterschiedlichen Anwendungen gegen die BizTalk Administration Console abgleichen,
|
||||
- Receive Locations und Orchestrierungen ebenfalls anwendungsrichtig gruppiert.
|
||||
6. **Shutdown** nur als Dry-run ausführen. Im Grid und in `shutdown-plan.json` müssen die echten Application-Namen erscheinen; Reihenfolge und Schrittzahl gegen den Snapshot prüfen.
|
||||
7. Erst nach erfolgreichem Katalog-, Snapshot- und Dry-run-Abgleich über einen echten Wartungslauf entscheiden.
|
||||
|
||||
## Fehlerpfad und Supportdaten
|
||||
|
||||
Sind die Diagnosezahlen unterschiedlich oder erscheinen weiterhin unbekannte Anwendungen, keinen echten Shutdown starten. Sichern:
|
||||
|
||||
- aktuelle Tageslogdatei,
|
||||
- Diagnose-Screenshot,
|
||||
- `before.json` und Sidecars,
|
||||
- `shutdown-plan.json` aus dem Dry-run,
|
||||
- Setup-Log,
|
||||
- genaue Windows-Identität des Toolprozesses,
|
||||
- WMI-/ExplorerOM-/SQL-Exception einschließlich HRESULT und Inner Exceptions.
|
||||
|
||||
Dann insbesondere prüfen: lokale BizTalk-Administrationskomponenten/ExplorerOM-Installation, Erreichbarkeit der in `MSBTS_GroupSetting` gemeldeten Management-Datenbank und Leseberechtigung des ausführenden Kontos.
|
||||
|
||||
## Microsoft-Quellen
|
||||
|
||||
- [MSBTS_SendPort (WMI)](https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-sendport-wmi)
|
||||
- [MSBTS_ReceiveLocation (WMI)](https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-receivelocation-wmi)
|
||||
- [MSBTS_Orchestration (WMI)](https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-orchestration-wmi)
|
||||
- [MSBTS_GroupSetting (WMI)](https://learn.microsoft.com/en-us/biztalk/core/technical-reference/msbts-groupsetting-wmi)
|
||||
- [BtsCatalogExplorer (ExplorerOM)](https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.btscatalogexplorer?view=bts-2020)
|
||||
- [Application (ExplorerOM)](https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.application?view=bts-2020)
|
||||
- [BtsOrchestration (ExplorerOM)](https://learn.microsoft.com/en-us/dotnet/api/microsoft.biztalk.explorerom.btsorchestration?view=bts-2020)
|
||||
@@ -0,0 +1,52 @@
|
||||
# PROD-Installer-Aktivierungsfehler vom 24.08.2026
|
||||
|
||||
## Kurzbefund
|
||||
|
||||
Der Screenshot zeigt nicht den aktuellen Repository-Stand, sondern `BizTalk Platform Management Tool 2.1.2`. Der Lauf bestand um 12:40:59 die Staging-Prüfung und scheiterte unmittelbar danach in Phase 3 mit:
|
||||
|
||||
```text
|
||||
SETUP-ACTIVATION
|
||||
System.InvalidOperationException: Installation/Update fehlgeschlagen
|
||||
System.IO.IOException: Access to the path
|
||||
'C:\Program Files\BizTalkPlatformManagementTool.staging.<guid>' is denied.
|
||||
at System.IO.Directory.InternalMove(...)
|
||||
```
|
||||
|
||||
Die Abschlussmeldung enthält `Kein Rollback erforderlich`. Im 2.1.2-Code bedeutet das, dass weder ein vorhandenes Installationsverzeichnis ins Backup verschoben noch ein neues Ziel aktiviert wurde. Der Fehler trat somit an der ersten Systemmutation auf; Paketkopie und Staging-Self-Test waren bereits erfolgreich.
|
||||
|
||||
## Ursachenbewertung
|
||||
|
||||
Version 2.1.2 führte für die Aktivierung genau einen `Directory.Move` aus. `Access denied` beim Umbenennen des vollständig erstellten und bereits ausführbaren Staging-Verzeichnisses ist mit einer kurzzeitigen Loader-/Virenscanner-/EDR-Sperre oder einer auf Rename/Delete beschränkten Richtlinie vereinbar. Der Screenshot allein identifiziert den blockierenden Prozess nicht. Er belegt aber:
|
||||
|
||||
- kein Manifest- oder SHA-256-Fehler,
|
||||
- keinen Fehler des WMI-freien Staging-Self-Tests,
|
||||
- keinen BizTalk-Laufzeitfehler,
|
||||
- keinen erforderlichen Rollback einer aktiven Version,
|
||||
- einen Fehler beim Verzeichnis-Rename unter `C:\Program Files`.
|
||||
|
||||
Der gleiche 2.1.2-Codepfad war bereits am 11.08.2026 in ACC aufgefallen. Der damals ab 2.1.3 ergänzte Retry- und Neuinstallationsfallback war in der auf dem Screenshot ausgeführten Datei noch nicht enthalten.
|
||||
|
||||
## Fix in Version 2.2.3
|
||||
|
||||
Version 2.2.3 enthält die bereits vorhandenen acht begrenzten Move-Versuche mit 250, 500, 1.000, 2.000, 3.000, 5.000 und 8.000 ms Backoff. Bleibt ausschließlich der Staging-Rename gesperrt, wird die validierte Payload in das fehlende Ziel kopiert und jede Zieldatei erneut gegen das Manifest geprüft.
|
||||
|
||||
Der Fix deckt jetzt beide sicheren Situationen ab:
|
||||
|
||||
1. Neuinstallation: Es existiert kein Installationsziel.
|
||||
2. Update: Die vollständige Vorversion wurde zuvor atomar ins Backup verschoben und das Installationsziel existiert nicht mehr.
|
||||
|
||||
Der Fallback überschreibt niemals eine aktive Installation. Bei einem Update bleibt das Backup während Kopie, Hashprüfung und zweitem Self-Test erhalten. Scheitert einer dieser Schritte, entfernt der Installer die teilweise neue Version und stellt das Backup wieder her. Kann schon das Backup nicht atomar erzeugt werden, bleibt die Vorversion unverändert aktiv und es gibt keinen Kopierfallback.
|
||||
|
||||
Zwei neue Failure-Injection-Regressionstests belegen den erfolgreichen Updatefallback und die vollständige Wiederherstellung der Vorversion nach einem erzwungen fehlgeschlagenen Ziel-Self-Test.
|
||||
|
||||
## Vorgehen in PROD
|
||||
|
||||
1. Die 2.1.2-Datei nicht erneut starten.
|
||||
2. Screenshot und vollständiges `setup-*.log` aus `%ProgramData%\BizTalkPlatformManagementTool\InstallerLogs` als Vorfallevidenz sichern.
|
||||
3. `artifacts\BizTalkPlatformManagementTool-Setup.zip.b64.txt` aus Version 2.2.4 mit `certutil -decode` rekonstruieren.
|
||||
4. Den SHA-256 des ZIPs mit `BizTalkPlatformManagementTool-Setup.zip.sha256.txt` vergleichen.
|
||||
5. Das ZIP in einen neuen Ordner entpacken und die dortige `Setup.exe` starten. Der Fenstertitel muss `2.2.4` zeigen.
|
||||
6. Im Erfolgslog `setup_version=2.2.4.0` und `activation_method=atomic_move` oder `activation_method=verified_copy_fallback` prüfen. Beim Fallback muss zusätzlich `scope=new_install` oder `scope=update_after_backup` protokolliert sein.
|
||||
7. Danach in der Anwendung zuerst **Diagnose** und anschließend mit aktiviertem **Dry run** den vorgesehenen Betriebsablauf prüfen.
|
||||
|
||||
Eine Windows-/BizTalk-/EDR-Abnahme in PROD bleibt erforderlich; die lokale Mono-Suite kann reale ACLs, Endpoint-Schutz, Registry und Verknüpfungen nicht simulieren.
|
||||
@@ -0,0 +1,44 @@
|
||||
# PROD-Runbook: Laufzeitlog-Ablage und Version 2.3.1
|
||||
|
||||
**Stand:** 2026-08-26
|
||||
**Zielversion:** 2.3.1
|
||||
|
||||
## Einordnung des Screenshots
|
||||
|
||||
Der gezeigte Ordner `C:\Program Files\BizTalkPlatformManagementTool` ist der Programmordner. Der primäre Laufzeitlogordner ist dagegen `%ProgramData%\BizTalkPlatformManagementTool\Logs`, üblicherweise `C:\ProgramData\BizTalkPlatformManagementTool\Logs`. `C:\ProgramData` ist im Explorer standardmäßig ausgeblendet. Im Programmordner wird deshalb im Normalfall kein Log erwartet.
|
||||
|
||||
Die frühere Implementierung konnte dennoch einen echten Fehler verdecken: Sie prüfte nur, ob sich der Ordner anlegen ließ, und ignorierte einen Fehler beim nachfolgenden `AppendAllText`. Damit konnte das Grid funktionieren, obwohl kein dauerhaftes Log geschrieben wurde.
|
||||
|
||||
## Fix in 2.3.1
|
||||
|
||||
- Jeder Kandidat muss einen echten Create/Write/Flush/Delete-Test bestehen.
|
||||
- Die Reihenfolge ist ProgramData, LocalAppData, EXE-Unterordner `Logs`, Temp.
|
||||
- Ein späterer Append-Fehler wiederholt denselben Datensatz auf dem nächsten Kandidaten.
|
||||
- Fallback und vollständiger Ausfall erscheinen mit Pfad und Exception im Grid.
|
||||
- Jeder GUI-Start schreibt `Runtime log storage verified by startup append. Active file: ...` in Grid und Tagesdatei.
|
||||
- Der Installer-Self-Test prüft einen vollständigen temporären Write/Read-Roundtrip.
|
||||
- Tagesdateien werden nach Abschluss komprimiert; aktueller Tag plus 29 Vortage bleiben erhalten. Bis zu 10.000 Einträge werden nach Neustart ins Grid geladen.
|
||||
|
||||
## PROD-Abnahme nach Update
|
||||
|
||||
1. Setup 2.3.1 als Administrator ausführen und erfolgreichen Ziel-Self-Test prüfen.
|
||||
2. Tool als Administrator starten, noch keine reale BizTalk-Operation ausführen.
|
||||
3. Im Grid den grünen Startup-Verifikationseintrag prüfen und seinen vollständigen Dateipfad notieren.
|
||||
4. Auf eine gelbe Pfad-Fallbackwarnung oder `RUNTIME FILE LOGGING UNAVAILABLE` achten.
|
||||
5. **Log Folder** öffnen und prüfen, dass exakt die genannte Tagesdatei existiert.
|
||||
6. Datei öffnen und den Startup-Verifikationseintrag dieses Starts prüfen.
|
||||
7. **Diagnose** ausführen, Tool regulär schließen und neu starten.
|
||||
8. Prüfen, dass Diagnoseeinträge wieder im Grid erscheinen und auch in der Tagesdatei stehen.
|
||||
9. Erst danach den ScheduledTask-Test zunächst als Dry-run und nach Planreview real durchführen.
|
||||
|
||||
Bei `RUNTIME FILE LOGGING UNAVAILABLE` keine reale Wartungsoperation beginnen. Screenshot des vollständigen Grid-Eintrags, aktiven Benutzer, freien Speicher, Endpoint-Security-Ereignisse und die ACLs der vier genannten Kandidaten sichern. Keine ACL eigenmächtig aufweiten; die Ursache mit dem Serverbetrieb klären.
|
||||
|
||||
## Supportpaket
|
||||
|
||||
- Aktuelle `.log` und relevante `.log.gz` aus **Log Folder**
|
||||
- Screenshot der Startup-Verifikation beziehungsweise vollständigen Speicherwarnung
|
||||
- `shutdown-plan.json`/`restore-plan.json` und passender `*-result.json`-Report
|
||||
- `before.json`, Nachher-Snapshot und unveränderte EXE-Konfiguration
|
||||
- Setup-Log mit `setup_version=2.3.1.0` und erfolgreichem Ziel-Self-Test
|
||||
|
||||
Die Windows-/BizTalk-/PROD-Prüfung bleibt die endgültige Abnahme; die portable Regressionstoolchain simuliert die drei Speicherfehlerpfade ohne BizTalk.
|
||||
@@ -0,0 +1,83 @@
|
||||
# PROD-Runbook: ScheduledTask-Steuerung und persistentes Laufzeitlogging
|
||||
|
||||
**Stand:** 2026-08-26
|
||||
|
||||
**Zielversion:** 2.3.4
|
||||
|
||||
**Betroffener Adapter:** BizTalk ScheduledTask Adapter 7.0.2
|
||||
|
||||
**Bestätigter Adapterpfad:** `C:\Program Files (x86)\BizTalk ScheduledTask Adapter 7.0.2`
|
||||
|
||||
## Ursache und Fix
|
||||
|
||||
`MSBTS_ReceiveLocation.Enable` und `.Disable` validieren die Transportdaten einer ScheduledTask-Receive-Location. Der Adapter benötigt dafür `Microsoft.BizTalk.Scheduler.dll`. Diese BizTalk-Assembly liegt im BizTalk-Installationsverzeichnis, ist aber nicht in jeder Umgebung im GAC auflösbar. Der Fehler lautete deshalb sinngemäß `Could not load file or assembly Microsoft.BizTalk.Scheduler, Version=3.13.0.0`.
|
||||
|
||||
Version 2.3.1 erkennt ScheduledTask-Schritte an Adaptername oder `scheduler:`-URI. Unmittelbar vor der WMI-Mutation sucht sie die Assembly in der lokalen BizTalk-/Adapterinstallation, prüft ihre .NET-Assemblyidentität und lädt sie nur für den laufenden Toolprozess. Weitere angeforderte Abhängigkeiten werden nach derselben Identitätsprüfung aufgelöst. Das Tool kopiert keine Fremd-DLL, registriert nichts und verändert den GAC nicht.
|
||||
|
||||
## Vorbereitung
|
||||
|
||||
1. Vorhandene `before.json`, Ergebnisdateien und Laufzeitlogs außerhalb des Installationsordners sichern.
|
||||
2. Setup 2.3.4 als Administrator installieren beziehungsweise aktualisieren.
|
||||
3. Im Setup-Log `setup_version=2.3.4.0` und erfolgreichen Ziel-Self-Test prüfen.
|
||||
4. Tool als Administrator starten, den grünen Eintrag `Runtime log storage verified by startup append` prüfen und mit **Log Folder** den dort genannten aktiven Pfad öffnen. Normalfall ist `%ProgramData%\BizTalkPlatformManagementTool\Logs`.
|
||||
5. Prüfen, dass der lokale BizTalk-Installationsordner `Microsoft.BizTalk.Scheduler.dll` enthält.
|
||||
6. Nur wenn BizTalk oder der Adapter abweichend installiert wurde: `AdapterAssemblySearchPaths` in `BizTalkPlatformManagementTool.exe.config` um den vorhandenen lokalen Ordner ergänzen. Mehrere Pfade werden mit Semikolon getrennt. Keine DLL aus ACC, einer alten BizTalk-Version oder einem Downloadordner kopieren.
|
||||
|
||||
## Kontrollierter Funktionstest
|
||||
|
||||
1. **Diagnose** ausführen.
|
||||
2. **Snapshot Before** ausführen und im Statusgrid die betroffene Receive Location mit Adapter und `scheduler:`-Adresse prüfen.
|
||||
3. **Dry run** aktiviert lassen und **Shutdown** ausführen.
|
||||
4. In `shutdown-plan.json` bei der betroffenen Receive Location `AdapterName` und `Address` prüfen.
|
||||
5. Erst nach Planreview Dry-run deaktivieren, **Shutdown** erneut ausführen und bestätigen.
|
||||
6. Im Operation Log müssen für den Scheduler-Schritt mindestens folgende Inhalte erscheinen:
|
||||
- `ScheduledTask adapter preflight`
|
||||
- `ProcessBitness=` und `SearchDirectories=`
|
||||
- `ScheduledTask dependency loaded process-locally`, `resolved through CLR/GAC` oder `already loaded`
|
||||
- `Calling MSBTS_ReceiveLocation.Disable`
|
||||
- `Reached: Disable receive location completed`
|
||||
7. In `shutdown-result.json` muss der Schritt `Succeeded` oder bei bereits erreichtem Zustand `AlreadySatisfied` sein.
|
||||
8. Am Drain-Checkpoint Receive-Location-Ergebnisse prüfen, Group Hub/Monitoring leer laufen lassen und erst dann **Yes** wählen.
|
||||
9. Nach der Wartung **Restore** zunächst im Dry-run, danach real ausführen.
|
||||
10. Entsprechend `Calling MSBTS_ReceiveLocation.Enable`, den erreichten Zustand und `Succeeded`/`AlreadySatisfied` prüfen.
|
||||
11. **Snapshot After** und **Compare** ausführen; die Receive Location muss dem gespeicherten Sollzustand entsprechen.
|
||||
|
||||
## Logging-Test über Neustart
|
||||
|
||||
1. Einen erkennbaren Diagnose- oder Dry-run-Lauf durchführen und Uhrzeit notieren.
|
||||
2. Tool regulär schließen und erneut starten.
|
||||
3. Das Operation Log muss die Einträge des vorherigen Prozesses mit vollständigem Datum und Uhrzeit wieder anzeigen.
|
||||
4. **Clear** leert nur das Grid. Nach erneutem Programmstart wird die aufbewahrte Historie wieder geladen.
|
||||
5. **Log Folder** muss den lokalen Ordner öffnen.
|
||||
6. Die aktuelle Tagesdatei heißt `BizTalkPlatformManagementTool-yyyy-MM-dd.log` und enthält den bei diesem Start erzeugten Verifikationseintrag.
|
||||
7. Nach dem ersten Start an einem Folgetag wird der abgeschlossene Vortag zu `.log.gz` komprimiert.
|
||||
8. Aktueller Tag plus 29 Vortage bleiben erhalten. Einträge außerhalb dieses Fensters werden beim Start entfernt.
|
||||
9. Das Grid lädt höchstens die neuesten 10.000 Einträge; die 30-Tage-Dateien bleiben davon unabhängig vollständig erhalten.
|
||||
|
||||
ProgramData ist ein separates, üblicherweise ausgeblendetes Windows-Verzeichnis. Im Installationsordner unter Program Files wird im Normalfall kein Log erwartet. Version 2.3.1 prüft ProgramData durch einen echten Schreibzugriff; danach folgen LocalAppData, ein `Logs`-Unterordner im Installationsverzeichnis und Temp. Jeder Fallback oder vollständige Ausfall muss im Grid mit dem betroffenen Pfad und der Exception sichtbar sein.
|
||||
|
||||
## Fehlerfall und Supportpaket
|
||||
|
||||
Bei einem Fehler keine Assembly austauschen und den GAC nicht spontan verändern. Folgende unveränderte Evidenz sichern:
|
||||
|
||||
1. Aktuelle `.log` sowie relevante `.log.gz` aus dem über **Log Folder** geöffneten Ordner.
|
||||
2. `shutdown-plan.json` oder `restore-plan.json`.
|
||||
3. `shutdown-result.json`, `restore-result.json` oder den timestamp-basierten Emergency-Report.
|
||||
4. `before.json` und vorhandenen Nachher-Snapshot.
|
||||
5. `BizTalkPlatformManagementTool.exe.config`.
|
||||
6. Screenshot des vollständigen roten Grid-Eintrags und der Umgebung.
|
||||
7. Dateieigenschaften/Version von `Microsoft.BizTalk.Scheduler.dll`; die Datei selbst nur nach interner Freigabe übermitteln.
|
||||
|
||||
Der Fehlerdatensatz enthält Exceptiontyp, HRESULT, innere Ausnahmen, vorhandenes Fusion-Loaderprotokoll, Stacktrace, angeforderte Assembly, anfordernde Assembly und alle geprüften Suchpfade. Damit lässt sich unterscheiden zwischen fehlendem Pfad, falscher BizTalk-Version, nicht passender Strong-Name-Identität, Bitness-/Abhängigkeitsproblem und eigentlichem WMI-Fehler.
|
||||
|
||||
## Abnahmekriterien
|
||||
|
||||
- ScheduledTask-Receive-Location lässt sich real deaktivieren und wieder auf den Snapshotzustand aktivieren.
|
||||
- Andere Receive Locations bleiben unverändert funktionsfähig und benötigen keinen Scheduler-Preflight.
|
||||
- Ein einzelner Fehler bleibt `Failed`, verhindert aber keine späteren unabhängigen Planschritte.
|
||||
- Ergebnisreport und Nachher-Snapshot werden auch bei einem Teilfehler soweit möglich geschrieben.
|
||||
- Historisches Log erscheint nach Neustart wieder im Grid.
|
||||
- Vortagslogs werden komprimiert und exakt 30 Kalendertage aufbewahrt.
|
||||
- Setup, Tool und Ergebnisdateien melden Version 2.3.4 beziehungsweise `2.3.4-net461`.
|
||||
|
||||
Die lokale Mono-Toolchain prüft Resolverlogik, Identitätsgrenze, Persistenz, Kompression und Aufbewahrung ohne BizTalk. Die endgültige Freigabe erfordert diesen realen Windows-/BizTalk-/PROD-Test.
|
||||
@@ -0,0 +1,57 @@
|
||||
# PROD-Analyse: Shutdown-Dialog nicht sichtbar
|
||||
|
||||
**Datum:** 27.08.2026
|
||||
|
||||
**Zielversion:** 2.3.4
|
||||
|
||||
**Befund:** Nach der Receive-Location-Phase wurde kein sichtbarer Dialog zur Bestätigung des Leerlaufens wahrgenommen.
|
||||
|
||||
## Ergebnis der Ursachenanalyse
|
||||
|
||||
Der fachliche Checkpoint war in Version 2.3.3 vorhanden: Jeder Shutdown-Plan mit nachgelagerter Arbeit enthält genau eine persistierte `OperatorCheckpoint`-Zeile vor Orchestrierungen, Send Ports und lokalen Host Instances. Ohne Callback, bei einem Fehler oder bei **Nein** stoppt der Executor fail-closed; keine geschützte spätere Phase wird ausgeführt.
|
||||
|
||||
Die Oberfläche hatte aber zwei voneinander unabhängige Sichtbarkeitsprobleme:
|
||||
|
||||
1. **Dry run ist standardmäßig aktiv.** In diesem Modus wird keine Receive Location deaktiviert. Deshalb wird der echte Entscheidungsdialog absichtlich nicht aufgerufen; nur die Checkpoint-Zeile wird simuliert. Der kleine Haken und der generische Status machten diesen Unterschied während der Ausführung nicht eindeutig.
|
||||
2. **Die Bestätigungen hatten keinen Fenster-Owner.** `MessageBox.Show(...)` wurde aus dem UI-Thread aufgerufen, aber nicht an das Hauptformular gebunden. Unter RDP, nach Monitorwechseln oder bei abweichender Z-Order konnte der modale Dialog hinter dem Hauptfenster beziehungsweise außerhalb des erwarteten Vordergrunds liegen. Der Background-Worker wartete dann korrekt auf `Invoke`, während das Hauptfenster weiterhin nur `Preparing shutdown...` zeigte und deaktiviert wirkte.
|
||||
|
||||
Der Screenshot allein unterscheidet die beiden Fälle nicht, weil der Einstellungsbereich mit **Dry run** nicht sichtbar und kein `shutdown-result.json` beigefügt ist. Der sichtbare Zustand `Preparing shutdown...` bei bereits dargestelltem Plan ist jedoch mit einem wartenden, owner-losen Plan- oder Drain-Dialog vereinbar. Ein abgeschlossenes `DryRun=true` mit leerer `CheckpointDecision` belegt dagegen die beabsichtigte Simulation.
|
||||
|
||||
## Korrektur in 2.3.4
|
||||
|
||||
- Planfreigabe, Drain-Entscheidung und Emergency-Restore-Bestätigung verwenden das Hauptformular explizit als Owner und holen es vor dem Anzeigen nach vorn.
|
||||
- Unmittelbar vor der echten Drain-Entscheidung meldet die Statuszeile: `ACTION REQUIRED: Shutdown paused`.
|
||||
- Der Titel des Checkpoints beginnt mit `ACTION REQUIRED`; der Text erklärt, dass der Shutdown pausiert ist und **Nein oder Schließen** sicher stoppt.
|
||||
- Die erste Freigabe eines echten Shutdowns kündigt den zweiten Dialog nach der Receive-Location-Phase ausdrücklich an.
|
||||
- Dry-run und Realbetrieb haben gut sichtbare, farblich getrennte Texte. Während einer Operation sind diese Einstellungen gesperrt.
|
||||
- Ein Shutdown-Dry-run zeigt einen eigenen owner-gebundenen Hinweis: keine Runtime-Änderung, keine deaktivierte Receive Location und daher keine echte Drain-Entscheidung.
|
||||
|
||||
Die Sicherheitssemantik bleibt unverändert: Das Tool behauptet keinen automatisch erkannten Leerlauf. Nur der Operator kann nach Prüfung von Group Hub und Enterprise-Monitoring mit **Ja** fortsetzen.
|
||||
|
||||
## Diagnose vorhandener 2.3.2/2.3.3-Läufe
|
||||
|
||||
`shutdown-result.json` und `shutdown-plan.json` sichern und wie folgt bewerten:
|
||||
|
||||
| Evidenz | Bedeutung |
|
||||
|---|---|
|
||||
| `DryRun=true`, Checkpoint-Outcome `DryRun`, keine `CheckpointDecision` | Erwartete Simulation; es gab keine Runtime-Änderung und bewusst keinen Entscheidungsdialog. |
|
||||
| Kein Ergebnisreport, UI bleibt bei `Preparing shutdown...` | Lauf wartet möglicherweise auf einen verdeckten Plan- oder Drain-Dialog; Taskwechsel/Alt+Tab prüfen. Prozess nicht blind beenden. |
|
||||
| `DryRun=false`, `CheckpointDecision=Stop` | Operator hat Nein gewählt oder sicher gestoppt; spätere Zeilen müssen `NotExecuted` sein. |
|
||||
| `DryRun=false`, `CheckpointDecision=Error` | Dialogmechanismus fehlte/fehlerhaft; fail-closed, spätere Zeilen müssen `NotExecuted` sein. |
|
||||
| `DryRun=false`, `CheckpointDecision=Continue` | Eine positive Entscheidung wurde erfasst; spätere Phasen durften laufen. |
|
||||
| Plan ohne `OperatorCheckpoint` | Nur zulässig, wenn keine Orchestrierung, kein Send Port und keine lokale Host Instance nachgelagert herunterzufahren war. |
|
||||
|
||||
## PROD-Abnahme 2.3.4
|
||||
|
||||
1. Setup 2.3.4 als Administrator installieren und im Setup-Log `setup_version=2.3.4.0` sowie den erfolgreichen Ziel-Self-Test prüfen.
|
||||
2. Tooldateiversion und Self-Test-Ausgabe `2.3.4-net461` prüfen.
|
||||
3. **Dry run** aktiviert lassen, **Shutdown** wählen und den Hinweis `Shutdown Dry Run - No Runtime Changes` prüfen. Es darf keine BizTalk-Mutation stattfinden.
|
||||
4. `shutdown-plan.json` prüfen: Bei späterer Shutdown-Arbeit steht `OperatorCheckpoint` vor Orchestrierungen, Send Ports und Host Instances.
|
||||
5. In einem freigegebenen Wartungsfenster **Dry run** deaktivieren. Der Modus muss `REAL EXECUTION - drain dialog required` anzeigen.
|
||||
6. Den gespeicherten Plan im ersten owner-gebundenen Dialog bestätigen.
|
||||
7. Nach den Receive Locations muss die Statuszeile `ACTION REQUIRED` zeigen und der Dialog `ACTION REQUIRED - Confirm BizTalk Inbound Drain` vor dem Hauptfenster stehen.
|
||||
8. Zuerst **Nein** testen. `shutdown-result.json` muss `CheckpointDecision=Stop` und für alle späteren Zeilen `NotExecuted` enthalten.
|
||||
9. Den kontrollierten Test wiederholen, Group Hub/Monitoring prüfen und erst nach bestätigtem Leerlauf **Ja** wählen. Danach dürfen Orchestrierungen, Send Ports und Host Instances folgen.
|
||||
10. RDP minimieren/wiederherstellen und, falls im Betrieb üblich, Monitorwechsel testen. Der owner-gebundene Dialog muss dem Hauptfenster zugeordnet bleiben.
|
||||
|
||||
Die portable Verifikation umfasst Release-Build aller vier Projekte, 43 Regressionstests, Runtime-Self-Test und die manifest-/hashgeprüfte Paketierung. Die abschließende Sichtbarkeits- und BizTalk-Abnahme bleibt ein Windows-/PROD-Test.
|
||||
@@ -0,0 +1,81 @@
|
||||
# PROD-Runbook: Shutdown-Drain-Checkpoint und Application-Status
|
||||
|
||||
**Stand:** 2026-08-26
|
||||
|
||||
**Zielversion:** 2.3.2
|
||||
|
||||
## Ziel
|
||||
|
||||
Nach dem Abschalten aller zuvor aktivierten Receive Locations muss BizTalk Zeit erhalten, bereits angenommene Nachrichten und laufende Service Instances kontrolliert zu verarbeiten. Version 2.3.2 hält deshalb vor Orchestrierungen, Send Ports und Host Instances an und verlangt eine explizite Operatorentscheidung.
|
||||
|
||||
Der Checkpoint ist als `OperatorCheckpoint` in `shutdown-plan.json` gespeichert. Er ist kein automatischer Nachweis, dass die Umgebung leer ist. Die Entscheidung stützt sich auf BizTalk Group Hub und die in der Enterprise-Umgebung vorhandenen Queue-, MessageBox-, Prozess- und Schnittstellenmetriken.
|
||||
|
||||
## Warum `Partially Started` erwartbar ist
|
||||
|
||||
Microsoft beschreibt **Partial Stop - Allow running instances to continue** als Deaktivieren der Receive Locations bei unverändert laufenden übrigen Artefakten. Genau dieser Zwischenzustand ermöglicht das Leerfahren und wird in der Administration Console erwartbar als teilweise gestartet sichtbar.
|
||||
|
||||
Ein pauschaler Application-Stop wird nicht ergänzt. Je nach ausgewähltem BizTalk-Modus würde er zusätzlich Orchestrierungen und Send Ports stoppen, Subscriptions entfernen, Artefakte unenlisten, Policies undeployen oder laufende Instanzen terminieren. Das wäre keine kosmetische Statuskorrektur und könnte die gerade gewünschte Drain-Phase abbrechen. Microsoft empfiehlt einen Full Stop nur zum Entfernen oder erneuten Bereitstellen einer Anwendung.
|
||||
|
||||
Quellen:
|
||||
|
||||
- [How to Start and Stop a BizTalk Application](https://learn.microsoft.com/en-us/biztalk/core/how-to-start-and-stop-a-biztalk-application)
|
||||
- [Stop Application Dialog Box](https://learn.microsoft.com/en-us/biztalk/core/technical-reference/stop-application-dialog-box)
|
||||
- [Restart services or shut down BizTalk Server](https://learn.microsoft.com/en-us/biztalk/core/how-to-start-stop-pause-resume-or-restart-biztalk-server-services)
|
||||
|
||||
## Dry-run und Planreview
|
||||
|
||||
1. Version 2.3.2 installieren und `setup_version=2.3.2.0` sowie erfolgreichen Ziel-Self-Test prüfen.
|
||||
2. **Diagnose** und **Snapshot Before** ausführen.
|
||||
3. **Dry run** aktiviert lassen und **Shutdown** wählen.
|
||||
4. In `shutdown-plan.json` die globale Reihenfolge prüfen:
|
||||
- alle `ReceiveLocation`-Zeilen,
|
||||
- genau ein `OperatorCheckpoint`, sofern spätere Shutdownarbeit existiert,
|
||||
- Orchestrierungen,
|
||||
- Send Ports,
|
||||
- Host Instances.
|
||||
5. Dry-run darf keinen Entscheidungsdialog öffnen; der Checkpoint erscheint als `DryRun`.
|
||||
|
||||
## Echter Shutdown
|
||||
|
||||
1. Dry-run deaktivieren, den gespeicherten Gesamtplan bestätigen und Shutdown starten.
|
||||
2. Die Receive-Location-Ergebnisse im Operation Log beobachten. Ein Scheduler-Fehler bleibt rot und wird im Checkpoint gezählt.
|
||||
3. Beim Dialog **Confirm BizTalk Inbound Drain** zunächst nichts wählen. Der Dialog darf während der gesamten Leerfahrzeit geöffnet bleiben.
|
||||
4. Mindestens prüfen:
|
||||
- keine neuen eingehenden Nachrichten an den abgeschalteten Schnittstellen,
|
||||
- Group Hub: laufende Service Instances entwickeln sich kontrolliert gegen null,
|
||||
- keine unerwarteten suspended/resumable Instances,
|
||||
- relevante MessageBox-/Queue-/Adapter- und Fremdsystemmetriken sind leer beziehungsweise stabil,
|
||||
- fachlich mehrteilige Prozesse haben alle benötigten Eingaben erhalten.
|
||||
5. Bei leer gelaufener und fehlerfreier Umgebung **Yes** wählen. Erst dann folgen Orchestrierungen, Send Ports und Host Instances.
|
||||
6. Bei Unsicherheit, Receive-Location-Fehlern oder weiter laufender Last **No** wählen. Das Tool verändert danach keine spätere Kategorie.
|
||||
|
||||
## Nachweis im Ergebnisreport
|
||||
|
||||
Bei **Yes**:
|
||||
|
||||
- Checkpointzeile: `Outcome=Confirmed`
|
||||
- `CheckpointDecision=Continue`
|
||||
- `OperatorStopped=false`
|
||||
|
||||
Bei **No**:
|
||||
|
||||
- Checkpointzeile: `Outcome=Declined`
|
||||
- `CheckpointDecision=Stop`
|
||||
- `OperatorStopped=true`
|
||||
- jede spätere Zeile: `Outcome=NotExecuted`
|
||||
- `NotExecutedCount` entspricht den geschützten Restzeilen
|
||||
|
||||
Bei fehlendem oder fehlerhaftem Bestätigungsmechanismus lautet die Entscheidung `Error`; der Checkpoint ist `Failed` und alle späteren Zeilen bleiben ebenfalls `NotExecuted`. In allen Fällen versucht das Tool anschließend `shutdown-after.json` und speichert `shutdown-result.json`.
|
||||
|
||||
## Abnahmekriterien
|
||||
|
||||
- Checkpoint steht im gespeicherten Plan exakt zwischen Receive Locations und Orchestrierungen.
|
||||
- Dry-run öffnet keinen echten Entscheidungsdialog.
|
||||
- Dialog verwendet **No** als sichere Standardauswahl.
|
||||
- **Yes** setzt ausschließlich die bereits gespeicherten späteren Schritte fort.
|
||||
- **No** und Dialogfehler führen zu keiner späteren WMI-Mutation.
|
||||
- Entscheidung, Zeitpunkt, Teilzustand und alle nicht ausgeführten Schritte sind in Grid, Log und Report nachvollziehbar.
|
||||
- Es wird kein zusätzlicher Application-Stop und insbesondere kein Full Stop ausgeführt.
|
||||
- Setup, Tool und neue Reports melden 2.3.2 beziehungsweise `2.3.2-net461`.
|
||||
|
||||
Die portable Toolchain prüft die Ablaufgrenzen ohne BizTalk. Die endgültige Freigabe benötigt einen Windows-/BizTalk-/PROD-Test mit den realen Enterprise-Monitoringquellen.
|
||||
@@ -23,7 +23,12 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
private const string ProductName = "BizTalk Platform Management Tool";
|
||||
|
||||
/// <summary>Aktuelle Produktversion des Installers und Uninstall-Eintrags.</summary>
|
||||
private const string ProductVersion = "2.1.2";
|
||||
private const string ProductVersion = "2.3.4";
|
||||
|
||||
/// <summary>
|
||||
/// Wartezeiten zwischen Wiederholungen atomarer Verzeichnisverschiebungen.
|
||||
/// </summary>
|
||||
private static readonly int[] DirectoryMoveRetryDelaysMilliseconds = { 250, 500, 1000, 2000, 3000, 5000, 8000 };
|
||||
|
||||
/// <summary>Maschinenweiter Registrypfad des Windows-Uninstall-Eintrags.</summary>
|
||||
private const string UninstallKeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BizTalkPlatformManagementTool";
|
||||
@@ -43,6 +48,12 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// <summary>Optional injizierte Self-Test-Funktion für portable Regressionstests.</summary>
|
||||
private readonly Func<string, bool> selfTestRunner;
|
||||
|
||||
/// <summary>Verschiebt Verzeichnisse produktiv oder über eine injizierte Regressionstest-Funktion.</summary>
|
||||
private readonly Action<string, string> directoryMover;
|
||||
|
||||
/// <summary>Wartet zwischen Move-Versuchen produktiv oder über eine injizierte Regressionstest-Funktion.</summary>
|
||||
private readonly Action<int> retryDelay;
|
||||
|
||||
/// <summary>Zuletzt tatsächlich verwendetes primäres oder temporäres Diagnoseverzeichnis.</summary>
|
||||
private string lastInstallerLogDirectory;
|
||||
|
||||
@@ -60,6 +71,9 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// <summary>Ruft den vorherigen Inhalt der Desktop-Verknüpfung ab oder legt ihn fest.</summary>
|
||||
public byte[] DesktopShortcut { get; set; }
|
||||
|
||||
/// <summary>Ruft ab oder legt fest, ob der optionale Desktop-Zustand sicher gelesen wurde.</summary>
|
||||
public bool DesktopShortcutCaptured { get; set; }
|
||||
|
||||
/// <summary>Ruft den vorherigen Inhalt der Startmenü-Verknüpfung ab oder legt ihn fest.</summary>
|
||||
public byte[] StartMenuShortcut { get; set; }
|
||||
|
||||
@@ -90,12 +104,36 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// <param name="registerWindowsIntegration"><c>true</c>, wenn Registry und Verknüpfungen verwaltet werden sollen.</param>
|
||||
/// <param name="selfTestRunner">Optionale Testfunktion für Regressionstests; <c>null</c> startet die reale EXE.</param>
|
||||
internal InstallerEngine(string packageDirectory, string installDirectory, string dataDirectory, bool registerWindowsIntegration, Func<string, bool> selfTestRunner)
|
||||
: this(packageDirectory, installDirectory, dataDirectory, registerWindowsIntegration, selfTestRunner, Directory.Move, System.Threading.Thread.Sleep)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialisiert den Installer mit zusätzlich austauschbarer Move- und Wartefunktion.
|
||||
/// </summary>
|
||||
/// <param name="packageDirectory">Das Verzeichnis mit Setup-Payload und Manifest.</param>
|
||||
/// <param name="installDirectory">Das aktive Programmverzeichnis.</param>
|
||||
/// <param name="dataDirectory">Das dauerhafte Daten- und Diagnoseverzeichnis.</param>
|
||||
/// <param name="registerWindowsIntegration"><c>true</c>, wenn Registry und Verknüpfungen verwaltet werden sollen.</param>
|
||||
/// <param name="selfTestRunner">Optionale Testfunktion für Regressionstests; <c>null</c> startet die reale EXE.</param>
|
||||
/// <param name="directoryMover">Austauschbare atomare Verzeichnisverschiebung.</param>
|
||||
/// <param name="retryDelay">Austauschbare Wartefunktion zwischen Wiederholungen.</param>
|
||||
internal InstallerEngine(
|
||||
string packageDirectory,
|
||||
string installDirectory,
|
||||
string dataDirectory,
|
||||
bool registerWindowsIntegration,
|
||||
Func<string, bool> selfTestRunner,
|
||||
Action<string, string> directoryMover,
|
||||
Action<int> retryDelay)
|
||||
{
|
||||
this.packageDirectory = Path.GetFullPath(packageDirectory);
|
||||
this.installDirectory = Path.GetFullPath(installDirectory);
|
||||
this.dataDirectory = Path.GetFullPath(dataDirectory);
|
||||
this.registerWindowsIntegration = registerWindowsIntegration;
|
||||
this.selfTestRunner = selfTestRunner;
|
||||
this.directoryMover = directoryMover ?? throw new ArgumentNullException("directoryMover");
|
||||
this.retryDelay = retryDelay ?? throw new ArgumentNullException("retryDelay");
|
||||
}
|
||||
|
||||
/// <summary>Ruft das feste maschinenweite Programmverzeichnis ab.</summary>
|
||||
@@ -120,6 +158,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
var uiReport = report ?? delegate { };
|
||||
var log = SetupOperationLog.Create(dataDirectory, "install-update");
|
||||
Action<string> write = message => ReportSafely(log, uiReport, "INFO", message);
|
||||
Action<string> warn = message => ReportSafely(log, uiReport, "WARN", message);
|
||||
if (!string.IsNullOrEmpty(log.CreationError))
|
||||
write((log.IsFallback ? "WARNUNG: Primaeres Diagnoselog nicht verfuegbar; Temp-Fallback wird verwendet: " : "WARNUNG: Diagnoselog konnte nicht angelegt werden: ") + log.CreationError);
|
||||
if (log.FilePath.Length != 0)
|
||||
@@ -138,7 +177,9 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
WindowsIntegrationSnapshot integrationSnapshot = null;
|
||||
var backupCreated = false;
|
||||
var activated = false;
|
||||
var activationUsedCopyFallback = false;
|
||||
var integrationMutationStarted = false;
|
||||
var optionalDesktopShortcutWarning = false;
|
||||
var phaseCode = "SETUP-INITIALIZATION";
|
||||
var phase = "Initialisierung";
|
||||
|
||||
@@ -161,13 +202,17 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
log.WriteFileDetails("setup_executable", Assembly.GetExecutingAssembly().Location);
|
||||
log.WriteFileDetails("existing_application", Path.Combine(installDirectory, ApplicationExeName));
|
||||
// Der vollständige Integrationszustand wird vor der ersten Mutation gesichert.
|
||||
integrationSnapshot = registerWindowsIntegration ? CaptureWindowsIntegration() : null;
|
||||
integrationSnapshot = registerWindowsIntegration ? CaptureWindowsIntegration(log, warn) : null;
|
||||
if (integrationSnapshot != null)
|
||||
{
|
||||
optionalDesktopShortcutWarning = !integrationSnapshot.DesktopShortcutCaptured;
|
||||
log.Write("INFO", "event=integration_snapshot registry_key_existed=" + integrationSnapshot.RegistryKeyExisted
|
||||
+ " registry_value_count=" + integrationSnapshot.RegistryValues.Count
|
||||
+ " desktop_shortcut_captured=" + integrationSnapshot.DesktopShortcutCaptured
|
||||
+ " desktop_shortcut=" + (integrationSnapshot.DesktopShortcut != null)
|
||||
+ " start_menu_shortcut=" + (integrationSnapshot.StartMenuShortcut != null)
|
||||
+ " uninstaller=" + (integrationSnapshot.Uninstaller != null));
|
||||
}
|
||||
|
||||
phaseCode = "SETUP-PACKAGE-VALIDATION";
|
||||
phase = "Paketmanifest und SHA-256 pruefen";
|
||||
@@ -195,14 +240,33 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
if (hadExistingInstallation)
|
||||
{
|
||||
log.Write("INFO", "event=directory_move role=backup source=\"" + installDirectory + "\" target=\"" + backupDirectory + "\"");
|
||||
Directory.Move(installDirectory, backupDirectory);
|
||||
MoveDirectoryWithRetry(installDirectory, backupDirectory, "backup", log);
|
||||
backupCreated = true;
|
||||
log.Write("INFO", "event=directory_move_complete role=backup");
|
||||
}
|
||||
log.Write("INFO", "event=directory_move role=activate source=\"" + stagingDirectory + "\" target=\"" + installDirectory + "\"");
|
||||
Directory.Move(stagingDirectory, installDirectory);
|
||||
try
|
||||
{
|
||||
MoveDirectoryWithRetry(stagingDirectory, installDirectory, "activate", log);
|
||||
activated = true;
|
||||
log.Write("INFO", "event=directory_move_complete role=activate");
|
||||
log.Write("INFO", "event=directory_move_complete role=activate method=atomic_move");
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
EnsureVerifiedCopyActivationIsSafe(hadExistingInstallation, backupCreated, installDirectory);
|
||||
// Bei einem Update bleibt die Vorversion vollständig im atomar erzeugten
|
||||
// Backup erhalten. Dadurch ist auch eine teilweise Zielkopie rückrollbar.
|
||||
activated = true;
|
||||
ActivateByVerifiedCopy(stagingDirectory, installDirectory, files, hadExistingInstallation, ex, log);
|
||||
activationUsedCopyFallback = true;
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
EnsureVerifiedCopyActivationIsSafe(hadExistingInstallation, backupCreated, installDirectory);
|
||||
activated = true;
|
||||
ActivateByVerifiedCopy(stagingDirectory, installDirectory, files, hadExistingInstallation, ex, log);
|
||||
activationUsedCopyFallback = true;
|
||||
}
|
||||
|
||||
phaseCode = "SETUP-ACTIVATED-SELFTEST";
|
||||
phase = "Aktivierte Version erneut pruefen";
|
||||
@@ -222,18 +286,27 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
if (registerWindowsIntegration)
|
||||
{
|
||||
integrationMutationStarted = true;
|
||||
RegisterWindowsIntegration(targetExe, createDesktopShortcut);
|
||||
ValidateWindowsIntegration(targetExe, createDesktopShortcut, log);
|
||||
var desktopConfigured = RegisterWindowsIntegration(targetExe, createDesktopShortcut, log, warn);
|
||||
var desktopValidated = ValidateWindowsIntegration(targetExe, createDesktopShortcut, log, warn);
|
||||
optionalDesktopShortcutWarning = optionalDesktopShortcutWarning || !desktopConfigured || !desktopValidated;
|
||||
}
|
||||
|
||||
phaseCode = "SETUP-CLEANUP";
|
||||
phase = "Backup bereinigen";
|
||||
write("Phase 6/6: " + phase + ".");
|
||||
var backupCleanupSucceeded = TryDeleteDirectory(backupDirectory, write);
|
||||
var stagingCleanupSucceeded = TryDeleteDirectory(stagingDirectory, write);
|
||||
var cleanupSucceeded = backupCleanupSucceeded && stagingCleanupSucceeded;
|
||||
var completionResult = cleanupSucceeded
|
||||
? (optionalDesktopShortcutWarning ? "success_with_optional_desktop_shortcut_warning" : "success")
|
||||
: (optionalDesktopShortcutWarning ? "success_with_multiple_warnings" : "success_with_temporary_cleanup_warning");
|
||||
log.Write(
|
||||
backupCleanupSucceeded ? "INFO" : "WARN",
|
||||
"event=setup_completed result=" + (backupCleanupSucceeded ? "success" : "success_with_backup_cleanup_warning")
|
||||
cleanupSucceeded && !optionalDesktopShortcutWarning ? "INFO" : "WARN",
|
||||
"event=setup_completed result=" + completionResult
|
||||
+ " backup_directory_preserved=" + Directory.Exists(backupDirectory)
|
||||
+ " staging_directory_preserved=" + Directory.Exists(stagingDirectory)
|
||||
+ " optional_desktop_shortcut_warning=" + optionalDesktopShortcutWarning
|
||||
+ " activation_method=" + (activationUsedCopyFallback ? "verified_copy_fallback" : "atomic_move")
|
||||
+ " install_directory=\"" + installDirectory + "\"");
|
||||
write("Installation/Update erfolgreich abgeschlossen: " + installDirectory);
|
||||
write("Technische Installationsabnahme erfolgreich. BizTalk-WMI wurde bewusst nicht als Installerkriterium verwendet; bitte anschliessend in der Anwendung 'Diagnose' und einen Dry-run ausfuehren.");
|
||||
@@ -264,7 +337,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
if (backupCreated && Directory.Exists(backupDirectory))
|
||||
{
|
||||
log.Write("WARN", "event=rollback_step step=restore_backup source=\"" + backupDirectory + "\" target=\"" + installDirectory + "\"");
|
||||
Directory.Move(backupDirectory, installDirectory);
|
||||
MoveDirectoryWithRetry(backupDirectory, installDirectory, "rollback_restore_backup", log);
|
||||
}
|
||||
write(backupCreated ? "Rollback: vorherige Programmversion wiederhergestellt." : "Rollback: unvollstaendige Neuinstallation entfernt.");
|
||||
log.Write("WARN", "event=rollback_step_complete step=files result=success");
|
||||
@@ -281,7 +354,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
if (registerWindowsIntegration && integrationSnapshot != null)
|
||||
{
|
||||
log.Write("WARN", "event=rollback_step step=restore_windows_integration");
|
||||
RestoreWindowsIntegration(integrationSnapshot);
|
||||
RestoreWindowsIntegration(integrationSnapshot, log, warn);
|
||||
log.Write("WARN", "event=rollback_step_complete step=windows_integration result=success");
|
||||
}
|
||||
}
|
||||
@@ -321,6 +394,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
var uiReport = report ?? delegate { };
|
||||
var log = SetupOperationLog.Create(dataDirectory, "uninstall");
|
||||
Action<string> write = message => ReportSafely(log, uiReport, "INFO", message);
|
||||
Action<string> warn = message => ReportSafely(log, uiReport, "WARN", message);
|
||||
if (!string.IsNullOrEmpty(log.CreationError))
|
||||
write((log.IsFallback ? "WARNUNG: Primaeres Diagnoselog nicht verfuegbar; Temp-Fallback wird verwendet: " : "WARNUNG: Diagnoselog konnte nicht angelegt werden: ") + log.CreationError);
|
||||
if (log.FilePath.Length != 0)
|
||||
@@ -329,6 +403,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
write("Diagnoselog: " + log.FilePath);
|
||||
}
|
||||
WindowsIntegrationSnapshot integrationSnapshot = null;
|
||||
var optionalDesktopShortcutWarning = false;
|
||||
var removalDirectory = installDirectory + ".removed." + Guid.NewGuid().ToString("N");
|
||||
var filesMoved = false;
|
||||
var phaseCode = "UNINSTALL-INITIALIZATION";
|
||||
@@ -338,7 +413,9 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
Directory.CreateDirectory(dataDirectory);
|
||||
log.Write("INFO", "event=uninstall_context install_directory=\"" + installDirectory + "\" removal_directory=\"" + removalDirectory + "\" data_directory=\"" + dataDirectory + "\"");
|
||||
log.WriteFileDetails("installed_application", Path.Combine(installDirectory, ApplicationExeName));
|
||||
integrationSnapshot = registerWindowsIntegration ? CaptureWindowsIntegration() : null;
|
||||
integrationSnapshot = registerWindowsIntegration ? CaptureWindowsIntegration(log, warn) : null;
|
||||
if (integrationSnapshot != null)
|
||||
optionalDesktopShortcutWarning = !integrationSnapshot.DesktopShortcutCaptured;
|
||||
|
||||
phaseCode = "UNINSTALL-RUNNING-APPLICATION";
|
||||
phase = "Laufende Anwendung ausschliessen";
|
||||
@@ -353,7 +430,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
if (Directory.Exists(installDirectory))
|
||||
{
|
||||
log.Write("INFO", "event=directory_move role=uninstall_quarantine source=\"" + installDirectory + "\" target=\"" + removalDirectory + "\"");
|
||||
Directory.Move(installDirectory, removalDirectory);
|
||||
MoveDirectoryWithRetry(installDirectory, removalDirectory, "uninstall_quarantine", log);
|
||||
filesMoved = true;
|
||||
log.Write("INFO", "event=directory_move_complete role=uninstall_quarantine");
|
||||
}
|
||||
@@ -361,10 +438,14 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
phaseCode = "UNINSTALL-WINDOWS-INTEGRATION";
|
||||
phase = "Windows-Integration entfernen";
|
||||
write("Phase 3/3: " + phase + ".");
|
||||
if (registerWindowsIntegration) RemoveWindowsIntegration(log);
|
||||
optionalDesktopShortcutWarning = optionalDesktopShortcutWarning || (registerWindowsIntegration && !RemoveWindowsIntegration(log, warn));
|
||||
var cleanupSucceeded = TryDeleteDirectory(removalDirectory, write);
|
||||
log.Write("INFO", "event=uninstall_completed result=" + (cleanupSucceeded ? "success" : "success_with_quarantine_cleanup_warning")
|
||||
+ " removal_directory_preserved=" + Directory.Exists(removalDirectory));
|
||||
var completionResult = cleanupSucceeded
|
||||
? (optionalDesktopShortcutWarning ? "success_with_optional_desktop_shortcut_warning" : "success")
|
||||
: (optionalDesktopShortcutWarning ? "success_with_multiple_warnings" : "success_with_quarantine_cleanup_warning");
|
||||
log.Write(cleanupSucceeded && !optionalDesktopShortcutWarning ? "INFO" : "WARN", "event=uninstall_completed result=" + completionResult
|
||||
+ " removal_directory_preserved=" + Directory.Exists(removalDirectory)
|
||||
+ " optional_desktop_shortcut_warning=" + optionalDesktopShortcutWarning);
|
||||
write("Deinstallation erfolgreich. Installer-Logs bleiben erhalten: " + Path.Combine(dataDirectory, "InstallerLogs"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -375,7 +456,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Move(removalDirectory, installDirectory);
|
||||
MoveDirectoryWithRetry(removalDirectory, installDirectory, "uninstall_rollback_restore", log);
|
||||
log.Write("WARN", "event=uninstall_rollback_step step=restore_program_directory result=success");
|
||||
}
|
||||
catch (Exception rollbackException)
|
||||
@@ -388,7 +469,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
{
|
||||
try
|
||||
{
|
||||
RestoreWindowsIntegration(integrationSnapshot);
|
||||
RestoreWindowsIntegration(integrationSnapshot, log, warn);
|
||||
log.Write("WARN", "event=uninstall_rollback_step step=restore_windows_integration result=success");
|
||||
}
|
||||
catch (Exception rollbackException)
|
||||
@@ -411,14 +492,26 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// </summary>
|
||||
/// <param name="targetExe">Der vollständige Pfad der aktivierten Anwendung.</param>
|
||||
/// <param name="createDesktopShortcut"><c>true</c>, wenn eine Desktop-Verknüpfung gewünscht ist.</param>
|
||||
private void RegisterWindowsIntegration(string targetExe, bool createDesktopShortcut)
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
/// <param name="warn">Die ausfallsichere Bedienerwarnung.</param>
|
||||
/// <returns><c>true</c>, wenn der optionale Desktop-Zustand ohne Fehler gesetzt wurde.</returns>
|
||||
private bool RegisterWindowsIntegration(string targetExe, bool createDesktopShortcut, SetupOperationLog log, Action<string> warn)
|
||||
{
|
||||
var programsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms), ProductName);
|
||||
Directory.CreateDirectory(programsDirectory);
|
||||
CreateShortcut(Path.Combine(programsDirectory, ProductName + ".lnk"), targetExe, installDirectory, ProductName);
|
||||
|
||||
var desktopConfigured = TryOptionalWindowsIntegrationStep(
|
||||
createDesktopShortcut ? "desktop_shortcut_create" : "desktop_shortcut_remove",
|
||||
"Desktop-Verknuepfung fuer alle Benutzer " + (createDesktopShortcut ? "erstellen" : "entfernen"),
|
||||
DesktopShortcutPath,
|
||||
() =>
|
||||
{
|
||||
if (createDesktopShortcut) CreateShortcut(DesktopShortcutPath, targetExe, installDirectory, ProductName);
|
||||
else if (File.Exists(DesktopShortcutPath)) File.Delete(DesktopShortcutPath);
|
||||
else DeleteFileIfExists(DesktopShortcutPath);
|
||||
},
|
||||
log,
|
||||
warn);
|
||||
|
||||
var setupDirectory = Path.Combine(dataDirectory, "Setup");
|
||||
Directory.CreateDirectory(setupDirectory);
|
||||
@@ -437,25 +530,40 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
key.SetValue("NoModify", 1, RegistryValueKind.DWord);
|
||||
key.SetValue("NoRepair", 1, RegistryValueKind.DWord);
|
||||
}
|
||||
return desktopConfigured;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entfernt und verifiziert die vom Setup verwaltete Windows-Integration.
|
||||
/// </summary>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
private void RemoveWindowsIntegration(SetupOperationLog log)
|
||||
/// <param name="warn">Die ausfallsichere Bedienerwarnung.</param>
|
||||
/// <returns><c>true</c>, wenn der optionale Desktop-Link entfernt oder bereits nicht vorhanden war.</returns>
|
||||
private bool RemoveWindowsIntegration(SetupOperationLog log, Action<string> warn)
|
||||
{
|
||||
var desktopRemoved = TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_uninstall_remove",
|
||||
"Desktop-Verknuepfung fuer alle Benutzer bei der Deinstallation entfernen",
|
||||
DesktopShortcutPath,
|
||||
() =>
|
||||
{
|
||||
DeleteFileIfExists(DesktopShortcutPath);
|
||||
if (File.Exists(DesktopShortcutPath))
|
||||
throw new InvalidOperationException("Desktop shortcut still exists after removal.");
|
||||
},
|
||||
log,
|
||||
warn);
|
||||
var programsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms), ProductName);
|
||||
DeleteFileIfExists(Path.Combine(programsDirectory, ProductName + ".lnk"));
|
||||
if (Directory.Exists(programsDirectory) && Directory.GetFileSystemEntries(programsDirectory).Length == 0) Directory.Delete(programsDirectory);
|
||||
Registry.LocalMachine.DeleteSubKeyTree(UninstallKeyPath, false);
|
||||
using (var remainingKey = Registry.LocalMachine.OpenSubKey(UninstallKeyPath, false))
|
||||
{
|
||||
if (File.Exists(DesktopShortcutPath) || File.Exists(StartMenuShortcutPath) || remainingKey != null)
|
||||
if (File.Exists(StartMenuShortcutPath) || remainingKey != null)
|
||||
throw new InvalidOperationException("Windows integration removal verification failed.");
|
||||
}
|
||||
log.Write("INFO", "event=windows_integration_removed registry_key=\"HKLM\\" + UninstallKeyPath + "\"");
|
||||
log.Write("INFO", "event=windows_integration_removed registry_key=\"HKLM\\" + UninstallKeyPath + "\" optional_desktop_shortcut_removed=" + desktopRemoved);
|
||||
return desktopRemoved;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -494,16 +602,24 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// <summary>
|
||||
/// Liest Registrywerte, Verknüpfungen und Uninstaller vor einer möglichen Mutation ein.
|
||||
/// </summary>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
/// <param name="warn">Die ausfallsichere Bedienerwarnung.</param>
|
||||
/// <returns>Ein wiederherstellbarer Snapshot der Windows-Integration.</returns>
|
||||
private WindowsIntegrationSnapshot CaptureWindowsIntegration()
|
||||
private WindowsIntegrationSnapshot CaptureWindowsIntegration(SetupOperationLog log, Action<string> warn)
|
||||
{
|
||||
var snapshot = new WindowsIntegrationSnapshot
|
||||
{
|
||||
RegistryValues = new Dictionary<string, Tuple<object, RegistryValueKind>>(StringComparer.OrdinalIgnoreCase),
|
||||
DesktopShortcut = ReadFileOrNull(DesktopShortcutPath),
|
||||
StartMenuShortcut = ReadFileOrNull(StartMenuShortcutPath),
|
||||
Uninstaller = ReadFileOrNull(UninstallerPath)
|
||||
};
|
||||
snapshot.DesktopShortcutCaptured = TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_snapshot",
|
||||
"vorhandene Desktop-Verknuepfung fuer alle Benutzer sichern",
|
||||
DesktopShortcutPath,
|
||||
() => snapshot.DesktopShortcut = ReadFileOrNull(DesktopShortcutPath),
|
||||
log,
|
||||
warn);
|
||||
using (var key = Registry.LocalMachine.OpenSubKey(UninstallKeyPath, false))
|
||||
{
|
||||
snapshot.RegistryKeyExisted = key != null;
|
||||
@@ -522,7 +638,9 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// Stellt einen zuvor erfassten Zustand der Windows-Integration wieder her.
|
||||
/// </summary>
|
||||
/// <param name="snapshot">Der wiederherzustellende Integrationszustand.</param>
|
||||
private void RestoreWindowsIntegration(WindowsIntegrationSnapshot snapshot)
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
/// <param name="warn">Die ausfallsichere Bedienerwarnung.</param>
|
||||
private void RestoreWindowsIntegration(WindowsIntegrationSnapshot snapshot, SetupOperationLog log, Action<string> warn)
|
||||
{
|
||||
if (snapshot == null) return;
|
||||
Registry.LocalMachine.DeleteSubKeyTree(UninstallKeyPath, false);
|
||||
@@ -537,9 +655,22 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
}
|
||||
}
|
||||
}
|
||||
RestoreFile(DesktopShortcutPath, snapshot.DesktopShortcut);
|
||||
RestoreFile(StartMenuShortcutPath, snapshot.StartMenuShortcut);
|
||||
RestoreFile(UninstallerPath, snapshot.Uninstaller);
|
||||
if (snapshot.DesktopShortcutCaptured)
|
||||
{
|
||||
TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_rollback_restore",
|
||||
"Desktop-Verknuepfung fuer alle Benutzer beim Rollback wiederherstellen",
|
||||
DesktopShortcutPath,
|
||||
() => RestoreFile(DesktopShortcutPath, snapshot.DesktopShortcut),
|
||||
log,
|
||||
warn);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Write("WARN", "event=optional_windows_integration_skipped role=desktop_shortcut_rollback_restore reason=snapshot_unavailable path=\"" + DesktopShortcutPath + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -727,11 +858,11 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
/// <param name="targetExe">Der erwartete Zielpfad der Anwendung.</param>
|
||||
/// <param name="desktopRequested">Der gewünschte Zustand der Desktop-Verknüpfung.</param>
|
||||
/// <param name="log">Das Diagnoseprotokoll für die validierten Dateien.</param>
|
||||
private void ValidateWindowsIntegration(string targetExe, bool desktopRequested, SetupOperationLog log)
|
||||
/// <param name="warn">Die ausfallsichere Bedienerwarnung.</param>
|
||||
/// <returns><c>true</c>, wenn auch der optionale Desktop-Zustand dem Wunsch entspricht.</returns>
|
||||
private bool ValidateWindowsIntegration(string targetExe, bool desktopRequested, SetupOperationLog log, Action<string> warn)
|
||||
{
|
||||
if (!File.Exists(StartMenuShortcutPath)) throw new FileNotFoundException("Start menu shortcut was not created.", StartMenuShortcutPath);
|
||||
if (desktopRequested != File.Exists(DesktopShortcutPath))
|
||||
throw new InvalidOperationException("Desktop shortcut state does not match the setup selection. Requested=" + desktopRequested + ".");
|
||||
if (!File.Exists(UninstallerPath)) throw new FileNotFoundException("Uninstaller was not installed.", UninstallerPath);
|
||||
|
||||
using (var key = Registry.LocalMachine.OpenSubKey(UninstallKeyPath, false))
|
||||
@@ -746,8 +877,66 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
|
||||
log.WriteFileDetails("registered_uninstaller", UninstallerPath);
|
||||
log.WriteFileDetails("start_menu_shortcut", StartMenuShortcutPath);
|
||||
if (desktopRequested) log.WriteFileDetails("desktop_shortcut", DesktopShortcutPath);
|
||||
log.Write("INFO", "event=windows_integration_validated registry_key=\"HKLM\\" + UninstallKeyPath + "\" desktop_shortcut=" + desktopRequested);
|
||||
var desktopValidated = TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_validate",
|
||||
"Desktop-Verknuepfung fuer alle Benutzer validieren",
|
||||
DesktopShortcutPath,
|
||||
() =>
|
||||
{
|
||||
var exists = File.Exists(DesktopShortcutPath);
|
||||
if (desktopRequested != exists)
|
||||
throw new InvalidOperationException("Desktop shortcut state does not match the setup selection. Requested=" + desktopRequested + ", exists=" + exists + ".");
|
||||
if (exists) log.WriteFileDetails("desktop_shortcut", DesktopShortcutPath);
|
||||
},
|
||||
log,
|
||||
warn);
|
||||
log.Write("INFO", "event=windows_integration_validated registry_key=\"HKLM\\" + UninstallKeyPath
|
||||
+ "\" desktop_shortcut_requested=" + desktopRequested
|
||||
+ " desktop_shortcut_validated=" + desktopValidated);
|
||||
return desktopValidated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Führt einen optionalen Windows-Integrationsschritt so aus, dass weder dessen Fehler
|
||||
/// noch eine fehlerhafte Bedienerwarnung Installation, Rollback oder Deinstallation abbrechen.
|
||||
/// </summary>
|
||||
/// <param name="role">Die maschinenlesbare Rolle für das Diagnoselog.</param>
|
||||
/// <param name="description">Die lesbare Beschreibung des optionalen Schritts.</param>
|
||||
/// <param name="path">Der betroffene Pfad.</param>
|
||||
/// <param name="operation">Die auszuführende optionale Operation.</param>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
/// <param name="warn">Die optionale Bedienerwarnung.</param>
|
||||
/// <returns><c>true</c> nach Erfolg, andernfalls <c>false</c>.</returns>
|
||||
internal static bool TryOptionalWindowsIntegrationStep(
|
||||
string role,
|
||||
string description,
|
||||
string path,
|
||||
Action operation,
|
||||
SetupOperationLog log,
|
||||
Action<string> warn)
|
||||
{
|
||||
if (operation == null) throw new ArgumentNullException("operation");
|
||||
try
|
||||
{
|
||||
operation();
|
||||
log.Write("INFO", "event=optional_windows_integration_completed role=" + role + " path=\"" + path + "\"");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Write("WARN", "event=optional_windows_integration_warning role=" + role + " path=\"" + path + "\" " + SetupOperationLog.FormatException(ex));
|
||||
var message = "WARNUNG: Optionaler Schritt '" + description + "' ist fehlgeschlagen: " + ex.Message
|
||||
+ " Die Kernoperation wird fortgesetzt; Details stehen im Diagnoselog.";
|
||||
try
|
||||
{
|
||||
if (warn != null) warn(message);
|
||||
}
|
||||
catch (Exception warningException)
|
||||
{
|
||||
log.Write("WARN", "event=optional_windows_integration_report_failed role=" + role + " " + SetupOperationLog.FormatException(warningException));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -838,6 +1027,112 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stellt sicher, dass ein Kopierfallback keine aktive oder ungesicherte Vorversion überschreibt.
|
||||
/// </summary>
|
||||
/// <param name="hadExistingInstallation"><c>true</c>, wenn beim Start eine Installation vorhanden war.</param>
|
||||
/// <param name="backupCreated"><c>true</c>, wenn diese Vorversion bereits atomar gesichert wurde.</param>
|
||||
/// <param name="targetDirectory">Das erwartungsgemäß nicht vorhandene Installationsziel.</param>
|
||||
private static void EnsureVerifiedCopyActivationIsSafe(
|
||||
bool hadExistingInstallation,
|
||||
bool backupCreated,
|
||||
string targetDirectory)
|
||||
{
|
||||
if (Directory.Exists(targetDirectory) || File.Exists(targetDirectory))
|
||||
throw new InvalidOperationException("Verified copy activation refused because the target path already exists: " + targetDirectory);
|
||||
if (hadExistingInstallation && !backupCreated)
|
||||
throw new InvalidOperationException("Verified copy activation refused because the existing installation was not backed up.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aktiviert eine Neuinstallation oder ein bereits gesichertes Update durch eine erneut
|
||||
/// hashgeprüfte Kopie, wenn Windows nur die Staging-Umbenennung dauerhaft sperrt.
|
||||
/// </summary>
|
||||
/// <param name="stagingDirectory">Das bereits validierte Staging-Verzeichnis.</param>
|
||||
/// <param name="targetDirectory">Das noch nicht vorhandene Installationsverzeichnis.</param>
|
||||
/// <param name="files">Die validierten Manifesteinträge.</param>
|
||||
/// <param name="hadExistingInstallation"><c>true</c> für ein Update mit erhaltenem Backup.</param>
|
||||
/// <param name="moveException">Der vorausgegangene dauerhafte Move-Fehler.</param>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
private static void ActivateByVerifiedCopy(
|
||||
string stagingDirectory,
|
||||
string targetDirectory,
|
||||
IEnumerable<PackageFile> files,
|
||||
bool hadExistingInstallation,
|
||||
Exception moveException,
|
||||
SetupOperationLog log)
|
||||
{
|
||||
var scope = hadExistingInstallation ? "update_after_backup" : "new_install";
|
||||
log.Write(
|
||||
"WARN",
|
||||
"event=activation_fallback_started method=verified_copy scope=" + scope + " reason=directory_move_exhausted "
|
||||
+ SetupOperationLog.FormatException(moveException));
|
||||
CopyPayload(stagingDirectory, targetDirectory, files);
|
||||
log.Write("INFO", "event=activation_fallback_complete method=verified_copy scope=" + scope + " target=\"" + targetDirectory + "\"");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wiederholt eine atomare Verzeichnisverschiebung bei kurzzeitigen Windows-Dateisperren.
|
||||
/// </summary>
|
||||
/// <param name="source">Das vorhandene Quellverzeichnis.</param>
|
||||
/// <param name="target">Das noch nicht vorhandene Zielverzeichnis.</param>
|
||||
/// <param name="role">Die maschinenlesbare Rolle für das Diagnoselog.</param>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
private void MoveDirectoryWithRetry(string source, string target, string role, SetupOperationLog log)
|
||||
{
|
||||
var maximumAttempts = DirectoryMoveRetryDelaysMilliseconds.Length + 1;
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
directoryMover(source, target);
|
||||
if (attempt > 1)
|
||||
{
|
||||
log.Write(
|
||||
"INFO",
|
||||
"event=directory_move_recovered role=" + role
|
||||
+ " attempt=" + attempt.ToString(CultureInfo.InvariantCulture)
|
||||
+ " max_attempts=" + maximumAttempts.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (attempt >= maximumAttempts) throw;
|
||||
WaitBeforeDirectoryMoveRetry(role, attempt, maximumAttempts, ex, log);
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
if (attempt >= maximumAttempts) throw;
|
||||
WaitBeforeDirectoryMoveRetry(role, attempt, maximumAttempts, ex, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Protokolliert und wartet vor einer weiteren Verzeichnisverschiebung.
|
||||
/// </summary>
|
||||
/// <param name="role">Die maschinenlesbare Rolle der Verschiebung.</param>
|
||||
/// <param name="failedAttempt">Die Nummer des fehlgeschlagenen Versuchs.</param>
|
||||
/// <param name="maximumAttempts">Die maximale Gesamtzahl der Versuche.</param>
|
||||
/// <param name="exception">Der als vorübergehend behandelte Dateisystemfehler.</param>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
private void WaitBeforeDirectoryMoveRetry(string role, int failedAttempt, int maximumAttempts, Exception exception, SetupOperationLog log)
|
||||
{
|
||||
var delayMilliseconds = DirectoryMoveRetryDelaysMilliseconds[failedAttempt - 1];
|
||||
// Direkt nach einem EXE-Self-Test können Loader, Virenscanner oder EDR das
|
||||
// Delete-/Rename-Handle noch kurz halten. Begrenztes Backoff erhält die atomare
|
||||
// Aktivierung; dauerhafte ACL-Fehler werden nach maximal 19,75 Sekunden sichtbar.
|
||||
log.Write(
|
||||
"WARN",
|
||||
"event=directory_move_retry role=" + role
|
||||
+ " failed_attempt=" + failedAttempt.ToString(CultureInfo.InvariantCulture)
|
||||
+ " max_attempts=" + maximumAttempts.ToString(CultureInfo.InvariantCulture)
|
||||
+ " delay_ms=" + delayMilliseconds.ToString(CultureInfo.InvariantCulture)
|
||||
+ " " + SetupOperationLog.FormatException(exception));
|
||||
retryDelay(delayMilliseconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stellt sicher, dass eine betriebsnotwendige Datei im Manifest enthalten ist.
|
||||
/// </summary>
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
{
|
||||
AutoSize = true,
|
||||
Font = new Font(Font.FontFamily, 14, FontStyle.Bold),
|
||||
Text = "BizTalk Platform Management Tool 2.1.2"
|
||||
Text = "BizTalk Platform Management Tool 2.3.4"
|
||||
});
|
||||
root.Controls.Add(new Label
|
||||
{
|
||||
@@ -74,8 +74,8 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
Text = "Transaktionaler Installer mit SHA-256-Pruefung, Staging-Self-Test und automatischem Rollback.\r\nZiel: " + engine.InstallDirectory
|
||||
});
|
||||
|
||||
desktopShortcut.Text = "Desktop-Verknuepfung fuer alle Benutzer erstellen";
|
||||
desktopShortcut.Checked = true;
|
||||
desktopShortcut.Text = "Optionale Desktop-Verknuepfung fuer alle Benutzer erstellen";
|
||||
desktopShortcut.Checked = false;
|
||||
desktopShortcut.AutoSize = true;
|
||||
desktopShortcut.Enabled = !uninstallMode;
|
||||
root.Controls.Add(desktopShortcut);
|
||||
|
||||
@@ -8,6 +8,6 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyProduct("BizTalk Platform Management Tool")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("675b68a9-bd80-46a5-b8c5-3b11b0b374e2")]
|
||||
[assembly: AssemblyVersion("2.1.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.1.2.0")]
|
||||
[assembly: AssemblyVersion("2.3.4.0")]
|
||||
[assembly: AssemblyFileVersion("2.3.4.0")]
|
||||
[assembly: InternalsVisibleTo("BizTalkPlatformManagementTool.Tests")]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="2.1.2.0" name="BizTalkPlatformManagementTool.Setup" />
|
||||
<assemblyIdentity version="2.3.4.0" name="BizTalkPlatformManagementTool.Setup" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security><requestedPrivileges><requestedExecutionLevel level="requireAdministrator" uiAccess="false" /></requestedPrivileges></security>
|
||||
</trustInfo>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<!-- Semicolon-delimited optional override. Normal BizTalk 2020 and ScheduledTask 7.x folders are auto-discovered. -->
|
||||
<add key="AdapterAssemblySearchPaths" value="%ProgramFiles(x86)%\Microsoft BizTalk Server 2020;%ProgramFiles(x86)%\BizTalk ScheduledTask Adapter 7.0.2" />
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
|
||||
@@ -39,10 +39,13 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
@@ -55,14 +58,19 @@
|
||||
<Compile Include="Models\DiffModels.cs" />
|
||||
<Compile Include="Models\OperationModels.cs" />
|
||||
<Compile Include="Services\BizTalkWmiClient.cs" />
|
||||
<Compile Include="Services\BizTalkApplicationResolver.cs" />
|
||||
<Compile Include="Services\AdapterAssemblyResolver.cs" />
|
||||
<Compile Include="Services\CsvWriter.cs" />
|
||||
<Compile Include="Services\HtmlReportWriter.cs" />
|
||||
<Compile Include="Services\JsonFileStore.cs" />
|
||||
<Compile Include="Services\OperationLogger.cs" />
|
||||
<Compile Include="Services\ExceptionDiagnostics.cs" />
|
||||
<Compile Include="Services\OperationPlanExecutor.cs" />
|
||||
<Compile Include="Services\SnapshotComparer.cs" />
|
||||
<Compile Include="Services\SnapshotValidator.cs" />
|
||||
<Compile Include="Services\SnapshotStore.cs" />
|
||||
<Compile Include="Services\BizTalkOperationService.cs" />
|
||||
<Compile Include="Ui\ShutdownOperatorPrompts.cs" />
|
||||
<Compile Include="Ui\MainForm.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -16,7 +16,13 @@ namespace BizTalkPlatformManagementTool.Models
|
||||
/// <summary>
|
||||
/// Plan mode for returning BizTalk runtime artifacts to a captured state.
|
||||
/// </summary>
|
||||
Restore
|
||||
Restore,
|
||||
|
||||
/// <summary>
|
||||
/// Recovery mode that uses an existing snapshot without creating or
|
||||
/// overwriting a new before snapshot.
|
||||
/// </summary>
|
||||
EmergencyRestore
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,6 +35,11 @@ namespace BizTalkPlatformManagementTool.Models
|
||||
/// </summary>
|
||||
ReceiveLocation,
|
||||
|
||||
/// <summary>
|
||||
/// An operator confirmation boundary between shutdown phases.
|
||||
/// </summary>
|
||||
OperatorCheckpoint,
|
||||
|
||||
/// <summary>
|
||||
/// A send port step.
|
||||
/// </summary>
|
||||
@@ -44,6 +55,11 @@ namespace BizTalkPlatformManagementTool.Models
|
||||
/// </summary>
|
||||
HostInstance,
|
||||
|
||||
/// <summary>
|
||||
/// A Windows service prerequisite such as Enterprise Single Sign-On.
|
||||
/// </summary>
|
||||
WindowsService,
|
||||
|
||||
/// <summary>
|
||||
/// An informational step that is intentionally not executed.
|
||||
/// </summary>
|
||||
@@ -173,6 +189,14 @@ namespace BizTalkPlatformManagementTool.Models
|
||||
/// </summary>
|
||||
[DataMember(Order = 13)]
|
||||
public string Warning { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the receive adapter name used for dependency preflight.</summary>
|
||||
[DataMember(Order = 14, EmitDefaultValue = false)]
|
||||
public string AdapterName { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the receive transport address used to identify scheduler URIs.</summary>
|
||||
[DataMember(Order = 15, EmitDefaultValue = false)]
|
||||
public string Address { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -210,4 +234,171 @@ namespace BizTalkPlatformManagementTool.Models
|
||||
/// </summary>
|
||||
public int PollIntervalSeconds { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the outcome recorded for one attempted operation-plan step.
|
||||
/// </summary>
|
||||
public static class OperationStepOutcomes
|
||||
{
|
||||
/// <summary>The step was executed and reached its target state.</summary>
|
||||
public const string Succeeded = "Succeeded";
|
||||
|
||||
/// <summary>The runtime object was already in the requested target state.</summary>
|
||||
public const string AlreadySatisfied = "AlreadySatisfied";
|
||||
|
||||
/// <summary>The step was intentionally not executable.</summary>
|
||||
public const string Skipped = "Skipped";
|
||||
|
||||
/// <summary>The step was shown without mutation because dry-run was enabled.</summary>
|
||||
public const string DryRun = "DryRun";
|
||||
|
||||
/// <summary>The step failed, while subsequent independent steps were still attempted.</summary>
|
||||
public const string Failed = "Failed";
|
||||
|
||||
/// <summary>The operator explicitly confirmed a non-mutating checkpoint.</summary>
|
||||
public const string Confirmed = "Confirmed";
|
||||
|
||||
/// <summary>The step was not reached because the operator stopped at a checkpoint.</summary>
|
||||
public const string NotExecuted = "NotExecuted";
|
||||
|
||||
/// <summary>The operator declined to continue at a checkpoint.</summary>
|
||||
public const string Declined = "Declined";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one durable step result from a shutdown, restore or emergency restore.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public sealed class OperationStepResult
|
||||
{
|
||||
/// <summary>Gets or sets the one-based plan-step number.</summary>
|
||||
[DataMember(Order = 1)]
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the artifact kind.</summary>
|
||||
[DataMember(Order = 2)]
|
||||
public string Kind { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the owning BizTalk application.</summary>
|
||||
[DataMember(Order = 3)]
|
||||
public string Application { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the artifact, host instance or service name.</summary>
|
||||
[DataMember(Order = 4)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the requested action.</summary>
|
||||
[DataMember(Order = 5)]
|
||||
public string Action { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the stable outcome value.</summary>
|
||||
[DataMember(Order = 6)]
|
||||
public string Outcome { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the local start timestamp.</summary>
|
||||
[DataMember(Order = 7)]
|
||||
public string StartedAt { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the local completion timestamp.</summary>
|
||||
[DataMember(Order = 8)]
|
||||
public string FinishedAt { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the complete operator-facing exception chain.</summary>
|
||||
[DataMember(Order = 9)]
|
||||
public string Error { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durable summary of a best-effort plan execution. A failed step never
|
||||
/// prevents later independent steps from being attempted.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public sealed class OperationExecutionReport
|
||||
{
|
||||
/// <summary>Initializes an empty report.</summary>
|
||||
public OperationExecutionReport()
|
||||
{
|
||||
Steps = new List<OperationStepResult>();
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the shutdown or restore mode.</summary>
|
||||
[DataMember(Order = 1)]
|
||||
public string Mode { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the target server.</summary>
|
||||
[DataMember(Order = 2)]
|
||||
public string Server { get; set; }
|
||||
|
||||
/// <summary>Gets or sets whether the execution was a dry-run.</summary>
|
||||
[DataMember(Order = 3)]
|
||||
public bool DryRun { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the local execution start timestamp.</summary>
|
||||
[DataMember(Order = 4)]
|
||||
public string StartedAt { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the local execution completion timestamp.</summary>
|
||||
[DataMember(Order = 5)]
|
||||
public string FinishedAt { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the number of successfully executed steps.</summary>
|
||||
[DataMember(Order = 6)]
|
||||
public int SucceededCount { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the number of steps already at their target state.</summary>
|
||||
[DataMember(Order = 7)]
|
||||
public int AlreadySatisfiedCount { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the number of intentionally skipped steps.</summary>
|
||||
[DataMember(Order = 8)]
|
||||
public int SkippedCount { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the number of dry-run-only steps.</summary>
|
||||
[DataMember(Order = 9)]
|
||||
public int DryRunCount { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the number of failed steps.</summary>
|
||||
[DataMember(Order = 10)]
|
||||
public int FailedCount { get; set; }
|
||||
|
||||
/// <summary>Gets or sets an error that prevented runtime initialization.</summary>
|
||||
[DataMember(Order = 11)]
|
||||
public string InitializationError { get; set; }
|
||||
|
||||
/// <summary>Gets or sets an error encountered while creating the post-operation snapshot.</summary>
|
||||
[DataMember(Order = 12)]
|
||||
public string PostSnapshotError { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the ordered per-step results.</summary>
|
||||
[DataMember(Order = 13)]
|
||||
public List<OperationStepResult> Steps { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the last durable operator-checkpoint decision.</summary>
|
||||
[DataMember(Order = 14, EmitDefaultValue = false)]
|
||||
public string CheckpointDecision { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the local timestamp of the checkpoint decision.</summary>
|
||||
[DataMember(Order = 15, EmitDefaultValue = false)]
|
||||
public string CheckpointAt { get; set; }
|
||||
|
||||
/// <summary>Gets or sets whether the operator stopped the remaining shutdown phases.</summary>
|
||||
[DataMember(Order = 16)]
|
||||
public bool OperatorStopped { get; set; }
|
||||
|
||||
/// <summary>Gets or sets how many remaining plan rows were not reached.</summary>
|
||||
[DataMember(Order = 17)]
|
||||
public int NotExecutedCount { get; set; }
|
||||
|
||||
/// <summary>Gets whether operator attention is required.</summary>
|
||||
public bool HasFailures
|
||||
{
|
||||
get { return FailedCount > 0 || !string.IsNullOrWhiteSpace(InitializationError) || !string.IsNullOrWhiteSpace(PostSnapshotError); }
|
||||
}
|
||||
|
||||
/// <summary>Gets whether failure or an intentional operator stop needs review.</summary>
|
||||
public bool RequiresOperatorReview
|
||||
{
|
||||
get { return HasFailures || OperatorStopped; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("BizTalk Platform Management Tool")]
|
||||
@@ -8,5 +9,6 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © 2026")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("2c5b2c0a-f407-46c2-9e3b-1fa09fa8445a")]
|
||||
[assembly: AssemblyVersion("2.1.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.1.2.0")]
|
||||
[assembly: AssemblyVersion("2.3.4.0")]
|
||||
[assembly: AssemblyFileVersion("2.3.4.0")]
|
||||
[assembly: InternalsVisibleTo("BizTalkPlatformManagementTool.Tests")]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BizTalkPlatformManagementTool.Models;
|
||||
using BizTalkPlatformManagementTool.Services;
|
||||
|
||||
@@ -35,6 +36,37 @@ namespace BizTalkPlatformManagementTool
|
||||
|
||||
SnapshotStore.SaveSnapshotSet(Path.Combine(directory, "before.json"), loaded);
|
||||
SnapshotStore.SaveDiffSet(Path.Combine(directory, "diff.json"), diff);
|
||||
|
||||
var runtimeLogDirectory = Path.Combine(directory, "runtime-logs");
|
||||
var runtimeLogger = new OperationLogger(null, runtimeLogDirectory);
|
||||
runtimeLogger.Info("runtime log self-test marker");
|
||||
if (!runtimeLogger.IsFileLoggingAvailable
|
||||
|| !File.Exists(runtimeLogger.LogFilePath)
|
||||
|| !runtimeLogger.ReadRecentEntries(10).Any(x => x.Message == "runtime log self-test marker"))
|
||||
{
|
||||
throw new InvalidOperationException("Runtime log write/read self-test failed.");
|
||||
}
|
||||
|
||||
var operationService = new BizTalkOperationService(null);
|
||||
var emergencyPlan = operationService.CreateEmergencyRestorePlan(loaded, loaded.Server);
|
||||
if (emergencyPlan.Steps.Count == 0 || emergencyPlan.Steps[0].Kind != "WindowsService" || emergencyPlan.Steps[0].Name != "ENTSSO")
|
||||
{
|
||||
throw new InvalidOperationException("Emergency restore self-test did not place ENTSSO first.");
|
||||
}
|
||||
var dryRunReport = operationService.ExecutePlan(emergencyPlan, new OperationOptions
|
||||
{
|
||||
Server = loaded.Server,
|
||||
OutputDirectory = directory,
|
||||
StateFile = snapshotPath,
|
||||
DryRun = true,
|
||||
WaitTimeoutSeconds = 30,
|
||||
PollIntervalSeconds = 1
|
||||
});
|
||||
if (dryRunReport.HasFailures || dryRunReport.DryRunCount != emergencyPlan.Steps.Count(x => x.Execute))
|
||||
{
|
||||
throw new InvalidOperationException("Emergency restore dry-run self-test returned an unexpected result.");
|
||||
}
|
||||
operationService.SaveExecutionReport(directory, "emergency-result.json", dryRunReport);
|
||||
Console.WriteLine("SELF_TEST_OK version=" + BizTalkOperationService.Version);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves custom-adapter and BizTalk support assemblies from installed product
|
||||
/// directories for the lifetime of one real operation-plan execution.
|
||||
/// </summary>
|
||||
internal sealed class AdapterAssemblyResolver : IDisposable
|
||||
{
|
||||
/// <summary>The dependency whose absence breaks ScheduledTask Enable/Disable validation.</summary>
|
||||
internal const string SchedulerAssemblyName = "Microsoft.BizTalk.Scheduler";
|
||||
|
||||
/// <summary>Logger receiving all search-path and load diagnostics.</summary>
|
||||
private readonly OperationLogger _logger;
|
||||
|
||||
/// <summary>Trusted directories searched after normal CLR resolution has failed.</summary>
|
||||
private readonly List<string> _searchDirectories;
|
||||
|
||||
/// <summary>Prevents duplicate event registration and unregisters safely.</summary>
|
||||
private bool _attached;
|
||||
|
||||
/// <summary>Prevents repeated ScheduledTask dependency preflight in one plan.</summary>
|
||||
private bool _schedulerPrepared;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes and attaches the process-local resolver.
|
||||
/// </summary>
|
||||
/// <param name="logger">The operation logger used for support diagnostics.</param>
|
||||
public AdapterAssemblyResolver(OperationLogger logger)
|
||||
: this(logger, DiscoverSearchDirectories())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a resolver with explicit directories for regression tests.</summary>
|
||||
/// <param name="logger">Optional logger.</param>
|
||||
/// <param name="searchDirectories">Directories that may contain dependencies.</param>
|
||||
internal AdapterAssemblyResolver(OperationLogger logger, IEnumerable<string> searchDirectories)
|
||||
{
|
||||
_logger = logger;
|
||||
_searchDirectories = NormalizeDirectories(searchDirectories).ToList();
|
||||
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
|
||||
_attached = true;
|
||||
}
|
||||
|
||||
/// <summary>Gets the immutable ordered dependency search path.</summary>
|
||||
internal IList<string> SearchDirectories
|
||||
{
|
||||
get { return _searchDirectories.AsReadOnly(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preloads the BizTalk Scheduler dependency before WMI validates a Scheduler
|
||||
/// receive location and emits actionable diagnostics when it cannot be found.
|
||||
/// </summary>
|
||||
public void PrepareScheduledTaskAdapter()
|
||||
{
|
||||
if (_schedulerPrepared)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_schedulerPrepared = true;
|
||||
|
||||
Info("ScheduledTask adapter preflight. ProcessBitness=" + (Environment.Is64BitProcess ? "64" : "32")
|
||||
+ "; SearchDirectories=" + string.Join(" | ", _searchDirectories.ToArray()));
|
||||
|
||||
var alreadyLoaded = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.FirstOrDefault(x => string.Equals(x.GetName().Name, SchedulerAssemblyName, StringComparison.OrdinalIgnoreCase));
|
||||
if (alreadyLoaded != null)
|
||||
{
|
||||
Success("ScheduledTask dependency already loaded: " + DescribeAssembly(alreadyLoaded));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Normal CLR/GAC resolution remains authoritative. If it fails, the attached
|
||||
// resolver gets the same request and may satisfy it from an installed product path.
|
||||
var normallyResolved = Assembly.Load(new AssemblyName(SchedulerAssemblyName));
|
||||
Success("ScheduledTask dependency resolved through CLR/GAC: " + DescribeAssembly(normallyResolved));
|
||||
return;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// The explicit path diagnostic below reports every searched installation directory.
|
||||
}
|
||||
catch (FileLoadException ex)
|
||||
{
|
||||
Warning("ScheduledTask dependency CLR/GAC resolution found an incompatible or unloadable assembly. " + ExceptionDiagnostics.Format(ex));
|
||||
}
|
||||
|
||||
var path = FindCandidateFile(SchedulerAssemblyName, null, _searchDirectories);
|
||||
if (path == null)
|
||||
{
|
||||
throw new FileNotFoundException(
|
||||
"ScheduledTask receive-location control requires Microsoft.BizTalk.Scheduler.dll. "
|
||||
+ "The assembly was not found in the BizTalk installation directory, the ScheduledTask Adapter directory, "
|
||||
+ "or configured AdapterAssemblySearchPaths. Search directories: "
|
||||
+ string.Join(" | ", _searchDirectories.ToArray())
|
||||
+ ". Install the matching BizTalk Scheduler assembly in the GAC or add its existing directory to "
|
||||
+ "BizTalkPlatformManagementTool.exe.config; do not copy an assembly from another BizTalk version.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.LoadFrom(path);
|
||||
Success("ScheduledTask dependency loaded process-locally: " + DescribeAssembly(assembly));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"ScheduledTask dependency was found but could not be loaded from '" + path + "'. "
|
||||
+ ExceptionDiagnostics.Format(ex), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Unregisters the process-local resolver.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_attached)
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve -= ResolveAssembly;
|
||||
_attached = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Handles unresolved CLR assembly requests using identity-checked files.</summary>
|
||||
private Assembly ResolveAssembly(object sender, ResolveEventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var requested = new AssemblyName(args.Name);
|
||||
var loaded = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => AssemblyIdentityMatches(requested, x.GetName()));
|
||||
if (loaded != null)
|
||||
{
|
||||
return loaded;
|
||||
}
|
||||
|
||||
var path = FindCandidateFile(requested.Name, requested, _searchDirectories);
|
||||
if (path == null)
|
||||
{
|
||||
Warning("Assembly resolution failed. Requested=" + args.Name
|
||||
+ "; RequestingAssembly=" + (args.RequestingAssembly == null ? "(unknown)" : args.RequestingAssembly.FullName)
|
||||
+ "; SearchDirectories=" + string.Join(" | ", _searchDirectories.ToArray()));
|
||||
return null;
|
||||
}
|
||||
|
||||
var assembly = Assembly.LoadFrom(path);
|
||||
Success("Resolved adapter dependency process-locally. Requested=" + args.Name
|
||||
+ "; Loaded=" + DescribeAssembly(assembly));
|
||||
return assembly;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Warning("Assembly resolution raised an error. Requested=" + args.Name + "; " + ExceptionDiagnostics.Format(ex));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an identity-compatible DLL without loading it into the current AppDomain.
|
||||
/// </summary>
|
||||
/// <param name="simpleName">Requested simple assembly name.</param>
|
||||
/// <param name="requested">Full requested identity, or null to accept any installed version.</param>
|
||||
/// <param name="directories">Trusted directories to search.</param>
|
||||
/// <returns>The matching DLL path, or null.</returns>
|
||||
internal static string FindCandidateFile(string simpleName, AssemblyName requested, IEnumerable<string> directories)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(simpleName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var directory in NormalizeDirectories(directories))
|
||||
{
|
||||
var candidate = Path.Combine(directory, simpleName + ".dll");
|
||||
if (!File.Exists(candidate))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
var actual = AssemblyName.GetAssemblyName(candidate);
|
||||
if (requested == null
|
||||
? string.Equals(actual.Name, simpleName, StringComparison.OrdinalIgnoreCase)
|
||||
: AssemblyIdentityMatches(requested, actual))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A native, corrupt or unrelated file is never loaded merely because its file name matches.
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Compares simple name, requested version, culture and public key token.</summary>
|
||||
private static bool AssemblyIdentityMatches(AssemblyName requested, AssemblyName actual)
|
||||
{
|
||||
if (requested == null || actual == null
|
||||
|| !string.Equals(requested.Name, actual.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (requested.Version != null && actual.Version != requested.Version)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(requested.CultureName)
|
||||
&& !string.Equals(requested.CultureName, actual.CultureName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var expectedToken = requested.GetPublicKeyToken();
|
||||
var actualToken = actual.GetPublicKeyToken();
|
||||
return expectedToken == null || expectedToken.Length == 0 || TokensEqual(expectedToken, actualToken);
|
||||
}
|
||||
|
||||
/// <summary>Compares strong-name public key tokens.</summary>
|
||||
private static bool TokensEqual(byte[] left, byte[] right)
|
||||
{
|
||||
if (left == null || right == null || left.Length != right.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < left.Length; i++)
|
||||
{
|
||||
if (left[i] != right[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Discovers BizTalk, ScheduledTask and explicitly configured directories.</summary>
|
||||
internal static IEnumerable<string> DiscoverSearchDirectories()
|
||||
{
|
||||
var result = new List<string>();
|
||||
AddConfiguredDirectories(result);
|
||||
AddRegistryDirectories(result);
|
||||
|
||||
var programFilesX86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
|
||||
AddMatchingDirectories(result, programFilesX86, "Microsoft BizTalk Server*");
|
||||
AddMatchingDirectories(result, programFilesX86, "BizTalk ScheduledTask Adapter*");
|
||||
AddMatchingDirectories(result, programFilesX86, "Biztalk ScheduledTask Adapter*");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Adds semicolon-delimited paths from App.config after environment expansion.</summary>
|
||||
private static void AddConfiguredDirectories(ICollection<string> result)
|
||||
{
|
||||
try
|
||||
{
|
||||
var configured = ConfigurationManager.AppSettings["AdapterAssemblySearchPaths"];
|
||||
if (string.IsNullOrWhiteSpace(configured))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var value in configured.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
result.Add(Environment.ExpandEnvironmentVariables(value.Trim()));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Registry and conventional installation directories remain available.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds known assembly-path values from both registry views.</summary>
|
||||
private static void AddRegistryDirectories(ICollection<string> result)
|
||||
{
|
||||
var views = new[] { RegistryView.Registry32, RegistryView.Registry64 };
|
||||
foreach (var view in views)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, view))
|
||||
{
|
||||
AddRegistryTreeDirectories(baseKey, @"SOFTWARE\Microsoft\BizTalk Server\3.0", result, 0);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Registry discovery is best-effort and never blocks normal BizTalk adapters.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads installation and assembly directories from a shallow BizTalk registry tree.</summary>
|
||||
private static void AddRegistryTreeDirectories(RegistryKey baseKey, string subKeyName, ICollection<string> result, int depth)
|
||||
{
|
||||
if (depth > 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var key = baseKey.OpenSubKey(subKeyName, false))
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var valueName in key.GetValueNames())
|
||||
{
|
||||
var value = key.GetValue(valueName) as string;
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
value = Environment.ExpandEnvironmentVariables(value.Trim().Trim('"'));
|
||||
if (value.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.Add(Path.GetDirectoryName(value));
|
||||
}
|
||||
else if (Directory.Exists(value))
|
||||
{
|
||||
result.Add(value);
|
||||
}
|
||||
}
|
||||
foreach (var child in key.GetSubKeyNames())
|
||||
{
|
||||
AddRegistryTreeDirectories(baseKey, subKeyName + "\\" + child, result, depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds directories matching one non-recursive product-folder pattern.</summary>
|
||||
private static void AddMatchingDirectories(ICollection<string> result, string parent, string pattern)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(parent))
|
||||
{
|
||||
foreach (var directory in Directory.GetDirectories(parent, pattern, SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
result.Add(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A denied optional discovery path is reported later if Scheduler preflight is required.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Normalizes, de-duplicates and filters existing directories.</summary>
|
||||
private static IEnumerable<string> NormalizeDirectories(IEnumerable<string> directories)
|
||||
{
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var value in directories ?? Enumerable.Empty<string>())
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fullPath;
|
||||
try
|
||||
{
|
||||
fullPath = Path.GetFullPath(value.Trim().Trim('"')).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Directory.Exists(fullPath) && seen.Add(fullPath))
|
||||
{
|
||||
yield return fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Builds a diagnostic assembly description.</summary>
|
||||
private static string DescribeAssembly(Assembly assembly)
|
||||
{
|
||||
return assembly.FullName + "; Location=" + assembly.Location;
|
||||
}
|
||||
|
||||
/// <summary>Writes informational diagnostics when a logger is available.</summary>
|
||||
private void Info(string message) { if (_logger != null) _logger.Info(message); }
|
||||
|
||||
/// <summary>Writes warning diagnostics when a logger is available.</summary>
|
||||
private void Warning(string message) { if (_logger != null) _logger.Warning(message); }
|
||||
|
||||
/// <summary>Writes successful dependency diagnostics when a logger is available.</summary>
|
||||
private void Success(string message) { if (_logger != null) _logger.Success(message); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves runtime artifacts to their owning BizTalk applications by reading the
|
||||
/// ExplorerOM application hierarchy without a compile-time BizTalk dependency.
|
||||
/// </summary>
|
||||
internal sealed class BizTalkApplicationResolver
|
||||
{
|
||||
/// <summary>The strong-name token used by Microsoft BizTalk product assemblies.</summary>
|
||||
private static readonly byte[] BizTalkPublicKeyToken = { 0x31, 0xbf, 0x38, 0x56, 0xad, 0x36, 0x4e, 0x35 };
|
||||
|
||||
/// <summary>Maps group-unique send-port names to application names.</summary>
|
||||
private readonly ArtifactApplicationMap _sendPorts = new ArtifactApplicationMap();
|
||||
|
||||
/// <summary>Maps receive-port names to application names.</summary>
|
||||
private readonly ArtifactApplicationMap _receivePorts = new ArtifactApplicationMap();
|
||||
|
||||
/// <summary>Maps receive-location names to application names.</summary>
|
||||
private readonly ArtifactApplicationMap _receiveLocations = new ArtifactApplicationMap();
|
||||
|
||||
/// <summary>Maps orchestration names and supported aliases to application names.</summary>
|
||||
private readonly ArtifactApplicationMap _orchestrations = new ArtifactApplicationMap();
|
||||
|
||||
/// <summary>Initializes an empty resolver, primarily for deterministic regression tests.</summary>
|
||||
internal BizTalkApplicationResolver()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the BizTalk Management database location through WMI and builds an
|
||||
/// application/artifact index through the locally installed ExplorerOM assembly.
|
||||
/// </summary>
|
||||
/// <param name="client">Connected BizTalk WMI client.</param>
|
||||
/// <param name="logger">Optional operation logger for support diagnostics.</param>
|
||||
/// <returns>A resolver populated from the BizTalk application catalog.</returns>
|
||||
internal static BizTalkApplicationResolver Load(BizTalkWmiClient client, OperationLogger logger)
|
||||
{
|
||||
if (client == null)
|
||||
{
|
||||
throw new ArgumentNullException("client");
|
||||
}
|
||||
|
||||
string databaseServer;
|
||||
string databaseName;
|
||||
ReadManagementDatabase(client, out databaseServer, out databaseName);
|
||||
|
||||
var assembly = LoadExplorerOmAssembly();
|
||||
var catalogType = assembly.GetType("Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer", true, false);
|
||||
var catalog = Activator.CreateInstance(catalogType);
|
||||
try
|
||||
{
|
||||
var connection = new SqlConnectionStringBuilder
|
||||
{
|
||||
DataSource = databaseServer,
|
||||
InitialCatalog = databaseName,
|
||||
IntegratedSecurity = true,
|
||||
ConnectTimeout = 15,
|
||||
ApplicationName = "BizTalkPlatformManagementTool"
|
||||
};
|
||||
SetProperty(catalog, "ConnectionString", connection.ConnectionString);
|
||||
|
||||
var resolver = new BizTalkApplicationResolver();
|
||||
resolver.IndexApplications(GetProperty(catalog, "Applications"));
|
||||
Info(logger, "BizTalk application catalog loaded through ExplorerOM. "
|
||||
+ "Applications=" + resolver.ApplicationCount
|
||||
+ "; SendPorts=" + resolver._sendPorts.Count
|
||||
+ "; ReceivePorts=" + resolver._receivePorts.Count
|
||||
+ "; ReceiveLocations=" + resolver._receiveLocations.Count
|
||||
+ "; Orchestrations=" + resolver._orchestrations.Count
|
||||
+ "; ManagementDatabase=" + databaseServer + "\\" + databaseName + ".");
|
||||
return resolver;
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"BizTalk ExplorerOM could not read the application catalog from "
|
||||
+ databaseServer + "\\" + databaseName + ". "
|
||||
+ ExceptionDiagnostics.Format(ex.InnerException ?? ex), ex.InnerException ?? ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
var disposable = catalog as IDisposable;
|
||||
if (disposable != null)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the number of distinct application names represented in the index.</summary>
|
||||
internal int ApplicationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sendPorts.ApplicationNames
|
||||
.Concat(_receivePorts.ApplicationNames)
|
||||
.Concat(_receiveLocations.ApplicationNames)
|
||||
.Concat(_orchestrations.ApplicationNames)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Count();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a send-port ownership record to the index.</summary>
|
||||
/// <param name="application">Owning BizTalk application.</param>
|
||||
/// <param name="name">Send-port name.</param>
|
||||
internal void AddSendPort(string application, string name)
|
||||
{
|
||||
_sendPorts.Add(application, name);
|
||||
}
|
||||
|
||||
/// <summary>Adds a receive-port ownership record to the index.</summary>
|
||||
/// <param name="application">Owning BizTalk application.</param>
|
||||
/// <param name="name">Receive-port name.</param>
|
||||
internal void AddReceivePort(string application, string name)
|
||||
{
|
||||
_receivePorts.Add(application, name);
|
||||
}
|
||||
|
||||
/// <summary>Adds a receive-location ownership record to the index.</summary>
|
||||
/// <param name="application">Owning BizTalk application.</param>
|
||||
/// <param name="name">Receive-location name.</param>
|
||||
internal void AddReceiveLocation(string application, string name)
|
||||
{
|
||||
_receiveLocations.Add(application, name);
|
||||
}
|
||||
|
||||
/// <summary>Adds an orchestration ownership record to the index.</summary>
|
||||
/// <param name="application">Owning BizTalk application.</param>
|
||||
/// <param name="name">Orchestration name or alias.</param>
|
||||
internal void AddOrchestration(string application, string name)
|
||||
{
|
||||
_orchestrations.Add(application, name);
|
||||
}
|
||||
|
||||
/// <summary>Resolves a send port to its owning application.</summary>
|
||||
/// <param name="name">Send-port name.</param>
|
||||
/// <returns>The application name, or null when absent or ambiguous.</returns>
|
||||
internal string ResolveSendPort(string name)
|
||||
{
|
||||
return _sendPorts.Resolve(name);
|
||||
}
|
||||
|
||||
/// <summary>Resolves a receive location, with its receive port as a stable fallback.</summary>
|
||||
/// <param name="locationName">Receive-location name.</param>
|
||||
/// <param name="receivePortName">Parent receive-port name.</param>
|
||||
/// <returns>The application name, or null when absent or ambiguous.</returns>
|
||||
internal string ResolveReceiveLocation(string locationName, string receivePortName)
|
||||
{
|
||||
return _receiveLocations.Resolve(locationName) ?? _receivePorts.Resolve(receivePortName);
|
||||
}
|
||||
|
||||
/// <summary>Resolves an orchestration to its owning application.</summary>
|
||||
/// <param name="name">WMI orchestration name.</param>
|
||||
/// <returns>The application name, or null when absent or ambiguous.</returns>
|
||||
internal string ResolveOrchestration(string name)
|
||||
{
|
||||
return _orchestrations.Resolve(name);
|
||||
}
|
||||
|
||||
/// <summary>Enumerates all applications and their runtime artifact collections.</summary>
|
||||
/// <param name="applications">ExplorerOM application collection.</param>
|
||||
private void IndexApplications(object applications)
|
||||
{
|
||||
foreach (var application in Enumerate(applications, "Applications"))
|
||||
{
|
||||
var applicationName = ReadString(application, "Name");
|
||||
if (string.IsNullOrWhiteSpace(applicationName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var sendPort in Enumerate(GetProperty(application, "SendPorts"), "Application.SendPorts"))
|
||||
{
|
||||
AddSendPort(applicationName, ReadString(sendPort, "Name"));
|
||||
}
|
||||
|
||||
foreach (var receivePort in Enumerate(GetProperty(application, "ReceivePorts"), "Application.ReceivePorts"))
|
||||
{
|
||||
AddReceivePort(applicationName, ReadString(receivePort, "Name"));
|
||||
foreach (var location in Enumerate(GetProperty(receivePort, "ReceiveLocations"), "ReceivePort.ReceiveLocations"))
|
||||
{
|
||||
AddReceiveLocation(applicationName, ReadString(location, "Name"));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var orchestration in Enumerate(GetProperty(application, "Orchestrations"), "Application.Orchestrations"))
|
||||
{
|
||||
AddOrchestration(applicationName, ReadString(orchestration, "FullName"));
|
||||
AddOrchestration(applicationName, ReadString(orchestration, "AssemblyQualifiedName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads the BizTalk Management database endpoint from MSBTS_GroupSetting.</summary>
|
||||
/// <param name="client">Connected WMI client.</param>
|
||||
/// <param name="server">Resolved SQL Server name.</param>
|
||||
/// <param name="database">Resolved management database name.</param>
|
||||
private static void ReadManagementDatabase(BizTalkWmiClient client, out string server, out string database)
|
||||
{
|
||||
var settings = client.Query("MSBTS_GroupSetting");
|
||||
try
|
||||
{
|
||||
if (settings.Count != 1)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Expected exactly one MSBTS_GroupSetting instance but found " + settings.Count + ".");
|
||||
}
|
||||
server = BizTalkWmiClient.SafeGetString(settings[0], "MgmtDbServerName", null);
|
||||
database = BizTalkWmiClient.SafeGetString(settings[0], "MgmtDbName", null);
|
||||
if (string.IsNullOrWhiteSpace(server) || string.IsNullOrWhiteSpace(database))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"MSBTS_GroupSetting did not expose MgmtDbServerName and MgmtDbName.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
foreach (ManagementObject setting in settings)
|
||||
{
|
||||
setting.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Loads an identity-verified ExplorerOM assembly from the CLR/GAC or installed BizTalk folders.</summary>
|
||||
/// <returns>The loaded Microsoft.BizTalk.ExplorerOM assembly.</returns>
|
||||
private static Assembly LoadExplorerOmAssembly()
|
||||
{
|
||||
var requested = new AssemblyName("Microsoft.BizTalk.ExplorerOM");
|
||||
requested.SetPublicKeyToken(BizTalkPublicKeyToken);
|
||||
|
||||
var loaded = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.FirstOrDefault(x => string.Equals(x.GetName().Name, requested.Name, StringComparison.OrdinalIgnoreCase));
|
||||
if (loaded != null)
|
||||
{
|
||||
RequireMicrosoftIdentity(loaded);
|
||||
return loaded;
|
||||
}
|
||||
|
||||
var explorerType = Type.GetType(
|
||||
"Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer, Microsoft.BizTalk.ExplorerOM",
|
||||
false);
|
||||
if (explorerType != null)
|
||||
{
|
||||
RequireMicrosoftIdentity(explorerType.Assembly);
|
||||
return explorerType.Assembly;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Assembly.Load(requested);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// The installed-directory fallback below keeps non-GAC BizTalk admin installations usable.
|
||||
}
|
||||
catch (FileLoadException)
|
||||
{
|
||||
// The fallback still enforces the Microsoft strong-name identity before loading a file.
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
// ExplorerOM versions vary across supported BizTalk installations. This GAC-only
|
||||
// compatibility API is followed by an explicit Microsoft public-key-token check.
|
||||
var partial = Assembly.LoadWithPartialName(requested.Name);
|
||||
#pragma warning restore 618
|
||||
if (partial != null)
|
||||
{
|
||||
RequireMicrosoftIdentity(partial);
|
||||
return partial;
|
||||
}
|
||||
|
||||
var path = AdapterAssemblyResolver.FindCandidateFile(
|
||||
requested.Name,
|
||||
requested,
|
||||
AdapterAssemblyResolver.DiscoverSearchDirectories());
|
||||
if (path == null)
|
||||
{
|
||||
throw new FileNotFoundException(
|
||||
"Microsoft.BizTalk.ExplorerOM.dll was not found through CLR/GAC resolution or in the configured/installed BizTalk directories. "
|
||||
+ "The application association cannot be derived from the runtime WMI classes alone.");
|
||||
}
|
||||
var fromPath = Assembly.LoadFrom(path);
|
||||
RequireMicrosoftIdentity(fromPath);
|
||||
return fromPath;
|
||||
}
|
||||
|
||||
/// <summary>Rejects a same-named assembly that is not signed with the BizTalk product token.</summary>
|
||||
/// <param name="assembly">Loaded ExplorerOM candidate.</param>
|
||||
private static void RequireMicrosoftIdentity(Assembly assembly)
|
||||
{
|
||||
var actual = assembly == null ? null : assembly.GetName().GetPublicKeyToken();
|
||||
if (actual == null || actual.Length != BizTalkPublicKeyToken.Length)
|
||||
{
|
||||
throw new FileLoadException("Microsoft.BizTalk.ExplorerOM has no valid BizTalk product public key token.");
|
||||
}
|
||||
for (var index = 0; index < actual.Length; index++)
|
||||
{
|
||||
if (actual[index] != BizTalkPublicKeyToken[index])
|
||||
{
|
||||
throw new FileLoadException("Microsoft.BizTalk.ExplorerOM has an unexpected public key token.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets a required public instance property through reflection.</summary>
|
||||
/// <param name="instance">Object that owns the property.</param>
|
||||
/// <param name="name">Property name.</param>
|
||||
/// <returns>The property value.</returns>
|
||||
private static object GetProperty(object instance, string name)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new InvalidOperationException("ExplorerOM object was null while reading property '" + name + "'.");
|
||||
}
|
||||
var property = instance.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public);
|
||||
if (property == null)
|
||||
{
|
||||
throw new MissingMemberException(instance.GetType().FullName, name);
|
||||
}
|
||||
return property.GetValue(instance, null);
|
||||
}
|
||||
|
||||
/// <summary>Sets a required public instance property through reflection.</summary>
|
||||
/// <param name="instance">Object that owns the property.</param>
|
||||
/// <param name="name">Property name.</param>
|
||||
/// <param name="value">Value to assign.</param>
|
||||
private static void SetProperty(object instance, string name, object value)
|
||||
{
|
||||
var property = instance.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public);
|
||||
if (property == null || !property.CanWrite)
|
||||
{
|
||||
throw new MissingMemberException(instance.GetType().FullName, name);
|
||||
}
|
||||
property.SetValue(instance, value, null);
|
||||
}
|
||||
|
||||
/// <summary>Reads an optional string property from one ExplorerOM object.</summary>
|
||||
/// <param name="instance">ExplorerOM object.</param>
|
||||
/// <param name="name">Property name.</param>
|
||||
/// <returns>The trimmed string value, or null.</returns>
|
||||
private static string ReadString(object instance, string name)
|
||||
{
|
||||
var property = instance.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public);
|
||||
if (property == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var value = property.GetValue(instance, null) as string;
|
||||
return string.IsNullOrWhiteSpace(value) ? null : value.Trim();
|
||||
}
|
||||
|
||||
/// <summary>Validates and enumerates one ExplorerOM collection.</summary>
|
||||
/// <param name="value">Collection object.</param>
|
||||
/// <param name="description">Property path used in diagnostics.</param>
|
||||
/// <returns>The collection as an enumerable sequence.</returns>
|
||||
private static IEnumerable Enumerate(object value, string description)
|
||||
{
|
||||
var enumerable = value as IEnumerable;
|
||||
if (enumerable == null)
|
||||
{
|
||||
throw new InvalidOperationException("ExplorerOM property '" + description + "' is not enumerable.");
|
||||
}
|
||||
return enumerable;
|
||||
}
|
||||
|
||||
/// <summary>Writes an informational message when logging is available.</summary>
|
||||
/// <param name="logger">Optional logger.</param>
|
||||
/// <param name="message">Message text.</param>
|
||||
private static void Info(OperationLogger logger, string message)
|
||||
{
|
||||
if (logger != null)
|
||||
{
|
||||
logger.Info(message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Stores one artifact-type mapping and rejects cross-application ambiguity.</summary>
|
||||
private sealed class ArtifactApplicationMap
|
||||
{
|
||||
/// <summary>Unambiguous name/application mappings.</summary>
|
||||
private readonly Dictionary<string, string> _applications = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>Names observed under more than one application.</summary>
|
||||
private readonly HashSet<string> _ambiguous = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>Gets the number of unambiguous artifact names.</summary>
|
||||
internal int Count { get { return _applications.Count; } }
|
||||
|
||||
/// <summary>Gets the represented application names.</summary>
|
||||
internal IEnumerable<string> ApplicationNames { get { return _applications.Values; } }
|
||||
|
||||
/// <summary>Adds one mapping unless the artifact name is blank or becomes ambiguous.</summary>
|
||||
/// <param name="application">Application name.</param>
|
||||
/// <param name="artifact">Artifact name.</param>
|
||||
internal void Add(string application, string artifact)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(artifact))
|
||||
{
|
||||
return;
|
||||
}
|
||||
application = application.Trim();
|
||||
artifact = artifact.Trim();
|
||||
if (_ambiguous.Contains(artifact))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string existing;
|
||||
if (_applications.TryGetValue(artifact, out existing)
|
||||
&& !string.Equals(existing, application, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_applications.Remove(artifact);
|
||||
_ambiguous.Add(artifact);
|
||||
return;
|
||||
}
|
||||
_applications[artifact] = application;
|
||||
}
|
||||
|
||||
/// <summary>Resolves one unambiguous artifact name.</summary>
|
||||
/// <param name="artifact">Artifact name.</param>
|
||||
/// <returns>The application name, or null.</returns>
|
||||
internal string Resolve(string artifact)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(artifact) || _ambiguous.Contains(artifact.Trim()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string application;
|
||||
return _applications.TryGetValue(artifact.Trim(), out application) ? application : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.ServiceProcess;
|
||||
using BizTalkPlatformManagementTool.Models;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Services
|
||||
@@ -15,10 +16,10 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
/// <summary>
|
||||
/// Current tool version written into generated snapshots.
|
||||
/// </summary>
|
||||
public const string Version = "2.1.2-net461";
|
||||
public const string Version = "2.3.4-net461";
|
||||
|
||||
/// <summary>
|
||||
/// Fallback application name used when WMI does not expose an application property.
|
||||
/// Fallback application name used when neither WMI nor the ExplorerOM catalog can resolve ownership.
|
||||
/// </summary>
|
||||
private const string UnknownApplication = "(Unknown Application)";
|
||||
|
||||
@@ -47,7 +48,17 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
var ports = client.Query("MSBTS_SendPort");
|
||||
try
|
||||
{
|
||||
_logger.Success("WMI/CIM diagnostic succeeded. Send ports visible: " + ports.Count);
|
||||
var applications = TryLoadApplicationResolver(client);
|
||||
var resolved = applications == null
|
||||
? 0
|
||||
: ports.Count(x => !string.IsNullOrWhiteSpace(applications.ResolveSendPort(BizTalkWmiClient.SafeGetString(x, "Name", null))));
|
||||
_logger.Success("WMI/CIM diagnostic succeeded. Send ports visible: " + ports.Count
|
||||
+ "; application associations resolved: " + resolved + ".");
|
||||
if (ports.Count > 0 && resolved != ports.Count)
|
||||
{
|
||||
_logger.Warning("Application association is incomplete. Unresolved send ports: "
|
||||
+ (ports.Count - resolved) + ". Check the preceding ExplorerOM and BizTalk Management database diagnostics.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -73,18 +84,21 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
};
|
||||
|
||||
var apps = new Dictionary<string, ApplicationSnapshot>(StringComparer.OrdinalIgnoreCase);
|
||||
var applicationResolver = TryLoadApplicationResolver(client);
|
||||
var receiveLocations = client.Query("MSBTS_ReceiveLocation");
|
||||
try
|
||||
{
|
||||
foreach (var item in receiveLocations)
|
||||
{
|
||||
var appName = GetApplicationName(item);
|
||||
var name = BizTalkWmiClient.SafeGetString(item, "Name", string.Empty);
|
||||
var receivePortName = BizTalkWmiClient.SafeGetString(item, "ReceivePortName", string.Empty);
|
||||
var appName = GetApplicationName(item, applicationResolver, "ReceiveLocation", name, receivePortName);
|
||||
var app = GetApplication(apps, appName);
|
||||
app.ReceiveLocations.Add(new ReceiveLocationState
|
||||
{
|
||||
Application = app.Application,
|
||||
Name = BizTalkWmiClient.SafeGetString(item, "Name", string.Empty),
|
||||
ReceivePortName = BizTalkWmiClient.SafeGetString(item, "ReceivePortName", string.Empty),
|
||||
Name = name,
|
||||
ReceivePortName = receivePortName,
|
||||
Enabled = !BizTalkWmiClient.SafeGetBoolean(item, "IsDisabled", true),
|
||||
AdapterName = BizTalkWmiClient.SafeGetString(item, "AdapterName", string.Empty),
|
||||
Address = BizTalkWmiClient.SafeGetString(item, "InboundTransportURL", string.Empty)
|
||||
@@ -101,12 +115,13 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
foreach (var item in sendPorts)
|
||||
{
|
||||
var appName = GetApplicationName(item);
|
||||
var name = BizTalkWmiClient.SafeGetString(item, "Name", string.Empty);
|
||||
var appName = GetApplicationName(item, applicationResolver, "SendPort", name, null);
|
||||
var app = GetApplication(apps, appName);
|
||||
app.SendPorts.Add(new SendPortState
|
||||
{
|
||||
Application = app.Application,
|
||||
Name = BizTalkWmiClient.SafeGetString(item, "Name", string.Empty),
|
||||
Name = name,
|
||||
Status = BizTalkWmiClient.SafeGetInt32(item, "Status", 0),
|
||||
PrimaryTransportType = BizTalkWmiClient.SafeGetString(item, "PTTransportType", string.Empty),
|
||||
PrimaryTransportAddress = BizTalkWmiClient.SafeGetString(item, "PTAddress", string.Empty)
|
||||
@@ -123,12 +138,13 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
foreach (var item in orchestrations)
|
||||
{
|
||||
var appName = GetApplicationName(item);
|
||||
var name = BizTalkWmiClient.SafeGetString(item, "Name", string.Empty);
|
||||
var appName = GetApplicationName(item, applicationResolver, "Orchestration", name, null);
|
||||
var app = GetApplication(apps, appName);
|
||||
app.Orchestrations.Add(new OrchestrationState
|
||||
{
|
||||
Application = app.Application,
|
||||
Name = BizTalkWmiClient.SafeGetString(item, "Name", string.Empty),
|
||||
Name = name,
|
||||
OrchestrationStatus = BizTalkWmiClient.SafeGetInt32(item, "OrchestrationStatus", 0)
|
||||
});
|
||||
}
|
||||
@@ -169,6 +185,14 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
snapshot.HostInstances = snapshot.HostInstances.OrderBy(x => x.Server).ThenBy(x => x.InstanceName).ToList();
|
||||
|
||||
SnapshotValidator.Validate(snapshot);
|
||||
ApplicationSnapshot unresolved;
|
||||
if (apps.TryGetValue(UnknownApplication, out unresolved) && _logger != null)
|
||||
{
|
||||
_logger.Warning("Snapshot contains unresolved BizTalk application associations. ReceiveLocations="
|
||||
+ unresolved.ReceiveLocations.Count + "; SendPorts=" + unresolved.SendPorts.Count
|
||||
+ "; Orchestrations=" + unresolved.Orchestrations.Count
|
||||
+ ". Review ExplorerOM and BizTalk Management database diagnostics before plan approval.");
|
||||
}
|
||||
_logger.Success("Snapshot created. Applications: " + snapshot.Applications.Count + ", host instances: " + snapshot.HostInstances.Count);
|
||||
return snapshot;
|
||||
}
|
||||
@@ -191,14 +215,35 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
foreach (var item in app.ReceiveLocations.Where(x => x.Enabled))
|
||||
{
|
||||
plan.Steps.Add(Step("ReceiveLocation", app.Application, item.Name, null, "Disable receive location", "MSBTS_ReceiveLocation", "Name", item.Name, "Disable", null, null));
|
||||
var step = Step("ReceiveLocation", app.Application, item.Name, null, "Disable receive location", "MSBTS_ReceiveLocation", "Name", item.Name, "Disable", null, null);
|
||||
SetReceiveTransport(step, item);
|
||||
plan.Steps.Add(step);
|
||||
}
|
||||
}
|
||||
|
||||
if (HasShutdownWorkAfterInboundPhase(snapshot, server))
|
||||
{
|
||||
plan.Steps.Add(new OperationStep
|
||||
{
|
||||
Kind = OperationStepKind.OperatorCheckpoint.ToString(),
|
||||
Application = string.Empty,
|
||||
Name = "Inbound drain verification",
|
||||
Action = "Confirm that in-flight BizTalk processing has drained before continuing shutdown",
|
||||
Execute = true,
|
||||
Warning = "The operator must verify Group Hub/runtime monitoring. No automatic empty-state claim is made."
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var app in snapshot.Applications)
|
||||
{
|
||||
foreach (var item in app.Orchestrations.Where(x => x.OrchestrationStatus == ArtifactStates.OrchestrationStarted))
|
||||
{
|
||||
plan.Steps.Add(Step("Orchestration", app.Application, item.Name, null, "Stop orchestration", "MSBTS_Orchestration", "Name", item.Name, "Stop", new[] { 1, 1 }, ArtifactStates.OrchestrationStopped));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var app in snapshot.Applications)
|
||||
{
|
||||
foreach (var item in app.SendPorts.Where(x => x.Status == ArtifactStates.SendPortStarted))
|
||||
{
|
||||
plan.Steps.Add(Step("SendPort", app.Application, item.Name, null, "Stop send port", "MSBTS_SendPort", "Name", item.Name, "Stop", null, ArtifactStates.SendPortStopped));
|
||||
@@ -208,7 +253,7 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
foreach (var item in snapshot.HostInstances.Where(x => x.RawState == ArtifactStates.HostStarted))
|
||||
{
|
||||
var step = Step("HostInstance", string.Empty, item.InstanceName, item.Server, "Stop host instance", "MSBTS_HostInstance", "InstanceName", item.InstanceName, "Stop", null, ArtifactStates.HostStopped);
|
||||
if (!string.IsNullOrEmpty(item.Server) && !string.Equals(item.Server, server, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrEmpty(item.Server) && !SnapshotValidator.ServerNamesEqual(item.Server, server))
|
||||
{
|
||||
step.Execute = false;
|
||||
step.Warning = "Host instance belongs to server '" + item.Server + "'. Run this action on that server.";
|
||||
@@ -235,7 +280,7 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
foreach (var item in snapshot.HostInstances.Where(x => x.RawState == ArtifactStates.HostStarted))
|
||||
{
|
||||
var step = Step("HostInstance", string.Empty, item.InstanceName, item.Server, "Start host instance", "MSBTS_HostInstance", "InstanceName", item.InstanceName, "Start", null, ArtifactStates.HostStarted);
|
||||
if (!string.IsNullOrEmpty(item.Server) && !string.Equals(item.Server, server, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrEmpty(item.Server) && !SnapshotValidator.ServerNamesEqual(item.Server, server))
|
||||
{
|
||||
step.Execute = false;
|
||||
step.Warning = "Host instance belongs to server '" + item.Server + "'. Run this action on that server.";
|
||||
@@ -260,7 +305,10 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
plan.Steps.Add(Step("SendPort", app.Application, item.Name, null, "Ensure send port is bound", "MSBTS_SendPort", "Name", item.Name, "UnEnlist", null, ArtifactStates.SendPortBound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var app in snapshot.Applications)
|
||||
{
|
||||
foreach (var item in app.Orchestrations)
|
||||
{
|
||||
if (item.OrchestrationStatus == ArtifactStates.OrchestrationStarted)
|
||||
@@ -290,22 +338,68 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
plan.Steps.Add(Step("Orchestration", app.Application, item.Name, null, "Unenlist orchestration", "MSBTS_Orchestration", "Name", item.Name, "UnenlistService", new[] { 1 }, ArtifactStates.OrchestrationUnbound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var app in snapshot.Applications)
|
||||
{
|
||||
foreach (var item in app.ReceiveLocations)
|
||||
{
|
||||
plan.Steps.Add(Step("ReceiveLocation", app.Application, item.Name, null, item.Enabled ? "Enable receive location" : "Disable receive location", "MSBTS_ReceiveLocation", "Name", item.Name, item.Enabled ? "Enable" : "Disable", null, null));
|
||||
var step = Step("ReceiveLocation", app.Application, item.Name, null, item.Enabled ? "Enable receive location" : "Disable receive location", "MSBTS_ReceiveLocation", "Name", item.Name, item.Enabled ? "Enable" : "Disable", null, null);
|
||||
SetReceiveTransport(step, item);
|
||||
plan.Steps.Add(step);
|
||||
}
|
||||
}
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a recovery plan from an existing snapshot without taking or
|
||||
/// overwriting a new before snapshot. Enterprise SSO is added as the first prerequisite.
|
||||
/// </summary>
|
||||
/// <param name="snapshot">The preserved pre-maintenance state.</param>
|
||||
/// <param name="server">The selected target server.</param>
|
||||
/// <returns>An ordered, state-aware emergency restore plan.</returns>
|
||||
public OperationPlan CreateEmergencyRestorePlan(BizTalkSnapshot snapshot, string server)
|
||||
{
|
||||
var plan = CreateRestorePlan(snapshot, server);
|
||||
plan.Mode = OperationMode.EmergencyRestore.ToString();
|
||||
plan.Steps.Insert(0, Step(
|
||||
"WindowsService",
|
||||
string.Empty,
|
||||
"ENTSSO",
|
||||
server,
|
||||
"Ensure Enterprise Single Sign-On service is running",
|
||||
"Win32_Service",
|
||||
"Name",
|
||||
"ENTSSO",
|
||||
"Start",
|
||||
null,
|
||||
(int)ServiceControllerStatus.Running));
|
||||
return plan;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes an operation plan or logs each step when dry-run mode is enabled.
|
||||
/// </summary>
|
||||
/// <param name="plan">The ordered plan to execute.</param>
|
||||
/// <param name="options">The runtime options controlling server, dry-run and wait behavior.</param>
|
||||
public void ExecutePlan(OperationPlan plan, OperationOptions options)
|
||||
public OperationExecutionReport ExecutePlan(OperationPlan plan, OperationOptions options)
|
||||
{
|
||||
return ExecutePlan(plan, options, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a plan with an optional fail-closed operator checkpoint callback.
|
||||
/// </summary>
|
||||
/// <param name="plan">The ordered plan to execute.</param>
|
||||
/// <param name="options">The runtime execution options.</param>
|
||||
/// <param name="checkpointHandler">Operator callback used by real shutdown plans.</param>
|
||||
/// <returns>The complete execution report.</returns>
|
||||
internal OperationExecutionReport ExecutePlan(
|
||||
OperationPlan plan,
|
||||
OperationOptions options,
|
||||
OperationCheckpointHandler checkpointHandler)
|
||||
{
|
||||
if (plan == null || options == null)
|
||||
{
|
||||
@@ -315,42 +409,50 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
throw new InvalidOperationException("The operation plan targets server '" + plan.Server + "' but execution was requested for '" + options.Server + "'.");
|
||||
}
|
||||
using (var client = CreateClient(options.Server))
|
||||
{
|
||||
foreach (var step in plan.Steps)
|
||||
{
|
||||
if (!step.Execute)
|
||||
{
|
||||
_logger.Warning(step.Action + (string.IsNullOrEmpty(step.Warning) ? string.Empty : " " + step.Warning));
|
||||
continue;
|
||||
}
|
||||
|
||||
var executor = new OperationPlanExecutor(_logger);
|
||||
if (options.DryRun)
|
||||
{
|
||||
// Dry-run löst das Objekt absichtlich nicht erneut per WMI auf und führt keine Methode aus.
|
||||
_logger.Info("DRY RUN: " + step.Action + " '" + step.Name + "'");
|
||||
continue;
|
||||
// Dry-run benötigt absichtlich weder WMI-Verbindung noch Servicezugriff.
|
||||
return executor.Execute(plan, options, null, checkpointHandler);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.Info("Executing step: " + DescribeStep(step));
|
||||
using (var instance = client.FindByProperty(step.WmiClass, step.KeyProperty, step.KeyValue))
|
||||
using (var runtime = new WmiOperationStepRuntime(options.Server, _logger))
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new InvalidOperationException(step.Kind + " not found: " + step.Name);
|
||||
}
|
||||
|
||||
ExecuteStep(client, instance, step, options);
|
||||
return executor.Execute(plan, options, runtime, checkpointHandler);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException("Step failed: " + DescribeStep(step) + ". Error: " + ex.Message, ex);
|
||||
}
|
||||
var error = OperationPlanExecutor.FormatException(ex);
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.Error("Plan runtime initialization failed. No executable step could be started. Error: " + error);
|
||||
}
|
||||
return new OperationExecutionReport
|
||||
{
|
||||
Mode = plan.Mode,
|
||||
Server = plan.Server,
|
||||
DryRun = false,
|
||||
StartedAt = DateTimeOffset.Now.ToString("o"),
|
||||
FinishedAt = DateTimeOffset.Now.ToString("o"),
|
||||
InitializationError = error
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Checks whether a shutdown has a runtime phase after receive locations.</summary>
|
||||
/// <param name="snapshot">The validated source snapshot.</param>
|
||||
/// <param name="server">The selected host-instance server.</param>
|
||||
/// <returns>True when orchestration, send-port or host-instance work follows.</returns>
|
||||
private static bool HasShutdownWorkAfterInboundPhase(BizTalkSnapshot snapshot, string server)
|
||||
{
|
||||
return snapshot.Applications.Any(app =>
|
||||
app.Orchestrations.Any(item => item.OrchestrationStatus == ArtifactStates.OrchestrationStarted)
|
||||
|| app.SendPorts.Any(item => item.Status == ArtifactStates.SendPortStarted))
|
||||
|| snapshot.HostInstances.Any(item => item.RawState == ArtifactStates.HostStarted
|
||||
&& (string.IsNullOrWhiteSpace(item.Server) || SnapshotValidator.ServerNamesEqual(item.Server, server)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -385,6 +487,25 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a complete execution report, including every failure and continued step.
|
||||
/// </summary>
|
||||
/// <param name="outputDirectory">The directory where the report is written.</param>
|
||||
/// <param name="fileName">The report file name.</param>
|
||||
/// <param name="report">The report to persist.</param>
|
||||
/// <returns>The saved report path.</returns>
|
||||
public string SaveExecutionReport(string outputDirectory, string fileName, OperationExecutionReport report)
|
||||
{
|
||||
Directory.CreateDirectory(outputDirectory);
|
||||
var path = Path.Combine(outputDirectory, fileName);
|
||||
JsonFileStore.Save(path, report);
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.Success("Saved execution report: " + path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a diff and its report sidecars.
|
||||
/// </summary>
|
||||
@@ -402,79 +523,243 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes one concrete WMI operation step and waits for its target state.
|
||||
/// Implements state-aware Windows-service and BizTalk-WMI execution for a plan step.
|
||||
/// </summary>
|
||||
/// <param name="client">The connected WMI client.</param>
|
||||
/// <param name="instance">The resolved WMI object for the step.</param>
|
||||
/// <param name="step">The operation step to execute.</param>
|
||||
/// <param name="options">The runtime options controlling wait behavior.</param>
|
||||
private void ExecuteStep(BizTalkWmiClient client, ManagementObject instance, OperationStep step, OperationOptions options)
|
||||
private sealed class WmiOperationStepRuntime : IOperationStepRuntime, IDisposable
|
||||
{
|
||||
/// <summary>Target server used for service and WMI operations.</summary>
|
||||
private readonly string _server;
|
||||
|
||||
/// <summary>Operation logger.</summary>
|
||||
private readonly OperationLogger _logger;
|
||||
|
||||
/// <summary>Process-local resolver for adapter validation dependencies.</summary>
|
||||
private readonly AdapterAssemblyResolver _assemblyResolver;
|
||||
|
||||
/// <summary>Lazily connected BizTalk WMI client.</summary>
|
||||
private BizTalkWmiClient _client;
|
||||
|
||||
/// <summary>Initializes the production runtime adapter.</summary>
|
||||
/// <param name="server">The target server.</param>
|
||||
/// <param name="logger">The operation logger.</param>
|
||||
public WmiOperationStepRuntime(string server, OperationLogger logger)
|
||||
{
|
||||
_server = string.IsNullOrWhiteSpace(server) ? Environment.MachineName : server.Trim();
|
||||
_logger = logger;
|
||||
_assemblyResolver = new AdapterAssemblyResolver(logger);
|
||||
}
|
||||
|
||||
/// <summary>Executes one Windows-service or BizTalk-WMI step state-aware.</summary>
|
||||
/// <param name="step">The operation step.</param>
|
||||
/// <param name="options">Timeout and polling options.</param>
|
||||
/// <returns>The successful runtime outcome.</returns>
|
||||
public RuntimeStepOutcome Execute(OperationStep step, OperationOptions options)
|
||||
{
|
||||
if (string.Equals(step.Kind, "WindowsService", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ExecuteWindowsService(step, options);
|
||||
}
|
||||
|
||||
var client = EnsureClient();
|
||||
using (var instance = client.FindByProperty(step.WmiClass, step.KeyProperty, step.KeyValue))
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
throw new InvalidOperationException(step.Kind + " not found: " + step.Name);
|
||||
}
|
||||
if (IsTargetStateReached(instance, step))
|
||||
{
|
||||
return RuntimeStepOutcome.AlreadySatisfied;
|
||||
}
|
||||
if (IsScheduledTaskReceiveLocation(step))
|
||||
{
|
||||
_assemblyResolver.PrepareScheduledTaskAdapter();
|
||||
}
|
||||
ExecuteWmiStep(instance, step, options);
|
||||
return RuntimeStepOutcome.Succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the lazily created WMI client.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_client != null)
|
||||
{
|
||||
_client.Dispose();
|
||||
_client = null;
|
||||
}
|
||||
_assemblyResolver.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>Detects the third-party ScheduledTask adapter from captured plan metadata.</summary>
|
||||
/// <param name="step">The receive-location step.</param>
|
||||
/// <returns>True when Scheduler dependency preflight is required.</returns>
|
||||
private static bool IsScheduledTaskReceiveLocation(OperationStep step)
|
||||
{
|
||||
return step != null
|
||||
&& string.Equals(step.Kind, "ReceiveLocation", StringComparison.OrdinalIgnoreCase)
|
||||
&& ((!string.IsNullOrWhiteSpace(step.Address)
|
||||
&& step.Address.TrimStart().StartsWith("scheduler:", StringComparison.OrdinalIgnoreCase))
|
||||
|| (!string.IsNullOrWhiteSpace(step.AdapterName)
|
||||
&& step.AdapterName.IndexOf("schedul", StringComparison.OrdinalIgnoreCase) >= 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects to BizTalk WMI only when the first BizTalk step is reached,
|
||||
/// allowing ENTSSO to start before any provider dependency is evaluated.
|
||||
/// </summary>
|
||||
/// <returns>The connected client.</returns>
|
||||
private BizTalkWmiClient EnsureClient()
|
||||
{
|
||||
if (_client != null)
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
var client = new BizTalkWmiClient(_server, _logger);
|
||||
try
|
||||
{
|
||||
client.Connect();
|
||||
_client = client;
|
||||
return _client;
|
||||
}
|
||||
catch
|
||||
{
|
||||
client.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Starts or resumes a Windows-service prerequisite and waits for Running.</summary>
|
||||
private RuntimeStepOutcome ExecuteWindowsService(OperationStep step, OperationOptions options)
|
||||
{
|
||||
var targetServer = string.IsNullOrWhiteSpace(step.Server) ? _server : step.Server;
|
||||
using (var service = new ServiceController(step.Name, targetServer))
|
||||
{
|
||||
service.Refresh();
|
||||
if (service.Status == ServiceControllerStatus.Running)
|
||||
{
|
||||
return RuntimeStepOutcome.AlreadySatisfied;
|
||||
}
|
||||
|
||||
if (service.Status == ServiceControllerStatus.StartPending
|
||||
|| service.Status == ServiceControllerStatus.ContinuePending)
|
||||
{
|
||||
service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(Math.Max(1, options.WaitTimeoutSeconds)));
|
||||
}
|
||||
else if (service.Status == ServiceControllerStatus.PausePending)
|
||||
{
|
||||
service.WaitForStatus(ServiceControllerStatus.Paused, TimeSpan.FromSeconds(Math.Max(1, options.WaitTimeoutSeconds)));
|
||||
service.Refresh();
|
||||
_logger.Info("Continuing Windows service '" + step.Name + "' on " + targetServer + ".");
|
||||
service.Continue();
|
||||
service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(Math.Max(1, options.WaitTimeoutSeconds)));
|
||||
}
|
||||
else if (service.Status == ServiceControllerStatus.Paused)
|
||||
{
|
||||
_logger.Info("Continuing Windows service '" + step.Name + "' on " + targetServer + ".");
|
||||
service.Continue();
|
||||
service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(Math.Max(1, options.WaitTimeoutSeconds)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (service.Status == ServiceControllerStatus.StopPending)
|
||||
{
|
||||
service.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(Math.Max(1, options.WaitTimeoutSeconds)));
|
||||
service.Refresh();
|
||||
}
|
||||
_logger.Info("Starting Windows service '" + step.Name + "' on " + targetServer + ".");
|
||||
service.Start();
|
||||
service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(Math.Max(1, options.WaitTimeoutSeconds)));
|
||||
}
|
||||
_logger.Success("Reached: Windows service '" + step.Name + "' is Running.");
|
||||
return RuntimeStepOutcome.Succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Executes one BizTalk WMI method or pseudo-method and verifies the target state.</summary>
|
||||
private void ExecuteWmiStep(ManagementObject instance, OperationStep step, OperationOptions options)
|
||||
{
|
||||
if (string.Equals(step.MethodName, "StopOrEnlist", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var status = BizTalkWmiClient.SafeGetInt32(instance, "Status", 0);
|
||||
if (status == ArtifactStates.SendPortBound)
|
||||
{
|
||||
client.InvokeMethod(instance, "Enlist");
|
||||
_client.InvokeMethod(instance, "Enlist");
|
||||
}
|
||||
else if (status == ArtifactStates.SendPortStarted)
|
||||
{
|
||||
client.InvokeMethod(instance, "Stop");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Info("Already stopped: " + step.Name);
|
||||
_client.InvokeMethod(instance, "Stop");
|
||||
}
|
||||
}
|
||||
else if (string.Equals(step.MethodName, "StopIfStarted", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var status = BizTalkWmiClient.SafeGetInt32(instance, "OrchestrationStatus", 0);
|
||||
if (status == ArtifactStates.OrchestrationStarted)
|
||||
if (BizTalkWmiClient.SafeGetInt32(instance, "OrchestrationStatus", 0) == ArtifactStates.OrchestrationStarted)
|
||||
{
|
||||
client.InvokeMethod(instance, "Stop", ToObjects(step.Arguments));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Info("No stop required: " + step.Name);
|
||||
_client.InvokeMethod(instance, "Stop", ToObjects(step.Arguments));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
client.InvokeMethod(instance, step.MethodName, ToObjects(step.Arguments));
|
||||
_client.InvokeMethod(instance, step.MethodName, ToObjects(step.Arguments));
|
||||
}
|
||||
|
||||
WaitForTarget(client, step, options);
|
||||
WaitForTarget(step, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits until a WMI object reaches the target state described by a plan step.
|
||||
/// </summary>
|
||||
/// <param name="client">The connected WMI client.</param>
|
||||
/// <param name="step">The step whose target state should be verified.</param>
|
||||
/// <param name="options">The runtime options controlling timeout and polling interval.</param>
|
||||
private void WaitForTarget(BizTalkWmiClient client, OperationStep step, OperationOptions options)
|
||||
/// <summary>Checks whether a live WMI object already matches the requested target state.</summary>
|
||||
private static bool IsTargetStateReached(ManagementObject instance, OperationStep step)
|
||||
{
|
||||
if (string.Equals(step.Kind, "ReceiveLocation", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var enabled = !BizTalkWmiClient.SafeGetBoolean(instance, "IsDisabled", true);
|
||||
return enabled == string.Equals(step.MethodName, "Enable", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
if (!step.TargetState.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(step.Kind, "SendPort", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return BizTalkWmiClient.SafeGetInt32(instance, "Status", 0) == step.TargetState.Value;
|
||||
}
|
||||
if (string.Equals(step.Kind, "Orchestration", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return BizTalkWmiClient.SafeGetInt32(instance, "OrchestrationStatus", 0) == step.TargetState.Value;
|
||||
}
|
||||
if (string.Equals(step.Kind, "HostInstance", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return BizTalkWmiClient.SafeGetInt32(instance, "ServiceState", 0) == step.TargetState.Value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Waits for the WMI target state after a mutation.</summary>
|
||||
private void WaitForTarget(OperationStep step, OperationOptions options)
|
||||
{
|
||||
if (!step.TargetState.HasValue)
|
||||
{
|
||||
if (step.Kind == "ReceiveLocation")
|
||||
{
|
||||
var shouldBeEnabled = string.Equals(step.MethodName, "Enable", StringComparison.OrdinalIgnoreCase);
|
||||
client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => !BizTalkWmiClient.SafeGetBoolean(o, "IsDisabled", true) == shouldBeEnabled, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
_client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => !BizTalkWmiClient.SafeGetBoolean(o, "IsDisabled", true) == shouldBeEnabled, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (step.Kind == "SendPort")
|
||||
{
|
||||
client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => BizTalkWmiClient.SafeGetInt32(o, "Status", 0) == step.TargetState.Value, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
_client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => BizTalkWmiClient.SafeGetInt32(o, "Status", 0) == step.TargetState.Value, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
}
|
||||
else if (step.Kind == "Orchestration")
|
||||
{
|
||||
client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => BizTalkWmiClient.SafeGetInt32(o, "OrchestrationStatus", 0) == step.TargetState.Value, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
_client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => BizTalkWmiClient.SafeGetInt32(o, "OrchestrationStatus", 0) == step.TargetState.Value, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
}
|
||||
else if (step.Kind == "HostInstance")
|
||||
{
|
||||
client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => BizTalkWmiClient.SafeGetInt32(o, "ServiceState", 0) == step.TargetState.Value, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
_client.WaitForState(step.WmiClass, step.KeyProperty, step.KeyValue, o => BizTalkWmiClient.SafeGetInt32(o, "ServiceState", 0) == step.TargetState.Value, step.Action + " completed", options.WaitTimeoutSeconds, options.PollIntervalSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,6 +825,15 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Copies receive transport metadata into a durable operation step.</summary>
|
||||
/// <param name="step">The plan step to enrich.</param>
|
||||
/// <param name="receiveLocation">The captured receive location.</param>
|
||||
private static void SetReceiveTransport(OperationStep step, ReceiveLocationState receiveLocation)
|
||||
{
|
||||
step.AdapterName = receiveLocation == null ? null : receiveLocation.AdapterName;
|
||||
step.Address = receiveLocation == null ? null : receiveLocation.Address;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts integer method arguments into the object array required by WMI.
|
||||
/// </summary>
|
||||
@@ -578,6 +872,8 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
+ ", class=" + step.WmiClass
|
||||
+ ", key=" + step.KeyProperty + "=" + (step.KeyValue ?? string.Empty)
|
||||
+ ", method=" + step.MethodName
|
||||
+ (string.IsNullOrWhiteSpace(step.AdapterName) ? string.Empty : ", adapter=" + step.AdapterName)
|
||||
+ (string.IsNullOrWhiteSpace(step.Address) ? string.Empty : ", address=" + step.Address)
|
||||
+ (string.IsNullOrWhiteSpace(step.Server) ? string.Empty : ", server=" + step.Server)
|
||||
+ "]";
|
||||
}
|
||||
@@ -600,24 +896,75 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the application name from the available WMI properties.
|
||||
/// Reads a directly exposed application name or resolves it through the
|
||||
/// ExplorerOM application hierarchy because the runtime WMI classes do not
|
||||
/// define a reliable application property.
|
||||
/// </summary>
|
||||
/// <param name="item">The WMI object being mapped into a snapshot item.</param>
|
||||
/// <param name="resolver">Optional ExplorerOM application resolver.</param>
|
||||
/// <param name="kind">Artifact kind used to select the catalog index.</param>
|
||||
/// <param name="name">Artifact name.</param>
|
||||
/// <param name="parentName">Optional parent receive-port name.</param>
|
||||
/// <returns>The discovered application name or a stable fallback.</returns>
|
||||
private static string GetApplicationName(ManagementObject item)
|
||||
private static string GetApplicationName(ManagementObject item, BizTalkApplicationResolver resolver, string kind, string name, string parentName)
|
||||
{
|
||||
var names = new[] { "ApplicationName", "Application", "BizTalkApplication" };
|
||||
foreach (var name in names)
|
||||
foreach (var propertyName in names)
|
||||
{
|
||||
var value = BizTalkWmiClient.SafeGetString(item, name, null);
|
||||
var value = BizTalkWmiClient.SafeGetString(item, propertyName, null);
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolver != null)
|
||||
{
|
||||
string application = null;
|
||||
if (string.Equals(kind, "SendPort", StringComparison.Ordinal))
|
||||
{
|
||||
application = resolver.ResolveSendPort(name);
|
||||
}
|
||||
else if (string.Equals(kind, "ReceiveLocation", StringComparison.Ordinal))
|
||||
{
|
||||
application = resolver.ResolveReceiveLocation(name, parentName);
|
||||
}
|
||||
else if (string.Equals(kind, "Orchestration", StringComparison.Ordinal))
|
||||
{
|
||||
application = resolver.ResolveOrchestration(name);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(application))
|
||||
{
|
||||
return application;
|
||||
}
|
||||
}
|
||||
return UnknownApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the optional ExplorerOM application index while preserving WMI-only
|
||||
/// snapshot availability and emitting an actionable warning on failure.
|
||||
/// </summary>
|
||||
/// <param name="client">Connected BizTalk WMI client.</param>
|
||||
/// <returns>The populated resolver, or null when the catalog could not be read.</returns>
|
||||
private BizTalkApplicationResolver TryLoadApplicationResolver(BizTalkWmiClient client)
|
||||
{
|
||||
try
|
||||
{
|
||||
return BizTalkApplicationResolver.Load(client, _logger);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.Warning("BizTalk application association could not be loaded. Runtime state collection remains available, "
|
||||
+ "but affected artifacts will be grouped under " + UnknownApplication + ". "
|
||||
+ ExceptionDiagnostics.Format(ex));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt alle von einer WMI-Abfrage übernommenen Objekte deterministisch frei.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates support-ready, single-line exception diagnostics for the GUI, durable
|
||||
/// execution reports and rolling log files.
|
||||
/// </summary>
|
||||
internal static class ExceptionDiagnostics
|
||||
{
|
||||
/// <summary>
|
||||
/// Formats the complete exception chain including type, HRESULT, fusion details
|
||||
/// and stack trace without embedding physical line breaks in the daily log.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception to format.</param>
|
||||
/// <returns>A detailed single-line diagnostic string.</returns>
|
||||
public static string Format(Exception exception)
|
||||
{
|
||||
if (exception == null)
|
||||
{
|
||||
return "Unknown operation error.";
|
||||
}
|
||||
|
||||
var parts = new List<string>();
|
||||
var current = exception;
|
||||
var depth = 0;
|
||||
while (current != null)
|
||||
{
|
||||
var label = depth == 0 ? "Exception" : "InnerException[" + depth.ToString(CultureInfo.InvariantCulture) + "]";
|
||||
var part = label
|
||||
+ " Type=" + current.GetType().FullName
|
||||
+ "; HResult=0x" + current.HResult.ToString("X8", CultureInfo.InvariantCulture)
|
||||
+ "; Message=" + Flatten(current.Message);
|
||||
|
||||
var fileNotFound = current as FileNotFoundException;
|
||||
if (fileNotFound != null && !string.IsNullOrWhiteSpace(fileNotFound.FusionLog))
|
||||
{
|
||||
part += "; FusionLog=" + Flatten(fileNotFound.FusionLog);
|
||||
}
|
||||
var fileLoad = current as FileLoadException;
|
||||
if (fileLoad != null && !string.IsNullOrWhiteSpace(fileLoad.FusionLog))
|
||||
{
|
||||
part += "; FusionLog=" + Flatten(fileLoad.FusionLog);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(current.StackTrace))
|
||||
{
|
||||
part += "; StackTrace=" + Flatten(current.StackTrace);
|
||||
}
|
||||
|
||||
parts.Add(part);
|
||||
current = current.InnerException;
|
||||
depth++;
|
||||
}
|
||||
return string.Join(" | ", parts.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>Replaces physical control characters with readable escape sequences.</summary>
|
||||
/// <param name="value">The text to flatten.</param>
|
||||
/// <returns>Single-line text suitable for one durable log record.</returns>
|
||||
private static string Flatten(string value)
|
||||
{
|
||||
return (value ?? string.Empty)
|
||||
.Replace("\r", "\\r")
|
||||
.Replace("\n", "\\n")
|
||||
.Replace("\t", "\\t");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
@@ -68,39 +71,88 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
private const string LogFileExtension = ".log";
|
||||
|
||||
/// <summary>
|
||||
/// Number of daily log files retained, including the current day.
|
||||
/// Number of calendar days retained, including the current day.
|
||||
/// </summary>
|
||||
private const int RetentionDays = 5;
|
||||
internal const int RetentionDays = 30;
|
||||
|
||||
/// <summary>Maximum number of historical records restored into the GUI by default.</summary>
|
||||
public const int DefaultGridHistoryLimit = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// Process-wide lock that serializes log file appends.
|
||||
/// </summary>
|
||||
private static readonly object FileLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Process-wide flag that ensures log cleanup runs only once.
|
||||
/// </summary>
|
||||
private static int _cleanupDone;
|
||||
|
||||
/// <summary>
|
||||
/// Optional callback for forwarding entries to the UI.
|
||||
/// </summary>
|
||||
private readonly Action<LogEntry> _sink;
|
||||
|
||||
/// <summary>
|
||||
/// Directory where daily log files are written.
|
||||
/// Ordered local directories available for primary and fallback logging.
|
||||
/// </summary>
|
||||
private readonly string _logDirectory;
|
||||
private readonly List<string> _candidateDirectories;
|
||||
|
||||
/// <summary>Index of the currently active writable directory, or minus one.</summary>
|
||||
private int _activeDirectoryIndex;
|
||||
|
||||
/// <summary>Directory where daily log files are currently written.</summary>
|
||||
private string _logDirectory;
|
||||
|
||||
/// <summary>Latest actionable storage warning for the operator.</summary>
|
||||
private string _storageWarning;
|
||||
|
||||
/// <summary>Last storage notice already forwarded to the UI sink.</summary>
|
||||
private string _reportedStorageNotice;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new logger that writes beside the executable.
|
||||
/// Initializes a logger that verifies ProgramData and ordered local fallback directories.
|
||||
/// </summary>
|
||||
/// <param name="sink">Optional callback that receives entries for display.</param>
|
||||
public OperationLogger(Action<LogEntry> sink)
|
||||
: this(sink, BuildLogDirectoryCandidates())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a logger with an explicit directory for regression tests.</summary>
|
||||
/// <param name="sink">Optional callback that receives new entries.</param>
|
||||
/// <param name="logDirectory">Directory used for plain and compressed logs.</param>
|
||||
internal OperationLogger(Action<LogEntry> sink, string logDirectory)
|
||||
: this(sink, new[] { logDirectory })
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a logger with ordered primary and fallback directories.</summary>
|
||||
/// <param name="sink">Optional callback that receives new entries.</param>
|
||||
/// <param name="candidateDirectories">Ordered local directories to verify.</param>
|
||||
internal OperationLogger(Action<LogEntry> sink, IEnumerable<string> candidateDirectories)
|
||||
{
|
||||
_sink = sink;
|
||||
_logDirectory = ResolveLogDirectory();
|
||||
CleanupOldLogs();
|
||||
_candidateDirectories = NormalizeDirectories(candidateDirectories).ToList();
|
||||
_activeDirectoryIndex = -1;
|
||||
SelectInitialLogDirectory();
|
||||
if (_logDirectory != null)
|
||||
{
|
||||
MaintainLogs(DateTime.Now.Date);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the directory containing active and compressed runtime logs.</summary>
|
||||
public string LogDirectory
|
||||
{
|
||||
get { lock (FileLock) { return _logDirectory ?? string.Empty; } }
|
||||
}
|
||||
|
||||
/// <summary>Gets whether a daily runtime log can currently be written.</summary>
|
||||
public bool IsFileLoggingAvailable
|
||||
{
|
||||
get { lock (FileLock) { return _activeDirectoryIndex >= 0 && !string.IsNullOrWhiteSpace(_logDirectory); } }
|
||||
}
|
||||
|
||||
/// <summary>Gets the latest fallback or total-storage-failure diagnostic.</summary>
|
||||
public string StorageWarning
|
||||
{
|
||||
get { lock (FileLock) { return _storageWarning; } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,9 +162,55 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(_logDirectory, LogFilePrefix + DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) + LogFileExtension);
|
||||
lock (FileLock)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(_logDirectory)
|
||||
? string.Empty
|
||||
: BuildLogFilePath(_logDirectory, DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads retained plain and GZip-compressed records for restoring the operation grid.
|
||||
/// Malformed legacy lines are ignored without affecting current logging.
|
||||
/// </summary>
|
||||
/// <param name="maximumEntries">Maximum newest entries to return.</param>
|
||||
/// <returns>Chronologically ordered retained log entries.</returns>
|
||||
public IList<LogEntry> ReadRecentEntries(int maximumEntries)
|
||||
{
|
||||
if (maximumEntries <= 0)
|
||||
{
|
||||
return new List<LogEntry>();
|
||||
}
|
||||
|
||||
var entries = new List<LogEntry>();
|
||||
var directory = LogDirectory;
|
||||
if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory))
|
||||
{
|
||||
return entries;
|
||||
}
|
||||
try
|
||||
{
|
||||
var files = Directory.GetFiles(directory, LogFilePrefix + "*" + LogFileExtension + "*")
|
||||
.Where(IsSupportedLogFile)
|
||||
.OrderBy(x => x, StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
foreach (var file in files)
|
||||
{
|
||||
ReadEntries(file, entries);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Historical display is optional; current operations and file logging continue.
|
||||
}
|
||||
|
||||
return entries
|
||||
.OrderBy(x => x.Timestamp)
|
||||
.Skip(Math.Max(0, entries.Count - maximumEntries))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an informational entry.
|
||||
@@ -164,62 +262,139 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
Message = message
|
||||
};
|
||||
|
||||
WriteToFile(entry);
|
||||
var storageNotice = WriteToFile(entry);
|
||||
DeliverToSink(entry);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(storageNotice))
|
||||
{
|
||||
var warning = new LogEntry
|
||||
{
|
||||
Timestamp = DateTime.Now,
|
||||
Level = LogLevel.Warning,
|
||||
Message = storageNotice
|
||||
};
|
||||
WriteToFile(warning);
|
||||
DeliverToSink(warning);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Forwards one record to the optional GUI without affecting runtime work.</summary>
|
||||
/// <param name="entry">The record to display.</param>
|
||||
private void DeliverToSink(LogEntry entry)
|
||||
{
|
||||
if (_sink == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_sink(entry);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Auch die optionale GUI-Weiterleitung ist nur ein Diagnosekanal. Ein Fehler
|
||||
// dort darf insbesondere nicht die Exception-Behandlung eines BizTalk-Schritts
|
||||
// erneut unterbrechen und dadurch alle späteren Planschritte verhindern.
|
||||
WriteToFile(new LogEntry
|
||||
{
|
||||
Timestamp = DateTime.Now,
|
||||
Level = LogLevel.Warning,
|
||||
Message = "Log display sink failed; runtime operation continues. Error: " + ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends one entry to the current daily log file.
|
||||
/// </summary>
|
||||
/// <param name="entry">The entry to write.</param>
|
||||
private void WriteToFile(LogEntry entry)
|
||||
{
|
||||
try
|
||||
/// <returns>A new operator-visible storage notice, or null.</returns>
|
||||
private string WriteToFile(LogEntry entry)
|
||||
{
|
||||
var line = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"[{0:yyyy-MM-dd HH:mm:ss}][{1}] {2}{3}",
|
||||
entry.Timestamp,
|
||||
entry.Level.ToString().ToUpperInvariant(),
|
||||
entry.Message,
|
||||
(entry.Message ?? string.Empty).Replace("\r", "\\r").Replace("\n", "\\n"),
|
||||
Environment.NewLine);
|
||||
|
||||
lock (FileLock)
|
||||
{
|
||||
File.AppendAllText(LogFilePath, line);
|
||||
}
|
||||
}
|
||||
catch
|
||||
var failures = new List<string>();
|
||||
var previousDirectory = _logDirectory;
|
||||
var startIndex = _activeDirectoryIndex >= 0 ? _activeDirectoryIndex : 0;
|
||||
for (var index = startIndex; index < _candidateDirectories.Count; index++)
|
||||
{
|
||||
// Ein Logfehler darf niemals eine fachliche BizTalk-Operation abbrechen.
|
||||
var candidate = _candidateDirectories[index];
|
||||
string error;
|
||||
if (!TryAppend(candidate, line, out error))
|
||||
{
|
||||
failures.Add(candidate + " => " + error);
|
||||
continue;
|
||||
}
|
||||
|
||||
_activeDirectoryIndex = index;
|
||||
_logDirectory = candidate;
|
||||
if (!string.Equals(previousDirectory, candidate, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_storageWarning = "Runtime log path switched to writable fallback '" + candidate
|
||||
+ "'. Failed path(s): " + string.Join(" | ", failures.ToArray());
|
||||
return TakeUnreportedStorageNotice(_storageWarning);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
_activeDirectoryIndex = -1;
|
||||
_logDirectory = null;
|
||||
_storageWarning = "RUNTIME FILE LOGGING UNAVAILABLE. No candidate directory accepted an append. Attempted: "
|
||||
+ string.Join(" | ", failures.ToArray()) + ". Operations continue and remain visible in the grid, but no durable runtime log is being written.";
|
||||
return TakeUnreportedStorageNotice(_storageWarning);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns a storage notice only once per distinct failure state.</summary>
|
||||
/// <param name="notice">The current diagnostic.</param>
|
||||
/// <returns>The notice when it has not been reported before; otherwise null.</returns>
|
||||
private string TakeUnreportedStorageNotice(string notice)
|
||||
{
|
||||
if (string.Equals(_reportedStorageNotice, notice, StringComparison.Ordinal))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_reportedStorageNotice = notice;
|
||||
return notice;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes log files older than the configured retention window.
|
||||
/// Compresses completed daily logs and removes all records outside retention.
|
||||
/// </summary>
|
||||
private void CleanupOldLogs()
|
||||
/// <param name="today">The current local date.</param>
|
||||
internal void MaintainLogs(DateTime today)
|
||||
{
|
||||
if (Interlocked.Exchange(ref _cleanupDone, 1) == 1)
|
||||
var directory = LogDirectory;
|
||||
if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var cutoff = DateTime.Now.Date.AddDays(-(RetentionDays - 1));
|
||||
foreach (var file in Directory.GetFiles(_logDirectory, LogFilePrefix + "*" + LogFileExtension))
|
||||
var cutoff = today.Date.AddDays(-(RetentionDays - 1));
|
||||
foreach (var file in Directory.GetFiles(directory, LogFilePrefix + "*" + LogFileExtension + "*"))
|
||||
{
|
||||
var lastWrite = File.GetLastWriteTime(file);
|
||||
if (lastWrite.Date < cutoff)
|
||||
DateTime fileDate;
|
||||
if (!TryGetLogDate(file, out fileDate))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (fileDate < cutoff)
|
||||
{
|
||||
File.Delete(file);
|
||||
continue;
|
||||
}
|
||||
if (fileDate < today.Date && file.EndsWith(LogFileExtension, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Compress(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,23 +404,255 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ermittelt das bevorzugte maschinenweite Logverzeichnis mit Rückfall auf das EXE-Verzeichnis.
|
||||
/// </summary>
|
||||
/// <returns>Ein verwendbares Verzeichnis für die täglichen Laufzeitlogs.</returns>
|
||||
private static string ResolveLogDirectory()
|
||||
/// <summary>Compresses a completed log atomically and removes the plain source afterward.</summary>
|
||||
/// <param name="source">The completed plain log.</param>
|
||||
private static void Compress(string source)
|
||||
{
|
||||
var commonData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
|
||||
var preferred = Path.Combine(commonData, "BizTalkPlatformManagementTool", "Logs");
|
||||
var target = source + ".gz";
|
||||
if (File.Exists(target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var temporary = target + ".tmp." + Guid.NewGuid().ToString("N");
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(preferred);
|
||||
return preferred;
|
||||
using (var input = File.OpenRead(source))
|
||||
using (var output = new FileStream(temporary, FileMode.CreateNew, FileAccess.Write, FileShare.None))
|
||||
using (var gzip = new GZipStream(output, CompressionLevel.Optimal))
|
||||
{
|
||||
input.CopyTo(gzip);
|
||||
}
|
||||
File.Move(temporary, target);
|
||||
File.Delete(source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(temporary))
|
||||
{
|
||||
File.Delete(temporary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads one supported plain or compressed file into an entry collection.</summary>
|
||||
private static void ReadEntries(string path, ICollection<LogEntry> entries)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var file = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
using (var payload = path.EndsWith(".gz", StringComparison.OrdinalIgnoreCase)
|
||||
? (Stream)new GZipStream(file, CompressionMode.Decompress)
|
||||
: file)
|
||||
using (var reader = new StreamReader(payload, Encoding.UTF8, true))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
LogEntry entry;
|
||||
if (TryParse(line, out entry))
|
||||
{
|
||||
entries.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return AppDomain.CurrentDomain.BaseDirectory;
|
||||
// One unreadable archive must not hide all other retained history.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Parses the stable daily log line format.</summary>
|
||||
/// <param name="line">One physical line.</param>
|
||||
/// <param name="entry">Parsed entry when successful.</param>
|
||||
/// <returns>True for a valid record.</returns>
|
||||
internal static bool TryParse(string line, out LogEntry entry)
|
||||
{
|
||||
entry = null;
|
||||
if (string.IsNullOrEmpty(line) || line.Length < 29 || line[0] != '[' || line[21] != '[')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var timestampEnd = line.IndexOf(']');
|
||||
var levelEnd = line.IndexOf(']', timestampEnd + 1);
|
||||
DateTime timestamp;
|
||||
LogLevel level;
|
||||
if (timestampEnd != 20 || levelEnd < 0
|
||||
|| !DateTime.TryParseExact(line.Substring(1, 19), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timestamp)
|
||||
|| !Enum.TryParse(line.Substring(timestampEnd + 2, levelEnd - timestampEnd - 2), true, out level))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var messageStart = levelEnd + 1;
|
||||
if (messageStart < line.Length && line[messageStart] == ' ')
|
||||
{
|
||||
messageStart++;
|
||||
}
|
||||
entry = new LogEntry { Timestamp = timestamp, Level = level, Message = line.Substring(messageStart) };
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Checks the supported exact file suffixes.</summary>
|
||||
private static bool IsSupportedLogFile(string path)
|
||||
{
|
||||
return path.EndsWith(LogFileExtension, StringComparison.OrdinalIgnoreCase)
|
||||
|| path.EndsWith(LogFileExtension + ".gz", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>Extracts the calendar date from a stable log file name.</summary>
|
||||
private static bool TryGetLogDate(string path, out DateTime date)
|
||||
{
|
||||
var name = Path.GetFileName(path);
|
||||
var suffixLength = name.EndsWith(LogFileExtension + ".gz", StringComparison.OrdinalIgnoreCase)
|
||||
? (LogFileExtension + ".gz").Length
|
||||
: name.EndsWith(LogFileExtension, StringComparison.OrdinalIgnoreCase) ? LogFileExtension.Length : 0;
|
||||
if (suffixLength == 0 || !name.StartsWith(LogFilePrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
date = default(DateTime);
|
||||
return false;
|
||||
}
|
||||
var value = name.Substring(LogFilePrefix.Length, name.Length - LogFilePrefix.Length - suffixLength);
|
||||
return DateTime.TryParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date);
|
||||
}
|
||||
|
||||
/// <summary>Selects the first directory that passes a real create/write/delete probe.</summary>
|
||||
private void SelectInitialLogDirectory()
|
||||
{
|
||||
var failures = new List<string>();
|
||||
for (var index = 0; index < _candidateDirectories.Count; index++)
|
||||
{
|
||||
string error;
|
||||
if (!TryVerifyWritable(_candidateDirectories[index], out error))
|
||||
{
|
||||
failures.Add(_candidateDirectories[index] + " => " + error);
|
||||
continue;
|
||||
}
|
||||
_activeDirectoryIndex = index;
|
||||
_logDirectory = _candidateDirectories[index];
|
||||
if (index > 0)
|
||||
{
|
||||
_storageWarning = "Primary runtime log path is not writable. Using verified fallback '"
|
||||
+ _logDirectory + "'. Failed path(s): " + string.Join(" | ", failures.ToArray());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_storageWarning = "RUNTIME FILE LOGGING UNAVAILABLE. No candidate directory passed the startup write probe. Attempted: "
|
||||
+ (failures.Count == 0 ? "(none)" : string.Join(" | ", failures.ToArray()))
|
||||
+ ". Operations remain visible in the grid, but no durable runtime log is being written.";
|
||||
}
|
||||
|
||||
/// <summary>Builds primary and local fallback directories in deterministic order.</summary>
|
||||
/// <returns>ProgramData, LocalAppData, executable-local and Temp candidates.</returns>
|
||||
private static IEnumerable<string> BuildLogDirectoryCandidates()
|
||||
{
|
||||
yield return Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
||||
"BizTalkPlatformManagementTool",
|
||||
"Logs");
|
||||
yield return Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"BizTalkPlatformManagementTool",
|
||||
"Logs");
|
||||
yield return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
|
||||
yield return Path.Combine(Path.GetTempPath(), "BizTalkPlatformManagementTool", "Logs");
|
||||
}
|
||||
|
||||
/// <summary>Normalizes and de-duplicates candidate paths without requiring existence.</summary>
|
||||
/// <param name="directories">Raw ordered paths.</param>
|
||||
/// <returns>Safe absolute unique paths.</returns>
|
||||
private static IEnumerable<string> NormalizeDirectories(IEnumerable<string> directories)
|
||||
{
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var directory in directories ?? Enumerable.Empty<string>())
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(directory))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fullPath;
|
||||
try
|
||||
{
|
||||
fullPath = Path.GetFullPath(directory.Trim()).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (seen.Add(fullPath))
|
||||
{
|
||||
yield return fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Performs a real write probe and removes the temporary probe file.</summary>
|
||||
/// <param name="directory">Candidate directory.</param>
|
||||
/// <param name="error">Detailed failure when the probe fails.</param>
|
||||
/// <returns>True only after bytes were created and flushed successfully.</returns>
|
||||
private static bool TryVerifyWritable(string directory, out string error)
|
||||
{
|
||||
var probe = Path.Combine(directory, ".runtime-log-write-probe-" + Guid.NewGuid().ToString("N") + ".tmp");
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
using (var stream = new FileStream(probe, FileMode.CreateNew, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
stream.WriteByte(0x42);
|
||||
stream.Flush();
|
||||
}
|
||||
File.Delete(probe);
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.GetType().Name + ": " + ex.Message;
|
||||
try
|
||||
{
|
||||
if (File.Exists(probe))
|
||||
{
|
||||
File.Delete(probe);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Probe cleanup is best-effort and the original write error remains authoritative.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Appends one physical line to a candidate daily log.</summary>
|
||||
/// <param name="directory">Candidate directory.</param>
|
||||
/// <param name="line">Serialized log line.</param>
|
||||
/// <param name="error">Detailed append failure.</param>
|
||||
/// <returns>True after the append completed.</returns>
|
||||
private static bool TryAppend(string directory, string line, out string error)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
File.AppendAllText(BuildLogFilePath(directory, DateTime.Now), line, new UTF8Encoding(false));
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.GetType().Name + ": " + ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Builds the stable daily file path for a directory and local date.</summary>
|
||||
/// <param name="directory">Active directory.</param>
|
||||
/// <param name="timestamp">Timestamp whose local date selects the file.</param>
|
||||
/// <returns>Full daily log path.</returns>
|
||||
private static string BuildLogFilePath(string directory, DateTime timestamp)
|
||||
{
|
||||
return Path.Combine(
|
||||
directory,
|
||||
LogFilePrefix + timestamp.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) + LogFileExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using BizTalkPlatformManagementTool.Models;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the successful outcomes returned by the runtime-specific execution layer.
|
||||
/// </summary>
|
||||
internal enum RuntimeStepOutcome
|
||||
{
|
||||
/// <summary>The requested method was executed and verified.</summary>
|
||||
Succeeded,
|
||||
|
||||
/// <summary>The object was already in the requested target state.</summary>
|
||||
AlreadySatisfied
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Abstracts one state-aware runtime step so best-effort orchestration can be
|
||||
/// regression-tested without a BizTalk WMI provider.
|
||||
/// </summary>
|
||||
internal interface IOperationStepRuntime
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes one step or reports that its target state already exists.
|
||||
/// </summary>
|
||||
/// <param name="step">The operation-plan step.</param>
|
||||
/// <param name="options">Timeout and polling options.</param>
|
||||
/// <returns>The successful runtime outcome.</returns>
|
||||
RuntimeStepOutcome Execute(OperationStep step, OperationOptions options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests an operator decision at a non-mutating boundary in an operation plan.
|
||||
/// </summary>
|
||||
/// <param name="checkpoint">The checkpoint plan row.</param>
|
||||
/// <param name="progress">The durable execution progress before the checkpoint.</param>
|
||||
/// <returns>True to continue with later phases; false to stop safely.</returns>
|
||||
internal delegate bool OperationCheckpointHandler(OperationStep checkpoint, OperationExecutionReport progress);
|
||||
|
||||
/// <summary>
|
||||
/// Runs every independent plan step, records durable outcomes and deliberately
|
||||
/// continues after isolated failures.
|
||||
/// </summary>
|
||||
internal sealed class OperationPlanExecutor
|
||||
{
|
||||
/// <summary>Logger used for detailed progress and failure diagnostics.</summary>
|
||||
private readonly OperationLogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new best-effort plan executor.
|
||||
/// </summary>
|
||||
/// <param name="logger">The operation logger, or null for isolated tests.</param>
|
||||
public OperationPlanExecutor(OperationLogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes or simulates every plan step and returns a complete report.
|
||||
/// </summary>
|
||||
/// <param name="plan">The validated operation plan.</param>
|
||||
/// <param name="options">The execution options.</param>
|
||||
/// <param name="runtime">The runtime implementation; optional only during dry-run.</param>
|
||||
/// <returns>A complete per-step execution report.</returns>
|
||||
public OperationExecutionReport Execute(OperationPlan plan, OperationOptions options, IOperationStepRuntime runtime)
|
||||
{
|
||||
return Execute(plan, options, runtime, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes or simulates every plan step with an optional operator checkpoint handler.
|
||||
/// </summary>
|
||||
/// <param name="plan">The validated operation plan.</param>
|
||||
/// <param name="options">The execution options.</param>
|
||||
/// <param name="runtime">The runtime implementation; optional only during dry-run.</param>
|
||||
/// <param name="checkpointHandler">UI-independent operator decision callback.</param>
|
||||
/// <returns>A complete per-step execution report, including unreached rows.</returns>
|
||||
internal OperationExecutionReport Execute(
|
||||
OperationPlan plan,
|
||||
OperationOptions options,
|
||||
IOperationStepRuntime runtime,
|
||||
OperationCheckpointHandler checkpointHandler)
|
||||
{
|
||||
if (plan == null || options == null)
|
||||
{
|
||||
throw new ArgumentNullException(plan == null ? "plan" : "options");
|
||||
}
|
||||
if (!options.DryRun && runtime == null)
|
||||
{
|
||||
throw new ArgumentNullException("runtime");
|
||||
}
|
||||
|
||||
var report = NewReport(plan, options);
|
||||
for (var index = 0; index < plan.Steps.Count; index++)
|
||||
{
|
||||
var step = plan.Steps[index];
|
||||
var stepResult = NewStepResult(index + 1, step);
|
||||
var stopAfterCurrentStep = false;
|
||||
try
|
||||
{
|
||||
if (!step.Execute)
|
||||
{
|
||||
stepResult.Outcome = OperationStepOutcomes.Skipped;
|
||||
report.SkippedCount++;
|
||||
Warning(step.Action + (string.IsNullOrWhiteSpace(step.Warning) ? string.Empty : " " + step.Warning));
|
||||
}
|
||||
else if (options.DryRun)
|
||||
{
|
||||
stepResult.Outcome = OperationStepOutcomes.DryRun;
|
||||
report.DryRunCount++;
|
||||
Info("DRY RUN: " + DescribeStep(step));
|
||||
}
|
||||
else if (IsOperatorCheckpoint(step))
|
||||
{
|
||||
Info("Operator checkpoint reached after the receive-location phase: " + step.Action);
|
||||
report.CheckpointAt = DateTimeOffset.Now.ToString("o");
|
||||
if (checkpointHandler == null)
|
||||
{
|
||||
throw new InvalidOperationException("No operator checkpoint handler is available. Shutdown stops safely before later runtime phases.");
|
||||
}
|
||||
|
||||
if (checkpointHandler(step, report))
|
||||
{
|
||||
report.CheckpointDecision = "Continue";
|
||||
stepResult.Outcome = OperationStepOutcomes.Confirmed;
|
||||
Success("Operator confirmed that the BizTalk environment is drained. Continuing with orchestrations, send ports and host instances.");
|
||||
}
|
||||
else
|
||||
{
|
||||
report.CheckpointDecision = "Stop";
|
||||
report.OperatorStopped = true;
|
||||
stepResult.Outcome = OperationStepOutcomes.Declined;
|
||||
stopAfterCurrentStep = true;
|
||||
Warning("Operator stopped the shutdown safely at the drain checkpoint. No later shutdown phase will be executed.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info("Executing step " + (index + 1) + "/" + plan.Steps.Count + ": " + DescribeStep(step));
|
||||
var outcome = runtime.Execute(step, options);
|
||||
if (outcome == RuntimeStepOutcome.AlreadySatisfied)
|
||||
{
|
||||
stepResult.Outcome = OperationStepOutcomes.AlreadySatisfied;
|
||||
report.AlreadySatisfiedCount++;
|
||||
Info("Already in target state: " + DescribeStep(step));
|
||||
}
|
||||
else
|
||||
{
|
||||
stepResult.Outcome = OperationStepOutcomes.Succeeded;
|
||||
report.SucceededCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
stepResult.Outcome = OperationStepOutcomes.Failed;
|
||||
stepResult.Error = FormatException(ex);
|
||||
report.FailedCount++;
|
||||
if (IsOperatorCheckpoint(step))
|
||||
{
|
||||
report.CheckpointDecision = "Error";
|
||||
report.CheckpointAt = report.CheckpointAt ?? DateTimeOffset.Now.ToString("o");
|
||||
report.OperatorStopped = true;
|
||||
stopAfterCurrentStep = true;
|
||||
Error("OPERATOR CHECKPOINT FAILED CLOSED; no later shutdown phase will be executed. Error: " + stepResult.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error("STEP FAILED; continuing with remaining independent steps: " + DescribeStep(step) + ". Error: " + stepResult.Error);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
stepResult.FinishedAt = DateTimeOffset.Now.ToString("o");
|
||||
report.Steps.Add(stepResult);
|
||||
}
|
||||
|
||||
if (stopAfterCurrentStep)
|
||||
{
|
||||
AddNotExecutedSteps(plan, index + 1, report);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
report.FinishedAt = DateTimeOffset.Now.ToString("o");
|
||||
var summary = "Plan execution summary: succeeded=" + report.SucceededCount
|
||||
+ ", already_satisfied=" + report.AlreadySatisfiedCount
|
||||
+ ", skipped=" + report.SkippedCount
|
||||
+ ", dry_run=" + report.DryRunCount
|
||||
+ ", failed=" + report.FailedCount
|
||||
+ ", not_executed=" + report.NotExecutedCount
|
||||
+ ", checkpoint=" + (report.CheckpointDecision ?? "not_required") + ".";
|
||||
if (report.OperatorStopped && report.FailedCount == 0)
|
||||
{
|
||||
Warning(summary + " Shutdown stopped safely by operator; review the partial-state snapshot and report.");
|
||||
}
|
||||
else if (report.FailedCount == 0)
|
||||
{
|
||||
Success(summary);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(summary + " Operator review is required.");
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
/// <summary>Checks whether a plan row is the non-mutating operator boundary.</summary>
|
||||
/// <param name="step">The plan row.</param>
|
||||
/// <returns>True for the stable operator-checkpoint kind.</returns>
|
||||
private static bool IsOperatorCheckpoint(OperationStep step)
|
||||
{
|
||||
return step != null && string.Equals(step.Kind, OperationStepKind.OperatorCheckpoint.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>Adds auditable results for all rows intentionally not reached after a stop.</summary>
|
||||
/// <param name="plan">The source plan.</param>
|
||||
/// <param name="startIndex">The zero-based first unreached row.</param>
|
||||
/// <param name="report">The report receiving the unreached rows.</param>
|
||||
private static void AddNotExecutedSteps(OperationPlan plan, int startIndex, OperationExecutionReport report)
|
||||
{
|
||||
for (var index = startIndex; index < plan.Steps.Count; index++)
|
||||
{
|
||||
var result = NewStepResult(index + 1, plan.Steps[index]);
|
||||
result.Outcome = OperationStepOutcomes.NotExecuted;
|
||||
result.Error = "Not reached because the operator stopped at the inbound-drain checkpoint.";
|
||||
result.FinishedAt = DateTimeOffset.Now.ToString("o");
|
||||
report.Steps.Add(result);
|
||||
report.NotExecutedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates the common execution-report header.</summary>
|
||||
/// <param name="plan">The source plan.</param>
|
||||
/// <param name="options">The execution options.</param>
|
||||
/// <returns>An initialized report.</returns>
|
||||
private static OperationExecutionReport NewReport(OperationPlan plan, OperationOptions options)
|
||||
{
|
||||
return new OperationExecutionReport
|
||||
{
|
||||
Mode = plan.Mode,
|
||||
Server = plan.Server,
|
||||
DryRun = options.DryRun,
|
||||
StartedAt = DateTimeOffset.Now.ToString("o")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Creates one report row from a plan step.</summary>
|
||||
/// <param name="index">The one-based step index.</param>
|
||||
/// <param name="step">The source step.</param>
|
||||
/// <returns>An initialized step result.</returns>
|
||||
private static OperationStepResult NewStepResult(int index, OperationStep step)
|
||||
{
|
||||
return new OperationStepResult
|
||||
{
|
||||
Index = index,
|
||||
Kind = step == null ? string.Empty : step.Kind,
|
||||
Application = step == null ? string.Empty : step.Application,
|
||||
Name = step == null ? string.Empty : step.Name,
|
||||
Action = step == null ? string.Empty : step.Action,
|
||||
StartedAt = DateTimeOffset.Now.ToString("o")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Builds a stable operator-facing step description.</summary>
|
||||
/// <param name="step">The plan step.</param>
|
||||
/// <returns>The compact description.</returns>
|
||||
private static string DescribeStep(OperationStep step)
|
||||
{
|
||||
if (step == null)
|
||||
{
|
||||
return "<unknown step>";
|
||||
}
|
||||
return step.Action + " '" + step.Name + "'"
|
||||
+ " [kind=" + step.Kind
|
||||
+ ", class=" + step.WmiClass
|
||||
+ ", key=" + step.KeyProperty + "=" + (step.KeyValue ?? string.Empty)
|
||||
+ ", method=" + step.MethodName
|
||||
+ (string.IsNullOrWhiteSpace(step.AdapterName) ? string.Empty : ", adapter=" + step.AdapterName)
|
||||
+ (string.IsNullOrWhiteSpace(step.Address) ? string.Empty : ", address=" + step.Address)
|
||||
+ (string.IsNullOrWhiteSpace(step.Server) ? string.Empty : ", server=" + step.Server)
|
||||
+ "]";
|
||||
}
|
||||
|
||||
/// <summary>Formats the complete unique exception-message chain.</summary>
|
||||
/// <param name="exception">The exception to format.</param>
|
||||
/// <returns>A single diagnostic message.</returns>
|
||||
internal static string FormatException(Exception exception)
|
||||
{
|
||||
return ExceptionDiagnostics.Format(exception);
|
||||
}
|
||||
|
||||
/// <summary>Writes an informational message when a logger is available.</summary>
|
||||
private void Info(string message) { if (_logger != null) _logger.Info(message); }
|
||||
|
||||
/// <summary>Writes a warning when a logger is available.</summary>
|
||||
private void Warning(string message) { if (_logger != null) _logger.Warning(message); }
|
||||
|
||||
/// <summary>Writes an error when a logger is available.</summary>
|
||||
private void Error(string message) { if (_logger != null) _logger.Error(message); }
|
||||
|
||||
/// <summary>Writes a success message when a logger is available.</summary>
|
||||
private void Success(string message) { if (_logger != null) _logger.Success(message); }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -110,11 +111,24 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
/// </summary>
|
||||
private Button _restoreButton;
|
||||
|
||||
/// <summary>
|
||||
/// Button that validates the selected recovery snapshot without contacting WMI.
|
||||
/// </summary>
|
||||
private Button _validateStateButton;
|
||||
|
||||
/// <summary>
|
||||
/// Button that performs a state-aware best-effort recovery from an existing snapshot.
|
||||
/// </summary>
|
||||
private Button _emergencyRestoreButton;
|
||||
|
||||
/// <summary>
|
||||
/// Button that clears visible grids and status.
|
||||
/// </summary>
|
||||
private Button _clearButton;
|
||||
|
||||
/// <summary>Button that opens the persistent runtime log directory.</summary>
|
||||
private Button _openLogsButton;
|
||||
|
||||
/// <summary>
|
||||
/// Button that closes the application.
|
||||
/// </summary>
|
||||
@@ -132,7 +146,7 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
{
|
||||
Text = "BizTalk Platform Management Tool";
|
||||
Width = 1180;
|
||||
Height = 760;
|
||||
Height = 800;
|
||||
MinimumSize = new Size(980, 640);
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
|
||||
@@ -140,7 +154,19 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
_service = new BizTalkOperationService(_logger);
|
||||
BuildUi();
|
||||
FormClosing += MainFormClosing;
|
||||
_logger.Info("Log file: " + _logger.LogFilePath);
|
||||
LoadLogHistory();
|
||||
if (!string.IsNullOrWhiteSpace(_logger.StorageWarning))
|
||||
{
|
||||
_logger.Warning(_logger.StorageWarning);
|
||||
}
|
||||
if (_logger.IsFileLoggingAvailable)
|
||||
{
|
||||
_logger.Success("Runtime log storage verified by startup append. Active file: " + _logger.LogFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Error("Runtime file logging is unavailable. Use the Operation Log grid and resolve the storage warning before a real maintenance operation.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -156,7 +182,7 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
Padding = new Padding(10)
|
||||
};
|
||||
root.RowStyles.Add(new RowStyle(SizeType.Absolute, 92));
|
||||
root.RowStyles.Add(new RowStyle(SizeType.Absolute, 54));
|
||||
root.RowStyles.Add(new RowStyle(SizeType.Absolute, 96));
|
||||
root.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
|
||||
root.RowStyles.Add(new RowStyle(SizeType.Absolute, 24));
|
||||
Controls.Add(root);
|
||||
@@ -212,9 +238,13 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
_dryRunCheckBox.Dock = DockStyle.Fill;
|
||||
_dryRunCheckBox.Margin = new Padding(8, 7, 8, 7);
|
||||
_dryRunCheckBox.TextAlign = ContentAlignment.MiddleLeft;
|
||||
_dryRunCheckBox.CheckedChanged += DryRunCheckBoxCheckedChanged;
|
||||
UpdateDryRunPresentation();
|
||||
|
||||
var browseButton = new Button { Text = "Browse...", Dock = DockStyle.Fill, Margin = new Padding(8, 5, 8, 5) };
|
||||
browseButton.Click += BrowseButtonClick;
|
||||
var stateBrowseButton = new Button { Text = "State...", Dock = DockStyle.Fill, Margin = new Padding(8, 5, 8, 5) };
|
||||
stateBrowseButton.Click += StateBrowseButtonClick;
|
||||
|
||||
_environmentStatusLabel.Dock = DockStyle.Fill;
|
||||
_environmentStatusLabel.Margin = new Padding(12, 5, 0, 5);
|
||||
@@ -234,6 +264,7 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
panel.Controls.Add(_stateFileTextBox, 1, 1);
|
||||
panel.SetColumnSpan(_stateFileTextBox, 2);
|
||||
panel.Controls.Add(_dryRunCheckBox, 3, 1);
|
||||
panel.Controls.Add(stateBrowseButton, 4, 1);
|
||||
panel.Controls.Add(Label("Poll sec."), 7, 1);
|
||||
panel.Controls.Add(_pollInput, 8, 1);
|
||||
panel.Controls.Add(_environmentStatusLabel, 9, 0);
|
||||
@@ -248,14 +279,18 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
/// <returns>The configured action panel.</returns>
|
||||
private Control BuildActionPanel()
|
||||
{
|
||||
var panel = new FlowLayoutPanel { Dock = DockStyle.Fill, FlowDirection = FlowDirection.LeftToRight, Padding = new Padding(0, 8, 0, 0), WrapContents = false };
|
||||
var panel = new FlowLayoutPanel { Dock = DockStyle.Fill, FlowDirection = FlowDirection.LeftToRight, Padding = new Padding(0, 8, 0, 0), WrapContents = true, AutoScroll = true };
|
||||
_diagnoseButton = ActionButton("Diagnose", DiagnoseClick);
|
||||
_beforeButton = ActionButton("Snapshot Before", BeforeClick);
|
||||
_afterButton = ActionButton("Snapshot After", AfterClick);
|
||||
_compareButton = ActionButton("Compare", CompareClick);
|
||||
_shutdownButton = ActionButton("Shutdown", ShutdownClick);
|
||||
_restoreButton = ActionButton("Restore", RestoreClick);
|
||||
_validateStateButton = ActionButton("Validate State", ValidateStateClick);
|
||||
_emergencyRestoreButton = ActionButton("Emergency Restore", EmergencyRestoreClick);
|
||||
_emergencyRestoreButton.Width = 142;
|
||||
_clearButton = ActionButton("Clear", ClearClick);
|
||||
_openLogsButton = ActionButton("Log Folder", OpenLogsClick);
|
||||
_closeButton = ActionButton("Close", CloseClick);
|
||||
|
||||
panel.Controls.Add(_diagnoseButton);
|
||||
@@ -264,7 +299,10 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
panel.Controls.Add(_compareButton);
|
||||
panel.Controls.Add(_shutdownButton);
|
||||
panel.Controls.Add(_restoreButton);
|
||||
panel.Controls.Add(_validateStateButton);
|
||||
panel.Controls.Add(_emergencyRestoreButton);
|
||||
panel.Controls.Add(_clearButton);
|
||||
panel.Controls.Add(_openLogsButton);
|
||||
panel.Controls.Add(_closeButton);
|
||||
return panel;
|
||||
}
|
||||
@@ -288,7 +326,7 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
statusPage.Controls.Add(_statusGrid);
|
||||
|
||||
ConfigureGrid(_logGrid);
|
||||
_logGrid.Columns.Add("Time", "Time");
|
||||
_logGrid.Columns.Add("Timestamp", "Timestamp");
|
||||
_logGrid.Columns.Add("Level", "Level");
|
||||
_logGrid.Columns.Add("Message", "Message");
|
||||
_logGrid.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
@@ -368,7 +406,9 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
private void ShutdownClick(object sender, EventArgs e)
|
||||
{
|
||||
var options = GetOptions();
|
||||
RunAsync("Preparing shutdown...", () =>
|
||||
RunAsync(options.DryRun
|
||||
? "DRY RUN: Preparing shutdown plan; no runtime state will be changed."
|
||||
: "REAL SHUTDOWN: Preparing snapshot and saved plan.", () =>
|
||||
{
|
||||
var snapshot = _service.CreateSnapshot(options.Server);
|
||||
_service.SaveSnapshot(options.OutputDirectory, "before.json", snapshot);
|
||||
@@ -376,18 +416,20 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
// Der exakte, frisch erzeugte Plan wird vor Bestätigung und jeder Laufzeitänderung gespeichert.
|
||||
var planPath = _service.SavePlan(options.OutputDirectory, "shutdown-plan.json", plan);
|
||||
ShowPlan(plan);
|
||||
if (!options.DryRun && !ConfirmPreparedPlan("Shutdown", plan, options.Server, planPath))
|
||||
if (options.DryRun)
|
||||
{
|
||||
ShowShutdownDryRunNotice(plan, planPath);
|
||||
}
|
||||
else if (!ConfirmPreparedPlan("Shutdown", plan, options.Server, planPath))
|
||||
{
|
||||
_logger.Warning("Shutdown cancelled after plan review. No runtime state was changed.");
|
||||
return;
|
||||
}
|
||||
_service.ExecutePlan(plan, options);
|
||||
if (!options.DryRun)
|
||||
{
|
||||
var after = _service.CreateSnapshot(options.Server);
|
||||
_service.SaveSnapshot(options.OutputDirectory, "shutdown-after.json", after);
|
||||
ShowSnapshot(after);
|
||||
}
|
||||
var report = _service.ExecutePlan(plan, options, ConfirmInboundDrainCheckpoint);
|
||||
CapturePostOperationSnapshot(options, report, "shutdown-after.json");
|
||||
var reportPath = _service.SaveExecutionReport(options.OutputDirectory, "shutdown-result.json", report);
|
||||
ShowExecutionReport(report);
|
||||
ThrowWhenOperatorReviewIsRequired(report, reportPath);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -411,14 +453,147 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
_logger.Warning("Restore cancelled after plan review. No runtime state was changed.");
|
||||
return;
|
||||
}
|
||||
_service.ExecutePlan(plan, options);
|
||||
if (!options.DryRun)
|
||||
var report = _service.ExecutePlan(plan, options);
|
||||
CapturePostOperationSnapshot(options, report, "restore-after.json");
|
||||
var reportPath = _service.SaveExecutionReport(options.OutputDirectory, "restore-result.json", report);
|
||||
ShowExecutionReport(report);
|
||||
ThrowWhenOperatorReviewIsRequired(report, reportPath);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the selected state file and target server without opening a WMI connection
|
||||
/// or changing any runtime state.
|
||||
/// </summary>
|
||||
/// <param name="sender">The control that raised the event.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
private void ValidateStateClick(object sender, EventArgs e)
|
||||
{
|
||||
var options = GetOptions();
|
||||
RunAsync("Validating recovery state file...", () =>
|
||||
{
|
||||
var sourcePath = ResolveStateFile(options);
|
||||
var snapshot = JsonFileStore.Load<BizTalkSnapshot>(sourcePath);
|
||||
SnapshotValidator.EnsureServerMatches(snapshot, options.Server);
|
||||
ShowSnapshot(snapshot);
|
||||
|
||||
var receiveLocationCount = snapshot.Applications.Sum(x => x.ReceiveLocations.Count);
|
||||
var sendPortCount = snapshot.Applications.Sum(x => x.SendPorts.Count);
|
||||
var orchestrationCount = snapshot.Applications.Sum(x => x.Orchestrations.Count);
|
||||
var summary = "Recovery state is valid. Source=" + sourcePath
|
||||
+ "; SnapshotVersion=" + (snapshot.ToolVersion ?? "(not recorded)")
|
||||
+ "; CreatedAt=" + (snapshot.CreatedAt ?? "(not recorded)")
|
||||
+ "; Server=" + snapshot.Server
|
||||
+ "; Applications=" + snapshot.Applications.Count
|
||||
+ "; HostInstances=" + snapshot.HostInstances.Count
|
||||
+ "; ReceiveLocations=" + receiveLocationCount
|
||||
+ "; SendPorts=" + sendPortCount
|
||||
+ "; Orchestrations=" + orchestrationCount + ".";
|
||||
_logger.Success(summary);
|
||||
ShowStateValidationSummary(summary);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles emergency recovery from the preserved state file without creating
|
||||
/// or overwriting <c>before.json</c>.
|
||||
/// </summary>
|
||||
/// <param name="sender">The control that raised the event.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
private void EmergencyRestoreClick(object sender, EventArgs e)
|
||||
{
|
||||
var options = GetOptions();
|
||||
RunAsync("Preparing emergency restore from preserved state...", () =>
|
||||
{
|
||||
var sourcePath = ResolveStateFile(options);
|
||||
var snapshot = JsonFileStore.Load<BizTalkSnapshot>(sourcePath);
|
||||
SnapshotValidator.EnsureServerMatches(snapshot, options.Server);
|
||||
var stamp = DateTime.Now.ToString("yyyyMMdd-HHmmss");
|
||||
var sourceCopyName = "emergency-source-before-" + stamp + ".json";
|
||||
_service.SaveSnapshot(options.OutputDirectory, sourceCopyName, snapshot);
|
||||
|
||||
var plan = _service.CreateEmergencyRestorePlan(snapshot, options.Server);
|
||||
var planName = "emergency-restore-plan-" + stamp + ".json";
|
||||
var planPath = _service.SavePlan(options.OutputDirectory, planName, plan);
|
||||
ShowPlan(plan);
|
||||
if (!options.DryRun && !ConfirmEmergencyRestore(plan, options.Server, sourcePath, planPath))
|
||||
{
|
||||
_logger.Warning("Emergency restore cancelled after plan review. No runtime state was changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
var report = _service.ExecutePlan(plan, options);
|
||||
var after = CapturePostOperationSnapshot(options, report, "emergency-restore-after-" + stamp + ".json");
|
||||
if (after != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var diff = SnapshotComparer.Compare(snapshot, after);
|
||||
var diffPath = _service.SaveDiff(options.OutputDirectory, "emergency-restore-diff-" + stamp + ".json", diff);
|
||||
_logger.Success("Saved emergency recovery target/actual comparison: " + diffPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = "Emergency recovery comparison failed: " + FormatException(ex);
|
||||
report.PostSnapshotError = string.IsNullOrWhiteSpace(report.PostSnapshotError)
|
||||
? error
|
||||
: report.PostSnapshotError + " | " + error;
|
||||
_logger.Error(error + " The execution report will still be saved.");
|
||||
}
|
||||
}
|
||||
var reportPath = _service.SaveExecutionReport(options.OutputDirectory, "emergency-restore-result-" + stamp + ".json", report);
|
||||
ShowExecutionReport(report);
|
||||
ThrowWhenOperatorReviewIsRequired(report, reportPath);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts the post-operation snapshot even after individual plan-step failures.
|
||||
/// </summary>
|
||||
/// <param name="options">The operation options.</param>
|
||||
/// <param name="report">The report that receives a snapshot error.</param>
|
||||
/// <param name="fileName">The snapshot file name.</param>
|
||||
private BizTalkSnapshot CapturePostOperationSnapshot(OperationOptions options, OperationExecutionReport report, string fileName)
|
||||
{
|
||||
if (options.DryRun)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
var after = _service.CreateSnapshot(options.Server);
|
||||
_service.SaveSnapshot(options.OutputDirectory, "restore-after.json", after);
|
||||
_service.SaveSnapshot(options.OutputDirectory, fileName, after);
|
||||
ShowSnapshot(after);
|
||||
return after;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
report.PostSnapshotError = FormatException(ex);
|
||||
_logger.Error("Post-operation snapshot failed, but the execution report will still be saved. Error: " + report.PostSnapshotError);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a completed partial failure into the visible failed UI status only
|
||||
/// after its complete execution report has been saved.
|
||||
/// </summary>
|
||||
/// <param name="report">The completed report.</param>
|
||||
/// <param name="reportPath">The durable report path.</param>
|
||||
private static void ThrowWhenOperatorReviewIsRequired(OperationExecutionReport report, string reportPath)
|
||||
{
|
||||
if (report != null && report.HasFailures)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Plan requires operator review. Failed steps: " + report.FailedCount
|
||||
+ "; later steps not executed: " + report.NotExecutedCount + ". Review: " + reportPath);
|
||||
}
|
||||
if (report != null && report.OperatorStopped)
|
||||
{
|
||||
throw new OperationCanceledException(
|
||||
"Shutdown stopped safely at the inbound-drain checkpoint. Later steps not executed: "
|
||||
+ report.NotExecutedCount + ". Review: " + reportPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -434,6 +609,26 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
_statusLabel.Text = "Ready.";
|
||||
}
|
||||
|
||||
/// <summary>Opens the persistent local runtime log directory in Windows Explorer.</summary>
|
||||
/// <param name="sender">The control that raised the event.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
private void OpenLogsClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_logger.IsFileLoggingAvailable || string.IsNullOrWhiteSpace(_logger.LogDirectory))
|
||||
{
|
||||
throw new InvalidOperationException(_logger.StorageWarning ?? "No writable runtime log directory is active.");
|
||||
}
|
||||
Directory.CreateDirectory(_logger.LogDirectory);
|
||||
Process.Start("explorer.exe", _logger.LogDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error("Could not open runtime log directory. " + ExceptionDiagnostics.Format(ex));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Close button click.
|
||||
/// </summary>
|
||||
@@ -460,6 +655,11 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
_logger.Success("Operation completed.");
|
||||
SetBusy(false, "Ready.");
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
_logger.Warning(ex.Message);
|
||||
SetBusy(false, "Stopped safely: " + ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(FormatException(ex));
|
||||
@@ -514,11 +714,13 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
var confirmed = false;
|
||||
Action showConfirmation = () =>
|
||||
{
|
||||
var executableSteps = plan.Steps.Count(x => x.Execute);
|
||||
_statusLabel.Text = "ACTION REQUIRED: Review the saved " + actionName.ToLowerInvariant() + " plan and answer the owned confirmation dialog.";
|
||||
Activate();
|
||||
BringToFront();
|
||||
var result = MessageBox.Show(
|
||||
actionName + " will execute " + executableSteps + " step(s) on server '" + server + "'.\n\n"
|
||||
+ "The exact plan was saved to:\n" + planPath + "\n\nContinue now?",
|
||||
"Confirm Prepared BizTalk Plan",
|
||||
this,
|
||||
ShutdownOperatorPrompts.BuildPreparedPlanConfirmation(actionName, plan, server, planPath),
|
||||
ShutdownOperatorPrompts.PreparedPlanTitle,
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning,
|
||||
MessageBoxDefaultButton.Button2);
|
||||
@@ -536,6 +738,114 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the dry-run boundary explicit: the prepared checkpoint is visible in
|
||||
/// the plan, but no receive location changes and no real drain decision occurs.
|
||||
/// </summary>
|
||||
/// <param name="plan">The prepared shutdown plan.</param>
|
||||
/// <param name="planPath">The durable path of the prepared plan.</param>
|
||||
private void ShowShutdownDryRunNotice(OperationPlan plan, string planPath)
|
||||
{
|
||||
Action showNotice = () =>
|
||||
{
|
||||
_statusLabel.Text = "DRY RUN: Plan prepared. No runtime changes and no real drain decision dialog.";
|
||||
Activate();
|
||||
BringToFront();
|
||||
MessageBox.Show(
|
||||
this,
|
||||
ShutdownOperatorPrompts.BuildDryRunNotice(plan, planPath),
|
||||
ShutdownOperatorPrompts.DryRunTitle,
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
};
|
||||
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(showNotice);
|
||||
}
|
||||
else
|
||||
{
|
||||
showNotice();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pauses a real shutdown after the receive-location phase until the operator
|
||||
/// confirms that the enterprise environment has drained.
|
||||
/// </summary>
|
||||
/// <param name="checkpoint">The persisted checkpoint plan row.</param>
|
||||
/// <param name="progress">The execution results already reached.</param>
|
||||
/// <returns>True only after an explicit Yes decision.</returns>
|
||||
private bool ConfirmInboundDrainCheckpoint(OperationStep checkpoint, OperationExecutionReport progress)
|
||||
{
|
||||
var confirmed = false;
|
||||
Action showConfirmation = () =>
|
||||
{
|
||||
_statusLabel.Text = ShutdownOperatorPrompts.WaitingForInboundDrainStatus;
|
||||
Activate();
|
||||
BringToFront();
|
||||
var result = MessageBox.Show(
|
||||
this,
|
||||
ShutdownOperatorPrompts.BuildInboundDrainConfirmation(progress),
|
||||
ShutdownOperatorPrompts.InboundDrainTitle,
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning,
|
||||
MessageBoxDefaultButton.Button2);
|
||||
confirmed = result == DialogResult.Yes;
|
||||
};
|
||||
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(showConfirmation);
|
||||
}
|
||||
else
|
||||
{
|
||||
showConfirmation();
|
||||
}
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Confirms the stronger emergency-recovery contract, including the preserved
|
||||
/// source snapshot and automatic Enterprise SSO prerequisite.
|
||||
/// </summary>
|
||||
/// <param name="plan">The prepared emergency plan.</param>
|
||||
/// <param name="server">The selected target server.</param>
|
||||
/// <param name="sourcePath">The preserved source snapshot.</param>
|
||||
/// <param name="planPath">The saved emergency plan.</param>
|
||||
/// <returns>True when the operator explicitly approves the recovery.</returns>
|
||||
private bool ConfirmEmergencyRestore(OperationPlan plan, string server, string sourcePath, string planPath)
|
||||
{
|
||||
var confirmed = false;
|
||||
Action showConfirmation = () =>
|
||||
{
|
||||
_statusLabel.Text = "ACTION REQUIRED: Review the emergency restore plan and answer the owned confirmation dialog.";
|
||||
Activate();
|
||||
BringToFront();
|
||||
var executableSteps = plan.Steps.Count(x => x.Execute);
|
||||
var result = MessageBox.Show(
|
||||
this,
|
||||
"EMERGENCY RESTORE will reconcile " + executableSteps + " step(s) on server '" + server + "'.\n\n"
|
||||
+ "Source snapshot (will not be overwritten):\n" + sourcePath + "\n\n"
|
||||
+ "Enterprise Single Sign-On will be ensured Running first. Already-correct states are skipped; isolated failures are recorded and later steps continue.\n\n"
|
||||
+ "Saved plan:\n" + planPath + "\n\nContinue now?",
|
||||
"Confirm Emergency Restore",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning,
|
||||
MessageBoxDefaultButton.Button2);
|
||||
confirmed = result == DialogResult.Yes;
|
||||
};
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(showConfirmation);
|
||||
}
|
||||
else
|
||||
{
|
||||
showConfirmation();
|
||||
}
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a snapshot in the status grid and updates the environment indicator.
|
||||
/// </summary>
|
||||
@@ -604,6 +914,30 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the durable per-step outcomes after best-effort execution.
|
||||
/// </summary>
|
||||
/// <param name="report">The execution report to display.</param>
|
||||
private void ShowExecutionReport(OperationExecutionReport report)
|
||||
{
|
||||
InvokeIfRequired(() =>
|
||||
{
|
||||
_statusGrid.Rows.Clear();
|
||||
foreach (var item in report.Steps)
|
||||
{
|
||||
_statusGrid.Rows.Add(item.Kind, item.Application, item.Name, item.Outcome, item.Error ?? item.Action);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(report.InitializationError))
|
||||
{
|
||||
_statusGrid.Rows.Add("Runtime", string.Empty, report.Server, "Failed", report.InitializationError);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(report.PostSnapshotError))
|
||||
{
|
||||
_statusGrid.Rows.Add("Snapshot", string.Empty, report.Server, "Failed", report.PostSnapshotError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends one operation log entry to the log grid.
|
||||
/// </summary>
|
||||
@@ -612,7 +946,38 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
{
|
||||
InvokeIfRequired(() =>
|
||||
{
|
||||
var index = _logGrid.Rows.Add(entry.Timestamp.ToString("HH:mm:ss"), entry.Level.ToString(), entry.Message);
|
||||
AddLogRow(entry);
|
||||
_logGrid.FirstDisplayedScrollingRowIndex = Math.Max(0, _logGrid.Rows.Count - 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Restores retained plain and compressed log records into the grid at startup.</summary>
|
||||
private void LoadLogHistory()
|
||||
{
|
||||
var entries = _logger.ReadRecentEntries(OperationLogger.DefaultGridHistoryLimit);
|
||||
_logGrid.SuspendLayout();
|
||||
try
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
AddLogRow(entry);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_logGrid.ResumeLayout();
|
||||
}
|
||||
if (_logGrid.Rows.Count > 0)
|
||||
{
|
||||
_logGrid.FirstDisplayedScrollingRowIndex = _logGrid.Rows.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds and colors one retained or live log row.</summary>
|
||||
/// <param name="entry">The log entry to display.</param>
|
||||
private void AddLogRow(LogEntry entry)
|
||||
{
|
||||
var index = _logGrid.Rows.Add(entry.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"), entry.Level.ToString(), entry.Message);
|
||||
var row = _logGrid.Rows[index];
|
||||
if (entry.Level == LogLevel.Error)
|
||||
{
|
||||
@@ -626,8 +991,6 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
{
|
||||
row.DefaultCellStyle.ForeColor = Color.DarkGreen;
|
||||
}
|
||||
_logGrid.FirstDisplayedScrollingRowIndex = Math.Max(0, _logGrid.Rows.Count - 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -646,12 +1009,48 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
_compareButton.Enabled = !busy;
|
||||
_shutdownButton.Enabled = !busy;
|
||||
_restoreButton.Enabled = !busy;
|
||||
_validateStateButton.Enabled = !busy;
|
||||
_emergencyRestoreButton.Enabled = !busy;
|
||||
_clearButton.Enabled = !busy;
|
||||
_openLogsButton.Enabled = !busy;
|
||||
_closeButton.Enabled = !busy;
|
||||
_statusLabel.Text = status;
|
||||
_serverTextBox.Enabled = !busy;
|
||||
_outputTextBox.Enabled = !busy;
|
||||
_stateFileTextBox.Enabled = !busy;
|
||||
_timeoutInput.Enabled = !busy;
|
||||
_pollInput.Enabled = !busy;
|
||||
_dryRunCheckBox.Enabled = !busy;
|
||||
_statusLabel.Text = !busy && string.Equals(status, "Ready.", StringComparison.Ordinal)
|
||||
? "Ready. " + (_dryRunCheckBox.Checked
|
||||
? "DRY RUN is enabled; shutdown will not change runtime state or request a drain decision."
|
||||
: "REAL EXECUTION is enabled; shutdown will pause for the owned drain decision.")
|
||||
: status;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Updates the prominent execution-mode warning when Dry run changes.</summary>
|
||||
/// <param name="sender">The checkbox that raised the event.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
private void DryRunCheckBoxCheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateDryRunPresentation();
|
||||
if (!_isBusy)
|
||||
{
|
||||
_statusLabel.Text = _dryRunCheckBox.Checked
|
||||
? "Ready. DRY RUN is enabled; shutdown will not change runtime state or request a drain decision."
|
||||
: "Ready. REAL EXECUTION is enabled; shutdown will pause for the owned drain decision.";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Uses explicit text and color instead of relying on a small check mark.</summary>
|
||||
private void UpdateDryRunPresentation()
|
||||
{
|
||||
_dryRunCheckBox.Text = _dryRunCheckBox.Checked
|
||||
? "DRY RUN - no changes / no drain dialog"
|
||||
: "REAL EXECUTION - drain dialog required";
|
||||
_dryRunCheckBox.BackColor = _dryRunCheckBox.Checked ? Color.LightGoldenrodYellow : Color.MistyRose;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the output directory Browse button click.
|
||||
/// </summary>
|
||||
@@ -669,6 +1068,54 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles selection of an existing JSON recovery snapshot.
|
||||
/// </summary>
|
||||
/// <param name="sender">The control that raised the event.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
private void StateBrowseButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
using (var dialog = new OpenFileDialog())
|
||||
{
|
||||
dialog.Title = "Select preserved BizTalk state snapshot";
|
||||
dialog.Filter = "BizTalk snapshot (*.json)|*.json|All files (*.*)|*.*";
|
||||
dialog.CheckFileExists = true;
|
||||
dialog.Multiselect = false;
|
||||
var currentPath = ResolveStateFile(GetOptions());
|
||||
if (File.Exists(currentPath))
|
||||
{
|
||||
dialog.InitialDirectory = Path.GetDirectoryName(currentPath);
|
||||
dialog.FileName = Path.GetFileName(currentPath);
|
||||
}
|
||||
if (dialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
_stateFileTextBox.Text = dialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the successful WMI-free state-file validation result to the operator.
|
||||
/// </summary>
|
||||
/// <param name="summary">The complete validation summary.</param>
|
||||
private void ShowStateValidationSummary(string summary)
|
||||
{
|
||||
Action show = () => MessageBox.Show(
|
||||
this,
|
||||
summary + "\n\nNo runtime state was changed and no WMI connection was opened.",
|
||||
"Recovery State Valid",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(show);
|
||||
}
|
||||
else
|
||||
{
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a UI update on the UI thread when required.
|
||||
/// </summary>
|
||||
@@ -817,19 +1264,7 @@ namespace BizTalkPlatformManagementTool.Ui
|
||||
return "Operation failed.";
|
||||
}
|
||||
|
||||
var message = ex.Message;
|
||||
var inner = ex.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(inner.Message) && message.IndexOf(inner.Message, StringComparison.OrdinalIgnoreCase) < 0)
|
||||
{
|
||||
message += " Inner error: " + inner.Message;
|
||||
}
|
||||
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
|
||||
return message;
|
||||
return ExceptionDiagnostics.Format(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BizTalkPlatformManagementTool.Models;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Ui
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds stable, testable operator guidance for shutdown plan review, dry-run
|
||||
/// simulation and the real inbound-drain checkpoint.
|
||||
/// </summary>
|
||||
internal static class ShutdownOperatorPrompts
|
||||
{
|
||||
/// <summary>Title of the non-mutating dry-run explanation.</summary>
|
||||
public const string DryRunTitle = "Shutdown Dry Run - No Runtime Changes";
|
||||
|
||||
/// <summary>Title of the saved-plan confirmation.</summary>
|
||||
public const string PreparedPlanTitle = "Confirm Prepared BizTalk Plan";
|
||||
|
||||
/// <summary>Title of the real inbound-drain decision.</summary>
|
||||
public const string InboundDrainTitle = "ACTION REQUIRED - Confirm BizTalk Inbound Drain";
|
||||
|
||||
/// <summary>Status displayed while the real shutdown waits for drain verification.</summary>
|
||||
public const string WaitingForInboundDrainStatus = "ACTION REQUIRED: Shutdown paused. Verify inbound drain and answer the owned confirmation dialog.";
|
||||
|
||||
/// <summary>Builds the explicit explanation shown for a shutdown dry-run.</summary>
|
||||
/// <param name="plan">The prepared shutdown plan.</param>
|
||||
/// <param name="planPath">The durable path of the prepared plan.</param>
|
||||
/// <returns>Operator-facing dry-run guidance.</returns>
|
||||
public static string BuildDryRunNotice(OperationPlan plan, string planPath)
|
||||
{
|
||||
if (plan == null)
|
||||
{
|
||||
throw new ArgumentNullException("plan");
|
||||
}
|
||||
|
||||
var checkpointCount = CountCheckpoints(plan);
|
||||
return "DRY RUN is enabled. This run only simulates the saved shutdown plan.\n\n"
|
||||
+ "No receive location is disabled and no runtime state is changed. Therefore the real inbound-drain decision dialog will not open during this run.\n\n"
|
||||
+ (checkpointCount == 0
|
||||
? "This plan has no later shutdown phase and therefore needs no drain checkpoint.\n\n"
|
||||
: "The plan contains the inbound-drain checkpoint. It will require an explicit Yes/No decision when the same plan is prepared with Dry run disabled.\n\n")
|
||||
+ "Prepared plan:\n" + planPath;
|
||||
}
|
||||
|
||||
/// <summary>Builds the confirmation for a fully prepared real operation.</summary>
|
||||
/// <param name="actionName">The operation name.</param>
|
||||
/// <param name="plan">The prepared operation plan.</param>
|
||||
/// <param name="server">The selected target server.</param>
|
||||
/// <param name="planPath">The durable path of the prepared plan.</param>
|
||||
/// <returns>Operator-facing prepared-plan confirmation.</returns>
|
||||
public static string BuildPreparedPlanConfirmation(string actionName, OperationPlan plan, string server, string planPath)
|
||||
{
|
||||
if (plan == null)
|
||||
{
|
||||
throw new ArgumentNullException("plan");
|
||||
}
|
||||
|
||||
var executableSteps = plan.Steps.Count(x => x.Execute && !IsCheckpoint(x));
|
||||
var checkpointCount = CountCheckpoints(plan);
|
||||
return actionName + " will execute " + executableSteps + " step(s) on server '" + server + "'.\n\n"
|
||||
+ (checkpointCount == 0
|
||||
? string.Empty
|
||||
: "The saved plan contains an operator drain checkpoint after all receive locations. The real shutdown will visibly pause there for a second, explicit decision.\n\n")
|
||||
+ "The exact plan was saved to:\n" + planPath + "\n\nContinue now?";
|
||||
}
|
||||
|
||||
/// <summary>Builds the real inbound-drain decision from completed receive-location results.</summary>
|
||||
/// <param name="progress">The execution results already reached.</param>
|
||||
/// <returns>Operator-facing drain verification guidance.</returns>
|
||||
public static string BuildInboundDrainConfirmation(OperationExecutionReport progress)
|
||||
{
|
||||
if (progress == null)
|
||||
{
|
||||
throw new ArgumentNullException("progress");
|
||||
}
|
||||
|
||||
var receiveResults = progress.Steps
|
||||
.Where(x => string.Equals(x.Kind, OperationStepKind.ReceiveLocation.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
var succeeded = receiveResults.Count(x => x.Outcome == OperationStepOutcomes.Succeeded);
|
||||
var alreadyDisabled = receiveResults.Count(x => x.Outcome == OperationStepOutcomes.AlreadySatisfied);
|
||||
var failed = receiveResults.Count(x => x.Outcome == OperationStepOutcomes.Failed);
|
||||
var failureWarning = failed == 0
|
||||
? string.Empty
|
||||
: "\nWARNING: " + failed + " receive location(s) failed. Review the red Operation Log entries before continuing.\n";
|
||||
|
||||
return "The receive-location shutdown phase has finished. The shutdown is PAUSED and no later phase can run until you decide.\n\n"
|
||||
+ "Disabled successfully: " + succeeded + "\n"
|
||||
+ "Already disabled: " + alreadyDisabled + "\n"
|
||||
+ "Failed: " + failed + "\n"
|
||||
+ failureWarning + "\n"
|
||||
+ "Keep this dialog open while you verify in BizTalk Group Hub and your enterprise monitoring that no new inbound work arrives and all in-flight service instances/messages have drained.\n\n"
|
||||
+ "Continue with orchestrations, send ports and host instances?\n\n"
|
||||
+ "Yes = continue shutdown. No or closing this dialog = stop safely and persist all remaining steps as NotExecuted.";
|
||||
}
|
||||
|
||||
/// <summary>Counts executable drain checkpoints in a plan.</summary>
|
||||
private static int CountCheckpoints(OperationPlan plan)
|
||||
{
|
||||
return plan.Steps.Count(x => x.Execute && IsCheckpoint(x));
|
||||
}
|
||||
|
||||
/// <summary>Checks whether a plan row is the stable operator checkpoint kind.</summary>
|
||||
private static bool IsCheckpoint(OperationStep step)
|
||||
{
|
||||
return step != null && string.Equals(step.Kind, OperationStepKind.OperatorCheckpoint.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="2.1.2.0" name="BizTalkPlatformManagementTool" />
|
||||
<assemblyIdentity version="2.3.4.0" name="BizTalkPlatformManagementTool" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
|
||||
@@ -2,10 +2,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using BizTalkPlatformManagementTool.Models;
|
||||
using BizTalkPlatformManagementTool.Services;
|
||||
using BizTalkPlatformManagementTool.Setup;
|
||||
using BizTalkPlatformManagementTool.Ui;
|
||||
|
||||
namespace BizTalkPlatformManagementTool.Tests
|
||||
{
|
||||
@@ -24,17 +26,46 @@ namespace BizTalkPlatformManagementTool.Tests
|
||||
Run("JsonRoundTripIsBomTolerantAndAtomic", JsonRoundTripIsBomTolerantAndAtomic);
|
||||
Run("DiffUsesApplicationAndNameIdentity", DiffUsesApplicationAndNameIdentity);
|
||||
Run("RestoreRejectsDifferentServer", RestoreRejectsDifferentServer);
|
||||
Run("Legacy213SnapshotIsAcceptedForRecovery", Legacy213SnapshotIsAcceptedForRecovery);
|
||||
Run("RestorePlanUsesSafeOrder", RestorePlanUsesSafeOrder);
|
||||
Run("ShutdownPlanUsesGlobalSafeOrder", ShutdownPlanUsesGlobalSafeOrder);
|
||||
Run("ShutdownPlanRequiresCheckpointBeforeLaterWorkWithoutReceiveLocations", ShutdownPlanRequiresCheckpointBeforeLaterWorkWithoutReceiveLocations);
|
||||
Run("ShutdownContinuesAcrossArtifactCategoriesAfterReceiveLocationFailure", ShutdownContinuesAcrossArtifactCategoriesAfterReceiveLocationFailure);
|
||||
Run("ShutdownCheckpointDeclineStopsLaterPhases", ShutdownCheckpointDeclineStopsLaterPhases);
|
||||
Run("ShutdownCheckpointMissingHandlerFailsClosed", ShutdownCheckpointMissingHandlerFailsClosed);
|
||||
Run("ShutdownCheckpointDryRunDoesNotPrompt", ShutdownCheckpointDryRunDoesNotPrompt);
|
||||
Run("ShutdownOperatorPromptsDistinguishDryRunAndRealDecision", ShutdownOperatorPromptsDistinguishDryRunAndRealDecision);
|
||||
Run("EmergencyRestorePlanStartsSsoFirst", EmergencyRestorePlanStartsSsoFirst);
|
||||
Run("HostInstancePlanAcceptsShortAndFqdnServer", HostInstancePlanAcceptsShortAndFqdnServer);
|
||||
Run("PlanExecutionContinuesAfterSchedulerFailure", PlanExecutionContinuesAfterSchedulerFailure);
|
||||
Run("PlanExecutionContinuesAfterMultipleUnexpectedExceptions", PlanExecutionContinuesAfterMultipleUnexpectedExceptions);
|
||||
Run("LoggerSinkFailureCannotAbortPlanExecution", LoggerSinkFailureCannotAbortPlanExecution);
|
||||
Run("PlanExecutionSkipsAlreadySatisfiedState", PlanExecutionSkipsAlreadySatisfiedState);
|
||||
Run("ExecutionReportRoundTripPreservesFailure", ExecutionReportRoundTripPreservesFailure);
|
||||
Run("ScheduledReceivePlanCarriesAdapterMetadata", ScheduledReceivePlanCarriesAdapterMetadata);
|
||||
Run("ApplicationResolverMapsArtifactsAndRejectsAmbiguity", ApplicationResolverMapsArtifactsAndRejectsAmbiguity);
|
||||
Run("AdapterAssemblyResolverRequiresMatchingIdentity", AdapterAssemblyResolverRequiresMatchingIdentity);
|
||||
Run("OperationLogPersistsCompressesAndRetainsThirtyDays", OperationLogPersistsCompressesAndRetainsThirtyDays);
|
||||
Run("OperationLogUsesVerifiedStartupFallback", OperationLogUsesVerifiedStartupFallback);
|
||||
Run("OperationLogFailsOverAfterAppendFailure", OperationLogFailsOverAfterAppendFailure);
|
||||
Run("OperationLogSurfacesTotalStorageFailure", OperationLogSurfacesTotalStorageFailure);
|
||||
Run("ExceptionDiagnosticsContainSupportContext", ExceptionDiagnosticsContainSupportContext);
|
||||
Run("CsvNeutralizesFormulaValues", CsvNeutralizesFormulaValues);
|
||||
Run("PackageManifestRejectsTampering", PackageManifestRejectsTampering);
|
||||
Run("PackageManifestRejectsUndeclaredAndTraversalFiles", PackageManifestRejectsUndeclaredAndTraversalFiles);
|
||||
Run("InstallerActivatesValidatedPayload", InstallerActivatesValidatedPayload);
|
||||
Run("InstallerRetriesTransientActivationMove", InstallerRetriesTransientActivationMove);
|
||||
Run("InstallerUsesVerifiedCopyFallbackForNewInstall", InstallerUsesVerifiedCopyFallbackForNewInstall);
|
||||
Run("InstallerUsesVerifiedCopyFallbackForBackedUpUpdate", InstallerUsesVerifiedCopyFallbackForBackedUpUpdate);
|
||||
Run("InstallerRollsBackFailedUpdateCopyFallback", InstallerRollsBackFailedUpdateCopyFallback);
|
||||
Run("InstallerStopsAfterBoundedUpdateMoveRetries", InstallerStopsAfterBoundedUpdateMoveRetries);
|
||||
Run("InstallerDoesNotMutateOnStagingFailure", InstallerDoesNotMutateOnStagingFailure);
|
||||
Run("InstallerRollsBackFailedActivatedSelfTest", InstallerRollsBackFailedActivatedSelfTest);
|
||||
Run("InstallerUninstallRemovesProgramDirectory", InstallerUninstallRemovesProgramDirectory);
|
||||
Run("InstallerDiagnosticLogContainsContextAndExceptionChain", InstallerDiagnosticLogContainsContextAndExceptionChain);
|
||||
Run("InstallerDiagnosticLogFallsBackToTemp", InstallerDiagnosticLogFallsBackToTemp);
|
||||
Run("InstallerSurvivesUiReportFailure", InstallerSurvivesUiReportFailure);
|
||||
Run("OptionalWindowsIntegrationFailuresAreNonFatal", OptionalWindowsIntegrationFailuresAreNonFatal);
|
||||
Console.WriteLine(failures == 0 ? "ALL TESTS PASSED" : failures + " TEST(S) FAILED");
|
||||
return failures == 0 ? 0 : 1;
|
||||
}
|
||||
@@ -89,6 +120,25 @@ namespace BizTalkPlatformManagementTool.Tests
|
||||
Expect<InvalidOperationException>(() => SnapshotValidator.EnsureServerMatches(snapshot, "BIZTALK-B"));
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass ein erhaltener 2.1.3-Snapshot ohne Versionssperre als Recovery-Quelle dient.</summary>
|
||||
private static void Legacy213SnapshotIsAcceptedForRecovery()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var original = Snapshot("APP", "PORT", ArtifactStates.SendPortStarted);
|
||||
original.ToolVersion = "2.1.3-net461";
|
||||
original.Server = "BIZTALK-A.example.local";
|
||||
var path = Path.Combine(directory, "before.json");
|
||||
JsonFileStore.Save(path, original);
|
||||
|
||||
var loaded = JsonFileStore.Load<BizTalkSnapshot>(path);
|
||||
SnapshotValidator.EnsureServerMatches(loaded, "BIZTALK-A");
|
||||
var plan = new BizTalkOperationService(null).CreateEmergencyRestorePlan(loaded, "BIZTALK-A");
|
||||
Assert(plan.Steps.First().Kind == "WindowsService", "legacy snapshot did not create an emergency plan");
|
||||
Assert(loaded.ToolVersion == "2.1.3-net461", "legacy tool version was not preserved");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft die sichere Restore-Reihenfolge und den Schutz gebundener Orchestrierungen.</summary>
|
||||
private static void RestorePlanUsesSafeOrder()
|
||||
{
|
||||
@@ -96,13 +146,409 @@ namespace BizTalkPlatformManagementTool.Tests
|
||||
snapshot.HostInstances.Add(new HostInstanceState { InstanceName = "HOST:SERVER", HostName = "HOST", Server = snapshot.Server, RawState = ArtifactStates.HostStarted });
|
||||
snapshot.Applications[0].Orchestrations.Add(new OrchestrationState { Application = "APP", Name = "ORCH", OrchestrationStatus = ArtifactStates.OrchestrationBound });
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP", Name = "RL", Enabled = true });
|
||||
var second = Snapshot("APP-B", "PORT-B", ArtifactStates.SendPortStarted).Applications[0];
|
||||
second.Orchestrations.Add(new OrchestrationState { Application = "APP-B", Name = "ORCH-B", OrchestrationStatus = ArtifactStates.OrchestrationStarted });
|
||||
second.ReceiveLocations.Add(new ReceiveLocationState { Application = "APP-B", Name = "RL-B", Enabled = true });
|
||||
snapshot.Applications.Add(second);
|
||||
var plan = new BizTalkOperationService(null).CreateRestorePlan(snapshot, snapshot.Server);
|
||||
Assert(plan.Steps.First().Kind == "HostInstance", "host instance must start first");
|
||||
Assert(plan.Steps.Last().Kind == "ReceiveLocation", "receive location must be restored last");
|
||||
var firstReceiveLocation = plan.Steps.FindIndex(x => x.Kind == "ReceiveLocation");
|
||||
var lastSendPort = plan.Steps.FindLastIndex(x => x.Kind == "SendPort");
|
||||
var lastOrchestration = plan.Steps.FindLastIndex(x => x.Kind == "Orchestration" || x.Kind == "Note");
|
||||
Assert(firstReceiveLocation > lastSendPort && firstReceiveLocation > lastOrchestration, "all receive locations must be restored after all send ports and orchestrations");
|
||||
var bound = plan.Steps.Single(x => x.Name == "ORCH");
|
||||
Assert(!bound.Execute && bound.Kind == "Note", "bound orchestration must remain unchanged");
|
||||
}
|
||||
|
||||
/// <summary>Prüft die globale Shutdown-Reihenfolge auch über mehrere Anwendungen hinweg.</summary>
|
||||
private static void ShutdownPlanUsesGlobalSafeOrder()
|
||||
{
|
||||
var snapshot = Snapshot("APP-A", "SP-A", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP-A", Name = "RL-A", Enabled = true });
|
||||
snapshot.Applications[0].Orchestrations.Add(new OrchestrationState { Application = "APP-A", Name = "ORCH-A", OrchestrationStatus = ArtifactStates.OrchestrationStarted });
|
||||
var appB = Snapshot("APP-B", "SP-B", ArtifactStates.SendPortStarted).Applications[0];
|
||||
appB.ReceiveLocations.Add(new ReceiveLocationState { Application = "APP-B", Name = "RL-B", Enabled = true });
|
||||
appB.Orchestrations.Add(new OrchestrationState { Application = "APP-B", Name = "ORCH-B", OrchestrationStatus = ArtifactStates.OrchestrationStarted });
|
||||
snapshot.Applications.Add(appB);
|
||||
snapshot.HostInstances.Add(new HostInstanceState { InstanceName = "HOST:SERVER", HostName = "HOST", Server = snapshot.Server, RawState = ArtifactStates.HostStarted });
|
||||
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var lastReceiveLocation = plan.Steps.FindLastIndex(x => x.Kind == "ReceiveLocation");
|
||||
var checkpoint = plan.Steps.FindIndex(x => x.Kind == OperationStepKind.OperatorCheckpoint.ToString());
|
||||
var firstOrchestration = plan.Steps.FindIndex(x => x.Kind == "Orchestration");
|
||||
var lastOrchestration = plan.Steps.FindLastIndex(x => x.Kind == "Orchestration");
|
||||
var firstSendPort = plan.Steps.FindIndex(x => x.Kind == "SendPort");
|
||||
var lastSendPort = plan.Steps.FindLastIndex(x => x.Kind == "SendPort");
|
||||
var firstHost = plan.Steps.FindIndex(x => x.Kind == "HostInstance");
|
||||
Assert(lastReceiveLocation < checkpoint && checkpoint < firstOrchestration, "operator checkpoint was not placed directly after the global receive-location phase");
|
||||
Assert(lastOrchestration < firstSendPort, "orchestrations were not globally before send ports");
|
||||
Assert(lastSendPort < firstHost, "host instances were not globally last");
|
||||
}
|
||||
|
||||
/// <summary>Prüft den Checkpoint auch dann, wenn keine aktive Receive Location als Planzeile existiert.</summary>
|
||||
private static void ShutdownPlanRequiresCheckpointBeforeLaterWorkWithoutReceiveLocations()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SEND", ArtifactStates.SendPortStarted);
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var checkpoint = plan.Steps.FindIndex(x => x.Kind == OperationStepKind.OperatorCheckpoint.ToString());
|
||||
var sendPort = plan.Steps.FindIndex(x => x.Kind == OperationStepKind.SendPort.ToString());
|
||||
|
||||
Assert(checkpoint >= 0, "later shutdown work did not create an inbound-drain checkpoint");
|
||||
Assert(checkpoint < sendPort, "checkpoint was not placed before later shutdown work");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass Scheduler-Erkennung auch nach Planpersistenz möglich bleibt.</summary>
|
||||
private static void ScheduledReceivePlanCarriesAdapterMetadata()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SP", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState
|
||||
{
|
||||
Application = "APP",
|
||||
Name = "RV_PMP_Trigger_Schedule",
|
||||
Enabled = true,
|
||||
AdapterName = "Schedule",
|
||||
Address = "scheduler://PMP-trigger"
|
||||
});
|
||||
var service = new BizTalkOperationService(null);
|
||||
var shutdown = service.CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var step = shutdown.Steps.Single(x => x.Kind == "ReceiveLocation");
|
||||
Assert(step.AdapterName == "Schedule", "adapter name missing from shutdown plan");
|
||||
Assert(step.Address == "scheduler://PMP-trigger", "scheduler URI missing from shutdown plan");
|
||||
|
||||
InTemp(directory =>
|
||||
{
|
||||
var path = Path.Combine(directory, "plan.json");
|
||||
JsonFileStore.Save(path, shutdown);
|
||||
var loaded = JsonFileStore.Load<OperationPlan>(path);
|
||||
Assert(loaded.Steps.Single(x => x.Kind == "ReceiveLocation").Address.StartsWith("scheduler:", StringComparison.OrdinalIgnoreCase), "scheduler metadata did not survive serialization");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft die ExplorerOM-basierte Zuordnung aller Laufzeitartefakte und den Ambiguitätsschutz.</summary>
|
||||
private static void ApplicationResolverMapsArtifactsAndRejectsAmbiguity()
|
||||
{
|
||||
var resolver = new BizTalkApplicationResolver();
|
||||
resolver.AddSendPort("APP-A", "SP-A");
|
||||
resolver.AddReceivePort("APP-B", "RP-B");
|
||||
resolver.AddReceiveLocation("APP-B", "RL-B");
|
||||
resolver.AddOrchestration("APP-C", "Company.Process.Order");
|
||||
|
||||
Assert(resolver.ApplicationCount == 3, "application count did not de-duplicate artifact owners");
|
||||
Assert(resolver.ResolveSendPort("sp-a") == "APP-A", "send port was not resolved case-insensitively");
|
||||
Assert(resolver.ResolveReceiveLocation("RL-B", null) == "APP-B", "receive location was not resolved");
|
||||
Assert(resolver.ResolveReceiveLocation("missing", "rp-b") == "APP-B", "receive-port fallback was not used");
|
||||
Assert(resolver.ResolveOrchestration("company.process.order") == "APP-C", "orchestration was not resolved");
|
||||
|
||||
resolver.AddSendPort("APP-D", "SP-A");
|
||||
Assert(resolver.ResolveSendPort("SP-A") == null, "cross-application duplicate was not rejected as ambiguous");
|
||||
}
|
||||
|
||||
/// <summary>Prüft Dateinamen- und vollständige Assemblyidentität vor prozesslokalem Laden.</summary>
|
||||
private static void AdapterAssemblyResolverRequiresMatchingIdentity()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var source = typeof(BizTalkOperationService).Assembly.Location;
|
||||
var identity = AssemblyName.GetAssemblyName(source);
|
||||
var candidate = Path.Combine(directory, identity.Name + ".dll");
|
||||
File.Copy(source, candidate);
|
||||
Assert(AdapterAssemblyResolver.FindCandidateFile(identity.Name, identity, new[] { directory }) == candidate, "matching assembly identity was not found");
|
||||
|
||||
var wrongVersion = new AssemblyName(identity.FullName);
|
||||
wrongVersion.Version = new Version(identity.Version.Major + 1, 0, 0, 0);
|
||||
Assert(AdapterAssemblyResolver.FindCandidateFile(identity.Name, wrongVersion, new[] { directory }) == null, "wrong assembly version was accepted");
|
||||
|
||||
File.Copy(source, Path.Combine(directory, AdapterAssemblyResolver.SchedulerAssemblyName + ".dll"));
|
||||
Assert(AdapterAssemblyResolver.FindCandidateFile(AdapterAssemblyResolver.SchedulerAssemblyName, null, new[] { directory }) == null, "file-name-only scheduler impostor was accepted");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft Neustart-Rehydration, Vortagskompression und die 30-Tage-Grenze.</summary>
|
||||
private static void OperationLogPersistsCompressesAndRetainsThirtyDays()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
var yesterday = Path.Combine(directory, "BizTalkPlatformManagementTool-" + today.AddDays(-1).ToString("yyyy-MM-dd") + ".log");
|
||||
var expired = Path.Combine(directory, "BizTalkPlatformManagementTool-" + today.AddDays(-30).ToString("yyyy-MM-dd") + ".log");
|
||||
File.WriteAllText(yesterday, "[" + today.AddDays(-1).ToString("yyyy-MM-dd") + " 08:00:00][WARNING] retained warning\r\n", Encoding.UTF8);
|
||||
File.WriteAllText(expired, "[" + today.AddDays(-30).ToString("yyyy-MM-dd") + " 08:00:00][INFO] expired\r\n", Encoding.UTF8);
|
||||
|
||||
var logger = new OperationLogger(null, directory);
|
||||
Assert(File.Exists(yesterday + ".gz") && !File.Exists(yesterday), "completed daily log was not compressed");
|
||||
Assert(!File.Exists(expired), "log outside 30-day retention was not deleted");
|
||||
logger.Error("durable failure marker");
|
||||
|
||||
var restarted = new OperationLogger(null, directory);
|
||||
var entries = restarted.ReadRecentEntries(100);
|
||||
Assert(entries.Any(x => x.Level == LogLevel.Warning && x.Message == "retained warning"), "compressed history was not restored");
|
||||
Assert(entries.Any(x => x.Level == LogLevel.Error && x.Message == "durable failure marker"), "current history was not restored after restart");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass erst ein real beschreibbarer Pfad als aktiv gilt.</summary>
|
||||
private static void OperationLogUsesVerifiedStartupFallback()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var blocked = Path.Combine(directory, "blocked-primary");
|
||||
var fallback = Path.Combine(directory, "writable-fallback");
|
||||
File.WriteAllText(blocked, "not a directory");
|
||||
|
||||
var logger = new OperationLogger(null, new[] { blocked, fallback });
|
||||
Assert(logger.IsFileLoggingAvailable, "writable fallback was not activated");
|
||||
Assert(string.Equals(logger.LogDirectory, fallback, StringComparison.OrdinalIgnoreCase), "wrong fallback directory selected");
|
||||
Assert(logger.StorageWarning.Contains("Primary runtime log path is not writable"), "startup fallback warning missing");
|
||||
logger.Info("verified fallback marker");
|
||||
Assert(File.Exists(logger.LogFilePath), "fallback log file was not created");
|
||||
Assert(File.ReadAllText(logger.LogFilePath).Contains("verified fallback marker"), "fallback append was not durable");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft automatisches Failover, wenn der aktive Pfad später ausfällt.</summary>
|
||||
private static void OperationLogFailsOverAfterAppendFailure()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var primary = Path.Combine(directory, "primary");
|
||||
var fallback = Path.Combine(directory, "fallback");
|
||||
var visible = new List<LogEntry>();
|
||||
var logger = new OperationLogger(visible.Add, new[] { primary, fallback });
|
||||
Assert(string.Equals(logger.LogDirectory, primary, StringComparison.OrdinalIgnoreCase), "primary directory was not initially selected");
|
||||
|
||||
Directory.Delete(primary, true);
|
||||
File.WriteAllText(primary, "now blocked");
|
||||
logger.Error("runtime failover marker");
|
||||
|
||||
Assert(string.Equals(logger.LogDirectory, fallback, StringComparison.OrdinalIgnoreCase), "append failure did not switch to fallback");
|
||||
Assert(File.ReadAllText(logger.LogFilePath).Contains("runtime failover marker"), "failed primary record was not written to fallback");
|
||||
Assert(visible.Any(x => x.Level == LogLevel.Warning && x.Message.Contains("Runtime log path switched")), "runtime fallback was not visible in the sink");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft eine sichtbare Warnung, wenn kein Dateipfad beschreibbar ist.</summary>
|
||||
private static void OperationLogSurfacesTotalStorageFailure()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var blockedOne = Path.Combine(directory, "blocked-one");
|
||||
var blockedTwo = Path.Combine(directory, "blocked-two");
|
||||
File.WriteAllText(blockedOne, "not a directory");
|
||||
File.WriteAllText(blockedTwo, "not a directory");
|
||||
var visible = new List<LogEntry>();
|
||||
var logger = new OperationLogger(visible.Add, new[] { blockedOne, blockedTwo });
|
||||
Assert(!logger.IsFileLoggingAvailable, "logger reported unavailable candidates as writable");
|
||||
Assert(logger.StorageWarning.Contains("RUNTIME FILE LOGGING UNAVAILABLE"), "total startup failure diagnostic missing");
|
||||
|
||||
logger.Error("grid-only marker");
|
||||
Assert(visible.Any(x => x.Message == "grid-only marker"), "business entry disappeared with file logging failure");
|
||||
Assert(visible.Any(x => x.Level == LogLevel.Warning && x.Message.Contains("RUNTIME FILE LOGGING UNAVAILABLE")), "file logging failure was not visible in the grid sink");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft Typ, HRESULT, innere Ausnahme und Stacktrace für Supportfälle.</summary>
|
||||
private static void ExceptionDiagnosticsContainSupportContext()
|
||||
{
|
||||
Exception failure;
|
||||
try
|
||||
{
|
||||
throw new InvalidOperationException("outer detail", new FileNotFoundException("scheduler dependency missing"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure = ex;
|
||||
}
|
||||
var diagnostic = ExceptionDiagnostics.Format(failure);
|
||||
Assert(diagnostic.Contains("Type=System.InvalidOperationException"), "exception type missing");
|
||||
Assert(diagnostic.Contains("HResult=0x"), "HRESULT missing");
|
||||
Assert(diagnostic.Contains("InnerException[1]"), "inner exception index missing");
|
||||
Assert(diagnostic.Contains("scheduler dependency missing"), "inner message missing");
|
||||
Assert(diagnostic.Contains("StackTrace="), "stack trace missing");
|
||||
}
|
||||
|
||||
/// <summary>Prüft den vollständigen Shutdown-Fortgang von Receive Location bis Host Instance nach einem frühen Fehler.</summary>
|
||||
private static void ShutdownContinuesAcrossArtifactCategoriesAfterReceiveLocationFailure()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SEND", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP", Name = "RV_PMP_Trigger_Schedule", Enabled = true });
|
||||
snapshot.Applications[0].Orchestrations.Add(new OrchestrationState { Application = "APP", Name = "ORCHESTRATION", OrchestrationStatus = ArtifactStates.OrchestrationStarted });
|
||||
snapshot.HostInstances.Add(new HostInstanceState { InstanceName = "HOST:SERVER", HostName = "HOST", Server = snapshot.Server, RawState = ArtifactStates.HostStarted });
|
||||
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var runtime = new FakeOperationStepRuntime { FailingName = "RV_PMP_Trigger_Schedule" };
|
||||
var checkpointSawReceiveFailure = false;
|
||||
var report = new OperationPlanExecutor(null).Execute(plan, TestOptions(false), runtime, (checkpoint, progress) =>
|
||||
{
|
||||
checkpointSawReceiveFailure = progress.FailedCount == 1;
|
||||
return true;
|
||||
});
|
||||
|
||||
Assert(runtime.Calls.SequenceEqual(new[] { "RV_PMP_Trigger_Schedule", "ORCHESTRATION", "SEND", "HOST:SERVER" }), "shutdown did not continue through every later artifact category");
|
||||
Assert(report.FailedCount == 1 && report.SucceededCount == 3, "cross-category shutdown outcome is incomplete");
|
||||
Assert(checkpointSawReceiveFailure, "checkpoint did not receive the completed receive-location failure summary");
|
||||
Assert(report.CheckpointDecision == "Continue" && report.Steps.Single(x => x.Kind == OperationStepKind.OperatorCheckpoint.ToString()).Outcome == OperationStepOutcomes.Confirmed, "confirmed drain checkpoint was not persisted");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass Nein am Drain-Checkpoint keine spätere Shutdown-Mutation zulässt.</summary>
|
||||
private static void ShutdownCheckpointDeclineStopsLaterPhases()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SEND", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP", Name = "RL", Enabled = true });
|
||||
snapshot.Applications[0].Orchestrations.Add(new OrchestrationState { Application = "APP", Name = "ORCHESTRATION", OrchestrationStatus = ArtifactStates.OrchestrationStarted });
|
||||
snapshot.HostInstances.Add(new HostInstanceState { InstanceName = "HOST:SERVER", HostName = "HOST", Server = snapshot.Server, RawState = ArtifactStates.HostStarted });
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var runtime = new FakeOperationStepRuntime();
|
||||
|
||||
var report = new OperationPlanExecutor(null).Execute(plan, TestOptions(false), runtime, (checkpoint, progress) => false);
|
||||
|
||||
Assert(runtime.Calls.SequenceEqual(new[] { "RL" }), "a later shutdown phase executed after checkpoint decline");
|
||||
Assert(report.OperatorStopped && report.CheckpointDecision == "Stop", "operator stop decision was not persisted");
|
||||
Assert(report.NotExecutedCount == 3, "not-executed downstream count is wrong");
|
||||
Assert(report.Steps.SkipWhile(x => x.Kind != OperationStepKind.OperatorCheckpoint.ToString()).Skip(1).All(x => x.Outcome == OperationStepOutcomes.NotExecuted), "downstream rows were not marked NotExecuted");
|
||||
Assert(report.RequiresOperatorReview && !report.HasFailures, "safe operator stop was incorrectly classified as a runtime failure");
|
||||
InTemp(directory =>
|
||||
{
|
||||
var path = Path.Combine(directory, "shutdown-result.json");
|
||||
JsonFileStore.Save(path, report);
|
||||
var loaded = JsonFileStore.Load<OperationExecutionReport>(path);
|
||||
Assert(loaded.OperatorStopped && loaded.CheckpointDecision == "Stop" && loaded.NotExecutedCount == 3, "serialized report lost checkpoint decision evidence");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft den sicheren Stopp, wenn der echte Lauf keinen Dialog-Handler besitzt.</summary>
|
||||
private static void ShutdownCheckpointMissingHandlerFailsClosed()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SEND", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP", Name = "RL", Enabled = true });
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var runtime = new FakeOperationStepRuntime();
|
||||
|
||||
var report = new OperationPlanExecutor(null).Execute(plan, TestOptions(false), runtime);
|
||||
|
||||
Assert(runtime.Calls.SequenceEqual(new[] { "RL" }), "missing checkpoint handler did not fail closed");
|
||||
Assert(report.OperatorStopped && report.CheckpointDecision == "Error" && report.FailedCount == 1, "checkpoint handler failure was not durable");
|
||||
Assert(report.NotExecutedCount == 1 && report.Steps.Last().Outcome == OperationStepOutcomes.NotExecuted, "later send port was not protected after checkpoint error");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass Dry-run den Checkpoint zeigt, aber keine Bedienerentscheidung anfordert.</summary>
|
||||
private static void ShutdownCheckpointDryRunDoesNotPrompt()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SEND", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP", Name = "RL", Enabled = true });
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var callbackCalls = 0;
|
||||
|
||||
var report = new OperationPlanExecutor(null).Execute(plan, TestOptions(true), null, (checkpoint, progress) => { callbackCalls++; return false; });
|
||||
|
||||
Assert(callbackCalls == 0, "dry-run requested a real operator checkpoint decision");
|
||||
Assert(report.DryRunCount == plan.Steps.Count(x => x.Execute), "dry-run did not display every executable plan row");
|
||||
Assert(!report.OperatorStopped && string.IsNullOrWhiteSpace(report.CheckpointDecision), "dry-run persisted a real checkpoint decision");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass Dry-run-Hinweis und echter Entscheidungsdialog nicht verwechselt werden können.</summary>
|
||||
private static void ShutdownOperatorPromptsDistinguishDryRunAndRealDecision()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "SEND", ArtifactStates.SendPortStarted);
|
||||
snapshot.Applications[0].ReceiveLocations.Add(new ReceiveLocationState { Application = "APP", Name = "RL", Enabled = true });
|
||||
var plan = new BizTalkOperationService(null).CreateShutdownPlan(snapshot, snapshot.Server);
|
||||
var dryRun = ShutdownOperatorPrompts.BuildDryRunNotice(plan, @"C:\evidence\shutdown-plan.json");
|
||||
var prepared = ShutdownOperatorPrompts.BuildPreparedPlanConfirmation("Shutdown", plan, snapshot.Server, @"C:\evidence\shutdown-plan.json");
|
||||
var progress = new OperationExecutionReport();
|
||||
progress.Steps.Add(new OperationStepResult { Kind = OperationStepKind.ReceiveLocation.ToString(), Outcome = OperationStepOutcomes.Succeeded });
|
||||
progress.Steps.Add(new OperationStepResult { Kind = OperationStepKind.ReceiveLocation.ToString(), Outcome = OperationStepOutcomes.Failed });
|
||||
var checkpoint = ShutdownOperatorPrompts.BuildInboundDrainConfirmation(progress);
|
||||
|
||||
Assert(dryRun.Contains("No receive location is disabled") && dryRun.Contains("will not open"), "dry-run notice does not explain the missing real dialog");
|
||||
Assert(prepared.Contains("second, explicit decision"), "real-plan confirmation does not announce the later checkpoint dialog");
|
||||
Assert(checkpoint.Contains("shutdown is PAUSED") && checkpoint.Contains("Disabled successfully: 1") && checkpoint.Contains("Failed: 1"), "checkpoint decision does not expose its blocking state and receive results");
|
||||
Assert(checkpoint.Contains("closing this dialog = stop safely"), "checkpoint close behavior is not explicit");
|
||||
}
|
||||
|
||||
/// <summary>Prüft ENTSSO als erste Voraussetzung des Emergency Restore.</summary>
|
||||
private static void EmergencyRestorePlanStartsSsoFirst()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "PORT", ArtifactStates.SendPortStarted);
|
||||
snapshot.HostInstances.Add(new HostInstanceState { InstanceName = "HOST:SERVER", HostName = "HOST", Server = snapshot.Server, RawState = ArtifactStates.HostStarted });
|
||||
var plan = new BizTalkOperationService(null).CreateEmergencyRestorePlan(snapshot, snapshot.Server);
|
||||
Assert(plan.Mode == OperationMode.EmergencyRestore.ToString(), "emergency restore mode missing");
|
||||
Assert(plan.Steps.First().Kind == "WindowsService" && plan.Steps.First().Name == "ENTSSO", "ENTSSO must be the first emergency step");
|
||||
Assert(plan.Steps[1].Kind == "HostInstance", "host instance must follow ENTSSO");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass Kurzname und FQDN dieselbe Host Instance nicht fälschlich überspringen.</summary>
|
||||
private static void HostInstancePlanAcceptsShortAndFqdnServer()
|
||||
{
|
||||
var snapshot = Snapshot("APP", "PORT", ArtifactStates.SendPortStarted);
|
||||
snapshot.Server = "BIZTALK-A.example.local";
|
||||
snapshot.HostInstances.Add(new HostInstanceState
|
||||
{
|
||||
InstanceName = "HOST:BIZTALK-A",
|
||||
HostName = "HOST",
|
||||
Server = "BIZTALK-A.example.local",
|
||||
RawState = ArtifactStates.HostStarted
|
||||
});
|
||||
var plan = new BizTalkOperationService(null).CreateRestorePlan(snapshot, "BIZTALK-A");
|
||||
Assert(plan.Steps.First(x => x.Kind == "HostInstance").Execute, "short name/FQDN match incorrectly skipped host instance");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass eine Scheduler-artige Exception spätere Schritte nicht mehr verhindert.</summary>
|
||||
private static void PlanExecutionContinuesAfterSchedulerFailure()
|
||||
{
|
||||
var plan = TestPlan("RL-A", "RV_PMP_Trigger_Schedule", "RL-C");
|
||||
var runtime = new FakeOperationStepRuntime { FailingName = "RV_PMP_Trigger_Schedule" };
|
||||
var report = new OperationPlanExecutor(null).Execute(plan, TestOptions(false), runtime);
|
||||
Assert(runtime.Calls.SequenceEqual(new[] { "RL-A", "RV_PMP_Trigger_Schedule", "RL-C" }), "executor stopped after isolated failure");
|
||||
Assert(report.SucceededCount == 2 && report.FailedCount == 1, "unexpected continuation summary");
|
||||
Assert(report.Steps[1].Outcome == OperationStepOutcomes.Failed, "failed step outcome missing");
|
||||
Assert(report.Steps[1].Error.Contains("Microsoft.BizTalk.Scheduler"), "nested Scheduler exception missing from report");
|
||||
}
|
||||
|
||||
/// <summary>Prüft die Fortsetzung auch bei mehreren unterschiedlichen, nicht adapterspezifischen Exceptions.</summary>
|
||||
private static void PlanExecutionContinuesAfterMultipleUnexpectedExceptions()
|
||||
{
|
||||
var runtime = new MultipleFailureOperationStepRuntime();
|
||||
var report = new OperationPlanExecutor(null).Execute(TestPlan("INVALID", "IO", "TIMEOUT", "CONTINUE"), TestOptions(false), runtime);
|
||||
Assert(runtime.Calls.SequenceEqual(new[] { "INVALID", "IO", "TIMEOUT", "CONTINUE" }), "an unexpected exception stopped later independent steps");
|
||||
Assert(report.FailedCount == 3 && report.SucceededCount == 1, "multiple failure summary is incomplete");
|
||||
Assert(report.Steps.All(x => !string.IsNullOrWhiteSpace(x.FinishedAt)), "a failure result has no completion timestamp");
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass selbst eine defekte GUI-Logweiterleitung keine fachlichen Schritte verhindert.</summary>
|
||||
private static void LoggerSinkFailureCannotAbortPlanExecution()
|
||||
{
|
||||
var logger = new OperationLogger(entry => { throw new InvalidOperationException("simulated UI sink failure"); });
|
||||
var runtime = new FakeOperationStepRuntime { FailingName = "TWO" };
|
||||
var report = new OperationPlanExecutor(logger).Execute(TestPlan("ONE", "TWO", "THREE"), TestOptions(false), runtime);
|
||||
Assert(runtime.Calls.SequenceEqual(new[] { "ONE", "TWO", "THREE" }), "logging failure stopped plan execution");
|
||||
Assert(report.SucceededCount == 2 && report.FailedCount == 1, "logging failure changed business outcomes");
|
||||
Assert(report.Steps[1].Error.Contains("Microsoft.BizTalk.Scheduler"), "business failure was lost while the log sink was failing");
|
||||
}
|
||||
|
||||
/// <summary>Prüft idempotentes Überspringen eines bereits erreichten Sollzustands.</summary>
|
||||
private static void PlanExecutionSkipsAlreadySatisfiedState()
|
||||
{
|
||||
var plan = TestPlan("ALREADY", "CHANGE");
|
||||
var runtime = new FakeOperationStepRuntime();
|
||||
runtime.AlreadySatisfiedNames.Add("ALREADY");
|
||||
var report = new OperationPlanExecutor(null).Execute(plan, TestOptions(false), runtime);
|
||||
Assert(report.AlreadySatisfiedCount == 1 && report.SucceededCount == 1 && report.FailedCount == 0, "idempotent outcome counts are wrong");
|
||||
Assert(runtime.MutatedNames.SequenceEqual(new[] { "CHANGE" }), "already-satisfied step was mutated");
|
||||
}
|
||||
|
||||
/// <summary>Prüft die dauerhafte Serialisierung eines Teilfehler-Reports.</summary>
|
||||
private static void ExecutionReportRoundTripPreservesFailure()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var report = new OperationPlanExecutor(null).Execute(TestPlan("FAIL", "CONTINUE"), TestOptions(false), new FakeOperationStepRuntime { FailingName = "FAIL" });
|
||||
var path = Path.Combine(directory, "restore-result.json");
|
||||
JsonFileStore.Save(path, report);
|
||||
var loaded = JsonFileStore.Load<OperationExecutionReport>(path);
|
||||
Assert(loaded.HasFailures && loaded.FailedCount == 1, "serialized report lost failure summary");
|
||||
Assert(loaded.Steps.Count == 2 && loaded.Steps[1].Outcome == OperationStepOutcomes.Succeeded, "serialized report lost continued step");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft die Neutralisierung formelartiger CSV-Feldwerte.</summary>
|
||||
private static void CsvNeutralizesFormulaValues()
|
||||
{
|
||||
@@ -147,6 +593,196 @@ namespace BizTalkPlatformManagementTool.Tests
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft die erfolgreiche Aktivierung nach einer kurzzeitigen Rename-Sperre.</summary>
|
||||
private static void InstallerRetriesTransientActivationMove()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var package = CreatePackage(directory, "new");
|
||||
var install = Path.Combine(directory, "install");
|
||||
var data = Path.Combine(directory, "data");
|
||||
var moveCalls = 0;
|
||||
var delays = new List<int>();
|
||||
var engine = new InstallerEngine(
|
||||
package,
|
||||
install,
|
||||
data,
|
||||
false,
|
||||
path => true,
|
||||
(source, target) =>
|
||||
{
|
||||
moveCalls++;
|
||||
if (moveCalls == 1) throw new IOException("simulated transient scanner lock");
|
||||
Directory.Move(source, target);
|
||||
},
|
||||
delays.Add);
|
||||
|
||||
engine.Install(false, null);
|
||||
|
||||
Assert(moveCalls == 2, "transient activation move was not retried exactly once");
|
||||
Assert(delays.SequenceEqual(new[] { 250 }), "unexpected retry delay for transient activation move");
|
||||
Assert(File.ReadAllText(Path.Combine(install, InstallerEngine.ApplicationExeName)) == "new", "payload was not activated after retry");
|
||||
var log = File.ReadAllText(Directory.GetFiles(Path.Combine(data, "InstallerLogs"), "setup-*.log").Single());
|
||||
Assert(log.Contains("event=directory_move_retry role=activate failed_attempt=1"), "transient move retry was not diagnosed");
|
||||
Assert(log.Contains("event=directory_move_recovered role=activate attempt=2"), "move recovery was not diagnosed");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft den verifizierten Kopierfallback einer durchgehend gesperrten Neuinstallation.</summary>
|
||||
private static void InstallerUsesVerifiedCopyFallbackForNewInstall()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var package = CreatePackage(directory, "new");
|
||||
var install = Path.Combine(directory, "install");
|
||||
var data = Path.Combine(directory, "data");
|
||||
var moveCalls = 0;
|
||||
var delays = new List<int>();
|
||||
var engine = new InstallerEngine(
|
||||
package,
|
||||
install,
|
||||
data,
|
||||
false,
|
||||
path => true,
|
||||
(source, target) =>
|
||||
{
|
||||
moveCalls++;
|
||||
throw new UnauthorizedAccessException("simulated permanent policy denial");
|
||||
},
|
||||
delays.Add);
|
||||
|
||||
engine.Install(false, null);
|
||||
|
||||
Assert(moveCalls == 8, "permanent move failure did not stop after eight attempts");
|
||||
Assert(delays.SequenceEqual(new[] { 250, 500, 1000, 2000, 3000, 5000, 8000 }), "bounded retry schedule changed unexpectedly");
|
||||
Assert(File.ReadAllText(Path.Combine(install, InstallerEngine.ApplicationExeName)) == "new", "verified copy fallback did not activate payload");
|
||||
Assert(!Directory.GetDirectories(directory, "install.staging.*").Any(), "staging remained after copy fallback");
|
||||
var log = File.ReadAllText(Directory.GetFiles(Path.Combine(data, "InstallerLogs"), "setup-*.log").Single());
|
||||
Assert(log.Contains("event=directory_move_retry role=activate failed_attempt=7"), "final scheduled retry was not diagnosed");
|
||||
Assert(log.Contains("exception_type=System.UnauthorizedAccessException"), "ACL failure type missing from retry diagnostics");
|
||||
Assert(log.Contains("event=activation_fallback_complete method=verified_copy"), "copy fallback completion was not diagnosed");
|
||||
Assert(log.Contains("scope=new_install"), "new-install fallback scope missing from diagnostics");
|
||||
Assert(log.Contains("activation_method=verified_copy_fallback"), "copy fallback missing from setup summary");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft den verifizierten Kopierfallback, nachdem eine Update-Vorversion atomar gesichert wurde.</summary>
|
||||
private static void InstallerUsesVerifiedCopyFallbackForBackedUpUpdate()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var package = CreatePackage(directory, "new");
|
||||
var install = Path.Combine(directory, "install");
|
||||
Directory.CreateDirectory(install);
|
||||
File.WriteAllText(Path.Combine(install, InstallerEngine.ApplicationExeName), "old");
|
||||
File.WriteAllText(Path.Combine(install, InstallerEngine.ApplicationExeName + ".config"), "old-config");
|
||||
var data = Path.Combine(directory, "data");
|
||||
var activationMoveAttempts = 0;
|
||||
var delays = new List<int>();
|
||||
var engine = new InstallerEngine(
|
||||
package,
|
||||
install,
|
||||
data,
|
||||
false,
|
||||
path => true,
|
||||
(source, target) =>
|
||||
{
|
||||
if (source.IndexOf(".staging.", StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
activationMoveAttempts++;
|
||||
throw new UnauthorizedAccessException("simulated staging rename policy denial");
|
||||
}
|
||||
Directory.Move(source, target);
|
||||
},
|
||||
delays.Add);
|
||||
|
||||
engine.Install(false, null);
|
||||
|
||||
Assert(activationMoveAttempts == 8, "update activation did not exhaust the bounded move attempts");
|
||||
Assert(delays.SequenceEqual(new[] { 250, 500, 1000, 2000, 3000, 5000, 8000 }), "unexpected update fallback retry schedule");
|
||||
Assert(File.ReadAllText(Path.Combine(install, InstallerEngine.ApplicationExeName)) == "new", "update copy fallback did not activate the new payload");
|
||||
Assert(!Directory.GetDirectories(directory, "install.backup.*").Any(), "successful update fallback left a backup directory");
|
||||
var log = File.ReadAllText(Directory.GetFiles(Path.Combine(data, "InstallerLogs"), "setup-*.log").Single());
|
||||
Assert(log.Contains("event=activation_fallback_complete method=verified_copy scope=update_after_backup"), "update fallback scope missing from diagnostics");
|
||||
Assert(log.Contains("activation_method=verified_copy_fallback"), "update copy fallback missing from setup summary");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft das Backup-Rollback, wenn der Ziel-Self-Test nach einem Update-Kopierfallback fehlschlägt.</summary>
|
||||
private static void InstallerRollsBackFailedUpdateCopyFallback()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var package = CreatePackage(directory, "new");
|
||||
var install = Path.Combine(directory, "install");
|
||||
Directory.CreateDirectory(install);
|
||||
File.WriteAllText(Path.Combine(install, InstallerEngine.ApplicationExeName), "old");
|
||||
File.WriteAllText(Path.Combine(install, InstallerEngine.ApplicationExeName + ".config"), "old-config");
|
||||
var selfTestCalls = 0;
|
||||
var engine = new InstallerEngine(
|
||||
package,
|
||||
install,
|
||||
Path.Combine(directory, "data"),
|
||||
false,
|
||||
path => ++selfTestCalls == 1,
|
||||
(source, target) =>
|
||||
{
|
||||
if (source.IndexOf(".staging.", StringComparison.Ordinal) >= 0)
|
||||
throw new UnauthorizedAccessException("simulated staging rename policy denial");
|
||||
Directory.Move(source, target);
|
||||
},
|
||||
milliseconds => { });
|
||||
|
||||
var exception = Capture<InvalidOperationException>(() => engine.Install(false, null));
|
||||
|
||||
Assert(File.ReadAllText(Path.Combine(install, InstallerEngine.ApplicationExeName)) == "old", "failed update fallback did not restore the previous payload");
|
||||
Assert(!Directory.GetDirectories(directory, "install.backup.*").Any(), "rollback left the previous version in a backup directory");
|
||||
Assert(!Directory.GetDirectories(directory, "install.staging.*").Any(), "rollback left the failed staging directory");
|
||||
Assert(exception.Message.Contains("Fehlercode=SETUP-ACTIVATED-SELFTEST"), "failed fallback reported the wrong setup phase");
|
||||
Assert(exception.Message.Contains("Rollback erfolgreich"), "failed fallback did not report successful rollback");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass ein Update bei dauerhaft gesperrtem Backup atomar und unverändert abbricht.</summary>
|
||||
private static void InstallerStopsAfterBoundedUpdateMoveRetries()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var package = CreatePackage(directory, "new");
|
||||
var install = Path.Combine(directory, "install");
|
||||
Directory.CreateDirectory(install);
|
||||
File.WriteAllText(Path.Combine(install, InstallerEngine.ApplicationExeName), "old");
|
||||
File.WriteAllText(Path.Combine(install, InstallerEngine.ApplicationExeName + ".config"), "old-config");
|
||||
var data = Path.Combine(directory, "data");
|
||||
var moveCalls = 0;
|
||||
var delays = new List<int>();
|
||||
var engine = new InstallerEngine(
|
||||
package,
|
||||
install,
|
||||
data,
|
||||
false,
|
||||
path => true,
|
||||
(source, target) =>
|
||||
{
|
||||
moveCalls++;
|
||||
throw new UnauthorizedAccessException("simulated permanent update policy denial");
|
||||
},
|
||||
delays.Add);
|
||||
|
||||
var exception = Capture<InvalidOperationException>(() => engine.Install(false, null));
|
||||
|
||||
Assert(moveCalls == 8, "permanent update move failure did not stop after eight attempts");
|
||||
Assert(delays.SequenceEqual(new[] { 250, 500, 1000, 2000, 3000, 5000, 8000 }), "bounded update retry schedule changed unexpectedly");
|
||||
Assert(File.ReadAllText(Path.Combine(install, InstallerEngine.ApplicationExeName)) == "old", "failed update modified the active installation");
|
||||
Assert(!Directory.GetDirectories(directory, "install.staging.*").Any(), "staging remained after permanent update failure");
|
||||
Assert(exception.Message.Contains("Fehlercode=SETUP-ACTIVATION"), "activation error code missing after update retries");
|
||||
Assert(exception.Message.Contains("Kein Rollback erforderlich"), "pre-mutation update denial reported a rollback");
|
||||
var log = File.ReadAllText(Directory.GetFiles(Path.Combine(data, "InstallerLogs"), "setup-*.log").Single());
|
||||
Assert(log.Contains("event=directory_move_retry role=backup failed_attempt=7"), "final update retry was not diagnosed");
|
||||
Assert(!log.Contains("event=activation_fallback_started"), "update incorrectly used the new-install copy fallback");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft die Ablehnung nicht deklarierter Dateien und ausbrechender Manifestpfade.</summary>
|
||||
private static void PackageManifestRejectsUndeclaredAndTraversalFiles()
|
||||
{
|
||||
@@ -262,6 +898,56 @@ namespace BizTalkPlatformManagementTool.Tests
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft, dass optionale Desktop- und Warnungsfehler niemals eine Kernoperation abbrechen.</summary>
|
||||
private static void OptionalWindowsIntegrationFailuresAreNonFatal()
|
||||
{
|
||||
InTemp(directory =>
|
||||
{
|
||||
var log = SetupOperationLog.Create(directory, "optional-integration-test");
|
||||
var warnings = new List<string>();
|
||||
var failed = InstallerEngine.TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_create",
|
||||
"Desktop-Verknuepfung erstellen",
|
||||
Path.Combine(directory, "Public Desktop", "Tool.lnk"),
|
||||
() => { throw new UnauthorizedAccessException("simulated public desktop ACL denial"); },
|
||||
log,
|
||||
warnings.Add);
|
||||
Assert(!failed, "optional ACL failure was reported as success");
|
||||
Assert(warnings.Count == 1 && warnings[0].Contains("Kernoperation wird fortgesetzt"), "operator continuation warning missing");
|
||||
|
||||
var warningFailureEscaped = false;
|
||||
try
|
||||
{
|
||||
InstallerEngine.TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_validate",
|
||||
"Desktop-Verknuepfung validieren",
|
||||
Path.Combine(directory, "Public Desktop", "Tool.lnk"),
|
||||
() => { throw new InvalidOperationException("simulated state mismatch"); },
|
||||
log,
|
||||
message => { throw new InvalidOperationException("simulated warning sink failure"); });
|
||||
}
|
||||
catch
|
||||
{
|
||||
warningFailureEscaped = true;
|
||||
}
|
||||
Assert(!warningFailureEscaped, "optional warning sink failure escaped the isolation boundary");
|
||||
|
||||
var succeeded = InstallerEngine.TryOptionalWindowsIntegrationStep(
|
||||
"desktop_shortcut_remove",
|
||||
"Desktop-Verknuepfung entfernen",
|
||||
Path.Combine(directory, "Public Desktop", "Tool.lnk"),
|
||||
() => { },
|
||||
log,
|
||||
warnings.Add);
|
||||
Assert(succeeded, "successful optional operation was reported as failure");
|
||||
|
||||
var content = File.ReadAllText(log.FilePath);
|
||||
Assert(content.Contains("event=optional_windows_integration_warning role=desktop_shortcut_create"), "optional ACL failure missing from diagnostics");
|
||||
Assert(content.Contains("event=optional_windows_integration_report_failed role=desktop_shortcut_validate"), "warning sink failure missing from diagnostics");
|
||||
Assert(content.Contains("event=optional_windows_integration_completed role=desktop_shortcut_remove"), "optional success missing from diagnostics");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Prüft den Diagnose-Log-Fallback bei einem nicht verwendbaren ProgramData-Pfad.</summary>
|
||||
private static void InstallerDiagnosticLogFallsBackToTemp()
|
||||
{
|
||||
@@ -284,6 +970,122 @@ namespace BizTalkPlatformManagementTool.Tests
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Erstellt einen minimalen ausführbaren Testplan.</summary>
|
||||
/// <param name="names">Die Namen der Testschritte in Ausführungsreihenfolge.</param>
|
||||
/// <returns>Ein Restore-Testplan.</returns>
|
||||
private static OperationPlan TestPlan(params string[] names)
|
||||
{
|
||||
var plan = new OperationPlan
|
||||
{
|
||||
Mode = OperationMode.Restore.ToString(),
|
||||
CreatedAt = DateTimeOffset.Now.ToString("o"),
|
||||
Server = Environment.MachineName
|
||||
};
|
||||
foreach (var name in names)
|
||||
{
|
||||
plan.Steps.Add(new OperationStep
|
||||
{
|
||||
Kind = "ReceiveLocation",
|
||||
Application = "APP",
|
||||
Name = name,
|
||||
Action = "Restore " + name,
|
||||
WmiClass = "MSBTS_ReceiveLocation",
|
||||
KeyProperty = "Name",
|
||||
KeyValue = name,
|
||||
MethodName = "Enable",
|
||||
Execute = true
|
||||
});
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
|
||||
/// <summary>Erstellt konsistente Optionen für portable Executor-Tests.</summary>
|
||||
/// <param name="dryRun">True für einen simulierenden Lauf.</param>
|
||||
/// <returns>Testoptionen.</returns>
|
||||
private static OperationOptions TestOptions(bool dryRun)
|
||||
{
|
||||
return new OperationOptions
|
||||
{
|
||||
Server = Environment.MachineName,
|
||||
OutputDirectory = Path.GetTempPath(),
|
||||
StateFile = "before.json",
|
||||
DryRun = dryRun,
|
||||
WaitTimeoutSeconds = 30,
|
||||
PollIntervalSeconds = 1
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Simuliert bereits erreichte Zustände, Mutationen und isolierte Laufzeitfehler.</summary>
|
||||
private sealed class FakeOperationStepRuntime : IOperationStepRuntime
|
||||
{
|
||||
/// <summary>Initialisiert die Aufruf- und Mutationslisten.</summary>
|
||||
public FakeOperationStepRuntime()
|
||||
{
|
||||
Calls = new List<string>();
|
||||
MutatedNames = new List<string>();
|
||||
AlreadySatisfiedNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the step name that throws the simulated Scheduler error.</summary>
|
||||
public string FailingName { get; set; }
|
||||
|
||||
/// <summary>Gets every runtime call in order.</summary>
|
||||
public List<string> Calls { get; private set; }
|
||||
|
||||
/// <summary>Gets only steps that required a simulated mutation.</summary>
|
||||
public List<string> MutatedNames { get; private set; }
|
||||
|
||||
/// <summary>Gets the names reported as already satisfied.</summary>
|
||||
public HashSet<string> AlreadySatisfiedNames { get; private set; }
|
||||
|
||||
/// <summary>Simuliert einen zustandsbewussten Laufzeitschritt.</summary>
|
||||
/// <param name="step">Der Testschritt.</param>
|
||||
/// <param name="options">Die ungenutzten Testoptionen.</param>
|
||||
/// <returns>Das simulierte Ergebnis.</returns>
|
||||
public RuntimeStepOutcome Execute(OperationStep step, OperationOptions options)
|
||||
{
|
||||
Calls.Add(step.Name);
|
||||
if (string.Equals(step.Name, FailingName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Could not validate TransportTypeData.",
|
||||
new FileNotFoundException("Could not load file or assembly Microsoft.BizTalk.Scheduler, Version=3.13.0.0."));
|
||||
}
|
||||
if (AlreadySatisfiedNames.Contains(step.Name))
|
||||
{
|
||||
return RuntimeStepOutcome.AlreadySatisfied;
|
||||
}
|
||||
MutatedNames.Add(step.Name);
|
||||
return RuntimeStepOutcome.Succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Wirft verschiedene Exception-Typen und liefert danach wieder ein erfolgreiches Ergebnis.</summary>
|
||||
private sealed class MultipleFailureOperationStepRuntime : IOperationStepRuntime
|
||||
{
|
||||
/// <summary>Initialisiert die vollständige Aufrufliste.</summary>
|
||||
public MultipleFailureOperationStepRuntime()
|
||||
{
|
||||
Calls = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>Gets all attempted step names.</summary>
|
||||
public List<string> Calls { get; private set; }
|
||||
|
||||
/// <summary>Wirft je nach Testschritt eine andere unerwartete Ausnahme.</summary>
|
||||
/// <param name="step">Der auszuführende Testschritt.</param>
|
||||
/// <param name="options">Die ungenutzten Testoptionen.</param>
|
||||
/// <returns>Erfolg für den abschließenden Fortsetzungsschritt.</returns>
|
||||
public RuntimeStepOutcome Execute(OperationStep step, OperationOptions options)
|
||||
{
|
||||
Calls.Add(step.Name);
|
||||
if (step.Name == "INVALID") throw new InvalidOperationException("unexpected state error");
|
||||
if (step.Name == "IO") throw new IOException("unexpected provider I/O error");
|
||||
if (step.Name == "TIMEOUT") throw new TimeoutException("unexpected provider timeout");
|
||||
return RuntimeStepOutcome.Succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Erstellt einen minimalen Snapshot für Vergleiche und Planprüfungen.</summary>
|
||||
/// <param name="application">Der Name der Testanwendung.</param>
|
||||
/// <param name="port">Der Name des Test-Send-Ports.</param>
|
||||
|
||||
Reference in New Issue
Block a user