Private/APUtil.ps1
$APAdapterParameters = @{ "Server" = "APPlusServer"; "Port" = "APPlusPort"; "WebServer" = "APPlusWebServer"; "WebPort" = "APPlusWebPort"; "WebSite" = "APPlusWebSite"; "WebServiceUrl" = "APPlusWebServiceUrl"; "WebServiceLogon" = "APPlusWebServiceLogOn"; "WebServicePassword" = "APPlusWebServicePassword"; "AuthorizationWebServiceUrl" = "APPlusAuthorizationWebServiceUrl"; "BulkFilePath" = "BulkFilePath"; "CalendarDelta" = "CalendarDelta"; "DefaultTransferMode" = "DefaultTransferMode"; "EntityCountToSwitchBatchMode" = "EntityCountToSwitchBatchMode"; "IdleTimeOnCapacityChange" = "IdleTimeOnCapacityChange"; "MaterialFixStartDateInTasks" = "MaterialFixStartDateInTasks"; } $APAdapterParametersType = @{ "Server" = "string"; "Port" = "int"; "WebServer" = "string"; "WebPort" = "int"; "WebSite" = "string"; "WebServiceUrl" = "string"; "WebServiceLogon" = "string"; "WebServicePassword" = "string"; "AuthorizationWebServiceUrl" = "string"; "BulkFilePath" = "string"; "CalendarDelta" = "int"; "terialFixStartDateInTasks DefaultTransferMode" = "string"; "EntityCountToSwitchBatchMode" = "int"; "IdleTimeOnCapacityChange" = "bool"; "MaterialFixStartDateInTasks" = "bool"; } function Set-APParameters( [string]$Tenant, [string]$Server, [int]$Port, [string]$Login, [string]$Password, [string]$WebServer, [int]$WebPort, [string]$WebSite, [string] $BulkPath) { if ($Server -eq "") { $Server = $Env:COMPUTERNAME } if ($Port -eq 0) { $Port = 2039 } if ($WebPort -eq 0) { $WebPort = 80 } if ($WebServer -eq "") { $WebServer = $Env:COMPUTERNAME } $webServiceUrl = 'http://' + $Server + ':' + $Port + "/ortems/MinimalPlanningDataService.jws" $entityCountSwitch = 50; $calendarDelta = 20; $transfertMode = "WebService"; $webAuthorization = "/Core/Authorization.asmx" $configuration = @{ UId = [System.Guid]::NewGuid(); Version = 0; APPlusServer = $Server; APPlusPort = $Port; APPlusWebServer = $WebServer; APPlusWebPort = $WebPort; APPLusWebSite = $WebSite; APPlusWebServiceUrl = $webServiceUrl; APPlusWebServiceLogOn = $Login; APPlusWebServicePassword = $Password; APPlusAuthorizationWebServiceUrl = $webAuthorization; BulkFilePath = $BulkPath; CalendarDelta = $calendarDelta; EntityCountToSwitchBatchMode = $entityCountSwitch; DefaultTransfertMode = $transfertMode; LastModificationDate = [System.DateTime]::UtcNow; } Write-APParameters $Tenant $configuration } function Write-APParameters($Tenant,$configuration) { $data = $configuration | ConvertTo-Json $storePath = Get-APConfigurationPath $Tenant [System.IO.File]::WriteAllText($storePath, $data) Write-Verbose "AP configuration stored in $storePath" } function Get-APConfigurationPath($Tenant) { return Get-ConfigurationPath $Tenant "AP.json" } function Set-APAdapterParameter([string] $Tenant, [string] $Name, [string] $Value) { $storePath = Get-APConfigurationPath $Tenant $parameters = Get-AdapterParameters $Tenant $storePath if ($parameters -eq $null) { $parameters = New-APAdapterParameters $Tenant $storePath } if ($parameters -eq $null) { Write-Warning "Cannot create or get AP parameters for tenant $Tenant" return } Set-AdapterParameter $Name $Value $parameters $APAdapterParameters $APAdapterParametersType "AP" Write-APParameters $Tenant $parameters Write-Verbose "Parameter set" } function New-APAdapterParameters([string] $Tenant, $StorePath) { if (!(Test-Path $StorePath)) { Set-APParameters } return Get-AdapterParameters $Tenant $StorePath } function Write-APValidParameters { Write-ValidParameters "AP" $APAdapterParameters } |