Refactor application data path handling and update instance names in Start-SPMigrationGUI.ps1

This commit is contained in:
Torsten Brendgen
2026-04-17 23:15:38 +02:00
parent 8de6047719
commit f0077b2e17
2 changed files with 4 additions and 24 deletions

View File

@@ -1,9 +0,0 @@
{
"WindowHeight": 940,
"FontSize": 9,
"LastOutputPath": "C:\\Users\\CodexSandboxOffline\\.codex\\.sandbox\\cwd\\c85dc9d4b6e088fe\\SPMigrationOutput",
"LastMappingTablePath": "",
"LastSourceUrl": "",
"WindowWidth": 1400,
"LastTargetUrl": ""
}

View File

@@ -10,19 +10,13 @@ param(
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$script:ApplicationDataRoot = Join-Path -Path (Split-Path -Parent $PSCommandPath) -ChildPath ".gui-state"
class SettingsManager {
[string]$SettingsPath
[hashtable]$Settings = @{}
SettingsManager([string]$AppName) {
$appRoot = if ([string]::IsNullOrWhiteSpace($script:ApplicationDataRoot)) {
[Environment]::GetFolderPath("ApplicationData")
}
else {
$script:ApplicationDataRoot
}
$appRoot = [Environment]::GetFolderPath("ApplicationData")
$appFolder = Join-Path -Path $appRoot -ChildPath $AppName
if (-not (Test-Path -LiteralPath $appFolder)) {
@@ -151,12 +145,7 @@ class LogManager {
[bool]$EnableConsole = $false
LogManager([string]$AppName) {
$appRoot = if ([string]::IsNullOrWhiteSpace($script:ApplicationDataRoot)) {
[Environment]::GetFolderPath("ApplicationData")
}
else {
$script:ApplicationDataRoot
}
$appRoot = [Environment]::GetFolderPath("ApplicationData")
$logFolder = Join-Path -Path $appRoot -ChildPath (Join-Path -Path $AppName -ChildPath "Logs")
if (-not (Test-Path -LiteralPath $logFolder)) {
@@ -800,8 +789,8 @@ class DialogBuilder : BaseComponent {
[System.Windows.Forms.Application]::EnableVisualStyles()
[System.Windows.Forms.Application]::SetCompatibleTextRenderingDefault($false)
$script:SettingsManager = [SettingsManager]::new("Start-SPMigration")
$script:LogManager = [LogManager]::new("Start-SPMigration")
$script:SettingsManager = [SettingsManager]::new("SPMigrationTool")
$script:LogManager = [LogManager]::new("SPMigrationTool")
[BaseComponent]::InitializeShared($script:SettingsManager, $script:LogManager)
$script:MigrationScriptPath = Join-Path -Path (Split-Path -Parent $PSCommandPath) -ChildPath "Start-SPMigration.ps1"