Refactor application data path handling and update instance names in Start-SPMigrationGUI.ps1
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user