-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings creation and first calls are already working. This uses the most current code of channel implementation.
- Loading branch information
Showing
28 changed files
with
2,448 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 |
---|---|---|
|
@@ -30,3 +30,4 @@ EpiServerCampaign/MarketingAutomation/recipientlists.json | |
*.xml | ||
*.sqlite | ||
*.zip | ||
*.json.* |
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,10 @@ | ||
|
||
$functionsSubfolder = "functions" | ||
$libSubfolder = "lib" | ||
$settingsFilename = "settings.json" | ||
if ( $params.ProcessId ) { | ||
$processId = $params.ProcessId | ||
} else { | ||
$processId = [guid]::NewGuid() | ||
} | ||
$timestamp = [datetime]::Now |
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,36 @@ | ||
|
||
# Load all PowerShell Code | ||
"Loading..." | ||
Get-ChildItem -Path ".\$( $functionsSubfolder )" -Recurse -Include @("*.ps1") | ForEach { | ||
. $_.FullName | ||
"... $( $_.FullName )" | ||
} | ||
|
||
If ( $configMode -and -not $settings) { | ||
|
||
# Don't load yet, when in config mode and settings object not yet available | ||
|
||
} else { | ||
|
||
If ( Test-Path -Path $libSubfolder ) { | ||
|
||
# Load all exe files in subfolder | ||
$libExecutables = Get-ChildItem -Path ".\$( $libSubfolder )" -Recurse -Include @("*.exe") | ||
$libExecutables | ForEach { | ||
"... $( $_.FullName )" | ||
|
||
} | ||
|
||
# Load dll files in subfolder | ||
$libDlls = Get-ChildItem -Path ".\$( $libSubfolder )" -Recurse -Include @("*.dll") | ||
$libDlls | ForEach { | ||
"Loading $( $_.FullName )" | ||
[Reflection.Assembly]::LoadFile($_.FullName) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
#Add-Type -AssemblyName System.Security |
95 changes: 95 additions & 0 deletions
95
OptimizelyCampaign/Unsubscribes/bin/load_networksettings.ps1
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,95 @@ | ||
# Allow only newer security protocols | ||
# hints: https://www.frankysweb.de/powershell-es-konnte-kein-geschuetzter-ssltls-kanal-erstellt-werden/ | ||
if ( $settings.changeTLS ) { | ||
$AllProtocols = @( | ||
[System.Net.SecurityProtocolType]::Tls12 | ||
) | ||
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols | ||
} | ||
|
||
# Setup default credentials for proxy communication per default | ||
$proxyUrl = $null | ||
if ( $settings.proxy.proxyUrl ) { | ||
$proxyUrl = $settings.proxy.proxyUrl | ||
$useDefaultCredentials = $true | ||
|
||
if ( $settings.proxy.proxyUseDefaultCredentials ) { | ||
$proxyUseDefaultCredentials = $true | ||
[System.Net.WebRequest]::DefaultWebProxy.Credentials=[System.Net.CredentialCache]::DefaultCredentials | ||
} else { | ||
$proxyUseDefaultCredentials = $false | ||
$proxyCredentials = New-Object PSCredential $settings.proxy.credentials.username,( Get-SecureToPlaintext -String $settings.proxy.credentials.password ) | ||
} | ||
|
||
} | ||
|
||
function Check-Proxy { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory=$true)][Hashtable]$invokeParams | ||
) | ||
|
||
begin { | ||
|
||
} | ||
|
||
process { | ||
if ( $script:proxyUrl ) { | ||
$invokeParams.Add("Proxy", $script:proxyUrl) | ||
$invokeParams.Add("UseDefaultCredentials", $script:useDefaultCredentials) | ||
if ( $script:proxyUseDefaultCredentials ) { | ||
$invokeParams.Add("ProxyUseDefaultCredentials", $true) | ||
} else { | ||
$invokeParams.Add("ProxyCredential", $script:proxyCredentials) | ||
} | ||
} | ||
} | ||
|
||
end { | ||
|
||
} | ||
} | ||
|
||
<# | ||
# Add proxy settings | ||
if ( $proxyUrl ) { | ||
$paramsPost.Add("Proxy", $proxyUrl) | ||
$paramsPost.Add("UseDefaultCredentials", $useDefaultCredentials) | ||
if ( $proxyUseDefaultCredentials ) { | ||
$paramsPost.Add("ProxyUseDefaultCredentials", $true) | ||
} else { | ||
$paramsPost.Add("ProxyCredential", $proxyCredentials) | ||
} | ||
} | ||
#> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<# | ||
# The following can be added to api calls | ||
if ( $proxyUrl ) { | ||
$paramsPost.Add("UseDefaultCredentials", $useDefaultCredentials) | ||
$paramsPost.Add("Proxy", $proxyUrl) | ||
} | ||
#if ( $settings.useDefaultCredentials ) { | ||
# $paramsPost.Add("UseDefaultCredentials", $true) | ||
#} | ||
$paramsPost.Add("ProxyCredential", pscredential) | ||
if ( $settings.ProxyUseDefaultCredentials ) { | ||
$paramsPost.Add("ProxyUseDefaultCredentials", $true) | ||
} | ||
#> |
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,3 @@ | ||
# Load settings | ||
$settings = Get-Content -Path $settingsFilename -Encoding UTF8 -Raw | ConvertFrom-Json #"$( $scriptPath )\$( $settingsFilename )" | ||
|
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,6 @@ | ||
|
||
#----------------------------------------------- | ||
# OPTI SESSIONS | ||
#----------------------------------------------- | ||
|
||
Get-EpiSession |
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,34 @@ | ||
|
||
# Log | ||
$logfile = $settings.logfile | ||
|
||
# append a suffix, if in debug mode | ||
if ( $debug -and -not $configMode) { | ||
$logfile = "$( $logfile ).debug" | ||
} | ||
|
||
# Start the log | ||
Write-Log -message "----------------------------------------------------" | ||
Write-Log -message "$( $modulename )" | ||
Write-Log -message "Got a file with these arguments: $( [Environment]::GetCommandLineArgs() )" -writeToHostToo $false | ||
|
||
# Check if params object exists | ||
if (Get-Variable "params" -Scope Global -ErrorAction SilentlyContinue) { | ||
$paramsExisting = $true | ||
} else { | ||
$paramsExisting = $false | ||
} | ||
|
||
# Log the params, if existing | ||
if ( $paramsExisting ) { | ||
$params.Keys | ForEach-Object { | ||
$param = $_ | ||
Write-Log -message " $( $param ) = '$( $params[$param] )'" -writeToHostToo $false | ||
} | ||
} | ||
|
||
# Add note in log file, that the file is a converted file | ||
# TODO [ ] Add these notes to other scripts, too | ||
if ( $params.path -match "\.converted$") { | ||
Write-Log -message "Be aware, that the exports are generated in Codepage 1252 and not UTF8. Please change this in the Channel Editor." -severity ( [LogSeverity]::WARNING ) | ||
} |
15 changes: 15 additions & 0 deletions
15
OptimizelyCampaign/Unsubscribes/functions/DataTypes/Count-Dimensions.ps1
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,15 @@ | ||
Function Count-Dimensions { | ||
|
||
param( | ||
[Parameter(Mandatory=$true)]$var | ||
) | ||
|
||
$return = 0 | ||
if ( $var -is [array] ) { | ||
$add = Count-Dimensions -var $var[0] | ||
$return = $add + 1 | ||
} | ||
|
||
return $return | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
OptimizelyCampaign/Unsubscribes/functions/DataTypes/Is-Numeric.ps1
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,10 @@ | ||
|
||
|
||
Function Is-Numeric { | ||
|
||
param( | ||
[Parameter(Mandatory=$true)]$Value | ||
) | ||
|
||
return $Value -match "^[\d\.]+$" | ||
} |
38 changes: 38 additions & 0 deletions
38
OptimizelyCampaign/Unsubscribes/functions/DataTypes/check-datatypes.ps1
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,38 @@ | ||
|
||
<# | ||
Is-Numeric 10 # True | ||
Is-Numeric "10" # True | ||
Is-Numeric "10f" # False | ||
Is-Numeric "+10" # True | ||
Is-Numeric "-10" # True | ||
Is-Numeric "-10.5" # False | ||
#> | ||
function Is-Int ($value) { | ||
return $value -match "^[+-]?[\d]+$" | ||
} | ||
|
||
<# | ||
Is-Float 10 # False | ||
Is-Float "10" # False | ||
Is-Float "10." # False | ||
Is-Float "10.5" # True | ||
Is-Float "10.545" # True | ||
Is-Float "+10.5" # True | ||
Is-Float "-10.5" # True | ||
#> | ||
function Is-Float () { | ||
return $value -match "^[+-]?[\d]+[\.]+[\d]+$" | ||
} | ||
|
||
<# | ||
# This should be True | ||
Is-Link "https://www.apteco.com/blog?customerId=123" | ||
# This should be False | ||
Is-Link "ftp://www.google.com" | ||
#> | ||
function Is-Link ($value) { | ||
$regexForLinks = "(http[s]?)(:\/\/)({{(.*?)}}|[^\s,])+" | ||
$containedLinks = [Regex]::Matches($value, $regexForLinks) | Select -ExpandProperty Value | ||
return $containedLinks.count -eq 1 | ||
} |
64 changes: 64 additions & 0 deletions
64
OptimizelyCampaign/Unsubscribes/functions/Files/Check-Path.ps1
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,64 @@ | ||
Function Check-Path { | ||
|
||
param( | ||
[Parameter(Mandatory=$false)][string]$Path | ||
) | ||
|
||
$b = $false | ||
|
||
try { | ||
$b = Test-Path -Path $Path | ||
} catch [System.Exception] { | ||
#$errText = $_.Exception | ||
#$errText | Write-Output | ||
#"$( [datetime]::UtcNow.ToString("yyyyMMddHHmmss") )`tError: $( $errText )" >> $logfile | ||
#$b = $false | ||
} | ||
|
||
return $b | ||
|
||
} | ||
|
||
<# | ||
Checks if an path is free | ||
Can be used like to wait for a path to be free | ||
$outArgs = @{ | ||
Path = "C:\temp\test.lock" | ||
fireExceptionIfUsed = $true | ||
} | ||
Retry-Command -Command 'Is-PathFree' -Args $outArgs -retries 10 -MillisecondsDelay 1000 | ||
#> | ||
function Is-PathFree { | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory=$true)][string]$Path | ||
,[Parameter(Mandatory=$false)][switch]$fireExceptionIfUsed = $false | ||
) | ||
|
||
# Check validity | ||
if ( ( Test-Path -Path $Path -IsValid ) -eq $false ) { | ||
throw [System.Management.Automation.ItemNotFoundException] | ||
} | ||
|
||
# Check if path is free | ||
$pathAlreadyUsed = Test-Path -Path $Path | ||
|
||
# Fire exception if not free | ||
if ( $fireExceptionIfUsed -and $pathAlreadyUsed) { | ||
throw [System.IO.InvalidDataException] | ||
} | ||
|
||
# Return the inverted value | ||
-not $pathAlreadyUsed | ||
} | ||
|
||
#Is-PathFree -Path "C:\temp\test.lock" -fireExceptionIfUsed | ||
|
||
#exit 0 | ||
|
Oops, something went wrong.