Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…emplate into Rework_sampleJobs
  • Loading branch information
StefanNairz committed Nov 8, 2022
2 parents 021e2e8 + b25c2a7 commit b12c3af
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 143 deletions.
6 changes: 3 additions & 3 deletions Files/DataStandard/CAD.Custom/Configuration/Inventor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
IsReadOnly="{Binding Prop[_EditMode].Value}"
Visibility="{Binding NumSchmFieldsEmpty, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=DSNumSchmsCtrl}" />
<Label x:Name="lblComments" Content="{Binding UIString[LBL7], FallbackValue=Comments}" Grid.Row="4" BorderThickness="1" Height="Auto"/>
<TextBox x:Name="txtComments" Grid.Column="1" Grid.Row="4" TextWrapping="Wrap" Text="{Binding Prop[Comments].Value}" BorderThickness="0,1,1,1"
<TextBox x:Name="txtComments" Grid.Column="1" Grid.Row="4" TextWrapping="Wrap" Text="{Binding Prop[Comments].Value}" BorderThickness="0,1,1,1"
VerticalContentAlignment="Top" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Height="50" MaxWidth="180"/>
<Border
BorderBrush="White"
Expand Down Expand Up @@ -305,13 +305,13 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label x:Name="lblStatusMessage" FontSize="14" Foreground="Red" HorizontalAlignment="Left" FontWeight="Medium" Grid.ColumnSpan="3" BorderThickness="0"/>
<Label x:Name="lblStatusMessage" FontSize="14" Foreground="Red" HorizontalAlignment="Left" FontWeight="Medium" Grid.ColumnSpan="3" BorderThickness="0"/>
</Grid>
<Rectangle Grid.Row="1">
<Rectangle.Fill>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ActiveBorderColorKey}}"/>
</Rectangle.Fill>
</Rectangle>
</Rectangle>
<Grid Grid.Row="2" Background="#FFFDFDFD">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
Expand Down
46 changes: 24 additions & 22 deletions Files/DataStandard/CAD.Custom/addins/powerGateMain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@
$matrix = $Application.TransientGeometry.CreateMatrix()
$occur = $Document.ComponentDefinition.Occurrences
$occur.AddVirtual($number, $matrix)
ShowMessageBox -Message "Virtual Component '$number' successfully inserted." -Title "powerGate ERP - Virtual Component" -Icon "Information" | Out-Null
$null = ShowMessageBox -Message "Virtual Component '$number' successfully inserted." -Title "powerGate ERP - Virtual Component" -Icon "Information"
}
catch {
ShowMessageBox -Message "'$number' already exists. Please choose another ERP item." -Title "powerGate ERP - Virtual Component" -Icon "Warning" | Out-Null
$null = ShowMessageBox -Message "'$number' already exists. Please choose another ERP item." -Title "powerGate ERP - Virtual Component" -Icon "Warning"
}
}
if ($prop["_FileExt"].Value -eq ".IPT") {
$prop["Raw_Number"].Value = $number
$prop["Raw_Quantity"].Value = 1
ShowMessageBox -Message "Raw Material '$number' successfully inserted." -Title "powerGate ERP - Raw Material" -Icon "Information" | Out-Null
}
$null = ShowMessageBox -Message "Raw Material '$number' successfully inserted." -Title "powerGate ERP - Raw Material" -Icon "Information"
}
}
}

