Skip to content

Commit

Permalink
PG-1260
Browse files Browse the repository at this point in the history
  -> moved datatrigger functionalities from BOM Tab xaml file into Add-VaultTab Action which now fully controls the ui behavior similar as ERP Item Tabs

   -> moved TO BE REMOVED content into a Debugging Section that gets executed only in powershell in ISE processes
  • Loading branch information
coolOrange-Public committed Nov 30, 2022
1 parent 674f655 commit e21d931
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 89 deletions.
18 changes: 6 additions & 12 deletions Files/powerEvents/Events/ERPBOM_Tab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@
<ColumnDefinition MinWidth="100" Width="*"/>
</Grid.ColumnDefinitions>
<Label Content="Number" Grid.Row="0" Grid.Column="0" />
<TextBox Text="{Binding ErpEntity.Number}" Grid.Row="0" Grid.Column="1" IsReadOnly="True" />
<TextBox Text="{Binding Number}" Grid.Row="0" Grid.Column="1" IsReadOnly="True" />
<Label Content="Description" Grid.Column="0" Grid.Row="1" />
<TextBox Text="{Binding ErpEntity.Description}" Grid.Column="1" Grid.Row="1" IsReadOnly="True"/>
<TextBox Text="{Binding Description}" Grid.Column="1" Grid.Row="1" IsReadOnly="True"/>
<Label Content="State" Grid.Row="0" Grid.Column="3" />
<ComboBox Grid.Row="0" Grid.Column="4" SelectedValue="{Binding ErpEntity.State}" DisplayMemberPath="Value" SelectedValuePath="Key" IsEnabled="False" ItemsSource="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=DataContext.Lists[BomStatesList]}" />
<ComboBox x:Name="BomStates" Grid.Row="0" Grid.Column="4" SelectedValue="{Binding State}" DisplayMemberPath="Value" SelectedValuePath="Key" IsEnabled="False" />
<Label Content="Last Modified Date" Grid.Column="3" Grid.Row="1" />
<TextBox Text="{Binding ErpEntity.ModifiedDate}" Grid.Column="4" Grid.Row="1" IsReadOnly="True" />
<TextBox Text="{Binding ModifiedDate}" Grid.Column="4" Grid.Row="1" IsReadOnly="True" />
</Grid>
</GroupBox>

<DataGrid Grid.Row="1" ItemsSource="{Binding ErpEntity.BomRows}" AutoGenerateColumns="False" ScrollViewer.CanContentScroll="False" HorizontalGridLinesBrush="WhiteSmoke" VerticalGridLinesBrush="WhiteSmoke" Background="White" Margin="6" Focusable="False" SelectionMode="Single" IsReadOnly="True">
<DataGrid Grid.Row="1" ItemsSource="{Binding BomRows}" AutoGenerateColumns="False" ScrollViewer.CanContentScroll="False" HorizontalGridLinesBrush="WhiteSmoke" VerticalGridLinesBrush="WhiteSmoke" Background="White" Margin="6" Focusable="False" SelectionMode="Single" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Position}" Header="Position" Width="60" IsReadOnly="True" SortDirection="Ascending">
<DataGridTextColumn.HeaderStyle>
Expand Down Expand Up @@ -172,13 +172,7 @@
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridComboBoxColumn SelectedValueBinding="{Binding Path=UnitOfMeasure}" Header="Base UOM" Width="80" IsReadOnly="True" DisplayMemberPath="Value" SelectedValuePath="Key">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=DataContext.Lists[UomList]}"/>
</Style>
</DataGridComboBoxColumn.ElementStyle>
</DataGridComboBoxColumn>
<DataGridComboBoxColumn x:Name="UnitOfMeasureComboboxColumn" SelectedValueBinding="{Binding Path=UnitOfMeasure}" Header="Base UOM" Width="80" IsReadOnly="True" DisplayMemberPath="Value" SelectedValuePath="Key" />
</DataGrid.Columns>
</DataGrid>
</Grid>
Expand Down
135 changes: 60 additions & 75 deletions Files/powerEvents/Events/TransferERPBomViaFileTab.ps1
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
#region TO BE REMOVED
if((Get-Process -Id $PID).ProcessName -eq 'powershell' -and $host.Name.StartsWith('powerEvents')){
return
}
if([System.Threading.Thread]::CurrentThread.GetApartmentState() -eq 'MTA' -and (Get-Process -Id $PID).ProcessName -ne 'powershell'){
Start-Process powershell.exe -ArgumentList "-STA",$MyInvocation.InvocationName -WindowStyle hidden
return
}

