Skip to content

Commit

Permalink
fixed #179 Vault process remains open after closing the Vault Client
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickGrub committed Jul 23, 2021
1 parent 5aa9426 commit c10a851
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
15 changes: 15 additions & 0 deletions Files/DataStandard/Vault.Custom/addinVault/Default.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,19 @@
$assocFiles = @(GetAssociatedFiles $itemids $([System.IO.Path]::GetDirectoryName($VaultContext.UserControl.XamlFile)))
$dsWindow.FindName("AssoicatedFiles").ItemsSource = $assocFiles
}
}

function OnLogOn {
#Executed when User logs on Vault
#$vaultUsername can be used to get the username, which is used in Vault on login

Import-Module "C:\ProgramData\coolOrange\powerGate\Modules\Initialize.psm1" -Global
Initialize-CoolOrange

$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\VDS_Vault-powerGate.log"
Set-LogFilePath -Path $logPath
}
function OnLogOff {
#Executed when User logs off Vault
Remove-CoolOrangeLogging
}
6 changes: 1 addition & 5 deletions Files/DataStandard/Vault.Custom/addinVault/powerGateMain.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
$global:addinPath = $PSScriptRoot
Import-Module "C:\ProgramData\coolOrange\powerGate\Modules\Initialize.psm1" -Global
Initialize-CoolOrange

$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\VDS_Vault-powerGate.log"
Set-LogFilePath -Path $logPath

Initialize-CoolOrange

ConnectToErpServerWithMessageBox

Expand Down
13 changes: 10 additions & 3 deletions Files/powerGate/Modules/Logging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function Initialize-CoolOrangeLogging {
$LogPath,
$DeleteLogFilesOlderThenDays = '4d' # Format example for 30 days: "30d"
)
# PSFramework Version 1.5.172
$commonModulePath = "C:\ProgramData\coolOrange\powerGate\PSFramework\PSFramework"
Import-Module -Name $commonModulePath -Global -Verbose

$paramSetPSFLoggingProvider = @{

# For all parameters of the "Logfile" provider read here: https://psframework.org/documentation/documents/psframework/logging/providers/logfile.html
Expand Down Expand Up @@ -103,9 +107,12 @@ function Log {
}
}

# PSFramework Version 1.5.172
$commonModulePath = "C:\ProgramData\coolOrange\powerGate\PSFramework\PSFramework"
Import-Module -Name $commonModulePath -Global -Verbose
function Remove-CoolOrangeLogging {
# Fixes https://github.com/coolOrangeLabs/powerGateTemplate/issues/179
Wait-PSFMessage
Get-PSFRunspace | Stop-PSFRunspace
[PSFramework.PSFCore.PSFCoreHost]::Uninitialize()
}

$generalLogPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\default.log"
Initialize-CoolOrangeLogging -LogPath $generalLogPath

0 comments on commit c10a851

Please sign in to comment.