From 5a6acb77f7706180ca1aeb46dbbee15ff1590ba7 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Sat, 3 Apr 2021 12:48:47 +0200 Subject: [PATCH] Definizione oggetti ProjectM e sistemazioni --- EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj | 2 + EgtBEAMWALL.Core/ProdFileM.vb | 42 ++++ EgtBEAMWALL.Core/ProjFileM.vb | 53 +++++ EgtBEAMWALL.Core/ProjectFileM.vb | 84 ++----- .../Controllers/ProdController.cs | 4 +- .../Controllers/ProjController.cs | 4 +- .../BTLParam/BTLPartVM.vb | 2 +- .../EgtBEAMWALL.ViewerOptimizer.vbproj | 3 +- .../Integration/CalcIntegration.vb | 23 +- .../MainMenu/MainMenuVM.vb | 5 +- .../MainWindow/MainWindowVM.vb | 2 +- .../OpenProjectFileDialogV.xaml.vb | 2 +- .../OpenProjectFileDialogVM.vb | 17 +- .../ProdManager/ProdManagerVM.vb | 16 +- .../ProjManager/ProjManagerVM.vb | 38 ++-- .../ProjectManager/ProdFileVM.vb | 208 ++++++++++++++++++ .../{ProjectFileVM.vb => ProjFileVM.vb} | 94 ++------ 17 files changed, 404 insertions(+), 195 deletions(-) create mode 100644 EgtBEAMWALL.Core/ProdFileM.vb create mode 100644 EgtBEAMWALL.Core/ProjFileM.vb create mode 100644 EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFileVM.vb rename EgtBEAMWALL.ViewerOptimizer/ProjectManager/{ProjectFileVM.vb => ProjFileVM.vb} (72%) diff --git a/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj b/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj index 122d3816..6b0b5824 100644 --- a/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj +++ b/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj @@ -99,7 +99,9 @@ + + diff --git a/EgtBEAMWALL.Core/ProdFileM.vb b/EgtBEAMWALL.Core/ProdFileM.vb new file mode 100644 index 00000000..103feb73 --- /dev/null +++ b/EgtBEAMWALL.Core/ProdFileM.vb @@ -0,0 +1,42 @@ +Imports System.IO +Imports EgtUILib + +Public Class ProdFileM + Inherits ProjectFileM + + Protected m_nProjIdList As List(Of Integer) + Public ReadOnly Property nProjIdList As List(Of Integer) + Get + Return m_nProjIdList + End Get + End Property + + Protected m_sName As String + Public ReadOnly Property sName As String + Get + Return m_sName + End Get + End Property + +#Region "CONSTRUCTORS" + + Protected Sub New() + End Sub + + Public Shared Function CreateNewProdFileM() As ProdFileM + Return New ProdFileM + End Function + + Public Shared Function CreateProdFileM(nProdId As Integer, nProjIdList As List(Of Integer), + dtCreateProjDate As DateTime, sName As String) As ProdFileM + Dim NewProjectFileM As New ProdFileM + NewProjectFileM.m_nProdId = nProdId + NewProjectFileM.m_nProjIdList = nProjIdList + NewProjectFileM.m_dtCreateDate = dtCreateProjDate + NewProjectFileM.m_sName = sName + Return NewProjectFileM + End Function + +#End Region ' CONSTRUCTORS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Core/ProjFileM.vb b/EgtBEAMWALL.Core/ProjFileM.vb new file mode 100644 index 00000000..4f79cd24 --- /dev/null +++ b/EgtBEAMWALL.Core/ProjFileM.vb @@ -0,0 +1,53 @@ +Imports System.IO +Imports EgtUILib + +Public Class ProjFileM + Inherits ProjectFileM + + Protected m_dtExportDate As DateTime + Public ReadOnly Property dtExportDate As DateTime + Get + Return m_dtExportDate + End Get + End Property + + Protected m_sListName As String + Public ReadOnly Property sListName As String + Get + Return m_sListName + End Get + End Property + + Protected m_sBTLFileName As String = String.Empty + Public ReadOnly Property sBTLFileName As String + Get + Return m_sBTLFileName + End Get + End Property + +#Region "CONSTRUCTORS" + + Protected Sub New() + End Sub + + Public Shared Function CreateNewProjFileM() As ProjFileM + Return New ProjFileM + End Function + + Public Shared Function CreateProjFileM(nProjectType As ProjectType, nProjId As Integer, nProdId As Integer, + dtCreateProjDate As DateTime, dtExportDate As DateTime, sListName As String, + sBTLFileName As String) As ProjFileM + Dim NewProjectFileM As New ProjFileM + NewProjectFileM.m_nProjectType = nProjectType + NewProjectFileM.m_nProjId = nProjId + NewProjectFileM.m_nProdId = nProdId + NewProjectFileM.m_dtCreateDate = dtCreateProjDate + NewProjectFileM.m_dtExportDate = dtExportDate + NewProjectFileM.m_sListName = sListName + NewProjectFileM.m_sBTLFileName = sBTLFileName + Return NewProjectFileM + End Function + +#End Region ' CONSTRUCTORS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Core/ProjectFileM.vb b/EgtBEAMWALL.Core/ProjectFileM.vb index dc787e6f..40c8ddd1 100644 --- a/EgtBEAMWALL.Core/ProjectFileM.vb +++ b/EgtBEAMWALL.Core/ProjectFileM.vb @@ -3,15 +3,15 @@ Imports EgtUILib Public Class ProjectFileM - Protected m_nProjectType As ProjectType - Public ReadOnly Property nProjectType As ProjectType - Get - Return m_nProjectType - End Get - End Property - Public Sub SetProjectType(nProjectType As ProjectType) - m_nProjectType = nProjectType - End Sub + 'Protected m_nProjectType As ProjectType + 'Public ReadOnly Property nProjectType As ProjectType + ' Get + ' Return m_nProjectType + ' End Get + 'End Property + 'Public Sub SetProjectType(nProjectType As ProjectType) + ' m_nProjectType = nProjectType + 'End Sub Protected m_nProjId As Integer = 0 Public ReadOnly Property nProjId As Integer @@ -34,76 +34,18 @@ Public Class ProjectFileM End Get End Property - Protected m_dtExportDate As DateTime - Public ReadOnly Property dtExportDate As DateTime + Protected m_bIsNew As Boolean + Public Property bIsNew As Boolean Get - Return m_dtExportDate - End Get - End Property - - Protected m_sName As String - Public ReadOnly Property sName As String - Get - Return m_sName - End Get - End Property - - Protected m_sBTLFileName As String = String.Empty - Public ReadOnly Property sBTLFileName As String - Get - Return m_sBTLFileName - End Get - End Property - - Protected m_NewProj As Boolean - Public Property NewProj As Boolean - Get - Return m_NewProj + Return m_bIsNew End Get Set(value As Boolean) - m_NewProj = value - End Set - End Property - - Protected m_NewProd As Boolean - Public Property NewProd As Boolean - Get - Return m_NewProd - End Get - Set(value As Boolean) - m_NewProd = value + m_bIsNew = value End Set End Property #Region "CONSTRUCTORS" - Protected Sub New() - End Sub - - Public Shared Function CreateNewProjectFileM() As ProjectFileM - Return New ProjectFileM - End Function - - Public Shared Function CreateProjectFileM(nProjectType As ProjectType, nProjId As Integer, nProdId As Integer, - dtCreateProjDate As DateTime, dtExportDate As DateTime, sListName As String, - sBTLFileName As String) As ProjectFileM - Dim NewProjectFileM As New ProjectFileM - NewProjectFileM.m_nProjectType = nProjectType - If NewProjectFileM.m_nProjectType = ProjectType.PROJ Then - NewProjectFileM.m_nProjId = nProjId - NewProjectFileM.m_nProdId = nProdId - NewProjectFileM.m_dtCreateDate = dtCreateProjDate - NewProjectFileM.m_dtExportDate = dtExportDate - NewProjectFileM.m_sName = sListName - NewProjectFileM.m_sBTLFileName = sBTLFileName - ElseIf NewProjectFileM.nProjectType = ProjectType.PROD Then - NewProjectFileM.m_nProdId = nProdId - NewProjectFileM.m_dtCreateDate = dtCreateProjDate - NewProjectFileM.m_sName = sListName - End If - Return NewProjectFileM - End Function - 'Sub New(nProjectType As ProjectType, nProjId As Integer, nProdId As Integer, sBTLFileName As String) ' m_nProjectType = nProjectType ' If m_nProjectType = ProjectType.PROJ Then diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs index 30b68810..030852aa 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs @@ -272,9 +272,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers /// /// /// - public List GetLastDesc(int numRecord) + public List GetLastDesc(int numRecord) { - List result = new List(); + List result = new List(); var dbResult = GetLastDbModelDesc(numRecord); diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs index caf2ee37..d6dafdbc 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs @@ -245,9 +245,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers /// /// /// - public List GetLastDesc(int numRecord) + public List GetLastDesc(int numRecord) { - List result = new List(); + List result = new List(); var dbResult = GetLastDbModelDesc(numRecord); diff --git a/EgtBEAMWALL.ViewerOptimizer/BTLParam/BTLPartVM.vb b/EgtBEAMWALL.ViewerOptimizer/BTLParam/BTLPartVM.vb index d36ec049..a4de5b33 100644 --- a/EgtBEAMWALL.ViewerOptimizer/BTLParam/BTLPartVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/BTLParam/BTLPartVM.vb @@ -1563,7 +1563,7 @@ Public Class BTLPartVM ColorDlg.FullOpen = True ColorDlg.Color = Col.ToColor() ' Visualizzo dialogo - If ColorDlg.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return False + If ColorDlg.ShowDialog() <> Forms.DialogResult.OK Then Return False ' Recupero colore scelto NewCol.FromString(ColorDlg.Color.R & "," & ColorDlg.Color.G & "," & ColorDlg.Color.B & "," & ColorDlg.Color.A) 'NewCol.FromColor(ColorDlg.Color) Return True diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj index 18746ad5..0feb45da 100644 --- a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -152,6 +152,7 @@ + WarehouseWndV.xaml @@ -211,7 +212,7 @@ ProdManagerV.xaml - + ProjectV.xaml diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb b/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb index a5d598b8..3d37535d 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb @@ -3,6 +3,7 @@ Imports System.Threading Imports System.Globalization Imports EgtUILib Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core.ConstBeam Public Class CalcIntegration @@ -273,26 +274,26 @@ Public Class CalcIntegration While nFeatureId <> GDB_ID.NULL ' verifico che sia una feature Dim nGRP As Integer - If EgtGetInfo( nFeatureId, BTL_FTR_GRP, nGRP) Then + If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then ' assegno TASKID alla feature per calcoli - EgtSetInfo( nFeatureId, "TASKID", nFeatureId, True) + EgtSetInfo(nFeatureId, "TASKID", nFeatureId, True) End If - nFeatureId = EgtGetNext( nFeatureId) + nFeatureId = EgtGetNext(nFeatureId) End While Return True End Function - Private Shared Sub ProcessResults( Bar As Bar) + Private Shared Sub ProcessResults(Bar As Bar) Dim BtlPath As String = Bar.sBarPath - Dim ResPath As String = Path.ChangeExtension( BtlPath, ".txt") + Dim ResPath As String = Path.ChangeExtension(BtlPath, ".txt") Dim bErrors As Boolean = False Dim nLastErr As Integer = 0 Dim sLastMsg As String = "" Dim nCurrCutId As Integer = 0 Dim nTotTime As Integer = 0 - If File.Exists( ResPath) Then + If File.Exists(ResPath) Then Dim nErr As Integer = 0 Dim sMsg As String = "" @@ -306,7 +307,7 @@ Public Class CalcIntegration Dim currBTLPart As BTLPartVM Dim currPart As Core.Part - Dim lines As String() = System.IO.File.ReadAllLines( ResPath) + Dim lines As String() = System.IO.File.ReadAllLines(ResPath) For Each line As String In lines If line.StartsWith("ERR=") Then @@ -399,12 +400,12 @@ Public Class CalcIntegration End If ElseIf line.StartsWith("TIME=") Then Dim nVal As Integer? = GetVal(line, "TIME") - nTotTime = ( If( nVal IsNot Nothing, nVal.Value, 0)) - If Bar.nBarType = ProjectType.PROJ AndAlso Not IsNothing( currBTLPart) Then + nTotTime = (If(nVal IsNot Nothing, nVal.Value, 0)) + If Bar.nBarType = ProjectType.PROJ AndAlso Not IsNothing(currBTLPart) Then EgtSetInfo(currBTLPart.nPartId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_TIME, ITG_PROD_TIME), nTotTime, True) End If - ElseIf Not String.IsNullOrWhiteSpace( line) AndAlso line <> "---" Then + ElseIf Not String.IsNullOrWhiteSpace(line) AndAlso line <> "---" Then sMsg = line End If Next @@ -441,7 +442,7 @@ Public Class CalcIntegration End Sub - Private Shared Function GetVal( sText As String, sKey As String) As Integer? + Private Shared Function GetVal(sText As String, sKey As String) As Integer? Dim sParts As String() = sText.Split("="c) If String.Compare(sParts(0), sKey) <> 0 Then Return Nothing Dim nVal As Integer = Nothing diff --git a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb index 46313630..2283b3f9 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb @@ -1,5 +1,6 @@ Imports System.Collections.ObjectModel Imports System.IO +Imports EgtBEAMWALL.Core.ConstBeam Imports EgtUILib Imports EgtWPFLib5 @@ -140,7 +141,7 @@ Public Class MainMenuVM Map.refProjectVM.SetProjManager_Visibility(False) Map.refProjectVM.SetProdManager_Visibility(True) ' verifico se progetto modificato, e chiedo se salvare - If bVerifyModification Then ProjectFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ) + If bVerifyModification Then ProjFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ) Return True End Function @@ -183,7 +184,7 @@ Public Class MainMenuVM Map.refProjectVM.SetProjManager_Visibility(True) Map.refProjectVM.SetProdManager_Visibility(False) ' verifico se progetto modificato, e chiedo se salvare - If bVerifyModification Then ProjectFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd, ProjectType.PROD) + If bVerifyModification Then ProjFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd, ProjectType.PROD) EgtResetCurrMachGroup() Return True End Function diff --git a/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowVM.vb b/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowVM.vb index 4c85cd08..19051a04 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowVM.vb @@ -62,7 +62,7 @@ Public Class MainWindowVM Public Sub UpdateTitle() Select Case Map.refMainMenuVM.SelPage Case Pages.VIEW - If Map.refProjManagerVM.CurrProj.NewProj Then + If Map.refProjManagerVM.CurrProj.bIsNew Then m_Title = "New" Else m_Title = Map.refProjManagerVM.CurrProj.nProjId.ToString("0000") & " - " & Map.refProjManagerVM.CurrProj.BTLFileName diff --git a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb index dd4d231c..43695c89 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogV.xaml.vb @@ -26,7 +26,7 @@ Public Class OpenProjectFileDialogV ' mostro la finestra di dialogo Return Me.ShowDialog() End Function - Public Function EgtShowDialog(ProjectType As ProjectType, ProjectList As List(Of ProjectFileVM)) As Boolean? + Public Function EgtShowDialog(ProjectType As ProjectType, ProjectList As List(Of ProjFileVM)) As Boolean? m_OpenProjFileDialogVM.Init(ProjectType, ProjectList) ' mostro la finestra di dialogo Return Me.ShowDialog() diff --git a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb index b3cbe91e..0df70e47 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb @@ -1,4 +1,5 @@ Imports System.IO +Imports EgtBEAMWALL.Core.ConstBeam Imports EgtUILib Public Class OpenProjectFileDialogVM @@ -47,8 +48,8 @@ Public Class OpenProjectFileDialogVM End Get End Property - Private m_ProjectList As New List(Of ProjectFileVM) - Public ReadOnly Property ProjectList As List(Of ProjectFileVM) + Private m_ProjectList As New List(Of ProjFileVM) + Public ReadOnly Property ProjectList As List(Of ProjFileVM) Get Return m_ProjectList End Get @@ -58,12 +59,12 @@ Public Class OpenProjectFileDialogVM 'End Set End Property - Private m_SelProject As ProjectFileVM - Public Property SelProject As ProjectFileVM + Private m_SelProject As ProjFileVM + Public Property SelProject As ProjFileVM Get Return m_SelProject End Get - Set(value As ProjectFileVM) + Set(value As ProjFileVM) m_SelProject = value End Set End Property @@ -96,11 +97,11 @@ Public Class OpenProjectFileDialogVM ' Definizione comandi Private m_cmdProjectDoubleClick As ICommand - Public Function Init(ProjectType As ProjectType, Optional ProjectList As List(Of ProjectFileVM) = Nothing) As Boolean? + Public Function Init(ProjectType As ProjectType, Optional ProjectList As List(Of ProjFileVM) = Nothing) As Boolean? m_ProjectType = ProjectType If IsNothing(ProjectList) OrElse ProjectList.Count = 0 Then ' leggo da db - Dim DbProjectList As New List(Of Core.ProjectFileM) + Dim DbProjectList As New List(Of Core.ProjFileM) If ProjectType = ProjectType.PROJ Then DbProjectList = DbControllers.m_ProjController.GetLastDesc(50) ElseIf ProjectType = ProjectType.PROD Then @@ -121,7 +122,7 @@ Public Class OpenProjectFileDialogVM Dim nProjId As Integer = 0 Dim nProdId As Integer = 0 Dim sBTLFileName As String = "" - If ProjectFileVM.VerifyProjectFile(m_ProjectType, Path.GetFileNameWithoutExtension(File), nProjId, nProdId, sBTLFileName) Then + If ProjFileVM.VerifyProjectFile(m_ProjectType, Path.GetFileNameWithoutExtension(File), nProjId, nProdId, sBTLFileName) Then m_ProjectList.Add(New ProjectFileVM(m_ProjectType, nProjId, nProdId, sBTLFileName)) End If End If diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb index ab8cfca0..df0cc1e3 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb @@ -1,5 +1,7 @@ Imports System.Collections.ObjectModel Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstBeam Imports EgtUILib Imports EgtWPFLib5 @@ -8,12 +10,12 @@ Public Class ProdManagerVM #Region "FIELDS & PROPERTIES" - Private m_CurrProd As ProjectFileVM - Friend Property CurrProd As ProjectFileVM + Private m_CurrProd As ProdFileVM + Friend Property CurrProd As ProdFileVM Get Return m_CurrProd End Get - Set(value As ProjectFileVM) + Set(value As ProdFileVM) m_CurrProd = value End Set End Property @@ -85,9 +87,9 @@ Public Class ProdManagerVM Friend Sub OpenProject(sFilePath As String) ' verifico se progetto modificato, e chiedo se salvare - ProjectFileVM.VerifyProjectModification(CurrProd, ProjectType.PROD) + ProdFileVM.VerifyProjectModification(CurrProd, ProjectType.PROD) ' se la string è vuota - Dim TempCurrProd As ProjectFileVM + Dim TempCurrProd As ProjFileVM Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing If String.IsNullOrEmpty(sFilePath) Then ' apro dialogo di scelta file @@ -101,7 +103,7 @@ Public Class ProdManagerVM Dim nProjId As Integer = 0 Dim nProdId As Integer = 0 Dim sBTLFileName As String = "" - If ProjectFileVM.VerifyProjectFile(ProjectType.PROD, Path.GetFileNameWithoutExtension(sFilePath), nProjId, nProdId, sBTLFileName) Then + If ProjFileVM.VerifyProjectFile(ProjectType.PROD, Path.GetFileNameWithoutExtension(sFilePath), nProjId, nProdId, sBTLFileName) Then TempCurrProd = New ProjectFileVM(ProjectType.PROD, nProjId, nProdId, sBTLFileName) Else MessageBox.Show("Error in file name!!") @@ -196,7 +198,7 @@ Public Class ProdManagerVM ''' Friend Sub GoToProj() ' verifico se salvare progetto corrente - ProjectFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd, ProjectType.PROD) + ProjFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd, ProjectType.PROD) ' recupero Proj associato da Db Dim DbProjList As List(Of DataLayer.DatabaseModels.ProjModel) = DbControllers.m_ProjController.GetByProdAsc(m_CurrProd.nProdId) Dim nProjId As Integer = 0 diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb index 991ef407..c9c32953 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb @@ -10,12 +10,12 @@ Public Class ProjManagerVM #Region "FIELDS & PROPERTIES" - Private m_CurrProj As ProjectFileVM - Friend Property CurrProj As ProjectFileVM + Private m_CurrProj As ProjFileVM + Friend Property CurrProj As ProjFileVM Get Return m_CurrProj End Get - Set(value As ProjectFileVM) + Set(value As ProjFileVM) m_CurrProj = value End Set End Property @@ -126,16 +126,16 @@ Public Class ProjManagerVM Private Sub NewProdFromProj() ' verifico se progetto modificato, e chiedo se salvare - ProjectFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) + ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) ' creo nuova ottimizzazione ' leggo indice di ottimizzazione - Dim nProdsIndex As Integer = DbControllers.m_ProdController.GetNextIndex(CurrProj.nProjId) - Dim sProdsDir As String = refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdsIndex.ToString("0000") + Dim nProdId As Integer = DbControllers.m_ProdController.GetNextIndex(CurrProj.nProjId) + Dim sProdDir As String = refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") ' creo cartella nuova ottimizzazione - If Not Directory.Exists(sProdsDir) Then - Directory.CreateDirectory(sProdsDir) + If Not Directory.Exists(sProdDir) Then + Directory.CreateDirectory(sProdDir) Else - Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProdsDir) + Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProdDir) For Each file As FileInfo In di.EnumerateFiles() file.Delete() Next @@ -143,11 +143,15 @@ Public Class ProjManagerVM dir.Delete(True) Next End If + ' inizializzo nuovo progetto + Dim nProdId As Integer = 0 + Dim sProjDir As String = "" + InitNewProject(nProdId, sProjDir) ' copio file progetto Dim sProjPath As String = String.Empty Dim bOk = False - Dim sProdPath As String = sProdsDir & "\" & nProdsIndex.ToString("0000") & ".nge" + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then Try File.Copy(sProjPath, sProdPath) @@ -160,14 +164,14 @@ Public Class ProjManagerVM End If If bOk Then ' aggiorno path proj - Map.refProjManagerVM.CurrProj.SetProdId(nProdsIndex) + Map.refProjManagerVM.CurrProj.SetProdId(nProdId) ' imposto currprod Map.refProdManagerVM.CurrProd = New ProjectFileVM(ProjectType.PROD, Path.GetFileNameWithoutExtension(sProdPath)) ' setto flag nuovo progetto in prod Map.refProdManagerVM.CurrProd.NewProd = True Else ' elimino da DB - DbControllers.m_ProdController.DeleteProd(nProdsIndex) + DbControllers.m_ProdController.DeleteProd(nProdId) End If End Sub @@ -206,7 +210,7 @@ Public Class ProjManagerVM Public Function SetCurrProj(nProjId As Integer) As Boolean Dim Currproj As ProjModel = DbControllers.m_ProjController.FindByProjId(nProjId) If IsNothing(Currproj) Then Return False - m_CurrProj = New ProjectFileVM(ProjectFileM.CreateProjectFileM(ProjectType.PROJ, Currproj.ProjId, 0, Date.Now, Date.Now, "", Currproj.BTLFileName)) + m_CurrProj = New ProjectFileVM(ProjFileM.CreateProjectFileM(ProjectType.PROJ, Currproj.ProjId, 0, Date.Now, Date.Now, "", Currproj.BTLFileName)) Return True End Function @@ -233,7 +237,7 @@ Public Class ProjManagerVM ''' Public Sub NewProject() ' verifico se progetto modificato, e chiedo se salvare - ProjectFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) + ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) If Map.refSceneHostVM.MainController.NewProject() Then ' inizializzo nuovo progetto Dim nProjId As Integer = 0 @@ -268,11 +272,11 @@ Public Class ProjManagerVM ''' Friend Sub Open() ' verifico se progetto modificato, e chiedo se salvare - ProjectFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) + ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) OpenProject(Nothing) End Sub - Friend Sub OpenProject(TempCurrProj As ProjectFileVM) + Friend Sub OpenProject(TempCurrProj As ProjFileVM) ' se la string è vuota Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing If IsNothing(TempCurrProj) Then @@ -387,7 +391,7 @@ Public Class ProjManagerVM ''' Execute the Export. This method is invoked by the ExportCommand. ''' Public Sub Import() - ProjectFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) + ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Dim sDir As String = String.Empty GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) ' apro finestra scelta file diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFileVM.vb new file mode 100644 index 00000000..ca3723b4 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFileVM.vb @@ -0,0 +1,208 @@ +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class ProdFileVM + Inherits VMBase + + Private m_ProdFileM As ProdFileM + + Public ReadOnly Property nProjIdList As List(Of Integer) + Get + Return m_ProdFileM.nProjIdList + End Get + End Property + + Public ReadOnly Property nProdId As Integer + Get + Return m_ProdFileM.nProdId + End Get + End Property + + Friend ReadOnly Property sProdDirPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_ProdFileM.nProdId) OrElse m_ProdFileM.nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") + End Get + End Property + Friend ReadOnly Property sProdPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_ProdFileM.nProdId) OrElse m_ProdFileM.nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge" + End Get + End Property + + Public Property bIsNew As Boolean + Get + Return m_ProdFileM.bIsNew + End Get + Set(value As Boolean) + m_ProdFileM.bIsNew = value + End Set + End Property + + ' nome del file mostrato nella finestra OpenProjFileDialog + Public ReadOnly Property OpenFileName As String + Get + Return m_ProdFileM.nProdId.ToString("0000") + End Get + End Property + +#Region "CONSTRUCTORS" + + Sub New(ProdFileM As ProdFileM) + m_ProdFileM = ProdFileM + End Sub + + 'Sub New(nProjectType As ProjectType, ProjectFileName As String) + ' m_nProjectType = nProjectType + ' If m_nProjectType = ProjectType.PROJ Then + ' Dim DataFromFileName As String() = ProjectFileName.Split(FILENAMESEPARATOR) + ' If Not String.IsNullOrEmpty(DataFromFileName(0)) Then + ' Integer.TryParse(DataFromFileName(0), m_nProjId) + ' End If + ' If Not String.IsNullOrEmpty(DataFromFileName(1)) Then + ' Integer.TryParse(DataFromFileName(1), m_nProdId) + ' Else + ' m_nProdId = 0 + ' End If + ' If Not String.IsNullOrEmpty(DataFromFileName(2)) Then + ' m_BTLFileName = DataFromFileName(2) + ' End If + ' ElseIf m_nProjectType = ProjectType.PROD Then + ' Integer.TryParse(ProjectFileName, m_nProdId) + ' End If + 'End Sub + + 'Sub New(nProjectType As ProjectType, nProjId As Integer, nProdId As Integer, sBTLFileName As String) + ' MyBase.New(nProjectType, nProjId, nProdId, sBTLFileName) + 'End Sub + +#End Region ' CONSTRUCTORS + + ' funzione che restituisce le parti di nome file + Friend Shared Function VerifyProjectFile(nProjectType As ProjectType, ProjectFileName As String, ByRef nProjId As Integer, ByRef nProdId As Integer, ByRef sBTLFileName As String) As Boolean + If nProjectType = ProjectType.PROJ Then + Dim DataFromFileName As String() = ProjectFileName.Split(FILENAMESEPARATOR) + If DataFromFileName.Count = 3 Then + If Not String.IsNullOrEmpty(DataFromFileName(0)) Then + Integer.TryParse(DataFromFileName(0), nProjId) + Else Return False + End If + If Not String.IsNullOrEmpty(DataFromFileName(1)) Then + Integer.TryParse(DataFromFileName(1), nProdId) + Else + nProdId = 0 + End If + If Not String.IsNullOrEmpty(DataFromFileName(2)) Then + sBTLFileName = DataFromFileName(2) + End If + Return True + Else Return False + End If + ElseIf nProjectType = ProjectType.PROD Then + Return Integer.TryParse(ProjectFileName, nProdId) + Else Return False + End If + End Function + + ' funzione che dato un nome file e il tipo restituisce il corretto numero di progetto + Friend Shared Function GetProjectNumber(nProjectType As ProjectType, ProjectFileName As String, ByRef nProjId As Integer, ByRef nProdId As Integer, ByRef sBTLFileName As String) As Boolean + If String.IsNullOrWhiteSpace(ProjectFileName) Then + nProjId = 0 + nProdId = 0 + sBTLFileName = "" + Return False + ElseIf ProjectFileName.Contains(FILENAMESEPARATOR) Then + Dim DataFromFileName As String() = ProjectFileName.Split(FILENAMESEPARATOR) + If DataFromFileName.Count = 3 Then + If Not String.IsNullOrEmpty(DataFromFileName(0)) Then + Integer.TryParse(DataFromFileName(0), nProjId) + Else Return False + End If + If Not String.IsNullOrEmpty(DataFromFileName(1)) Then + Integer.TryParse(DataFromFileName(1), nProdId) + Else + nProdId = 0 + End If + If Not String.IsNullOrEmpty(DataFromFileName(2)) Then + sBTLFileName = DataFromFileName(2) + End If + Return True + Else Return False + End If + ElseIf nProjectType = ProjectType.PROJ Then + Dim ProjectFileNameProd As String = Integer.TryParse(ProjectFileName, nProdId) + Dim nTempProjId As Integer = 0 + Dim nTempProdId As Integer = 0 + Dim sTempBTLFileName As String = "" + ' ricavo lista cartelle proj + Dim AllDirsInDir As IEnumerable(Of String) = IO.Directory.EnumerateDirectories(Map.refMainWindowVM.MainWindowM.sProjsDir) + For Each Directory In AllDirsInDir + Dim AllFilesInDir As IEnumerable(Of String) = IO.Directory.EnumerateFiles(Directory) + For Each File In AllFilesInDir + If Path.GetExtension(File).ToLower() = ".nge" Then + If File.Contains(FILENAMESEPARATOR) Then + Dim DataFromFileName As String() = ProjectFileName.Split(FILENAMESEPARATOR) + If DataFromFileName.Count = 3 Then + If Not String.IsNullOrEmpty(DataFromFileName(0)) Then + Integer.TryParse(DataFromFileName(0), nTempProjId) + Else Return False + End If + If Not String.IsNullOrEmpty(DataFromFileName(1)) Then + Integer.TryParse(DataFromFileName(1), nTempProdId) + Else + nProdId = 0 + End If + If Not String.IsNullOrEmpty(DataFromFileName(2)) Then + sTempBTLFileName = DataFromFileName(2) + End If + If ProjectFileNameProd = nTempProdId Then + nProjId = nTempProjId + nProdId = nTempProdId + sTempBTLFileName = sBTLFileName + Return True + End If + Else Return False + End If + End If + End If + Next + Next + End If + Return False + End Function + + Friend Shared Function VerifyProjectModification(CurrProject As ProdFileVM, Type As ProjectType) As Boolean + If IsNothing(CurrProject) Then Return False + Dim bNewProject As Boolean = False + Dim sProjectDirPath As String = "" + sProjectDirPath = CurrProject.sProdDirPath + ' verifico se progetto modificato, e chiedo se salvare + If (EgtGetModified() Or CurrProject.bIsNew) Then + If MessageBox.Show("Salvare le modifiche apportate al progetto?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' salvo proj + Map.refProdManagerVM.Save() + Return True + Else + ' se da non salvare e nuovo prod + If CurrProject.bIsNew Then + ' lo elimino + Directory.Delete(sProjectDirPath, True) + DbControllers.m_ProjController.DeleteProj(CurrProject.nProdId) + If CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId Then + ' reset prod in path proj + Map.refProjManagerVM.CurrProj.ResetProdId() + End If + CurrProject = Nothing + End If + EgtResetModified() + Return False + End If + End If + Return True + End Function + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjFileVM.vb similarity index 72% rename from EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb rename to EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjFileVM.vb index e92bf446..17098d10 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFileVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjFileVM.vb @@ -2,41 +2,35 @@ Imports EgtBEAMWALL.Core Imports EgtUILib -Public Class ProjectFileVM +Public Class ProjFileVM Inherits VMBase - Private m_ProjectFileM As ProjectFileM - - Public ReadOnly Property nProjectType As ProjectType - Get - Return m_ProjectFileM.nProjectType - End Get - End Property + Private m_ProjFileM As ProjFileM Public ReadOnly Property nProjId As Integer Get - Return m_ProjectFileM.nProjId + Return m_ProjFileM.nProjId End Get End Property Public ReadOnly Property nProdId As Integer Get - Return m_ProjectFileM.nProdId + Return m_ProjFileM.nProdId End Get End Property Friend ReadOnly Property sProjDirPath As String Get - If IsNothing(m_ProjectFileM.nProjId) OrElse m_ProjectFileM.nProjId = 0 Then Return String.Empty + If IsNothing(m_ProjFileM.nProjId) OrElse m_ProjFileM.nProjId = 0 Then Return String.Empty Return refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") End Get End Property Friend ReadOnly Property sProjPath As String Get Dim sPath As String = String.Empty - If IsNothing(m_ProjectFileM.nProjId) OrElse m_ProjectFileM.nProjId = 0 Then Return String.Empty + If IsNothing(m_ProjFileM.nProjId) OrElse m_ProjFileM.nProjId = 0 Then Return String.Empty sPath = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & FILENAMESEPARATOR - If Not IsNothing(m_ProjectFileM.nProdId) AndAlso m_ProjectFileM.nProdId > 0 Then + If Not IsNothing(m_ProjFileM.nProdId) AndAlso m_ProjFileM.nProdId > 0 Then sPath &= nProdId.ToString("0000") End If sPath &= FILENAMESEPARATOR & BTLFileName & ".nge" @@ -44,63 +38,32 @@ Public Class ProjectFileVM End Get End Property - Friend ReadOnly Property sProdDirPath As String - Get - Dim sPath As String = String.Empty - If IsNothing(m_ProjectFileM.nProdId) OrElse m_ProjectFileM.nProdId = 0 Then Return String.Empty - Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") - End Get - End Property - Friend ReadOnly Property sProdPath As String - Get - Dim sPath As String = String.Empty - If IsNothing(m_ProjectFileM.nProdId) OrElse m_ProjectFileM.nProdId = 0 Then Return String.Empty - Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge" - End Get - End Property - Public ReadOnly Property BTLFileName As String Get - Return m_ProjectFileM.sBTLFileName + Return m_ProjFileM.sBTLFileName End Get End Property - Public Property NewProj As Boolean + Public Property bIsNew As Boolean Get - Return m_ProjectFileM.NewProj + Return m_ProjFileM.bIsNew End Get Set(value As Boolean) - m_ProjectFileM.NewProj = value + m_ProjFileM.bIsNew = value End Set End Property - Public Property NewProd As Boolean - Get - Return m_ProjectFileM.NewProd - End Get - Set(value As Boolean) - m_ProjectFileM.NewProd = value - End Set - End Property - - ' nome del file mostrato nella finestra OpenProjFileDialog Public ReadOnly Property OpenFileName As String Get - If m_ProjectFileM.nProjectType = ProjectType.PROJ Then - Return m_ProjectFileM.nProjId.ToString("0000") & " " & BTLFileName - ElseIf m_ProjectFileM.nProjectType = ProjectType.PROD Then - Return m_ProjectFileM.nProdId.ToString("0000") - Else - Return "" - End If + Return m_ProjFileM.nProjId.ToString("0000") & " " & BTLFileName End Get End Property #Region "CONSTRUCTORS" - Sub New(ProjectFileM As ProjectFileM) - m_ProjectFileM = ProjectFileM + Sub New(ProjectFileM As ProjFileM) + m_ProjFileM = ProjectFileM End Sub 'Sub New(nProjectType As ProjectType, ProjectFileName As String) @@ -132,7 +95,7 @@ Public Class ProjectFileVM Friend Sub SetProdId(nProdId As Integer) ' rinomino proj con riferimento a prod Dim OldPath As String = sProjPath - m_nProdId = nProdId + '''m_ProjFileM.nProdId = nProdId Dim NewPath As String = sProjPath File.Move(OldPath, NewPath) End Sub @@ -234,36 +197,25 @@ Public Class ProjectFileVM Return False End Function - Friend Shared Function VerifyProjectModification(CurrProject As ProjectFileVM, Type As ProjectType) As Boolean + Friend Shared Function VerifyProjectModification(CurrProject As ProjFileVM, Type As ProjectType) As Boolean If IsNothing(CurrProject) Then Return False - Dim bNewProject As Boolean = False Dim sProjectDirPath As String = "" - If Type = ProjectType.PROJ Then - bNewProject = DbControllers.m_ProjController.FindByProjId(CurrProject.m_nProjId).IsNew - sProjectDirPath = CurrProject.sProjDirPath - Else - bNewProject = CurrProject.NewProd - sProjectDirPath = CurrProject.sProdDirPath - End If + sProjectDirPath = CurrProject.sProjDirPath ' verifico se progetto modificato, e chiedo se salvare - If (EgtGetModified() Or bNewProject) Then + If (EgtGetModified() Or CurrProject.bIsNew) Then If MessageBox.Show("Salvare le modifiche apportate al progetto?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then ' salvo proj - If Type = ProjectType.PROJ Then - Map.refProjManagerVM.Save() - Else - Map.refProdManagerVM.Save() - End If + Map.refProjManagerVM.Save() Return True Else ' se da non salvare e nuovo proj - If bNewProject Then + If CurrProject.bIsNew Then ' lo elimino Directory.Delete(sProjectDirPath, True) - DbControllers.m_ProjController.DeleteProj(CurrProject.m_nProjId) - If Type = ProjectType.PROD AndAlso CurrProject.m_nProdId = Map.refProjManagerVM.CurrProj.m_nProdId Then + DbControllers.m_ProjController.DeleteProj(CurrProject.nProjId) + If Type = ProjectType.PROD AndAlso CurrProject.nProdId = Map.refProjManagerVM.CurrProj.nProdId Then ' reset prod in path proj - Map.refProjManagerVM.CurrProj.ResetProdId() + '''Map.refProjManagerVM.CurrProj.ResetProdId() End If CurrProject = Nothing End If