Refactor application data path handling and update instance names in Start-SPMigrationGUI.ps1
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"WindowHeight": 940,
|
|
||||||
"FontSize": 9,
|
|
||||||
"LastOutputPath": "C:\\Users\\CodexSandboxOffline\\.codex\\.sandbox\\cwd\\c85dc9d4b6e088fe\\SPMigrationOutput",
|
|
||||||
"LastMappingTablePath": "",
|
|
||||||
"LastSourceUrl": "",
|
|
||||||
"WindowWidth": 1400,
|
|
||||||
"LastTargetUrl": ""
|
|
||||||
}
|
|
||||||
@@ -10,19 +10,13 @@ param(
|
|||||||
|
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
$script:ApplicationDataRoot = Join-Path -Path (Split-Path -Parent $PSCommandPath) -ChildPath ".gui-state"
|
|
||||||
|
|
||||||
class SettingsManager {
|
class SettingsManager {
|
||||||
[string]$SettingsPath
|
[string]$SettingsPath
|
||||||
[hashtable]$Settings = @{}
|
[hashtable]$Settings = @{}
|
||||||
|
|
||||||
SettingsManager([string]$AppName) {
|
SettingsManager([string]$AppName) {
|
||||||
$appRoot = if ([string]::IsNullOrWhiteSpace($script:ApplicationDataRoot)) {
|
$appRoot = [Environment]::GetFolderPath("ApplicationData")
|
||||||
[Environment]::GetFolderPath("ApplicationData")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$script:ApplicationDataRoot
|
|
||||||
}
|
|
||||||
$appFolder = Join-Path -Path $appRoot -ChildPath $AppName
|
$appFolder = Join-Path -Path $appRoot -ChildPath $AppName
|
||||||
|
|
||||||
if (-not (Test-Path -LiteralPath $appFolder)) {
|
if (-not (Test-Path -LiteralPath $appFolder)) {
|
||||||
@@ -151,12 +145,7 @@ class LogManager {
|
|||||||
[bool]$EnableConsole = $false
|
[bool]$EnableConsole = $false
|
||||||
|
|
||||||
LogManager([string]$AppName) {
|
LogManager([string]$AppName) {
|
||||||
$appRoot = if ([string]::IsNullOrWhiteSpace($script:ApplicationDataRoot)) {
|
$appRoot = [Environment]::GetFolderPath("ApplicationData")
|
||||||
[Environment]::GetFolderPath("ApplicationData")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$script:ApplicationDataRoot
|
|
||||||
}
|
|
||||||
$logFolder = Join-Path -Path $appRoot -ChildPath (Join-Path -Path $AppName -ChildPath "Logs")
|
$logFolder = Join-Path -Path $appRoot -ChildPath (Join-Path -Path $AppName -ChildPath "Logs")
|
||||||
|
|
||||||
if (-not (Test-Path -LiteralPath $logFolder)) {
|
if (-not (Test-Path -LiteralPath $logFolder)) {
|
||||||
@@ -800,8 +789,8 @@ class DialogBuilder : BaseComponent {
|
|||||||
[System.Windows.Forms.Application]::EnableVisualStyles()
|
[System.Windows.Forms.Application]::EnableVisualStyles()
|
||||||
[System.Windows.Forms.Application]::SetCompatibleTextRenderingDefault($false)
|
[System.Windows.Forms.Application]::SetCompatibleTextRenderingDefault($false)
|
||||||
|
|
||||||
$script:SettingsManager = [SettingsManager]::new("Start-SPMigration")
|
$script:SettingsManager = [SettingsManager]::new("SPMigrationTool")
|
||||||
$script:LogManager = [LogManager]::new("Start-SPMigration")
|
$script:LogManager = [LogManager]::new("SPMigrationTool")
|
||||||
[BaseComponent]::InitializeShared($script:SettingsManager, $script:LogManager)
|
[BaseComponent]::InitializeShared($script:SettingsManager, $script:LogManager)
|
||||||
|
|
||||||
$script:MigrationScriptPath = Join-Path -Path (Split-Path -Parent $PSCommandPath) -ChildPath "Start-SPMigration.ps1"
|
$script:MigrationScriptPath = Join-Path -Path (Split-Path -Parent $PSCommandPath) -ChildPath "Start-SPMigration.ps1"
|
||||||
|
|||||||
Reference in New Issue
Block a user