-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit of emarsys functionality for debugging purposes in #10
- Loading branch information
Showing
29 changed files
with
3,472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
################################################ | ||
# | ||
# INPUT | ||
# | ||
################################################ | ||
|
||
Param( | ||
[hashtable] $params | ||
) | ||
|
||
|
||
################################################ | ||
# | ||
# NOTES | ||
# | ||
################################################ | ||
|
||
|
||
<# | ||
This script is used for when you want everything to be executed with PowerShell Core | ||
This one gets called and uses the original scripts through pwsh | ||
#> | ||
|
||
################################################ | ||
# | ||
# SETTINGS | ||
# | ||
################################################ | ||
|
||
# temporary files to handle objects | ||
$inputFile = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$( $Env:Temp )/$( [System.Guid]::NewGuid().toString() )_input.tmp") | ||
$outputFile = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$( $Env:Temp )/$( [System.Guid]::NewGuid().toString() )_output.tmp") | ||
|
||
$verb = "Broadcast" | ||
|
||
|
||
################################################ | ||
# | ||
# PROGRAM | ||
# | ||
################################################ | ||
|
||
|
||
#----------------------------------------------- | ||
# FIND OUT CURRENT DIRECTORY | ||
#----------------------------------------------- | ||
|
||
$settingsFile = Get-Item -Path $params.settingsFile | ||
|
||
|
||
#----------------------------------------------- | ||
# CHECK IF PWSH IS INSTALLED | ||
#----------------------------------------------- | ||
|
||
$isPwshInstalled = $false | ||
try { | ||
if ( (pwsh { 1+1 }) -eq 2 ) { | ||
$isPwshInstalled = $true | ||
} | ||
} catch { | ||
#"not there" | ||
} | ||
|
||
|
||
#----------------------------------------------- | ||
# START PWSH PROCESS | ||
#----------------------------------------------- | ||
|
||
If ( $isPwshInstalled -eq $true ) { | ||
|
||
# Save the hashtable to a json file | ||
$htInput | ConvertTo-Json -Compress -Depth 99 | Set-Content -Path $inputFile -Encoding UTF8 | ||
|
||
# Call pwsh with the test file and some parameters and wait for finish | ||
# TODO [ ] Add error handling and maybe timeout? | ||
$coreWrapper = Join-Path -Path $settingsFile.DirectoryName -ChildPath "core_wrapper.ps1" | ||
pwsh -File $coreWrapper -Verb $verb -InputFile $inputFile -OutputFile $outputFile | ||
|
||
# Read return values | ||
$j = Get-Content -Path $outputFile -Raw -Encoding UTF8 | ConvertFrom-Json | ||
|
||
# Convert the PSCustomObject back to a hashtable | ||
$htOutput = [Hashtable]@{} | ||
$j.psobject.properties | ForEach-Object { | ||
$htOutput[$_.Name] = $_.Value | ||
} | ||
|
||
# Remove the temporary json files | ||
Remove-Item -Path $InputFile | ||
Remove-Item -Path $OutputFile | ||
|
||
} else { | ||
|
||
"Sorry, please install pwsh" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
################################################ | ||
# | ||
# INPUT | ||
# | ||
################################################ | ||
|
||
Param( | ||
[hashtable] $params | ||
) | ||
|
||
|
||
################################################ | ||
# | ||
# NOTES | ||
# | ||
################################################ | ||
|
||
|
||
<# | ||
This script is used for when you want everything to be executed with PowerShell Core | ||
This one gets called and uses the original scripts through pwsh | ||
#> | ||
|
||
################################################ | ||
# | ||
# SETTINGS | ||
# | ||
################################################ | ||
|
||
# temporary files to handle objects | ||
$inputFile = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$( $Env:Temp )/$( [System.Guid]::NewGuid().toString() )_input.tmp") | ||
$outputFile = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$( $Env:Temp )/$( [System.Guid]::NewGuid().toString() )_output.tmp") | ||
|
||
$verb = "GetMessageLists" | ||
|
||
|
||
################################################ | ||
# | ||
# PROGRAM | ||
# | ||
################################################ | ||
|
||
|
||
#----------------------------------------------- | ||
# FIND OUT CURRENT DIRECTORY | ||
#----------------------------------------------- | ||
|
||
$settingsFile = Get-Item -Path $params.settingsFile | ||
|
||
|
||
#----------------------------------------------- | ||
# CHECK IF PWSH IS INSTALLED | ||
#----------------------------------------------- | ||
|
||
$isPwshInstalled = $false | ||
try { | ||
if ( (pwsh { 1+1 }) -eq 2 ) { | ||
$isPwshInstalled = $true | ||
} | ||
} catch { | ||
#"not there" | ||
} | ||
|
||
|
||
#----------------------------------------------- | ||
# START PWSH PROCESS | ||
#----------------------------------------------- | ||
|
||
If ( $isPwshInstalled -eq $true ) { | ||
|
||
# Save the hashtable to a json file | ||
$htInput | ConvertTo-Json -Compress -Depth 99 | Set-Content -Path $inputFile -Encoding UTF8 | ||
|
||
# Call pwsh with the test file and some parameters and wait for finish | ||
# TODO [ ] Add error handling and maybe timeout? | ||
$coreWrapper = Join-Path -Path $settingsFile.DirectoryName -ChildPath "core_wrapper.ps1" | ||
pwsh -File $coreWrapper -Verb $verb -InputFile $inputFile -OutputFile $outputFile | ||
|
||
# Read return values | ||
$j = Get-Content -Path $outputFile -Raw -Encoding UTF8 | ConvertFrom-Json | ||
|
||
# Convert the PSCustomObject back to a hashtable | ||
$htOutput = [Hashtable]@{} | ||
$j.psobject.properties | ForEach-Object { | ||
$htOutput[$_.Name] = $_.Value | ||
} | ||
|
||
# Remove the temporary json files | ||
Remove-Item -Path $InputFile | ||
Remove-Item -Path $OutputFile | ||
|
||
} else { | ||
|
||
"Sorry, please install pwsh" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
################################################ | ||
# | ||
# INPUT | ||
# | ||
################################################ | ||
|
||
Param( | ||
[hashtable] $params | ||
) | ||
|
||
|
||
################################################ | ||
# | ||
# NOTES | ||
# | ||
################################################ | ||
|
||
|
||
<# | ||
This script is used for when you want everything to be executed with PowerShell Core | ||
This one gets called and uses the original scripts through pwsh | ||
#> | ||
|
||
################################################ | ||
# | ||
# SETTINGS | ||
# | ||
################################################ | ||
|
||
# temporary files to handle objects | ||
$inputFile = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$( $Env:Temp )/$( [System.Guid]::NewGuid().toString() )_input.tmp") | ||
$outputFile = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$( $Env:Temp )/$( [System.Guid]::NewGuid().toString() )_output.tmp") | ||
|
||
$verb = "GetMessages" | ||
|
||
|
||
################################################ | ||
# | ||
# PROGRAM | ||
# | ||
################################################ | ||
|
||
|
||
#----------------------------------------------- | ||
# FIND OUT CURRENT DIRECTORY | ||
#----------------------------------------------- | ||
|
||
$settingsFile = Get-Item -Path $params.settingsFile | ||
|
||
|
||
#----------------------------------------------- | ||
# CHECK IF PWSH IS INSTALLED | ||
#----------------------------------------------- | ||
|
||
$isPwshInstalled = $false | ||
try { | ||
if ( (pwsh { 1+1 }) -eq 2 ) { | ||
$isPwshInstalled = $true | ||
} | ||
} catch { | ||
#"not there" | ||
} | ||
|
||
|
||
#----------------------------------------------- | ||
# START PWSH PROCESS | ||
#----------------------------------------------- | ||
|
||
If ( $isPwshInstalled -eq $true ) { | ||
|
||
# Save the hashtable to a json file | ||
$htInput | ConvertTo-Json -Compress -Depth 99 | Set-Content -Path $inputFile -Encoding UTF8 | ||
|
||
# Call pwsh with the test file and some parameters and wait for finish | ||
# TODO [ ] Add error handling and maybe timeout? | ||
$coreWrapper = Join-Path -Path $settingsFile.DirectoryName -ChildPath "core_wrapper.ps1" | ||
pwsh -File $coreWrapper -Verb $verb -InputFile $inputFile -OutputFile $outputFile | ||
|
||
# Read return values | ||
$j = Get-Content -Path $outputFile -Raw -Encoding UTF8 | ConvertFrom-Json | ||
|
||
# Convert the PSCustomObject back to a hashtable | ||
$htOutput = [Hashtable]@{} | ||
$j.psobject.properties | ForEach-Object { | ||
$htOutput[$_.Name] = $_.Value | ||
} | ||
|
||
# Remove the temporary json files | ||
Remove-Item -Path $InputFile | ||
Remove-Item -Path $OutputFile | ||
|
||
} else { | ||
|
||
"Sorry, please install pwsh" | ||
|
||
} |
Oops, something went wrong.