-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ created TransferERPBOMViaItemTab script with duplicated logic from similar File Tab script
- Loading branch information
1 parent
e21d931
commit c46cd0f
Showing
1 changed file
with
94 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,94 @@ | ||
#region Debugging | ||
if((Get-Process -Id $PID).ProcessName -in @('powershell','powershell_ise')){ | ||
Import-Module powerEvents | ||
|
||
Open-VaultConnection -Server $env:Computername -Vault Vault -User Administrator -Password "" | ||
$selectedItem = Get-VaultItem -Number 'co-00000' | ||
|
||
function Add-VaultTab($name, $EntityType, $Action){ | ||
Add-Type -AssemblyName PresentationFramework | ||
|
||
$xamlReader = New-Object System.Xml.XmlNodeReader ([xml]@' | ||
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Window.Resources> | ||
<Style TargetType="{x:Type Window}"> | ||
<Setter Property="FontFamily" Value="Segoe UI" /> | ||
<Setter Property="Background" Value="#FFFDFDFD" /> | ||
</Style> | ||
</Window.Resources> | ||
</Window> | ||
'@) | ||
$debugERPTab_window = [Windows.Markup.XamlReader]::Load($xamlReader) | ||
$debugERPTab_window.Title = "powerGate Debug Window for Tab: $name" | ||
$debugERPTab_window.AddChild($action.InvokeReturnAsIs($selectedItem)) | ||
$debugERPTab_window.ShowDialog() | ||
} | ||
|
||
|
||
Import-Module powergate | ||
Connect-ERP -Service 'http://localhost:8080/PGS/ErpServices' | ||
} | ||
#endregion | ||
|
||
$global:addinPath = $PSScriptRoot | ||
Import-Module "C:\ProgramData\coolOrange\powerGate\Modules\Initialize.psm1" -Global | ||
Initialize-CoolOrange | ||
|
||
Remove-CoolOrangeLogging | ||
$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\VDS_Vault-powerGate.log" | ||
Set-LogFilePath -Path $logPath | ||
|
||
|
||
Add-VaultTab -Name 'ERP BOM' -EntityType 'Item' -Action { | ||
param($selectedItem) | ||
|
||
$erpBomTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\ERPBOM_Tab.xaml"))) | ||
|
||
$statusMessage_label = $erpItemTab_control.FindName('lblStatusMessage') | ||
$erpServices = Get-ERPServices -Available | ||
if (-not $erpServices) { | ||
$statusMessage_label.Content = "One or more services are not available!" | ||
$statusMessage_label.Foreground = "Red" | ||
$erpBomTab_control.IsEnabled = $false | ||
return $erpBomTab_control | ||
} | ||
|
||
$unitOfMeasure_comboboxColumn = $tab_control.FindName('UnitOfMeasureComboboxColumn') | ||
$unitOfMeasure_comboboxColumn.ItemsSource = @(GetUnitOfMeasuresList) | ||
|
||
$bomStates_combobox = $erpItemTab_control.FindName('BomStates') | ||
$bomStates_combobox.ItemsSource = @(GetBOMStateList) | ||
|
||
$erpItemTab_GoToBOMButton = $erpItemTab_control.FindName('GoToBomButton') | ||
|
||
$number = GetEntityNumber -entity $selectedFile | ||
$erpBomHeader = Get-ERPObject -EntitySet "BomHeaders" -Keys @{Number = $number } -Expand "BomRows" | ||
if(-not $?) { | ||
$statusMessage_label.Content = $Error[0] | ||
$statusMessage_label.Foreground = "Red" | ||
$erpBomTab_control.IsEnabled = $false | ||
return $erpBomTab_control | ||
} | ||
|
||
if(-not $erpBomHeader) { | ||
$erpItemTab_GoToBOMButton.IsEnabled = $false | ||
} | ||
else { | ||
$erpItemTab_GoToBOMButton.Add_Click({ | ||
param($Sender) | ||
|
||
GoToErpBom -ErpEntity $erpBomHeader | ||
}) | ||
} | ||
$erpBomTab_control.DataContext = $erpBomHeader | ||
|
||
$erpItemTab_ShowBomWindowButton = $erpBomTab_control.FindName('ShowBomWindowButton') | ||
$erpItemTab_ShowBomWindowButton.Add_Click({ | ||
param($Sender, $EventArgs) | ||
|
||
ShowBomWindow -VaultEntity $selectedItem | ||
}) | ||
|
||
return $erpBomTab_control | ||
} |