function OpenErpMaterialWindow {
[xml]$windowXaml = Get-Content "C:\ProgramData\coolOrange\powerGate\UI\ContainerWindow.xaml"
$reader = (New-Object System.Xml.XmlNodeReader $windowXaml)
$global:window = [Windows.Markup.XamlReader]::Load($reader)
$global:window = [Windows.Markup.XamlReader]::Load($reader)

[xml]$userControlXaml = Get-Content $PSScriptRoot.Replace('\CAD.Custom\addins', '\Vault.Custom\Configuration\File\ERP Item.xaml')
$reader = (New-Object System.Xml.XmlNodeReader $userControlXaml)
$global:userControl = [Windows.Markup.XamlReader]::Load($reader)

$window.FindName("ContentControl").Children.Add($userControl)
$window.DataContext = $dsWindow.DataContext

$userControl.DataContext = $dsWindow.DataContext

InitErpMaterialTab -number $prop["Part Number"].Value

if ($window.ShowDialog() -eq "OK") {
Expand Down Expand Up @@ -85,7 +85,7 @@ function IsEntityUnlocked {
$fullFileName = $prop["_FilePath"].Value + "\" + $prop["_FileName"].Value
if (Test-Path -Path $fullFileName) {
$status = Get-ChildItem $fullFileName
return (-not $status.IsReadOnly)
return (-not $status.IsReadOnly)
}
else {
return $true
Expand Down Expand Up @@ -122,15 +122,15 @@ function CreateOrUpdateErpMaterial {
if ($? -eq $false) {
return
}
ShowMessageBox -Message "$($createErpMaterialResult.Number) successfully created" -Title "powerGate ERP - Create Material" -Icon "Information" | Out-Null
$null = ShowMessageBox -Message "$($createErpMaterialResult.Number) successfully created" -Title "powerGate ERP - Create Material" -Icon "Information"
SetEntityProperties -erpMaterial $createErpMaterialResult
}
else {
$updateErpMaterialResult = Update-ERPObject -EntitySet "Materials" -Key $materialTabContext.Entity._Keys -Properties $materialTabContext.Entity._Properties
if ($? -eq $false) {
return
}
ShowMessageBox -Message "$($updateErpMaterialResult.Number) successfully updated" -Title "powerGate ERP - Update Material" -Icon "Information" | Out-Null
$null = ShowMessageBox -Message "$($updateErpMaterialResult.Number) successfully updated" -Title "powerGate ERP - Update Material" -Icon "Information"
}

RefreshView
Expand Down Expand Up @@ -166,7 +166,7 @@ function LinkErpMaterial {
}

function RefreshView {
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
[System.Windows.Forms.SendKeys]::SendWait("{F5}")
InitErpMaterialTab -number $prop["Part Number"].Value
}

Expand All @@ -183,17 +183,19 @@ function SetEntityProperties($erpMaterial) {
function InitializeWindow
{
Import-Module "C:\ProgramData\coolOrange\powerGate\Modules\Initialize.psm1" -Global
Initialize-CoolOrange
Disconnect-ERP
$Error.Clear()
ConnectToErpServerWithMessageBox
if ($Error) {
$dsWindow.FindName("powerGateGrid").IsEnabled =$false
Initialize-CoolOrange

$erpServices = Get-ERPServices -Available
if (-not $erpServices -or $erpServices.Count -le 0) {
$dswindow.FindName("lblStatusMessage").Content = "One or more services are not available!"
$dswindow.FindName("lblStatusMessage").Foreground = "Red"
$dsWindow.FindName("powerGateGrid").IsEnabled = $false
}

$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\VDS_Inventor-powerGate.log"
Set-LogFilePath -Path $logPath
#begin rules applying commonly
$dsWindow.Title = SetWindowTitle
$dsWindow.Title = SetWindowTitle
InitializeCategory
InitializeNumSchm
InitializeBreadCrumb
Expand Down Expand Up @@ -238,7 +240,7 @@ function InitializeCategory()
function InitializeNumSchm()
{
#Adopted from a DocumentService call, which always pulls FILE class numbering schemes
$global:numSchems = @($vault.NumberingService.GetNumberingSchemes('FILE', 'Activated'))
$global:numSchems = @($vault.NumberingService.GetNumberingSchemes('FILE', 'Activated'))
if ($Prop["_CreateMode"].Value)
{
if (-not $Prop["_SaveCopyAsMode"].Value)
Expand All @@ -251,7 +253,7 @@ function InitializeNumSchm()
{
$Prop["_NumSchm"].Value = $numSchm.Name
}
}
}
})
}
else
Expand Down Expand Up @@ -312,7 +314,7 @@ function SetWindowTitle
else
{
$windowTitle = "$($UIString["LBL25"]) - $($Prop["_FileName"].Value)"
}
}
}
}
return $windowTitle
Expand All @@ -336,7 +338,7 @@ function GetNumSchms
$noneNumSchm = New-Object 'Autodesk.Connectivity.WebServices.NumSchm'
$noneNumSchm.Name = $UIString["LBL77"]
return $numSchems += $noneNumSchm
}
}
return $numSchems
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
</Grid.ColumnDefinitions>

