diff --git a/EgtBEAMWALL.Core/Constants/ConstMachIni.vb b/EgtBEAMWALL.Core/Constants/ConstMachIni.vb index 75989e72..13739a75 100644 --- a/EgtBEAMWALL.Core/Constants/ConstMachIni.vb +++ b/EgtBEAMWALL.Core/Constants/ConstMachIni.vb @@ -7,6 +7,8 @@ Public Const K_NCTYPE As String = "NCType" Public Const K_CONNECTIONSTRING As String = "ConnectionString" + Public Const K_SUPERVISOR As String = "Supervisor" + Public Const K_SAVECNCPATH As String = "SaveCncPath" Public Const S_CHANNELS As String = "Channels" diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb index 0ab55fd2..31c871c5 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb @@ -611,27 +611,32 @@ Public Class ProdManagerVM ''' Friend Sub GoToSupervisor() If IsNothing(m_CurrProd) Then Return - ' apro supervisore - Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" - ' recupero processo del supervisore - Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) - If localProc.Length > 0 Then - For Each p As Process In localProc - ' porto in primo piano il Supervisor - BringWindowToFront(p.MainWindowHandle) - Exit For - Next + ' verifico se modalita' supervisore attiva + If GetPrivateProfileInt(S_GENERAL, K_SUPERVISOR, 1, CurrentMachine.sMachIniFile) = 1 Then + ' apro supervisore + Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" + ' recupero processo del supervisore + Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) + If localProc.Length > 0 Then + For Each p As Process In localProc + ' porto in primo piano il Supervisor + BringWindowToFront(p.MainWindowHandle) + Exit For + Next + Else + Dim sSupervisorPath As String = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) & "\" & sSupervisorName & ".exe" + Try + Process.Start(sSupervisorPath, "1 " & CurrProd.nProdId) + Catch ex As Exception + EgtOutLog("Error: impossible starting supervisor from path " & sSupervisorPath) + End Try + End If + ' mando richiesta di apertura progetto in supervisore + 'Dim x = DbControllers.m_StatusMapController.GetProd + DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, Map.refProdManagerVM.CurrProd.nProdId, Map.refProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") Else - Dim sSupervisorPath As String = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) & "\" & sSupervisorName & ".exe" - Try - Process.Start(sSupervisorPath, "1 " & CurrProd.nProdId) - Catch ex As Exception - EgtOutLog("Error: impossible starting supervisor from path " & sSupervisorPath) - End Try + MessageBox.Show("Supervisor is not available for this machine!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) End If - ' mando richiesta di apertura progetto in supervisore - 'Dim x = DbControllers.m_StatusMapController.GetProd - DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, Map.refProdManagerVM.CurrProd.nProdId, Map.refProdManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") End Sub #End Region ' GoToSupervisor diff --git a/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelVM.vb index 23c95cdf..eb7f1e4d 100644 --- a/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelVM.vb @@ -1,4 +1,5 @@ Imports System.Collections.ObjectModel +Imports System.IO Imports EgtBEAMWALL.Core Imports EgtUILib Imports EgtWPFLib5 @@ -240,8 +241,25 @@ Public Class TopPanelVM Map.refCALCPanelVM.Verify() Return End If - If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then - MessageBox.Show(ErrorMsg) + ' verifico se modalita' supervisore attiva + If GetPrivateProfileInt(S_GENERAL, K_SUPERVISOR, 1, CurrentMachine.sMachIniFile) = 1 Then + If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MessageBox.Show(ErrorMsg) + End If + Else + ' altrimenti lo copio se path disponibile + If Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.OK Or Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.INFO Then + Dim sSaveCncPath As String = "" + GetPrivateProfileString(S_GENERAL, K_SAVECNCPATH, "", sSaveCncPath, CurrentMachine.sMachIniFile) + If String.IsNullOrWhiteSpace(sSaveCncPath) OrElse Not Directory.Exists(sSaveCncPath) Then Return + Try + Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & Map.refMachGroupPanelVM.SelectedMachGroup.Name.ToString() & ".cnc" + Dim sNewPath As String = sSaveCncPath & "\" & Map.refProdManagerVM.CurrProd.sProdId & "-" & Map.refMachGroupPanelVM.SelectedMachGroup.Name.ToString() & ".cnc" + File.Copy(sMachGroupFilePath, sNewPath, True) + Catch ex As Exception + + End Try + End If End If End Sub @@ -307,9 +325,26 @@ Public Class TopPanelVM If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then Dim MachgroupErrorList As New List(Of MachGroupVM) For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList - Dim ErrorMsg As String = "" - If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then - MachgroupErrorList.Add(Machgroup) + ' verifico se modalita' supervisore attiva + If GetPrivateProfileInt(S_GENERAL, K_SUPERVISOR, 1, CurrentMachine.sMachIniFile) = 1 Then + Dim ErrorMsg As String = "" + If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MachgroupErrorList.Add(Machgroup) + End If + Else + ' altrimenti lo copio se path disponibile + If Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.OK Or Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.INFO Then + Dim sSaveCncPath As String = "" + GetPrivateProfileString(S_GENERAL, K_SAVECNCPATH, "", sSaveCncPath, CurrentMachine.sMachIniFile) + If String.IsNullOrWhiteSpace(sSaveCncPath) OrElse Not Directory.Exists(sSaveCncPath) Then Return + Try + Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & Map.refMachGroupPanelVM.SelectedMachGroup.Name.ToString() & ".cnc" + Dim sNewPath As String = sSaveCncPath & "\" & Map.refProdManagerVM.CurrProd.sProdId & "-" & Map.refMachGroupPanelVM.SelectedMachGroup.Name.ToString() & ".cnc" + File.Copy(sMachGroupFilePath, sNewPath, True) + Catch ex As Exception + + End Try + End If End If Next If MachgroupErrorList.Count > 0 Then