Import-Module powerEvents
Open-VaultConnection -Server $env:Computername -Vault Vault -User Administrator -Password ""
$selectedFile = Get-VaultFile -Properties @{Name = 'FlcRootItem.iam'}

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>
#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 ""
$selectedFile = Get-VaultFile -File '$/Designs/FlcRootItem.iam'

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($selectedFile))
$debugERPTab_window.ShowDialog()
}
$debugERPTab_window = [Windows.Markup.XamlReader]::Load($xamlReader)
$debugERPTab_window.Title = "powerGate Debug Window for Tab: $name"
$debugERPTab_window.AddChild($action.InvokeReturnAsIs($selectedFile))
$debugERPTab_window.ShowDialog()
}


Import-Module powergate
Connect-ERP -Service 'http://thomas-rossi:8080/PGS/ErpServices'
Import-Module powergate
Connect-ERP -Service 'http://localhost:8080/PGS/ErpServices'
}
#endregion

$global:addinPath = $PSScriptRoot
Expand All @@ -48,62 +43,52 @@ Set-LogFilePath -Path $logPath
Add-VaultTab -Name 'ERP BOM' -EntityType 'File' -Action {
param($selectedFile)

$Script:erpBomTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\ERPBOM_Tab.xaml")))
$erpBomTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\ERPBOM_Tab.xaml")))

#region Initialize viewmodel
$bomTabContext = New-Object -Type PsObject -Property @{
ErpEntity = $null
VaultEntity = $selectedFile

Lists = @{
BomStatesList = @(GetBOMStateList)
UomList = @(GetUnitOfMeasuresList)
}
$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
}
#endregion Initialize viewmodel


#region Initialize UI Components
$erpItemTab_ShowBomWindowButton = $Script:erpBomTab_control.FindName("ShowBomWindowButton")
$erpItemTab_ShowBomWindowButton.Add_Click({
param($Sender, $EventArgs)

ShowBomWindow -VaultEntity $Sender.DataContext.VaultEntity
})

$erpItemTab_GoToBomButton = $Script:erpBomTab_control.FindName("GoToBomButton")
$erpItemTab_GoToBomButton.Add_Click({
param($Sender)
$unitOfMeasure_comboboxColumn = $tab_control.FindName('UnitOfMeasureComboboxColumn')
$unitOfMeasure_comboboxColumn.ItemsSource = @(GetUnitOfMeasuresList)

GoToErpBom -ErpEntity $Sender.DataContext.ErpEntity
})
#endregion Initialize UI Components
$bomStates_combobox = $erpItemTab_control.FindName('BomStates')
$bomStates_combobox.ItemsSource = @(GetBOMStateList)

$erpServices = Get-ERPServices -Available
if (-not $erpServices) {
$Script:erpBomTab_control.FindName("lblStatusMessage").Content = "One or more services are not available!"
$Script:erpBomTab_control.FindName("lblStatusMessage").Foreground = "Red"
$Script:erpBomTab_control.IsEnabled = $false
return $Script:erpBomTab_control
}
$erpItemTab_GoToBOMButton = $erpItemTab_control.FindName('GoToBomButton')

$number = GetEntityNumber -entity $selectedFile
$erpBomHeader = Get-ERPObject -EntitySet "BomHeaders" -Keys @{Number = $number } -Expand "BomRows"
if(-not $?) {
$Script:erpBomTab_control.FindName("lblStatusMessage").Content = $Error[0]
$Script:erpBomTab_control.FindName("lblStatusMessage").Foreground = "Red"
$Script:erpBomTab_control.IsEnabled = $false
return $Script:erpBomTab_control
$statusMessage_label.Content = $Error[0]
$statusMessage_label.Foreground = "Red"
$erpBomTab_control.IsEnabled = $false
return $erpBomTab_control
}

if(-not $erpBomHeader) {
$Script:erpBomTab_control.FindName("GoToBomButton").IsEnabled = $false
$erpItemTab_GoToBOMButton.IsEnabled = $false
}
else {
$bomTabContext.ErpEntity = $erpBomHeader
$Script:erpBomTab_control.FindName("GoToBomButton").IsEnabled = $true
$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 $selectedFile
})

$Script:erpBomTab_control.DataContext = $bomTabContext
return $Script:erpBomTab_control
return $erpBomTab_control
}
4 changes: 2 additions & 2 deletions Files/powerEvents/Events/TransferERPItemViaFileTab.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#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 ""
$selectedFile = Get-VaultFile -File '$/Designs/MultipageInv.idw'

Expand Down Expand Up @@ -45,7 +45,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {

$erpItemTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\ERPItem_Tab.xaml")))

$statusMessage_label = $erpItemTab_control.FindName("lblStatusMessage")
$statusMessage_label = $erpItemTab_control.FindName('lblStatusMessage')
$erpServices = Get-ERPServices -Available
if (-not $erpServices) {
$statusMessage_label.Content = "One or more services are not available!"
Expand Down

0 comments on commit e21d931

Please sign in to comment.