Skip to content

Commit

Permalink
PG-1250
Browse files Browse the repository at this point in the history
 + fixed PJP jobs which require the EntitySet 'Documents' (entity type 'Document') that is not available in the previously connected ERP default plugin of PGS (-> PGS-227)
 -> moved the PJP connection module logic directly into the job script which allows simplifying the $vaultToPgsMapping values that are directly available in job executions.
  • Loading branch information
coolOrange-Public committed Nov 14, 2022
1 parent b25c2a7 commit 358b68c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
13 changes: 12 additions & 1 deletion Files/powerJobs/Jobs/Erp.Service.CreatePDFFromItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@ $hidePDF = $false

# To enable faster opening of released Inventor drawings without downloading and opening their model files set Yes, otherwise No
$openReleasedDrawingsFast = $true

# Define for test and production Vaults, on which host the powergateServer runs
$vaultToPgsMapping = @{ 'Vault' = $vaultConnection.Server; 'TestVault' = 'localhost'}
#endregion

$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\ErpService.Create.Pdf-Job.log"
Set-LogFilePath -Path $logPath

Write-Host "Starting job 'Create PDF as attachment' for item '$($item._Name)' ..."

ConnectToPowerGateServer
if ($vaultConnection.Vault -notin $vaultToPgsMapping.Keys) {
throw "The currently connected Vault '$($vaultConnection.Vault)' is not mapped to any powerGateServer URL. Please extend the configuration and re-submit the job!"
}

Write-Host "Connecting to powerGateServer on: $($vaultToPgsMapping[$vaultConnection.Vault])"
$connected = Connect-ERP -Service "http://$($vaultToPgsMapping[$vaultConnection.Vault]):8080/PGS/ErpServices"
if(-not $connected) {
throw("Connection to ERP could not be established! Reason: $($Error[0]) (Source: $($Error[0].Exception.Source))")
}

$attachedDrawings = Get-VaultItemAssociations -Number $item._Number
foreach ($drawing in $attachedDrawings) {
Expand Down
13 changes: 12 additions & 1 deletion Files/powerJobs/Jobs/ErpService.Create.PDF.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ $hidePDF = $false

# To enable faster opening of released Inventor drawings without downloading and opening their model files set Yes, otherwise No
$openReleasedDrawingsFast = $true

# Define for test and production Vaults, on which host the powergateServer runs
$vaultToPgsMapping = @{ 'Vault' = $vaultConnection.Server; 'TestVault' = 'localhost'}
#endregion

$localPDFfileLocation = "$workingDirectory\$($file._Name).pdf"
Expand All @@ -31,7 +34,15 @@ if ( @("idw", "dwg") -notcontains $file._Extension ) {
return
}

ConnectToPowerGateServer
if ($vaultConnection.Vault -notin $vaultToPgsMapping.Keys) {
throw "The currently connected Vault '$($vaultConnection.Vault)' is not mapped to any powerGateServer URL. Please extend the configuration and re-submit the job!"
}

Write-Host "Connecting to powerGateServer on: $($vaultToPgsMapping[$vaultConnection.Vault])"
$connected = Connect-ERP -Service "http://$($vaultToPgsMapping[$vaultConnection.Vault]):8080/PGS/ErpServices"
if(-not $connected) {
throw("Connection to ERP could not be established! Reason: $($Error[0]) (Source: $($Error[0].Exception.Source))")
}

$ipjVaultPath = $vault.DocumentService.GetInventorProjectFileLocation()
$localWorkspaceFolder = ($vaultConnection.WorkingFoldersManager.GetWorkingFolder("$/")).FullPath
Expand Down
25 changes: 0 additions & 25 deletions Files/powerJobs/Modules/ConnectToPowerGateServer.psm1

This file was deleted.

0 comments on commit 358b68c

Please sign in to comment.