- aggiunta modifica nome progetto
- migliorata gestione archiviazione - migliorata gestione cancellazione
This commit is contained in:
+110
-139
@@ -55,24 +55,13 @@ Public Class NewOpenProjectFileDialogVM
|
||||
dtStart = dtStartDate + TimeSpan.FromDays(1)
|
||||
dtEnd = dtEndDate
|
||||
End Select
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
' leggo da db
|
||||
If m_ProjectType = ProjectType.PROJ Then
|
||||
Dim DbProjList As New List(Of ProjFileM)
|
||||
If m_SelBTLDateType = BTLDateTypes.CREATEDATE Then
|
||||
DbProjList = DbControllers.m_ProjController.GetLastDesc(dtStart, dtEnd, nRowQuantity, True)
|
||||
DbProjList = DbControllers.m_ProjController.GetLastDesc(dtStart, dtEnd, nRowQuantity, True, bViewArchived)
|
||||
Else
|
||||
DbProjList = DbControllers.m_ProjController.GetLastByExpDesc(dtStart, dtEnd, nRowQuantity, True)
|
||||
DbProjList = DbControllers.m_ProjController.GetLastByExpDesc(dtStart, dtEnd, nRowQuantity, True, bViewArchived)
|
||||
End If
|
||||
For Each Project In DbProjList
|
||||
If IsNothing(Project.nProjId) OrElse Project.nProjId = 0 Then Continue For
|
||||
@@ -135,137 +124,119 @@ Public Class NewOpenProjectFileDialogVM
|
||||
|
||||
Public Overrides Sub Archive()
|
||||
If IsNothing(SelProject) Then Return
|
||||
If IsNothing(SelProject.ProdFileVM) Then Return
|
||||
' archivio il progetto
|
||||
DbControllers.m_ProdController.UpdateArchived(SelProject.ProdFileVM.nProdId, True)
|
||||
If Not IsNothing(SelProject.ProdFileVM) Then
|
||||
' archivio il progetto
|
||||
DbControllers.m_ProdController.UpdateArchived(SelProject.ProdFileVM.nProdId, Not SelProject.bIsArchived)
|
||||
NotifyPropertyChanged(NameOf(Archive_Msg))
|
||||
Else
|
||||
If m_SelProject.ProjFileList.Count > 0 Then
|
||||
' DbControllers.m_ProjController.archived
|
||||
Else Return
|
||||
End If
|
||||
End If
|
||||
' aggiorno lista progetti
|
||||
RefreshProjectList()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Delete()
|
||||
'If IsNothing(SelProject) Then Return
|
||||
'' recupero indice per riselezionare
|
||||
'Dim ProjListIndex As Integer = m_ProjectList.IndexOf(SelProject)
|
||||
'If m_ProjectType = ProjectType.PROJ Then
|
||||
' ' verifico se proj selezionato e' il corrente
|
||||
' If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso SelProject.ProjFileList.Any(Function(x) x.nProjId = Map.refProjManagerVM.CurrProj.nProjId) Then
|
||||
' MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning)
|
||||
' Return
|
||||
' End If
|
||||
' ' verifico se proj selezionato ha prod
|
||||
' If Not IsNothing(SelProject.ProdFileVM) AndAlso SelProject.ProdFileVM.nProdId > 0 Then
|
||||
' MessageBox.Show(EgtMsg(61873), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning)
|
||||
' Return
|
||||
' End If
|
||||
' ' rimuovo dai progetti correnti
|
||||
' For Each Project In SelProject.ProjFileList
|
||||
' Map.refProjManagerVM.m_MruFiles.Remove(Project.sProjPath)
|
||||
' Next
|
||||
' Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames))
|
||||
' ' cancello progetto
|
||||
' ' CheckMe impostata come cancellazione FISICA dal DB...
|
||||
' DbControllers.m_ProjController.DeleteProj(SelProject.nProjId, True)
|
||||
' ' cancello cartella del Proj
|
||||
' Try
|
||||
' Directory.Delete(SelProject.sProjDirPath, True)
|
||||
' Catch ex As Exception
|
||||
' EgtOutLog("Error in deleting directory " & SelProject.sProjDirPath)
|
||||
' End Try
|
||||
' ' aggiorno lista progetti
|
||||
' RefreshProjectList()
|
||||
' 'm_ProjectList.Clear()
|
||||
' 'Dim DbProjectList As New List(Of ProjFileM)
|
||||
' 'DbProjectList = DbControllers.m_ProjController.GetLastDesc(50, False)
|
||||
' 'For Each Project In DbProjectList
|
||||
' ' m_ProjectList.Add(New ProjFileVM(Project))
|
||||
' 'Next
|
||||
'ElseIf m_ProjectType = ProjectType.PROD Then
|
||||
' ' verifico se prod selezionato e' il corrente
|
||||
' If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso SelProject.nProdId = Map.refProdManagerVM.CurrProd.nProdId Then
|
||||
' MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning)
|
||||
' Return
|
||||
' End If
|
||||
' ' verifico se ci sono grezzi mandati al supervisore
|
||||
' If DbControllers.m_ProdController.IsAnyInSupervisor(SelProject.nProdId) Then
|
||||
' MessageBox.Show(EgtMsg(61874), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning)
|
||||
' Return
|
||||
' End If
|
||||
' Map.refProdManagerVM.m_MruFiles.Remove(SelProject.sProdPath)
|
||||
' Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames))
|
||||
' ' cancello progetto
|
||||
' DbControllers.m_ProdController.DeleteProd(SelProject.nProdId)
|
||||
' ' riporto prod in proj
|
||||
' Dim nCurrCtx As Integer = EgtGetCurrentContext()
|
||||
' Dim nTempCtx As Integer = EgtInitContext()
|
||||
' If nTempCtx <> 0 Then
|
||||
' ' inizializzo gestore lavorazioni
|
||||
' EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir)
|
||||
' ' apro, ripulisco e salvo il progetto in tutti i proj correlati
|
||||
' Dim ProdFile As ProdFileVM = DirectCast(SelProject, ProdFileVM)
|
||||
' For Each nProjId In ProdFile.nProjIdList
|
||||
' EgtOpenFile(SelProject.sProdPath)
|
||||
' ' cancello tutti i gruppi di lavorazione
|
||||
' Dim nMachGroupId As Integer = EgtGetFirstMachGroup()
|
||||
' While nMachGroupId <> GDB_ID.NULL
|
||||
' EgtSetCurrMachGroup(nMachGroupId)
|
||||
' Dim nRawPartId As Integer = EgtGetFirstRawPart()
|
||||
' While nRawPartId <> GDB_ID.NULL
|
||||
' Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
|
||||
' While nPartId <> GDB_ID.NULL
|
||||
' EgtRemovePartFromRawPart(nPartId)
|
||||
' ' elimino pezzo copia
|
||||
' EgtErase(nPartId)
|
||||
' nPartId = EgtGetFirstPartInRawPart(nRawPartId)
|
||||
' End While
|
||||
' nRawPartId = EgtGetNextRawPart(nRawPartId)
|
||||
' End While
|
||||
' EgtRemoveMachGroup(nMachGroupId)
|
||||
' nMachGroupId = EgtGetFirstMachGroup()
|
||||
' End While
|
||||
' ' cancello tutti i gruppi che sono di un progetto diverso da questo
|
||||
' Dim nGroupId As Integer = EgtGetFirstInGroup(GDB_ID.ROOT)
|
||||
' While nGroupId <> GDB_ID.NULL
|
||||
' Dim nGroupProjId As Integer = GDB_ID.NULL
|
||||
' Dim nNextGroupId As Integer = EgtGetNext(nGroupId)
|
||||
' If EgtGetInfo(nGroupId, BTL_PRT_PROJ, nGroupProjId) Then
|
||||
' If nGroupProjId <> nProjId Then
|
||||
' EgtErase(nGroupId)
|
||||
' End If
|
||||
' End If
|
||||
' nGroupId = nNextGroupId
|
||||
' End While
|
||||
' EgtSaveFile(ProdFile.GetProjPath(nProjId), NGE.CMPTEXT)
|
||||
' Next
|
||||
' ' torno sul contesto corrente
|
||||
' EgtSetCurrentContext(nCurrCtx)
|
||||
' EgtDeleteContext(nTempCtx)
|
||||
' End If
|
||||
' ' se proj corrente era il prod cancellato, aggiorno proj corrente
|
||||
' If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso Map.refProjManagerVM.CurrProj.nProdId = SelProject.nProdId Then
|
||||
' Map.refProjManagerVM.UpdateCurrProj()
|
||||
' End If
|
||||
' ' cancello cartella del Prod
|
||||
' Try
|
||||
' Directory.Delete(SelProject.sProdDirPath, True)
|
||||
' Catch ex As Exception
|
||||
' EgtOutLog("Error in deleting directory " & SelProject.sProdDirPath)
|
||||
' End Try
|
||||
' ' aggiorno lista progetti
|
||||
' m_ProjectList.Clear()
|
||||
' Dim DbProjectList As New List(Of ProdFileM)
|
||||
' DbProjectList = DbControllers.m_ProdController.GetLastDesc(50, False)
|
||||
' For Each Project In DbProjectList
|
||||
' m_ProjectList.Add(New ProdFileVM(Project))
|
||||
' Next
|
||||
'End If
|
||||
'' ripristino selezionato
|
||||
'If ProjListIndex >= 0 AndAlso ProjListIndex <= m_ProjectList.Count - 1 Then
|
||||
' SelProject = m_ProjectList(ProjListIndex)
|
||||
' NotifyPropertyChanged(NameOf(SelProject))
|
||||
'End If
|
||||
'' reset dei controller per tornare in sync
|
||||
'DbControllers.m_ProjController.ResetController()
|
||||
'DbControllers.m_ProdController.ResetController()
|
||||
If IsNothing(SelProject) Then Return
|
||||
' recupero indice per riselezionare
|
||||
Dim ProjListIndex As Integer = m_ProjectList.IndexOf(SelProject)
|
||||
' verifico se proj selezionato e' il corrente
|
||||
If Not IsNothing(Map.refProjManagerVM.CurrProj) AndAlso SelProject.ProjFileList.Any(Function(x) x.nProjId = Map.refProjManagerVM.CurrProj.nProjId) Then
|
||||
If m_ProjectType = ProjectType.PROJ AndAlso MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.Cancel Then
|
||||
Return
|
||||
Else
|
||||
m_ChangeOpenedProjectOnCancel = True
|
||||
End If
|
||||
End If
|
||||
' verifico se prod selezionato e' il corrente
|
||||
If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso SelProject.ProdFileVM.nProdId = Map.refProdManagerVM.CurrProd.nProdId Then
|
||||
If m_ProjectType = ProjectType.PROD AndAlso MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.Cancel Then
|
||||
Return
|
||||
Else
|
||||
m_ChangeOpenedProjectOnCancel = True
|
||||
End If
|
||||
End If
|
||||
' rimuovo da lista ultimi progetti aperti
|
||||
For Each Project In SelProject.ProjFileList
|
||||
Map.refProjManagerVM.m_MruFiles.Remove(Project.sProjPath)
|
||||
Next
|
||||
Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames))
|
||||
If Not IsNothing(SelProject.ProdFileVM) Then
|
||||
Map.refProdManagerVM.m_MruFiles.Remove(SelProject.ProdFileVM.sProdPath)
|
||||
Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames))
|
||||
End If
|
||||
' cancello progetto
|
||||
If Not IsNothing(SelProject.ProdFileVM) Then
|
||||
DbControllers.m_ProdController.DeleteProd(SelProject.ProdFileVM.nProdId, True)
|
||||
'' cancello cartella del Prod
|
||||
'Try
|
||||
' Directory.Delete(SelProject.ProdFileVM.sProdDirPath, True)
|
||||
'Catch ex As Exception
|
||||
' EgtOutLog("Error in deleting directory " & SelProject.ProdFileVM.sProdDirPath)
|
||||
'End Try
|
||||
End If
|
||||
For Each Project In SelProject.ProjFileList
|
||||
DbControllers.m_ProjController.DeleteProj(Project.nProjId, True)
|
||||
'' cancello cartella del Proj
|
||||
'Try
|
||||
' Directory.Delete(Project.sProjDirPath, True)
|
||||
'Catch ex As Exception
|
||||
' EgtOutLog("Error in deleting directory " & Project.sProjDirPath)
|
||||
'End Try
|
||||
Next
|
||||
' aggiorno lista progetti
|
||||
RefreshProjectList()
|
||||
' ripristino selezionato
|
||||
If ProjListIndex >= 0 AndAlso ProjListIndex <= m_ProjectList.Count - 1 Then
|
||||
SelProject = m_ProjectList(ProjListIndex)
|
||||
NotifyPropertyChanged(NameOf(SelProject))
|
||||
End If
|
||||
' reset dei controller per tornare in sync
|
||||
DbControllers.m_ProjController.ResetController()
|
||||
DbControllers.m_ProdController.ResetController()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Cancel()
|
||||
If m_ChangeOpenedProjectOnCancel Then
|
||||
Dim bOpened As Boolean = False
|
||||
If m_ProjectType = ProjectType.PROJ Then
|
||||
For Each ProjectName In Map.refProjManagerVM.m_MruFiles.FileNames
|
||||
If Not String.IsNullOrWhiteSpace(ProjectName) Then
|
||||
Dim sProjId As String = Path.GetFileNameWithoutExtension(ProjectName)
|
||||
If Not String.IsNullOrWhiteSpace(sProjId) Then
|
||||
Dim nProjId As Integer = 0
|
||||
Integer.TryParse(sProjId, nProjId)
|
||||
Dim PjFileM = DbControllers.m_ProjController.FindByProjIdConv(nProjId)
|
||||
Dim PjFileVM = New ProjFileVM(PjFileM)
|
||||
Map.refProjManagerVM.OpenProject(PjFileVM)
|
||||
bOpened = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
If Not bOpened Then
|
||||
Map.refProjManagerVM.OpenProject(m_ProjectList(0).ProjFileList(0))
|
||||
End If
|
||||
ElseIf m_ProjectType = ProjectType.PROD Then
|
||||
For Each ProjectName In Map.refProdManagerVM.m_MruFiles.FileNames
|
||||
If Not String.IsNullOrWhiteSpace(ProjectName) Then
|
||||
Dim sProdId As String = Path.GetFileNameWithoutExtension(ProjectName)
|
||||
If Not String.IsNullOrWhiteSpace(sProdId) Then
|
||||
Dim nProdId As Integer = 0
|
||||
Integer.TryParse(sProdId, nProdId)
|
||||
Dim PjFileM = DbControllers.m_ProdController.FindCoreByProdId(nProdId)
|
||||
Dim PjFileVM = New ProdFileVM(PjFileM)
|
||||
Map.refProdManagerVM.OpenProject(PjFileVM)
|
||||
bOpened = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
CloseWindow(False)
|
||||
End Sub
|
||||
|
||||
#End Region ' METHODS
|
||||
|
||||
Reference in New Issue
Block a user