- modificata gestione Open, Save e ImportBTL
- modificata finestra ProjectTypeWnd - spostato strategit sotto tab Macchina - aggiunta in strategie gestione Beam o Wall
This commit is contained in:
@@ -173,6 +173,7 @@ Public Class OnlyProdManagerVM
|
||||
Private m_cmdExportProject As ICommand
|
||||
Private m_cmdImportProject As ICommand
|
||||
Private m_cmdAddProj As ICommand
|
||||
Private m_cmdAddBTL As ICommand
|
||||
Private m_cmdGoToSupervisor As ICommand
|
||||
Private m_cmdShowPopUpStartBtnCmd As ICommand
|
||||
Private m_cmdShowPopUpSaveBtnCmd As ICommand
|
||||
@@ -279,31 +280,31 @@ Public Class OnlyProdManagerVM
|
||||
Return SetCurrProj(CurrProj.nProjId)
|
||||
End Function
|
||||
|
||||
Private Function InitNewProj(ByRef nProjId As Integer, ByRef sProjectDir As String, nType As BWType, Machine As Machine) As Boolean
|
||||
Private Function InitNewProj(ByRef nProjId As Integer, ByRef sProjectDir As String, nType As BWType, Machine As String) As Boolean
|
||||
' se non ho ricevuto numero progetto da sovrascrivere
|
||||
If nProjId = 0 Then
|
||||
' richiedo indice nuovo progetto
|
||||
nProjId = DbControllers.m_ProjController.GetNextIndex(Map.refMainWindowVM.MainWindowM.GetKeyNumber())
|
||||
End If
|
||||
' salvo data creazione progetto
|
||||
' salvo dati creazione progetto
|
||||
DbControllers.m_ProjController.Update(New ProjModel() With {.ProjId = nProjId,
|
||||
.DtCreated = DateTime.Now(),
|
||||
.PType = nType,
|
||||
.Machine = If(Not IsNothing(Machine), Machine.Name, Nothing)})
|
||||
If nProjId <= 0 Then Return False
|
||||
sProjectDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000")
|
||||
' creo cartella nuovo progetto
|
||||
If Not Directory.Exists(sProjectDir) Then
|
||||
Directory.CreateDirectory(sProjectDir)
|
||||
Else
|
||||
Dim di As New DirectoryInfo(sProjectDir)
|
||||
For Each file As FileInfo In di.EnumerateFiles()
|
||||
file.Delete()
|
||||
Next
|
||||
For Each dir As DirectoryInfo In di.EnumerateDirectories()
|
||||
dir.Delete(True)
|
||||
Next
|
||||
End If
|
||||
.Machine = Machine})
|
||||
'If nProjId <= 0 Then Return False
|
||||
'sProjectDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000")
|
||||
'' creo cartella nuovo progetto
|
||||
'If Not Directory.Exists(sProjectDir) Then
|
||||
' Directory.CreateDirectory(sProjectDir)
|
||||
'Else
|
||||
' Dim di As New DirectoryInfo(sProjectDir)
|
||||
' For Each file As FileInfo In di.EnumerateFiles()
|
||||
' file.Delete()
|
||||
' Next
|
||||
' For Each dir As DirectoryInfo In di.EnumerateDirectories()
|
||||
' dir.Delete(True)
|
||||
' Next
|
||||
'End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
@@ -408,6 +409,319 @@ Public Class OnlyProdManagerVM
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function CreateNewProd() As Boolean
|
||||
' creo proj
|
||||
Dim nProjId As Integer = 0
|
||||
Dim sBTLFileName As String = ""
|
||||
Dim nType As BWType = BWType.NULL
|
||||
Dim sMachine As String = ""
|
||||
If Not CreateNewProj(Nothing, nProjId, sBTLFileName, nType, sMachine) Then
|
||||
EgtOutLog("Errore! Creazione nuovo prod fallita!")
|
||||
Return False
|
||||
End If
|
||||
' inizializzo nuovo progetto PROD
|
||||
Dim nProdId As Integer = 0
|
||||
Dim sProdDir As String = ""
|
||||
If Not InitNewProd(nProjId, nProdId, sProdDir) Then
|
||||
EgtOutLog("Errore! Impossibile creare nuovo progetto!")
|
||||
Return False
|
||||
End If
|
||||
' setto il PType del Prod
|
||||
DbControllers.m_ProdController.UpdatePType(nProdId, nType)
|
||||
' setto la Macchina associata al Prod
|
||||
DbControllers.m_ProdController.UpdateMachine(nProdId, sMachine)
|
||||
' copio file importato
|
||||
Dim sImportFilePath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\" & sBTLFileName
|
||||
Dim sProdPath As String = sProdDir & "\" & sBTLFileName
|
||||
If File.Exists(sImportFilePath) Then
|
||||
Try
|
||||
File.Copy(sImportFilePath, sProdPath)
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Impossibile copiare il file importato nella cartella del progetto!")
|
||||
End Try
|
||||
Try
|
||||
File.Delete(sImportFilePath)
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Impossibile cancellare il file importato dalla cartella Temp!")
|
||||
End Try
|
||||
End If
|
||||
' salvo il progetto
|
||||
Dim sProdFileName As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge"
|
||||
EgtSaveFile(sProdFileName, NGE.CMPTEXT)
|
||||
' resetto stato new del proj
|
||||
DbControllers.m_ProjController.ResetNew(nProjId)
|
||||
' imposto currprod
|
||||
SetCurrProd(nProdId)
|
||||
'' imposto TempCurrProd
|
||||
'TempCurrProd = CurrProd
|
||||
'' setto flag nuovo progetto in prod
|
||||
'CurrProd.bIsNew = True
|
||||
'' elimino da DB
|
||||
''DbControllers.m_ProdController.DeleteProd(nProdId, True)
|
||||
'' riapro progetto prod
|
||||
'OpenProject(TempCurrProd)
|
||||
' Ricavo il tipo di Warehouse settato nell'INI
|
||||
Dim nDefault As Integer = 2
|
||||
If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then
|
||||
' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse
|
||||
WarehouseWndVM.UpdateSectionXMaterial()
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function CreateNewProj(ProdFileVM As ProdFileVM, Optional ByRef nProjId As Integer = 0, Optional ByRef sBTLFileName As String = "", Optional ByRef nType As BWType = BWType.NULL, Optional ByRef sMachine As String = "") As Boolean
|
||||
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return
|
||||
Dim sDir As String = String.Empty
|
||||
GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir)
|
||||
' apro finestra scelta file
|
||||
Dim sImportFilePath As String = ""
|
||||
Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With {
|
||||
.DefaultExt = ".btl",
|
||||
.Filter = "BTL (*.btl)|*.btl" &
|
||||
"|BTLX (*.btlx)|*.btlx",
|
||||
.InitialDirectory = If(Directory.Exists(sDir), sDir, ""),
|
||||
.CheckFileExists = True,
|
||||
.ValidateNames = True}
|
||||
If BTLDlg.ShowDialog() Then
|
||||
sImportFilePath = BTLDlg.FileName
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Dim sProjDir As String = ""
|
||||
' verifico se non e' tra i BTL gia' importati
|
||||
sBTLFileName = Path.GetFileName(sImportFilePath)
|
||||
Dim nAlreadyImported As Integer = DbControllers.m_ProjController.AlreadyImported(Path.GetFileNameWithoutExtension(sImportFilePath))
|
||||
If nAlreadyImported > 0 Then
|
||||
' recupero progetto con lo stesso nome
|
||||
Dim ToDeleteProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nAlreadyImported)
|
||||
' se esiste gia' un'ottimizzazione
|
||||
If ToDeleteProj.nProdId > 0 Then
|
||||
Select Case MessageBox.Show(EgtMsg(61942), "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) ' BTL file already imported and optimized. Do you want to import it again?
|
||||
Case MessageBoxResult.Yes
|
||||
' lo importo, quindi non devo fare nulla
|
||||
Case MessageBoxResult.No
|
||||
Return False
|
||||
End Select
|
||||
End If
|
||||
End If
|
||||
Dim Machine As Machine = Nothing
|
||||
If IsNothing(ProdFileVM) Then
|
||||
' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato
|
||||
' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il progetto importato
|
||||
Dim ProjectTypeWndVM As New ProjectTypeWndVM()
|
||||
If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then
|
||||
Machine = ProjectTypeWndVM.SelMachine
|
||||
nType = DirectCast(Machine, MyMachine).nType
|
||||
Else
|
||||
Dim ProjectTypeWnd As New OnlyProdProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM)
|
||||
If ProjectTypeWnd.ShowDialog() Then
|
||||
Machine = ProjectTypeWndVM.SelMachine
|
||||
nType = ProjectTypeWndVM.nSelType
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
sMachine = Machine.Name
|
||||
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
|
||||
' creo progetto per file BTL
|
||||
If Not CreateFirstBTLProj(sImportFilePath, nType, sMachine, nProjId, sProjDir) Then Return False
|
||||
Else
|
||||
' creo progetto per file BTL
|
||||
If Not AddNewBTLProj(sImportFilePath, ProdFileVM, nProjId, sProjDir) Then Return False
|
||||
End If
|
||||
' carico filtri di ricerca
|
||||
Map.refProjectVM.BTLStructureVM.LoadFilters()
|
||||
' gestisco log di importazione
|
||||
ManageImportLog(nProjId, sProjDir)
|
||||
'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function CreateFirstBTLProj(sImportFilePath As String, nType As BWType, sMachine As String, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean
|
||||
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return False
|
||||
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
|
||||
' copio file BTL
|
||||
Dim sBtlCopyPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\" & Path.GetFileName(sImportFilePath)
|
||||
Dim bOk = False
|
||||
Try
|
||||
File.Copy(sImportFilePath, sBtlCopyPath, True)
|
||||
bOk = True
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Impossibile copiare il file BTL!")
|
||||
Return False
|
||||
End Try
|
||||
' inizializzo nuovo progetto
|
||||
If InitNewProj(nProjId, sProjDir, nType, sMachine) Then
|
||||
' imposto ProjId di caricamento
|
||||
ProjectManagerVM.nLoadingProjId = nProjId
|
||||
Else
|
||||
EgtOutLog("Errore! Impossibile creare indice nuovo progetto!")
|
||||
' elimino file Btl copiato
|
||||
Try
|
||||
File.Delete(sBtlCopyPath)
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Eliminazione file BTL copiato fallita!")
|
||||
End Try
|
||||
Return False
|
||||
End If
|
||||
' importo file
|
||||
If Not Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False) Then
|
||||
EgtOutLog("Errore! Inserimento nel progetto del file BTL fallito!")
|
||||
' elimino file Btl copiato
|
||||
Try
|
||||
File.Delete(sBtlCopyPath)
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Eliminazione file BTL copiato fallita!")
|
||||
End Try
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' elimino da Db
|
||||
' CheckMe impostata come cancellazione FISICA dal DB...
|
||||
DbControllers.m_ProjController.DeleteProj(nProjId, False)
|
||||
Return False
|
||||
End If
|
||||
'Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL
|
||||
If bOk Then 'OrElse bFirstPart Then
|
||||
'' salvo path di importazione
|
||||
'WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile))
|
||||
'' salvo il progetto
|
||||
'bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT)
|
||||
'SectionXMaterial.SetType(nType)
|
||||
'Core.ViewPanelVM.UpdateBWType(nType)
|
||||
' imposto flag secondo tipo di progetto (travi o pareti)
|
||||
Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG)
|
||||
Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
|
||||
EgtBeamSetFlag(nFlag)
|
||||
Else
|
||||
EgtOutLog("Errore nell'importazione BTL")
|
||||
End If
|
||||
' aggiorno Db
|
||||
Dim ExportDate As DateTime
|
||||
Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sImportFilePath)
|
||||
DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " &
|
||||
Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate)
|
||||
DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, sMachine)
|
||||
SetCurrProj(nProjId)
|
||||
' se progetto pareti e vista ruotata
|
||||
If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then
|
||||
' ruoto le pareti di 180 per raddrizzarle rispetto alla vista
|
||||
For Each Wall In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Wall.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False)
|
||||
Next
|
||||
End If
|
||||
' calcolo volumi pezzi
|
||||
For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Part.CalcBTLPartVolume()
|
||||
Next
|
||||
'Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))
|
||||
'Map.refPartManagerVM.LockVisibilityUpdate()
|
||||
'LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' mostro tutti i pezzi
|
||||
Map.refShowBeamPanelVM.ShowAll(True)
|
||||
'If bOk Then
|
||||
''' salvo il progetto
|
||||
''Dim sProjFileName As String = sProdDir & "\" & nProjId.ToString("0000") & ".nge"
|
||||
''EgtSaveFile(sProjFileName, NGE.CMPTEXT)
|
||||
'End If
|
||||
'' carico filtri di ricerca
|
||||
'Map.refProjectVM.BTLStructureVM.LoadFilters()
|
||||
'' gestisco log di importazione
|
||||
'ManageImportLog(nProjId, sProjDir)
|
||||
'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function AddNewBTLProj(sImportFilePath As String, ProdFileVM As ProdFileVM, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean
|
||||
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return False
|
||||
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
|
||||
' copio file BTL
|
||||
Dim sBtlCopyPath As String = ProdFileVM.sProdDirPath & "\" & Path.GetFileName(sImportFilePath)
|
||||
Dim bOk = False
|
||||
Try
|
||||
File.Copy(sImportFilePath, sBtlCopyPath, True)
|
||||
bOk = True
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Impossibile copiare il file BTL!")
|
||||
Return False
|
||||
End Try
|
||||
' inizializzo nuovo progetto
|
||||
If Not InitNewProj(nProjId, sProjDir, ProdFileVM.nType, ProdFileVM.sMachine) Then
|
||||
EgtOutLog("Errore! Impossibile creare indice nuovo progetto!")
|
||||
' elimino file Btl copiato
|
||||
Try
|
||||
File.Delete(sBtlCopyPath)
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Eliminazione file BTL copiato fallita!")
|
||||
End Try
|
||||
Return False
|
||||
End If
|
||||
' importo file
|
||||
If Not Map.refSceneHostVM.MainController.InsertProject(sBtlCopyPath, False) Then
|
||||
EgtOutLog("Errore! Inserimento nel progetto del file BTL fallito!")
|
||||
' elimino file Btl copiato
|
||||
Try
|
||||
File.Delete(sBtlCopyPath)
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore! Eliminazione file BTL copiato fallita!")
|
||||
End Try
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' elimino da Db
|
||||
' CheckMe impostata come cancellazione FISICA dal DB...
|
||||
DbControllers.m_ProjController.DeleteProj(nProjId, False)
|
||||
Return False
|
||||
End If
|
||||
Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge"
|
||||
Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL
|
||||
If bOk Then 'OrElse bFirstPart Then
|
||||
'' salvo path di importazione
|
||||
'WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile))
|
||||
'' salvo il progetto
|
||||
'bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT)
|
||||
'SectionXMaterial.SetType(nType)
|
||||
'Core.ViewPanelVM.UpdateBWType(nType)
|
||||
' imposto flag secondo tipo di progetto (travi o pareti)
|
||||
Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG)
|
||||
Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
|
||||
EgtBeamSetFlag(nFlag)
|
||||
Else
|
||||
EgtOutLog("Errore nell'importazione BTL")
|
||||
End If
|
||||
' aggiorno Db
|
||||
Dim ExportDate As DateTime
|
||||
Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sImportFilePath)
|
||||
DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " &
|
||||
Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate)
|
||||
DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, ProdFileVM.nType, ProdFileVM.sMachine)
|
||||
SetCurrProj(nProjId)
|
||||
' se progetto pareti e vista ruotata
|
||||
If ProdFileVM.nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then
|
||||
' ruoto le pareti di 180 per raddrizzarle rispetto alla vista
|
||||
For Each Wall In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Wall.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False)
|
||||
Next
|
||||
End If
|
||||
' calcolo volumi pezzi
|
||||
For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Part.CalcBTLPartVolume()
|
||||
Next
|
||||
'Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))
|
||||
'Map.refPartManagerVM.LockVisibilityUpdate()
|
||||
'LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' mostro tutti i pezzi
|
||||
Map.refShowBeamPanelVM.ShowAll(True)
|
||||
'If bOk Then
|
||||
' ' salvo il progetto
|
||||
' bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT)
|
||||
'End If
|
||||
'' carico filtri di ricerca
|
||||
'Map.refProjectVM.BTLStructureVM.LoadFilters()
|
||||
'' gestisco log di importazione
|
||||
'ManageImportLog(nProjId, sProjDir)
|
||||
'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub ManageImportLog(nProjId As Integer, sProjDir As String)
|
||||
Dim LogFile As New List(Of String)
|
||||
Using FileStream As New FileStream(Map.refMainWindowVM.MainWindowM.sLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
|
||||
@@ -511,7 +825,7 @@ Public Class OnlyProdManagerVM
|
||||
' inizializzo nuovo progetto PROJ
|
||||
Dim nProjId As Integer = 0
|
||||
Dim sProjDir As String = ""
|
||||
InitNewProj(nProjId, sProjDir, nType, Machine)
|
||||
InitNewProj(nProjId, sProjDir, nType, Machine.Name)
|
||||
SetCurrProj(nProjId)
|
||||
' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel
|
||||
Map.refCALCPanelVM.LoadMachineList()
|
||||
@@ -694,13 +1008,13 @@ Public Class OnlyProdManagerVM
|
||||
If bShowLoading Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63007), EgtMsg(63012), 70) ' Project saving ' Saving geometry
|
||||
Dim bOk As Boolean = Map.refSceneHostVM.SaveProject()
|
||||
If bShowLoading Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63013), 70, 100) ' Saving data on Db
|
||||
' aggiorno pezzi su Db
|
||||
Dim MyMachGroupList As New List(Of MyMachGroupM)
|
||||
If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then
|
||||
For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList
|
||||
MyMachGroupList.Add(MachGroup)
|
||||
Next
|
||||
End If
|
||||
' aggiorno pezzi su Db
|
||||
If Not DbControllers.m_ProdController.UpdateMachGroup(CurrProd.nProdId, MyMachGroupList) And bShowLoading Then
|
||||
LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD)
|
||||
Return False
|
||||
@@ -750,6 +1064,12 @@ Public Class OnlyProdManagerVM
|
||||
''' Execute the ImportBTL. This method is invoked by the ImportBTLCommand.
|
||||
''' </summary>
|
||||
Public Sub ImportBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True)
|
||||
If Not CreateNewProd() Then
|
||||
Dim sErrMsg As String = "Errore! Creazione del progetto fallita!"
|
||||
MessageBox.Show(sErrMsg)
|
||||
EgtOutLog(sErrMsg)
|
||||
End If
|
||||
Return
|
||||
If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return
|
||||
Dim sDir As String = String.Empty
|
||||
GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir)
|
||||
@@ -784,21 +1104,6 @@ Public Class OnlyProdManagerVM
|
||||
Case MessageBoxResult.No
|
||||
Return
|
||||
End Select
|
||||
Else
|
||||
' se non ha ottimizazione, chiedo se sovrascriverlo
|
||||
Select Case MessageBox.Show(EgtMsg(61943), "Information", MessageBoxButton.YesNoCancel, MessageBoxImage.Information) ' BTL file already imported. Do you want to overwrite it?
|
||||
Case MessageBoxResult.Yes
|
||||
' cancello BTLParts su DB
|
||||
DbControllers.m_ProjController.UpdateBtlParts(nAlreadyImported, New List(Of BTLPartM))
|
||||
' cancello nome BTL
|
||||
DbControllers.m_ProjController.UpdateInfo(nAlreadyImported, DateTime.Now.ToString(), DateTime.Now.ToString(), "", DateTime.MinValue, BWType.NULL, "")
|
||||
nProjId = nAlreadyImported
|
||||
sProjDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000")
|
||||
Case MessageBoxResult.No
|
||||
' lo importo, quindi non devo fare nulla
|
||||
Case MessageBoxResult.Cancel
|
||||
Return
|
||||
End Select
|
||||
End If
|
||||
End If
|
||||
' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato
|
||||
@@ -820,12 +1125,12 @@ Public Class OnlyProdManagerVM
|
||||
End If
|
||||
LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
|
||||
' inizializzo nuovo progetto
|
||||
InitNewProj(nProjId, sProjDir, nType, Machine)
|
||||
SetCurrProj(nProjId)
|
||||
' imposto il tipo di parametri Q da utilizzare
|
||||
BTLIniFile.m_nBTLBWType = nType
|
||||
' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel
|
||||
Map.refCALCPanelVM.LoadMachineList()
|
||||
InitNewProj(nProjId, sProjDir, nType, Machine.Name)
|
||||
'SetCurrProj(nProjId)
|
||||
'' imposto il tipo di parametri Q da utilizzare
|
||||
'BTLIniFile.m_nBTLBWType = nType
|
||||
'' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel
|
||||
'Map.refCALCPanelVM.LoadMachineList()
|
||||
' imposto ProjId di caricamento
|
||||
ProjectManagerVM.nLoadingProjId = nProjId
|
||||
' copio file BTL
|
||||
@@ -838,9 +1143,9 @@ Public Class OnlyProdManagerVM
|
||||
EgtOutLog("Impossibile copiare il file")
|
||||
bOk = False
|
||||
End Try
|
||||
' disattivo temporaneamente bottone assemblato per non prendere il riferimento sbagliato durante importazione
|
||||
Dim bAssembly As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked
|
||||
Map.refShowBeamPanelVM.ShowBuilding_IsChecked = False
|
||||
'' disattivo temporaneamente bottone assemblato per non prendere il riferimento sbagliato durante importazione
|
||||
'Dim bAssembly As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = False
|
||||
' importo file
|
||||
If bOk Then
|
||||
bOk = Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False)
|
||||
@@ -882,11 +1187,11 @@ Public Class OnlyProdManagerVM
|
||||
Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))
|
||||
'Map.refPartManagerVM.LockVisibilityUpdate()
|
||||
LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics
|
||||
Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' mostro tutti i pezzi
|
||||
Map.refShowBeamPanelVM.ShowAll(True)
|
||||
Else
|
||||
Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' elimino da Db
|
||||
' CheckMe impostata come cancellazione FISICA dal DB...
|
||||
DbControllers.m_ProjController.DeleteProj(nProjId, False)
|
||||
@@ -1624,7 +1929,7 @@ Public Class OnlyProdManagerVM
|
||||
' inizializzo nuovo proj
|
||||
Dim nNewProjId As Integer = 0
|
||||
Dim sNewProjDir As String = ""
|
||||
InitNewProj(nNewProjId, sNewProjDir, nType, Machine)
|
||||
InitNewProj(nNewProjId, sNewProjDir, nType, Machine.Name)
|
||||
NewProjIdList.Add(nNewProjId)
|
||||
' imposto ProjId di caricamento
|
||||
ProjectManagerVM.nLoadingProjId = nImportProjId
|
||||
@@ -1807,6 +2112,10 @@ Public Class OnlyProdManagerVM
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub AddProj()
|
||||
If Not CreateNewProj(CurrProd, 0) Then
|
||||
MessageBox.Show("Errore! Aggiunta file fallita!")
|
||||
End If
|
||||
Return
|
||||
' verifico se progetto modificato, e chiedo se salvare
|
||||
If IsNothing(CurrProd) Then Return
|
||||
Dim bNewProject As Boolean = False
|
||||
@@ -1880,6 +2189,175 @@ Public Class OnlyProdManagerVM
|
||||
|
||||
#End Region ' AddProj
|
||||
|
||||
#Region "AddBTL"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do Save.
|
||||
''' </summary>
|
||||
Public ReadOnly Property AddBTL_Command As ICommand
|
||||
Get
|
||||
If m_cmdAddBTL Is Nothing Then
|
||||
m_cmdAddBTL = New Command(AddressOf AddBTL)
|
||||
End If
|
||||
Return m_cmdAddBTL
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the Save. This method is invoked by the SaveCommand.
|
||||
''' </summary>
|
||||
Public Sub AddBTL()
|
||||
'' verifico ci sia un progetto aperto
|
||||
If IsNothing(CurrProd) Then Return
|
||||
' apro finestra scelta file
|
||||
Dim sDir As String = String.Empty
|
||||
GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir)
|
||||
Dim sFile As String = ""
|
||||
Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With {
|
||||
.DefaultExt = ".btl",
|
||||
.Filter = "BTL (*.btl)|*.btl" &
|
||||
"|BTLX (*.btlx)|*.btlx",
|
||||
.InitialDirectory = If(Directory.Exists(sDir), sDir, ""),
|
||||
.CheckFileExists = True,
|
||||
.ValidateNames = True}
|
||||
If BTLDlg.ShowDialog() Then
|
||||
sFile = BTLDlg.FileName
|
||||
Else
|
||||
Return
|
||||
End If
|
||||
Dim nNewProjId As Integer = 0
|
||||
Dim sProjDir As String = ""
|
||||
' verifico se non e' tra i BTL gia' importati
|
||||
Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sFile)
|
||||
Dim nAlreadyImported As Integer = DbControllers.m_ProjController.AlreadyImported(sBTLFileName)
|
||||
If nAlreadyImported > 0 Then
|
||||
Select Case MessageBox.Show(EgtMsg(61942), "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) ' BTL file already imported and optimized. Do you want to import it again?
|
||||
Case MessageBoxResult.Yes
|
||||
' lo importo, quindi non devo fare nulla
|
||||
Case MessageBoxResult.No
|
||||
Return
|
||||
End Select
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
''LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
|
||||
' inizializzo nuovo progetto
|
||||
InitNewProj(nNewProjId, sProjDir, CurrProd.nType, CurrProd.sMachine)
|
||||
''SetCurrProj(nProjId)
|
||||
'' imposto il tipo di parametri Q da utilizzare
|
||||
'BTLIniFile.m_nBTLBWType = nType
|
||||
'' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel
|
||||
'Map.refCALCPanelVM.LoadMachineList()
|
||||
'' imposto ProjId di caricamento
|
||||
'ProjectManagerVM.nLoadingProjId = nProjId
|
||||
' copio file BTL
|
||||
Dim sBtlCopyPath As String = CurrProd.sProdDirPath & "\" & Path.GetFileName(sFile)
|
||||
Dim bOk = False
|
||||
Try
|
||||
File.Copy(sFile, sBtlCopyPath, True)
|
||||
bOk = True
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Impossibile copiare il file")
|
||||
bOk = False
|
||||
End Try
|
||||
'' disattivo temporaneamente bottone assemblato per non prendere il riferimento sbagliato durante importazione
|
||||
'Dim bAssembly As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = False
|
||||
' aggiungo file BTL
|
||||
'Dim nPartCount As Integer = EgtGetPartCount()
|
||||
If bOk Then
|
||||
bOk = Map.refSceneHostVM.MainController.InsertProject(sBtlCopyPath, False)
|
||||
End If
|
||||
Dim sProjFileName As String = sProjDir & "\" & nNewProjId.ToString("0000") & ".nge"
|
||||
' Dim nNewPartCount As Integer = EgtGetPartCount()
|
||||
If bOk Then ' AndAlso nNewPartCount > nPartCount Then
|
||||
'' salvo path di importazione
|
||||
'WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile))
|
||||
' salvo il progetto
|
||||
bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT)
|
||||
SectionXMaterial.SetType(nType)
|
||||
Core.ViewPanelVM.UpdateBWType(nType)
|
||||
' imposto flag secondo tipo di progetto (travi o pareti)
|
||||
Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG)
|
||||
Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
|
||||
EgtBeamSetFlag(nFlag)
|
||||
Else
|
||||
EgtOutLog("Errore nell'importazione BTL")
|
||||
End If
|
||||
If bOk Then
|
||||
' aggiorno Db
|
||||
Dim ExportDate As DateTime
|
||||
DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " &
|
||||
Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate)
|
||||
DbControllers.m_ProjController.UpdateInfo(nNewProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Map.refMachinePanelVM.SelectedMachine.Name)
|
||||
SetCurrProj(nNewProjId)
|
||||
' se progetto pareti e vista ruotata
|
||||
If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then
|
||||
' ruoto le pareti di 180 per raddrizzarle rispetto alla vista
|
||||
For Each Wall In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Wall.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False)
|
||||
Next
|
||||
End If
|
||||
' calcolo volumi pezzi
|
||||
For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
||||
Part.CalcBTLPartVolume()
|
||||
Next
|
||||
Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))
|
||||
'Map.refPartManagerVM.LockVisibilityUpdate()
|
||||
LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' mostro tutti i pezzi
|
||||
Map.refShowBeamPanelVM.ShowAll(True)
|
||||
Else
|
||||
'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly
|
||||
' elimino da Db
|
||||
' CheckMe impostata come cancellazione FISICA dal DB...
|
||||
DbControllers.m_ProjController.DeleteProj(nNewProjId, False)
|
||||
End If
|
||||
If bOk Then
|
||||
' salvo il progetto
|
||||
bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT)
|
||||
'' inizializzo nuovo progetto PROD
|
||||
'NewProdFromProj()
|
||||
End If
|
||||
' carico filtri di ricerca
|
||||
Map.refProjectVM.BTLStructureVM.LoadFilters()
|
||||
' gestisco log di importazione
|
||||
ManageImportLog(nNewProjId, sProjDir)
|
||||
'' aggiorno titolo
|
||||
'Map.refMainWindowVM.UpdateTitle()
|
||||
'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'' inserisco proj nel prod corrente
|
||||
'Dim bOk As Boolean = EgtInsertFile(OpenProjectFileDialogVM.SelProject.sProjPath)
|
||||
' lo salvo
|
||||
bOk = bOk AndAlso Save(False)
|
||||
If bOk Then
|
||||
' riporto aggiunta proj a prod su Db
|
||||
DbControllers.m_ProdController.AddProj(CurrProd.nProdId, nNewProjId)
|
||||
End If
|
||||
' Ricavo il tipo di Warehouse settato nell'INI
|
||||
Dim nDefault As Integer = 2
|
||||
If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then
|
||||
' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse
|
||||
WarehouseWndVM.UpdateSectionXMaterial()
|
||||
End If
|
||||
' aggiorno CurrProd
|
||||
Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(CurrProd.nProdId)
|
||||
CurrProd.ProdFileM.SetProjIdList(PdFileM.nProjIdList)
|
||||
' ricarico BTLPartList
|
||||
OpenProject(CurrProd)
|
||||
End Sub
|
||||
|
||||
#End Region ' AddBTL
|
||||
|
||||
#Region "ShowPopUpStartBtnCommand"
|
||||
|
||||
Public ReadOnly Property ShowPopUpStartBtnCommand As ICommand
|
||||
|
||||
Reference in New Issue
Block a user