<Label Content="Item Category Code" Grid.Column="0" Grid.Row="0" />
<ComboBox Name="Category" SelectedValue="{Binding Entity.Category}" DisplayMemberPath="Value" SelectedValuePath="Key" Grid.Column="1" Grid.Row="0" ItemsSource="{Binding DataContext.PsList[GetCategoryList], ElementName=MainWindow}" />
<ComboBox Name="Category" SelectedValue="{Binding Entity.Category}" DisplayMemberPath="Value" SelectedValuePath="Key" Grid.Column="1" Grid.Row="0" />

<Label Content="Search Description" Grid.Column="0" Grid.Row="1" />
<TextBox Text="{Binding Entity.SearchDescription}" Grid.Column="1" Grid.Row="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
</Grid.ColumnDefinitions>

<Label Content="Item Category Code" Grid.Column="0" Grid.Row="0" />
<ComboBox Name="Category" SelectedValue="{Binding Entity.Category}" DisplayMemberPath="Value" SelectedValuePath="Key" Grid.Column="1" Grid.Row="0" ItemsSource="{Binding DataContext.PsList[GetCategoryList], ElementName=MainWindow}" />
<ComboBox Name="Category" SelectedValue="{Binding Entity.Category}" DisplayMemberPath="Value" SelectedValuePath="Key" Grid.Column="1" Grid.Row="0" />

<Label Content="Search Description" Grid.Column="0" Grid.Row="1" />
<TextBox Text="{Binding Entity.SearchDescription}" Grid.Column="1" Grid.Row="1" />
Expand Down
4 changes: 1 addition & 3 deletions Files/DataStandard/Vault.Custom/addinVault/Default.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function OnTabContextChanged {
$global:ErrorActionPreference = "Stop"
$xamlFile = [System.IO.Path]::GetFileName($VaultContext.UserControl.XamlFile)
OnTabContextChanged_powerGate -xamlFile $xamlFile
OnTabContextChanged_powerGate -xamlFile $xamlFile
if ($VaultContext.SelectedObject.TypeId.SelectionContext -eq "FileMaster" -and $xamlFile -eq "CAD BOM.xaml") {
$fileMasterId = $vaultContext.SelectedObject.Id
$file = $vault.DocumentService.GetLatestFileByMasterId($fileMasterId)
Expand All @@ -23,9 +23,7 @@ function OnLogOn {

Import-Module "C:\ProgramData\coolOrange\powerGate\Modules\Initialize.psm1" -Global
Initialize-CoolOrange
Disconnect-ERP
Open-VaultConnection
ConnectToErpServerWithMessageBox
$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\VDS_Vault-powerGate.log"
Set-LogFilePath -Path $logPath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
Start-Process -FilePath C:\Windows\explorer.exe -ArgumentList "/select, ""$cfgPath"""
}
catch {
(ShowMessageBox -Message $_.Exception.Message -Button "OK" -Icon "Error") | Out-Null
($null = ShowMessageBox -Message $_.Exception.Message -Button "OK" -Icon "Error")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
$cfgPath = "c:\temp\powerGateCfg\powerGateConfiguration.xml"
$testPath = Test-Path $cfgPath
if ($testPath -eq $false) {
ShowMessageBox -Message "No config file found in '$cfgPath' `n Please download/edit the config file first and then save it back to the Vault server!" -Button "OK" -Icon "Warning" | Out-Null
$null = ShowMessageBox -Message "No config file found in '$cfgPath' `n Please download/edit the config file first and then save it back to the Vault server!" -Button "OK" -Icon "Warning"
return
}
[byte[]]$cfg = [System.IO.File]::ReadAllBytes($cfgPath)
Set-PowerGateConfigFromVault -Content $cfg
ShowMessageBox -Message "Config file saved to Vault server" -Button "OK" -Icon "Information" | Out-Null
$null = ShowMessageBox -Message "Config file saved to Vault server" -Button "OK" -Icon "Information"


Remove-Item $cfgPath -Force
}
catch {
(ShowMessageBox -Message $_.Exception.Message -Button "OK" -Icon "Error") | Out-Null
($null = ShowMessageBox -Message $_.Exception.Message -Button "OK" -Icon "Error")
}

0 comments on commit b12c3af

Please sign in to comment.