diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb index 050306a9..1a7f8786 100644 --- a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelVM.vb @@ -580,32 +580,36 @@ Public Class LeftPanelVM Dim sL As String = String.Empty sL = LenToString(CurrSParam.dL, 3) ' ricavo l'indice del SecionXMaterial dalla Beam_List - Dim SectXMatIndex As Integer = 1 - Dim sSxMValue As String = "" - While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, SectXMatIndex, String.Empty, sSxMValue, sWarehousePath) - Dim sSectXMatValues() As String = sSxMValue.Split(","c) - ' creo parametro - Dim dW As Double = 0 - Dim dH As Double = 0 - Dim sMaterial As String = sSectXMatValues(2) - StringToLen(sSectXMatValues(0), dW) - StringToLen(sSectXMatValues(1), dH) - If CurrSParam.SectXMat.dW = dW AndAlso CurrSParam.SectXMat.dH = dH AndAlso CurrSParam.SectXMat.sMaterial(0) = sMaterial Then - ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo - Exit While - End If - SectXMatIndex += 1 - End While + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.BEAM, CurrSParam.SectXMat) + 'Dim sSxMValue As String = "" + 'While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, SectXMatIndex, String.Empty, sSxMValue, sWarehousePath) + ' Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' ' creo parametro + ' Dim dW As Double = 0 + ' Dim dH As Double = 0 + ' Dim sMaterial As String = sSectXMatValues(2) + ' StringToLen(sSectXMatValues(0), dW) + ' StringToLen(sSectXMatValues(1), dH) + ' If CurrSParam.SectXMat.dW = dW AndAlso CurrSParam.SectXMat.dH = dH AndAlso CurrSParam.SectXMat.sMaterial(0) = sMaterial Then + ' ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + ' Exit While + ' End If + ' SectXMatIndex += 1 + 'End While ' ricavo nuovo indice materiale Dim ParamIndex As Integer = 1 Dim sParam As String = "" While GetPrivateProfileString(S_BEAM, K_L & ParamIndex, "", sParam, sWarehousePath) > 0 ParamIndex += 1 End While - ' lo aggiungo in warehouse - WritePrivateProfileString(S_BEAM, K_L & ParamIndex, + If SectXMatIndex > 0 Then + ' lo aggiungo in warehouse + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, SectXMatIndex & "," & sL & "," & CurrSParam.nQuantity & "," & If(CurrSParam.bActive, 1, 0), sWarehousePath) + Else + EgtOutLog("Error in material creation, section not found!") + End If Return CurrSParam ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then ' creo sParam diff --git a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseHelper.vb b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseHelper.vb index fb8350a1..31ebecf9 100644 --- a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseHelper.vb +++ b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseHelper.vb @@ -339,4 +339,35 @@ Module WarehouseHelper End If End Sub + Friend Function GetSectIndexFromSection(Type As BWType, Section As SectionXMaterial) As Integer + Dim nIndex As Integer = 1 + Dim sSectionData As String = "" + While GetPrivateProfileString(If(Type = BWType.BEAM, S_BEAM_LIST, S_WALL_LIST), nIndex, "", sSectionData, GetWarehouseIniPath()) > 0 + If String.IsNullOrWhiteSpace(sSectionData) Then Continue While + Dim sSectionValues() As String = sSectionData.Split(","c) + Select Case Type + Case BWType.BEAM + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim sMaterial As String = sSectionValues(2) + StringToLen(sSectionValues(0), dW) + StringToLen(sSectionValues(1), dH) + If Section.dW = dW AndAlso Section.dH = dH AndAlso Section.sMaterial(0) = sMaterial Then + ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + Return nIndex + End If + Case BWType.WALL + Dim dH As Double = 0 + Dim sMaterial As String = sSectionValues(1) + StringToLen(sSectionValues(0), dH) + If Section.dH = dH AndAlso Section.sMaterial(0) = sMaterial Then + ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + Return nIndex + End If + End Select + nIndex += 1 + End While + Return -1 + End Function + End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb index cce1e066..94f48268 100644 --- a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb @@ -682,28 +682,32 @@ Public Class WarehouseWndVM Dim sL As String = String.Empty sL = LenToString(SParamList(ParamIndex - 1).dL, 3) - ' ricavo l'indice del SecionXMaterial dalla Beam_List - Dim SectXMatIndex As Integer = 1 - Dim sSxMValue As String = "" - While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, SectXMatIndex, String.Empty, sSxMValue, sWarehousePath) - Dim sSectXMatValues() As String = sSxMValue.Split(","c) - ' creo parametro - Dim dW As Double = 0 - Dim dH As Double = 0 - Dim sMaterial As String = sSectXMatValues(2) - StringToLen(sSectXMatValues(0), dW) - StringToLen(sSectXMatValues(1), dH) - If SParamList(ParamIndex - 1).SectXMat.dW = dW AndAlso SParamList(ParamIndex - 1).SectXMat.dH = dH AndAlso SParamList(ParamIndex - 1).SectXMat.sMaterial(0) = sMaterial Then - ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo - Exit While - End If - SectXMatIndex += 1 - End While - WritePrivateProfileString(S_BEAM, K_L & ParamIndex, + ' ricavo l'indice del SecionXMaterial dalla Beam_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.BEAM, SParamList(ParamIndex - 1).SectXMat) + 'Dim sSxMValue As String = "" + 'While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, SectXMatIndex, String.Empty, sSxMValue, sWarehousePath) + ' Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' ' creo parametro + ' Dim dW As Double = 0 + ' Dim dH As Double = 0 + ' Dim sMaterial As String = sSectXMatValues(2) + ' StringToLen(sSectXMatValues(0), dW) + ' StringToLen(sSectXMatValues(1), dH) + ' If SParamList(ParamIndex - 1).SectXMat.dW = dW AndAlso SParamList(ParamIndex - 1).SectXMat.dH = dH AndAlso SParamList(ParamIndex - 1).SectXMat.sMaterial(0) = sMaterial Then + ' ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + ' Exit While + ' End If + ' SectXMatIndex += 1 + 'End While + If SectXMatIndex > 0 Then + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, SectXMatIndex & "," & sL & "," & SParamList(ParamIndex - 1).nQuantity & "," & If(SParamList(ParamIndex - 1).bActive, 1, 0), sWarehousePath) - ParamIndex += 1 + ParamIndex += 1 + Else + EgtOutLog("Error in material creation, section not found!") + End If Next ' Se ci sono parametri da rimuovere li rimuovo For Index = ParamIndex To ParamIndex + m_RemovedParamsCount @@ -745,20 +749,23 @@ Public Class WarehouseWndVM sL = LenToString(SParamList(ParamIndex - 1).dL, 3) ' ricavo l'indice del SecionXMaterial dalla Wall_List - Dim SectXMatIndex As Integer = 1 - Dim sSxMValue As String = "" - While EgtUILib.GetPrivateProfileString(S_WALL_LIST, SectXMatIndex, String.Empty, sSxMValue, sWarehousePath) - If sSxMValue = SParamList(ParamIndex - 1).sValue Then - ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo - Exit While - End If - SectXMatIndex += 1 - End While - - WritePrivateProfileString(S_WALL, K_S & ParamIndex, + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.WALL, SParamList(ParamIndex - 1).SectXMat) + 'Dim sSxMValue As String = "" + 'While EgtUILib.GetPrivateProfileString(S_WALL_LIST, SectXMatIndex, String.Empty, sSxMValue, sWarehousePath) + ' If sSxMValue = SParamList(ParamIndex - 1).sValue Then + ' ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + ' Exit While + ' End If + ' SectXMatIndex += 1 + 'End While + If SectXMatIndex > 0 Then + WritePrivateProfileString(S_WALL, K_S & ParamIndex, SectXMatIndex & "," & sW & "," & sL & "," & SParamList(ParamIndex - 1).nQuantity & "," & If(SParamList(ParamIndex - 1).bActive, 1, 0), sWarehousePath) - ParamIndex += 1 + ParamIndex += 1 + Else + EgtOutLog("Error in material creation, section not found!") + End If Next ' Se ci sono parametri da rimuovere li rimuovo For Index = ParamIndex To ParamIndex + m_RemovedParamsCount @@ -1108,7 +1115,9 @@ Public Class WarehouseWndVM ' creo parametro Dim dH As Double = 0 StringToLen(sSectXMatValues(0), dH) - SectXMatList.Add(New SectionXMaterial(0, dH, 0, sSectXMatValues(1))) + If Not SectXMatList.Any(Function(x) x.dH = dH AndAlso x.sMaterial(0) = sSectXMatValues(1)) Then + SectXMatList.Add(New SectionXMaterial(0, dH, 0, sSectXMatValues(1))) + End If sSectXMatIndex += 1 End While End If