From 05cfbba5ca427e89eea3ecd8a75ea5858e479beb Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 16 Feb 2017 11:32:58 +0000 Subject: [PATCH] EgtCAM5 : - sistemazioni varie per feedback via mail. --- Constants/ConstIni.vb | 2 +- IniFile.vb | 3 +- MainWindow/MainWindowViewModel.vb | 4 +- TopCommandBar/TopCommandBarViewModel.vb | 90 ++++++++++++++++--------- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 4c7a077..6915f86 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -91,7 +91,7 @@ Module ConstIni Public Const S_DOORS As String = "Doors" Public Const K_DDFENABLE As String = "DdfEnable" - Public Const K_DIRECTORYPATH As String = "DirectoryPath" + Public Const K_BASEDIR As String = "BaseDir" Public Const K_DDFEXEC As String = "DdfExec" Public Const K_DDFFUNCTION As String = "DdfFun" Public Const K_DDFDIR As String = "DdfDir" diff --git a/IniFile.vb b/IniFile.vb index 1d5b65a..a11a2fe 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -49,6 +49,7 @@ Public Module IniFile Friend m_sTempDir As String Friend m_sMachinesRoot As String Friend m_sTablesRoot As String + Friend m_sLogFile As String ' path della cartella DOORS Friend m_sDoorsDirPath As String @@ -188,7 +189,7 @@ Public Module IniFile Friend Function IsActiveDoors() As Boolean Dim bIsActive As Boolean = (IniFile.m_nKeyOptions And KEY_OPT.DOORS) <> 0 And (GetPrivateProfileInt(S_DOORS, K_DDFENABLE, 0) <> 0) If bIsActive Then - GetPrivateProfileString(S_DOORS, K_DIRECTORYPATH, "", m_sDoorsDirPath) + GetPrivateProfileString(S_DOORS, K_BASEDIR, "", m_sDoorsDirPath) End If Return bIsActive End Function diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb index 2f18829..32cb2cc 100644 --- a/MainWindow/MainWindowViewModel.vb +++ b/MainWindow/MainWindowViewModel.vb @@ -314,14 +314,14 @@ Namespace EgtCAM5 EgtGetKeyOptions(3279, 18, 1, IniFile.m_nKeyOptions) ' Inizializzazione generale di EgtInterface m_nDebug = GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0) - Dim sLogFile As String = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) + IniFile.m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) Dim sLogMsg As String = "User " & Environment.UserName & "\" & Environment.MachineName & " (" & m_nInstance.ToString() & ")" & vbLf & My.Application.Info.Description.ToString() & " ver. " & My.Application.Info.Version.Major.ToString() & "." & My.Application.Info.Version.Minor.ToString() & (ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() & My.Application.Info.Version.Revision.ToString() - EgtInit(m_nDebug, sLogFile, sLogMsg) + EgtInit(m_nDebug, IniFile.m_sLogFile, sLogMsg) ' Leggo direttorio dei messaggi (se manca uso direttorio di configurazione) Dim sMsgDir As String = String.Empty If GetPrivateProfileString(S_GENERAL, K_MESSAGESDIR, "", sMsgDir) = 0 Then diff --git a/TopCommandBar/TopCommandBarViewModel.vb b/TopCommandBar/TopCommandBarViewModel.vb index adbb35f..21eccb1 100644 --- a/TopCommandBar/TopCommandBarViewModel.vb +++ b/TopCommandBar/TopCommandBarViewModel.vb @@ -85,6 +85,11 @@ Namespace EgtCAM5 Return EgtMsg(MSG_TOPCOMMANDBAR + 9) End Get End Property + Public ReadOnly Property SendFeedbackToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 13) + End Get + End Property #End Region ' ToolTip @@ -374,7 +379,7 @@ Namespace EgtCAM5 #Region "SendFeedbackCommand" ''' - ''' Returns a command that do Export. + ''' Returns a command that do SendFeedback. ''' Public ReadOnly Property SendFeedbackCommand As ICommand Get @@ -386,28 +391,30 @@ Namespace EgtCAM5 End Property ''' - ''' Execute the Export. This method is invoked by the ExportCommand. + ''' Execute the SendFeedback. This method is invoked by the SendFeedbackCommand. ''' Public Sub SendFeedback(ByVal param As Object) - ' recupero indirizzo supporto + ' Recupero indirizzo a cui spedire la mail Dim sSupportAddress As String = String.Empty - GetPrivateProfileString(S_GENERAL, K_SUPPORT, "", sSupportAddress) + GetPrivateProfileString(S_GENERAL, K_SUPPORT, "support@egaltech.com", sSupportAddress) ' se vuoto do messaggio di errore ed esco If String.IsNullOrWhiteSpace(sSupportAddress) Then MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 10), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return End If - ' recupero numero chiave + ' Recupero numero chiave Dim sKey As String = String.Empty EgtGetKeyInfo(sKey) - ' recupero file del progetto corrente + ' Recupero file del progetto corrente Dim sCurrProject As String = String.Empty EgtGetCurrFilePath(sCurrProject) + ' se nome file vuoto, chiedo se si vuole salvare If String.IsNullOrWhiteSpace(sCurrProject) Then If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then Application.Msn.NotifyColleagues(Application.SAVEPROJECT) End If EgtGetCurrFilePath(sCurrProject) + ' se modificato, chiedo se si vuole salvare Else If EgtGetModified() Then If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then @@ -415,43 +422,66 @@ Namespace EgtCAM5 End If End If End If - Dim DoorOtherFiles As New List(Of String) - ' se door attivo - If IniFile.IsActiveDoors Then - ' recupero file con lo stesso nome del progetto - If Not String.IsNullOrWhiteSpace(sCurrProject) Then - Dim sCurrProjectDir As String = Path.GetDirectoryName(sCurrProject) - If Not String.IsNullOrWhiteSpace(sCurrProjectDir) Then - Dim TempFiles() As String = Directory.GetFiles(sCurrProjectDir) - For FileIndex = 0 To TempFiles.Count - 1 - If Path.GetFileNameWithoutExtension(TempFiles(FileIndex)).Contains(Path.GetFileNameWithoutExtension(sCurrProject)) AndAlso TempFiles(FileIndex) <> sCurrProject Then - DoorOtherFiles.Add(TempFiles(FileIndex)) - End If - Next - End If + ' Verifico se il progetto corrente è una porta + Dim nPartId As Integer = EgtGetFirstPart() + If nPartId = GDB_ID.NULL Then + nPartId = EgtGetFirstPartInRawPart(EgtGetFirstRawPart()) + End If + Dim sPartName As String = String.Empty + EgtGetName(nPartId, sPartName) + Dim bPrjIsDoor As Boolean = (String.Compare(sPartName, "DOOR") = 0) + ' Recupero macchine dei gruppi di lavoro del progetto + Dim Machines As New List(Of String) + Dim nMchGrpId As Integer = EgtGetFirstMachGroup() + While nMchGrpId <> GDB_ID.NULL + Dim sMachineName As String = String.Empty + EgtGetMachGroupMachineName(nMchGrpId, sMachineName) + If Not String.IsNullOrWhiteSpace(sMachineName) Then + Machines.Add(sMachineName) + End If + nMchGrpId = EgtGetNextMachGroup(nMchGrpId) + End While + ' Recupero altri file con lo stesso nome del progetto + Dim OtherFiles As New List(Of String) + If Not String.IsNullOrWhiteSpace(sCurrProject) Then + Dim sCurrProjectDir As String = Path.GetDirectoryName(sCurrProject) + If Not String.IsNullOrWhiteSpace(sCurrProjectDir) Then + Dim TempFiles() As String = Directory.GetFiles(sCurrProjectDir) + For FileIndex = 0 To TempFiles.Count - 1 + If Path.GetFileNameWithoutExtension(TempFiles(FileIndex)).Contains(Path.GetFileNameWithoutExtension(sCurrProject)) AndAlso TempFiles(FileIndex) <> sCurrProject Then + OtherFiles.Add(TempFiles(FileIndex)) + End If + Next End If End If - ' creo zip file da allegare + ' Creo zip file da allegare Dim sZipToCreate As String = IniFile.m_sTempDir & "\Feedback.zip" If File.Exists(sZipToCreate) Then File.Delete(sZipToCreate) End If Try Using zip As New Ionic.Zip.ZipFile(sZipToCreate, Console.Out) - ' aggiungo file macchina - zip.AddItem(IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName, IniFile.m_sMachineName) + ' aggiungo file macchine + For Each sMachineName As String In Machines + Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & sMachineName + If Directory.Exists(sMachineDir) Then + zip.AddItem(sMachineDir, sMachineName) + End If + Next ' aggiungo progetto corrente If Not String.IsNullOrWhiteSpace(sCurrProject) Then zip.AddItem(sCurrProject, "") End If - ' se door attivo - If IniFile.IsActiveDoors Then + ' aggiungo file log + zip.AddItem(IniFile.m_sLogFile, "") + ' aggiungo file ausiliari + For Each sOther As String In OtherFiles + zip.AddItem(sOther, "") + Next + ' se door attivo, progetto corrente è una porta e definito direttorio base di Doors + If IniFile.IsActiveDoors And bPrjIsDoor And Directory.Exists(IniFile.m_sDoorsDirPath) Then + ' aggiungo Doors completo zip.AddItem(IniFile.m_sDoorsDirPath, "Doors") - If DoorOtherFiles.Count > 0 Then - For FileIndex = 0 To DoorOtherFiles.Count - 1 - zip.AddItem(DoorOtherFiles(FileIndex), "") - Next - End If End If ' salvo lo zip zip.Save()