diff --git a/EgtBEAMWALL.Core/BTLFeature.vb b/EgtBEAMWALL.Core/BTLFeature.vb new file mode 100644 index 00000000..30fd8238 --- /dev/null +++ b/EgtBEAMWALL.Core/BTLFeature.vb @@ -0,0 +1,409 @@ +Imports System.Collections.ObjectModel +Imports System.Windows +Imports System.Windows.Input +Imports System.Windows.Media +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BTLFeature + Inherits VMBase + + ' Feature a cui appartiene il parametro + Protected m_ParentPart As BTLPart + Public ReadOnly Property ParentPart As BTLPart + Get + Return m_ParentPart + End Get + End Property + + ' Id geometrico della feature + Protected m_nFeatureId As Integer + Public ReadOnly Property nFeatureId As Integer + Get + Return m_nFeatureId + End Get + End Property + Public Sub SetFeatureId(nFeatureId As Integer) + m_nFeatureId = nFeatureId + End Sub + + ' lista dei gruppi + Protected m_GRPList As New ObservableCollection(Of Integer) + Public Property GRPList As ObservableCollection(Of Integer) + Get + Return m_GRPList + End Get + Set(value As ObservableCollection(Of Integer)) + m_GRPList = value + End Set + End Property + + Protected m_nSelGRP As Integer = -1 + Public Overridable Property nSelGRP As Integer + Get + Return m_nSelGRP + End Get + Set(value As Integer) + m_nSelGRP = value + End Set + End Property + + ' Processo + Protected m_nPRC As Integer + Public Property nPRC As Integer + Get + Return m_nPRC + End Get + Set(value As Integer) + m_nPRC = value + End Set + End Property + + ' Lato + Protected m_SIDEList As New ObservableCollection(Of Integer)({1, 2, 3, 4}) + Public Property SIDEList As ObservableCollection(Of Integer) + Get + Return m_SIDEList + End Get + Set(value As ObservableCollection(Of Integer)) + m_SIDEList = value + End Set + End Property + Protected m_nSelSIDE As Integer = -1 + Public Overridable Property nSelSIDE As Integer + Get + Return m_nSelSIDE + End Get + Set(value As Integer) + m_nSelSIDE = value + End Set + End Property + + ' Nome + Protected m_sName As String + Public ReadOnly Property sName As String + Get + Return m_sName + End Get + End Property + Public Sub SetName(sName As String) + m_sName = sName + End Sub + + Protected m_bDO As Boolean + Public Overridable Property bDO As Boolean + Get + Return m_bDO + End Get + Set(value As Boolean) + m_bDO = value + End Set + End Property + + Protected m_nPRID As Integer + Public Property nPRID As Integer + Get + Return m_nPRID + End Get + Set(value As Integer) + m_nPRID = value + End Set + End Property + + Protected m_sDES As String = String.Empty + Public Property sDES As String + Get + Return m_sDES + End Get + Set(value As String) + m_sDES = value + End Set + End Property + + Protected m_frFRAME As New Frame3d + Public Property frFRAME As Frame3d + Get + Return m_frFRAME + End Get + Set(value As Frame3d) + m_frFRAME = value + End Set + End Property + + Protected m_nState As CalcStates = -1 + Public ReadOnly Property nState As CalcStates + Get + Return m_nState + End Get + End Property + + Protected m_nCALC_ERR As Integer = -1 + Public ReadOnly Property nCALC_ERR As Integer + Get + Return m_nCALC_ERR + End Get + End Property + + Protected m_nCALC_ROT As Integer + Public ReadOnly Property nCALC_ROT As Integer + Get + Return m_nCALC_ROT + End Get + End Property + + Protected m_nCALC_FALL As Integer + Public ReadOnly Property nCALC_FALL As Integer + Get + Return m_nCALC_FALL + End Get + End Property + + Protected m_sCALC_MSG As String + Public ReadOnly Property nCALC_MSG As String + Get + Return m_sCALC_MSG + End Get + End Property + + ' lista dei parametri della feature + Protected m_PParamList As ObservableCollection(Of BTLParam) + Public Property PParamList As ObservableCollection(Of BTLParam) + Get + Return m_PParamList + End Get + Set(value As ObservableCollection(Of BTLParam)) + m_PParamList = value + End Set + End Property + + Protected m_SelPParam As BTLParam + Public Overridable Property SelPParam As BTLParam + Get + Return m_SelPParam + End Get + Set(value As BTLParam) + m_SelPParam = value + End Set + End Property + + ' lista dei parametri della feature + Protected m_QParamList As ObservableCollection(Of BTLParam) + Public Property QParamList As ObservableCollection(Of BTLParam) + Get + Return m_QParamList + End Get + Set(value As ObservableCollection(Of BTLParam)) + m_QParamList = value + End Set + End Property + + Protected m_SelQParam As BTLParam + Public Overridable Property SelQParam As BTLParam + Get + Return m_SelQParam + End Get + Set(value As BTLParam) + m_SelQParam = value + End Set + End Property + +#Region "MESSAGES" + + Public ReadOnly Property Name_Msg As String + Get + Return EgtMsg(61614) + End Get + End Property + + Public ReadOnly Property Value_Msg As String + Get + Return EgtMsg(61615) + End Get + End Property + + Public ReadOnly Property Min_Msg As String + Get + Return EgtMsg(61616) + End Get + End Property + + Public ReadOnly Property Max_Msg As String + Get + Return EgtMsg(61617) + End Get + End Property + +#End Region + + Sub New(ParentPart As BTLPart, nFeatureId As Integer) + m_ParentPart = ParentPart + m_nFeatureId = nFeatureId + m_PParamList = New ObservableCollection(Of BTLParam) + m_QParamList = New ObservableCollection(Of BTLParam) + End Sub + + Sub New(nPRC As Integer, nGRP As Integer, nSIDE As Integer) + m_PParamList = New ObservableCollection(Of BTLParam) + m_QParamList = New ObservableCollection(Of BTLParam) + m_nPRC = nPRC + m_nSelGRP = nGRP + m_nSelSIDE = nSIDE + m_bDO = True + End Sub + + ' funzione che crea l'elenco dei parametri + Public Overridable Sub CreateFeatureParams() + Dim ParamIndex As Integer = 1 + Dim NewBTLParam As BTLParam = Nothing + ' leggo tutti i P della feature + While BTLIniFile.GetBeamPrivateProfileParam(m_nSelGRP, m_nPRC, True, ParamIndex, Me, NewBTLParam) + m_PParamList.Add(NewBTLParam) + ParamIndex += 1 + End While + ' leggo tutti i Q della feature + ParamIndex = 1 + While BTLIniFile.GetBeamPrivateProfileParam(m_nSelGRP, m_nPRC, False, ParamIndex, Me, NewBTLParam) + m_QParamList.Add(NewBTLParam) + ParamIndex += 1 + End While + End Sub + + ' funzione che legge il valore corrente del parametro + Public Function ReadFeatureParams() As Boolean + Return ReadFeatureParams(PParamList) And ReadFeatureParams(QParamList) + End Function + Private Function ReadFeatureParams(ParamList As ObservableCollection(Of Core.BTLParam)) As Boolean + ' leggo valore parametro da struttura geometrica + For Each Param As BTLParam In ParamList + If Param.nType = BTLParamType.DOUBLE_ Or Param.nType = BTLParamType.LENGTH Then + Dim dParamValue As Double = 0 + If Not EgtGetInfo(m_nFeatureId, Param.sName, dParamValue) Then + dParamValue = 0 + End If + Param.dValue = dParamValue + ElseIf Param.nType = BTLParamType.STRING_ Then + Dim sParamValue As String = String.Empty + EgtGetInfo(m_nFeatureId, Param.sName, sParamValue) + Param.sValue = sParamValue + ElseIf Param.nType = BTLParamType.COMBO Then + Dim nParamValue As Integer + EgtGetInfo(m_nFeatureId, Param.sName, nParamValue) + Param.nSelValue = nParamValue + End If + Next + Return False + End Function + + ' funzione che setta i valori di default a tutti i parametri + Public Function SetDefaultValues() As Boolean + Return SetDefaultValues(PParamList) And SetDefaultValues(QParamList) + End Function + Private Function SetDefaultValues(ParamList As ObservableCollection(Of Core.BTLParam)) As Boolean + ' leggo valore parametro da struttura geometrica + For Each Param As BTLParam In ParamList + If Param.nType = BTLParamType.DOUBLE_ Or Param.nType = BTLParamType.LENGTH Then + Param.dValue = Param.dDefault + ElseIf Param.nType = BTLParamType.STRING_ Then + Param.sValue = "" + ElseIf Param.nType = BTLParamType.COMBO Then + Param.nSelValue = Param.dDefault + End If + Next + Return False + End Function + + ' funzione che calcola array dei valori dei parametri + Public Function CalcParamArray(ByRef vPar() As Double, ByRef sPar As String) As Boolean + ' verifico che lista parametri non sia vuota + If IsNothing(m_PParamList) OrElse m_PParamList.Count = 0 Then Return False + ' caclcolo lunghezza array + Dim nLastParId As Integer = m_PParamList(m_PParamList.Count - 1).nId - 1 + Dim vTempPar(nLastParId) As Double + Dim sTempPar As String = String.Empty + ' carico tutti i parametri su array + For ParIndex = 0 To m_PParamList.Count - 1 + Dim BTLPar As BTLParam = DirectCast(m_PParamList(ParIndex), BTLParam) + Select Case BTLPar.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + vTempPar(BTLPar.nId - 1) = BTLPar.dValue + Case BTLParamType.STRING_ + sTempPar = BTLPar.sValue + 'Case BTLParamType.COMBO + ' Dim cBTLPar As BTLParamCombo = DirectCast(ParentFeature.PParamList(ParIndex), BTLParamCombo) + ' vPar(ParIndex) = cBTLPar. + End Select + Next + vPar = vTempPar + If String.IsNullOrEmpty(sTempPar) Then + sPar = " " + Else + sPar = sTempPar + End If + Return True + End Function + + Public Overridable Function Copy() As BTLFeature + ' creo nuova feature + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Me.CalcParamArray(vPar, sPar) + ' aggiorno la feature con nuovo valore + EgtBeamSetPart(Me.ParentPart.nPartId) + Dim nNewFeatureId As Integer = EgtBeamAddProcess(Me.nSelGRP, Me.nPRC, Me.nSelSIDE, Me.sDES, Me.ParentPart.NewProcId(), Me.frFRAME, vPar, sPar) + ' se è stata creata + If nNewFeatureId <> GDB_ID.NULL Then + Dim NewFeat As New BTLFeature(Me.ParentPart, nNewFeatureId) + ' la aggiungo a struttura BTL corrente + Me.ParentPart.FeatureList.Add(NewFeat) + Return NewFeat + End If + Return Nothing + End Function + + Public Overridable Function Copy(DestBTLPart As BTLPart) As Boolean + ' creo nuova feature + Dim vPar() As Double + Dim sPar As String = String.Empty + Me.CalcParamArray(vPar, sPar) + ' aggiorno la feature con nuovo valore + EgtBeamSetPart(DestBTLPart.nPartId) + Dim nNewFeatureId As Integer = EgtBeamAddProcess(Me.nSelGRP, Me.nPRC, Me.nSelSIDE, Me.sDES, DestBTLPart.NewProcId(), Me.frFRAME, vPar, sPar) + ' se è stata creata + If nNewFeatureId <> GDB_ID.NULL Then + Dim NewFeat As New BTLFeature(Me.ParentPart, nNewFeatureId) + ' la aggiungo a struttura BTL pezzo di destinazione + DestBTLPart.FeatureList.Add(NewFeat) + Return True + End If + Return False + End Function + + ' funzione che aggiorna parametri della feature + Public Function UpdateParams(nNewGRP As Integer, nNewPRC As Integer, nNewSIDE As Integer, sNewDesc As String, nNewProcId As Integer, + frNewRef As Frame3d, vNewPar() As Double, sNewPar As String) As Boolean + ' aggiorno la feature con nuovo valore + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + CalcParamArray(vPar, sPar) + Dim nFeatureId As Integer = EgtBeamModifyProcess(Me.nFeatureId, nNewGRP, nNewPRC, nNewSIDE, sNewDesc, nNewProcId, + frNewRef, vNewPar, sNewPar) + If nFeatureId <> GDB_ID.NULL Then + SetFeatureId(nFeatureId) + ' imposto modificato per copie + EgtDuploSetModified(ParentPart.nPartId) + Return True + Else + MessageBox.Show("Impossible create feature with this values", "Error") + nFeatureId = EgtBeamModifyProcess(Me.nFeatureId, Me.nSelGRP, Me.nPRC, Me.nSelSIDE, "", Me.nPRID, New Frame3d(), vPar, sPar) + SetFeatureId(nFeatureId) + Return False + End If + End Function + + ' funzione che restituisce se la feature è un contorno libero + Public Function IsFreeContour() As Boolean + Return m_nPRC = 250 OrElse m_nPRC = 251 OrElse m_nPRC = 252 + End Function + +End Class + diff --git a/EgtBEAMWALL.Core/BTLParam.vb b/EgtBEAMWALL.Core/BTLParam.vb new file mode 100644 index 00000000..b8535d3e --- /dev/null +++ b/EgtBEAMWALL.Core/BTLParam.vb @@ -0,0 +1,187 @@ +Imports System.Collections.ObjectModel +Imports System.Windows +Imports System.Windows.Input +Imports System.Windows.Media +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BTLParam + Inherits VMBase + + ' parametro che dice se il parametro e' P o Q + Protected m_bIsP As Boolean = True + Public ReadOnly Property bIsP As Boolean + Get + Return m_bIsP + End Get + End Property + + ' parametri da struttura + Protected m_sName As String + Public Property sName As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + Protected m_nId As Integer + Public ReadOnly Property nId As Integer + Get + Return m_nId + End Get + End Property + + Protected m_sDescription As String + Public Property sDescription As String + Get + Return m_sDescription + End Get + Set(value As String) + m_sDescription = value + End Set + End Property + + ' parametri da struttura + Protected m_dMin As Double + + Protected m_dMax As Double + + Protected m_ValueList As List(Of String) + Public ReadOnly Property ValueList As List(Of String) + Get + Return m_ValueList + End Get + End Property + + ' parametri da geometria + Protected m_dValue As Double + Protected m_sValue As String + Public Overridable Property sValue As String + Get + Return m_sValue + End Get + Set(value As String) + m_sValue = value + End Set + End Property + Public Overridable Property dValue As Double + Get + Return m_dValue + End Get + Set(value As Double) + m_dValue = value + End Set + End Property + + Protected m_nSelValue As Integer + Public Property nSelValue As Integer + Get + Return m_nSelValue + End Get + Set(value As Integer) + m_nSelValue = value + End Set + End Property + + Protected m_dDefault As Double + Public ReadOnly Property dDefault As Double + Get + Return m_dDefault + End Get + End Property + + Protected m_sDrawPath As String + + ' tipo della variabile + Protected m_nType As BTLParamType + Public ReadOnly Property nType As BTLParamType + Get + Return m_nType + End Get + End Property + + ' Feature a cui appartiene il parametro + Protected m_ParentFeature As BTLFeature + Public ReadOnly Property ParentFeature As BTLFeature + Get + Return m_ParentFeature + End Get + End Property + +#Region "MESSAGES" + + Public ReadOnly Property Name_Msg As String + Get + Return EgtMsg(61614) + End Get + End Property + + Public ReadOnly Property Value_Msg As String + Get + Return EgtMsg(61615) + End Get + End Property + + Public ReadOnly Property Min_Msg As String + Get + Return EgtMsg(61616) + End Get + End Property + + Public ReadOnly Property Max_Msg As String + Get + Return EgtMsg(61617) + End Get + End Property + +#End Region + + Public Sub StdInit(ParentFeature As BTLFeature, IsP As Boolean, Type As BTLParamType, sName As String, sDescription As String) + m_ParentFeature = ParentFeature + m_bIsP = IsP + m_nType = Type + m_sName = sName + Dim nDescription As Integer + If IsNumeric(sDescription) AndAlso Integer.TryParse(sDescription, nDescription) Then + m_sDescription = EgtMsg(sDescription) + Else + m_sDescription = sDescription + End If + If Not String.IsNullOrWhiteSpace(sName) Then + Dim sId As String = sName.Trim({"P"c, "Q"c, "p"c, "q"c}) + Integer.TryParse(sId, m_nId) + End If + End Sub + + ' new per double e length + Sub New(ParentFeature As BTLFeature, IsP As Boolean, nType As BTLParamType, sParamName As String, dMin As Double, dMax As Double, dDefault As Double, sDescription As String) + StdInit(ParentFeature, IsP, nType, sParamName, sDescription) + m_dMin = dMin + m_dMax = dMax + m_dDefault = dDefault + End Sub + + ' new per stringhe + Sub New(ParentFeature As BTLFeature, IsP As Boolean, nType As BTLParamType, sParamName As String, sDescription As String) + StdInit(ParentFeature, IsP, nType, sParamName, sDescription) + End Sub + + ' new per combobox + Sub New(ParentFeature As BTLFeature, IsP As Boolean, nType As BTLParamType, sParamName As String, nMin As Integer, nMax As Integer, nDefault As Integer, sDescription As String, ValueList As List(Of String)) + StdInit(ParentFeature, IsP, nType, sParamName, sDescription) + m_dMin = nMin + m_dMax = nMax + m_dDefault = nDefault + m_ValueList = ValueList + End Sub + + ' new per parametro vuoto + Sub New(IsP As Boolean, nType As BTLParamType, sParamName As String) + StdInit(Nothing, IsP, nType, sParamName, "") + End Sub + +End Class + diff --git a/EgtBEAMWALL.Core/BTLPart.vb b/EgtBEAMWALL.Core/BTLPart.vb new file mode 100644 index 00000000..a84fec75 --- /dev/null +++ b/EgtBEAMWALL.Core/BTLPart.vb @@ -0,0 +1,235 @@ +Imports System.Collections.ObjectModel + +Public Class BTLPart + Inherits VMBase + + ' Feature a cui appartiene il parametro + Protected m_ParentStructure As BTLStructure + Public ReadOnly Property ParentStructure As BTLStructure + Get + Return m_ParentStructure + End Get + End Property + + ' Id geometrico del pezzo + Protected m_nPartId As Integer + Public ReadOnly Property nPartId As Integer + Get + Return m_nPartId + End Get + End Property + Public WriteOnly Property SetPartId As Integer + Set(value As Integer) + m_nPartId = value + End Set + End Property + + ' Info del pezzo + Protected m_nPDN As Integer + Public Property nPDN As Integer + Get + Return m_nPDN + End Get + Set(value As Integer) + m_nPDN = value + End Set + End Property + + Protected m_bDO As Boolean + Public Overridable Property bDO As Boolean + Get + Return m_bDO + End Get + Set(value As Boolean) + m_bDO = value + End Set + End Property + + Protected m_sNAM As String + Public Overridable Property sNAM As String + Get + Return m_sNAM + End Get + Set(value As String) + m_sNAM = value + End Set + End Property + + Protected m_dL As Double + Public Property dL As Double + Get + Return m_dL + End Get + Set(value As Double) + m_dL = value + End Set + End Property + + Protected m_dW As Double + Public Property dW As Double + Get + Return m_dW + End Get + Set(value As Double) + m_dW = value + End Set + End Property + + Protected m_dH As Double + Public Property dH As Double + Get + Return m_dH + End Get + Set(value As Double) + m_dH = value + End Set + End Property + + Protected m_sMATERIAL As String + Public Overridable Property sMATERIAL As String + Get + Return m_sMATERIAL + End Get + Set(value As String) + m_sMATERIAL = value + End Set + End Property + + Protected m_nCNT As Integer + Public Property nCNT As Integer + Get + Return m_nCNT + End Get + Set(value As Integer) + m_nCNT = value + End Set + End Property + + Protected m_nTBP As Integer + Public Property nTBP As Integer + Get + Return m_nTBP + End Get + Set(value As Integer) + m_nTBP = value + End Set + End Property + + Protected m_nDON As Integer + Public Property nDON As Integer + Get + Return m_nDON + End Get + Set(value As Integer) + m_nDON = value + End Set + End Property + + Protected m_nROT As Integer + Public Property nROT As Integer + Get + Return m_nROT + End Get + Set(value As Integer) + m_nROT = value + End Set + End Property + + Protected m_sGRP As String + Public Property sGRP As String + Get + Return m_sGRP + End Get + Set(value As String) + m_sGRP = value + End Set + End Property + + Protected m_nUNT As Integer + Public Property nUNT As Integer + Get + Return m_nUNT + End Get + Set(value As Integer) + m_nUNT = value + End Set + End Property + + Protected m_nGlobalState As CalcStates = -1 + Protected m_nState As CalcStates = -1 + Public Property nState As CalcStates + Get + Return m_nState + End Get + Set(value As CalcStates) + m_nState = value + End Set + End Property + + Protected m_nCALC_ROT As Integer + Public Property nCALC_ROT As Integer + Get + Return m_nCALC_ROT + End Get + Set(value As Integer) + m_nCALC_ROT = value + End Set + End Property + + Protected m_nCALC_TIME As Integer + Public Property nCALC_TIME As Integer + Get + Return m_nCALC_TIME + End Get + Set(value As Integer) + m_nCALC_TIME = value + End Set + End Property + + ' lista delle feature del pezzo + Protected m_FeatureList As ObservableCollection(Of BTLFeature) + Public Property FeatureList As ObservableCollection(Of BTLFeature) + Get + Return m_FeatureList + End Get + Set(value As ObservableCollection(Of BTLFeature)) + m_FeatureList = value + End Set + End Property + + Protected m_SelFeature As BTLFeature + Public Overridable Property SelFeature As BTLFeature + Get + Return m_SelFeature + End Get + Set(value As BTLFeature) + m_SelFeature = value + End Set + End Property + + Public ReadOnly Property Section As SectionXMaterial + Get + Return New SectionXMaterial(m_dW, m_dH, m_dL, m_sMATERIAL) + End Get + End Property + +#Region "CONSTRUCTOR" + + Sub New(ParentStructure As BTLStructure, nPartId As Integer) + m_ParentStructure = ParentStructure + Me.SetPartId = nPartId + m_FeatureList = New ObservableCollection(Of BTLFeature) + End Sub + +#End Region ' CONSTRUCTOR + + Public Function NewProcId() As Integer + Dim nMaxProcId As Integer = 0 + If Not IsNothing(Me.FeatureList) AndAlso Me.FeatureList.Count > 0 Then + nMaxProcId = Me.FeatureList.Max(Function(x) x.nPRID) + End If + Return nMaxProcId + 1 + End Function + +End Class + diff --git a/EgtBEAMWALL.Core/BTLStructure.vb b/EgtBEAMWALL.Core/BTLStructure.vb new file mode 100644 index 00000000..e6399761 --- /dev/null +++ b/EgtBEAMWALL.Core/BTLStructure.vb @@ -0,0 +1,382 @@ +Imports System.Collections.ObjectModel +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BTLStructure + Inherits VMBase + + Dim m_bOldEnMod As Boolean = False + Dim m_nBTLInfoId As Integer = 0 + + ' pezzi da BTL + Protected m_PartList As New ObservableCollection(Of BTLPart) + Public Property PartList As ObservableCollection(Of BTLPart) + Get + Return m_PartList + End Get + Set(value As ObservableCollection(Of BTLPart)) + m_PartList = value + End Set + End Property + + Protected m_SelPart As BTLPart + Public Overridable Property SelPart As BTLPart + Get + Return m_SelPart + End Get + Set(value As BTLPart) + m_SelPart = value + End Set + End Property + + ' grezzi da BTL + Protected m_BTLRawPartList As List(Of BTLRawPart) + +#Region "Parametri generici" + + Protected m_sPROJNUM As String + Public Overridable Property sPROJNUM As String + Get + Return m_sPROJNUM + End Get + Set(value As String) + m_sPROJNUM = value + End Set + End Property + + Protected m_sPROJNAME As String + Public Overridable Property sPROJNAME As String + Get + Return m_sPROJNAME + End Get + Set(value As String) + m_sPROJNAME = value + End Set + End Property + + Protected m_sPROJPART As String + Public Overridable Property sPROJPART As String + Get + Return m_sPROJPART + End Get + Set(value As String) + m_sPROJPART = value + End Set + End Property + + Protected m_sPROJGUID As String + Public Overridable Property sPROJGUID As String + Get + Return m_sPROJGUID + End Get + Set(value As String) + m_sPROJGUID = value + End Set + End Property + + Protected m_sLISTNAME As String + Public Overridable Property sLISTNAME As String + Get + Return m_sLISTNAME + End Get + Set(value As String) + m_sLISTNAME = value + End Set + End Property + + Protected m_sCUSTOMER As String + Public Overridable Property sCUSTOMER As String + Get + Return m_sCUSTOMER + End Get + Set(value As String) + m_sCUSTOMER = value + End Set + End Property + + Protected m_sARCHITECT As String + Public Overridable Property sARCHITECT As String + Get + Return m_sARCHITECT + End Get + Set(value As String) + m_sARCHITECT = value + End Set + End Property + + Protected m_sEDITOR As String + Public Overridable Property sEDITOR As String + Get + Return m_sEDITOR + End Get + Set(value As String) + m_sEDITOR = value + End Set + End Property + + Protected m_sDELIVDATE As String + Public Overridable Property sDELIVDATE As String + Get + Return m_sDELIVDATE + End Get + Set(value As String) + m_sDELIVDATE = value + End Set + End Property + + Protected m_sEXPDATE As String + Public Overridable Property sEXPDATE As String + Get + Return m_sEXPDATE + End Get + Set(value As String) + m_sEXPDATE = value + End Set + End Property + + Protected m_sEXPTIME As String + Public Overridable Property sEXPTIME As String + Get + Return m_sEXPTIME + End Get + Set(value As String) + m_sEXPTIME = value + End Set + End Property + + Protected m_sEXPRELEASE As String + Public Overridable Property sEXPRELEASE As String + Get + Return m_sEXPRELEASE + End Get + Set(value As String) + m_sEXPRELEASE = value + End Set + End Property + + Protected m_sLANGUAGE As String + Public Overridable Property sLANGUAGE As String + Get + Return m_sLANGUAGE + End Get + Set(value As String) + m_sLANGUAGE = value + End Set + End Property + + Protected m_ocRANGE As New ObservableCollection(Of Object)({New IdNameStruct(Range.STANDARD, EgtMsg(61710)), + New IdNameStruct(Range.EXTENDED, EgtMsg(61711))}) + Public ReadOnly Property ocRANGE As ObservableCollection(Of Object) + Get + Return m_ocRANGE + End Get + End Property + + Protected m_SelRANGE As Integer + Public Overridable Property SelRANGE As Integer + Get + Return m_SelRANGE + End Get + Set(value As Integer) + m_SelRANGE = value + End Set + End Property + + Protected m_ocPROCESSINGQUALITY As New ObservableCollection(Of Object)({New IdNameStruct(ProcessingQuality.AUTOMATIC, EgtMsg(61658)), + New IdNameStruct(ProcessingQuality.VISIBLE, EgtMsg(61659)), + New IdNameStruct(ProcessingQuality.FAST, EgtMsg(61660))}) + Public ReadOnly Property ocPROCESSINGQUALITY As ObservableCollection(Of Object) + Get + Return m_ocPROCESSINGQUALITY + End Get + End Property + + Protected m_SelPROCESSINGQUALITY As Integer + Public Overridable Property SelPROCESSINGQUALITY As Integer + Get + Return m_SelPROCESSINGQUALITY + End Get + Set(value As Integer) + m_SelPROCESSINGQUALITY = value + End Set + End Property + + Protected m_sCOMPUTERNAME As String + Public Overridable Property sCOMPUTERNAME As String + Get + Return m_sCOMPUTERNAME + End Get + Set(value As String) + m_sCOMPUTERNAME = value + End Set + End Property + + Protected m_sUSER As String + Public Overridable Property sUSER As String + Get + Return m_sUSER + End Get + Set(value As String) + m_sUSER = value + End Set + End Property + + Protected m_sSRCFILE As String + Public Overridable Property sSRCFILE As String + Get + Return m_sSRCFILE + End Get + Set(value As String) + m_sSRCFILE = value + End Set + End Property + + Protected m_sEXPFILE As String + Public Overridable Property sEXPFILE As String + Get + Return m_sEXPFILE + End Get + Set(value As String) + m_sEXPFILE = value + End Set + End Property + + Protected m_ocRECESS As New ObservableCollection(Of Object)({New IdNameStruct(Recess.AUTOMATIC, EgtMsg(61658)), + New IdNameStruct(Recess.MANUAL, EgtMsg(61661))}) + Public ReadOnly Property ocRECESS As ObservableCollection(Of Object) + Get + Return m_ocRECESS + End Get + End Property + + Protected m_SelRECESS As Integer + Public Overridable Property SelRECESS As Integer + Get + Return m_SelRECESS + End Get + Set(value As Integer) + m_SelRECESS = value + End Set + End Property + + Protected m_sUSERATTRIBUTE As String + Public Overridable Property sUSERATTRIBUTE As String + Get + Return m_sUSERATTRIBUTE + End Get + Set(value As String) + m_sUSERATTRIBUTE = value + End Set + End Property + +#End Region ' Parametri generici + +#Region "MESSAGES" + + ' Info del pezzo + Public ReadOnly Property PDN_Msg As String + Get + Return EgtMsg(61601) + End Get + End Property + + Public ReadOnly Property DO_Msg As String + Get + Return EgtMsg(61602) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61604) + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61605) + End Get + End Property + + Public ReadOnly Property H_Msg As String + Get + Return EgtMsg(61606) + End Get + End Property + + Public ReadOnly Property MAT_Msg As String + Get + Return EgtMsg(61607) + End Get + End Property + + Public ReadOnly Property CNT_Msg As String + Get + Return EgtMsg(61608) + End Get + End Property + + Public ReadOnly Property TBP_Msg As String + Get + Return EgtMsg(61609) + End Get + End Property + + Public ReadOnly Property DON_Msg As String + Get + Return EgtMsg(61610) + End Get + End Property + + Public ReadOnly Property ROT_Msg As String + Get + Return EgtMsg(61611) + End Get + End Property + + Public ReadOnly Property GRP_Msg As String + Get + Return EgtMsg(61612) + End Get + End Property + + Public ReadOnly Property UNT_Msg As String + Get + Return EgtMsg(61613) + End Get + End Property + +#End Region ' MESSAGES + +#Region "CONSTRUCTOR" + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Public Function NewPDN() As Integer + Dim nMaxPDN As Integer = 0 + If Not IsNothing(PartList) And PartList.Count > 0 Then + nMaxPDN = PartList.Max(Function(x) x.nPDN) + End If + Return nMaxPDN + 1 + End Function + + Public Shared Function Empty() + Return New BTLStructure + End Function + +#End Region ' METHODS + +End Class + +Public Class BTLRawPart + +End Class + diff --git a/EgtBEAMWALL.Core/Beam.vb b/EgtBEAMWALL.Core/Beam.vb new file mode 100644 index 00000000..9adddad5 --- /dev/null +++ b/EgtBEAMWALL.Core/Beam.vb @@ -0,0 +1,39 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class Beam + Inherits Part + + Protected m_dOffset As Double + Public ReadOnly Property dOffset As Double + Get + Return m_dOffset + End Get + End Property + + ' Id del grezzo + Protected m_nRawPartId As Integer = GDB_ID.NULL + +#Region "CONSTRUCTOR" + + Sub New(nParentMachGroup As Core.MyMachGroup, nPartId As Integer, nRawPartId As Integer) + MyBase.New(nParentMachGroup, nPartId) + m_nRawPartId = nRawPartId + End Sub + +#End Region ' CONSTRUCTOR + + Friend Sub UpdateOffset() + ' calcolo offset + Dim nBeamIndex As Integer = ParentMachGroup.PartList.IndexOf(Me) + If nBeamIndex > 0 Then + m_dOffset = dPOSX - (ParentMachGroup.PartList(nBeamIndex - 1).dPOSX + ParentMachGroup.PartList(nBeamIndex - 1).dL) + Else + Dim BeamMachGroup As BeamMachGroup = DirectCast(ParentMachGroup, BeamMachGroup) + m_dOffset = BeamMachGroup.dStartCut + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/BeamMachGroup.vb b/EgtBEAMWALL.Core/BeamMachGroup.vb new file mode 100644 index 00000000..b141464d --- /dev/null +++ b/EgtBEAMWALL.Core/BeamMachGroup.vb @@ -0,0 +1,60 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BeamMachGroup + Inherits MyMachGroup + + Protected m_dStartCut As Double + Public ReadOnly Property dStartCut As Double + Get + Return m_dStartCut + End Get + End Property + + Sub New(nId As Integer, sName As String, sMachine As String) + MyBase.New(nId, sName, sMachine) + SetMachineType(MachineType.BEAM) + EgtGetInfo(nId, MGR_RPT_BARLEN, dL) + EgtGetInfo(nId, MGR_RPT_BARHEIGHT, dH) + EgtGetInfo(nId, MGR_RPT_BARWIDTH, dW) + m_dTotMat = dL + For Each Part In PartList + m_dMatForPart += Part.dL + Next + End Sub + + Public Overrides Sub RefreshPartList() + ' leggo StartCut da posizione primo pezzo + Dim sInfo As String = "" + Dim sSplitInfo() As String + Dim bFound As Boolean = False + EgtGetInfo(Id, MGR_RPT_PART & 1, sInfo) + If Not String.IsNullOrWhiteSpace(sInfo) Then + sSplitInfo = sInfo.Split(","c) + StringToDouble(sSplitInfo(1), m_dStartCut) + Else + m_dStartCut = 0 + End If + ' aggiorno lista pezzi + PartList.Clear() + Dim nRawPartId As Integer = EgtGetFirstRawPart() + While nRawPartId <> GDB_ID.NULL + Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + If nPartId <> GDB_ID.NULL Then + Dim NewBeam As Beam = New Beam(Me, nPartId, nRawPartId) + PartList.Add(NewBeam) + NewBeam.UpdateOffset() + End If + nRawPartId = EgtGetNextRawPart(nRawPartId) + End While + End Sub + + Public Overrides Sub RefreshGroupData() + EgtGetInfo(Id, MGR_RPT_BARLEN, dL) + EgtGetInfo(Id, MGR_RPT_BARHEIGHT, dH) + EgtGetInfo(Id, MGR_RPT_BARWIDTH, dW) + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/Constants/ConstBeam.vb b/EgtBEAMWALL.Core/Constants/ConstBeam.vb new file mode 100644 index 00000000..b1642789 --- /dev/null +++ b/EgtBEAMWALL.Core/Constants/ConstBeam.vb @@ -0,0 +1,257 @@ +Public Module ConstBeam + + Public Enum BTLParamType As Integer + DOUBLE_ = 1 + STRING_ = 2 + COMBO = 3 + LENGTH = 4 + CHECKBOX = 5 + End Enum + + Public Enum BTLPartParam As Integer + NULL = 0 + PDN = 1 + NAM = 2 + GRP = 3 + End Enum + + Public Enum GRPType As Integer + L = 0 + T = 1 + End Enum + + Enum MachineType As Integer + NULL = 0 + BEAM = 1 + WALL = 2 + End Enum + + Enum CalcStates As Integer + NOTCALCULATED = -1 + OK = 0 + WARNING = 1 + ERROR_ = 2 + End Enum + + Public Enum Range As Integer + STANDARD = 1 + EXTENDED = 2 + End Enum + + Public Enum PartOffset_RefSideFixClamp As Integer + INACTIVE = 0 + REFSIDE1 = 1 + REFSIDE2 = 2 + REFSIDE3 = 3 + REFSIDE4 = 4 + End Enum + + Public Enum ProcessingQuality As Integer + AUTOMATIC = 1 + VISIBLE = 2 + FAST = 3 + End Enum + + Public Enum Recess As Integer + AUTOMATIC = 1 + MANUAL = 2 + End Enum + + Public Enum StoreyType As Integer + CEILING = 1 + ROOF = 2 + WALL = 3 + End Enum + + Public Enum AlignmentLocation As Integer + INACTIV = 0 + BR = 1 + TR = 2 + BA = 3 + TA = 4 + HC = 5 + VC = 6 + AC = 7 + End Enum + + Public Enum AlignmentEndtype As Integer + R = 1 + A = 2 + D = 3 + End Enum + + Public Enum MaterialType As Integer + INACTIV = 0 + BA = 1 + CL = 2 + MT = 3 + ME_ = 4 + GB = 5 + GF = 6 + IN_ = 7 + SH = 8 + FB = 9 + PB = 10 + PL = 11 + End Enum + + Public Enum MoveDirections As Integer + UP = -1 + DOWN = 1 + End Enum + + Public Const BTLFEATURES_FILE_NAME As String = "BTLFeatures.ini" + + 'Public Const S_GENERAL As String = "General" + 'Public Const K_DEBUG As String = "Debug" + + ' Tipo di progetto + Public Enum ProjectType As Integer + PROJ = 1 + PROD = 2 + End Enum + + Friend Const PROJ As String = "PROJ" + Friend Const FILENAMESEPARATOR As Char = "^"c + Friend Const BTLINFO As String = "BtlInfo" + + ' info parametri BTL + Friend Const BTL_PRT_PDN As String = "PDN" + Friend Const BTL_PRT_DO As String = "DO" + Friend Const BTL_PRT_NAM As String = "NAM" + Friend Const BTL_PRT_L As String = "L" + Friend Const BTL_PRT_W As String = "W" + Friend Const BTL_PRT_H As String = "H" + Friend Const BTL_PRT_CNT As String = "CNT" + Friend Const BTL_PRT_ROTATED As String = "ROTATED" + Friend Const BTL_PRT_INVERTED As String = "INVERTED" + Friend Const BTL_PRT_MATERIAL As String = "MATERIAL" + ' parametri pezzo + Friend Const BTL_PRT_SINGLEMEMBERNUM = "SINGLEMEMBERNUMBER" + Friend Const BTL_PRT_ASSEMBLYNUM = "ASSEMBLYNUMBER" + Friend Const BTL_PRT_ORDERNUM = "ORDERNUMBER" + Friend Const BTL_PRT_DESIGNATION = "DESIGNATION" + Friend Const BTL_PRT_ANNOTATION = "ANNOTATION" + Friend Const BTL_PRT_STOREY = "STOREY" + Friend Const BTL_PRT_GROUP = "GROUP" + Friend Const BTL_PRT_PACKAGE = "PACKAGE" + Friend Const BTL_PRT_TIMBERGRADE = "TIMBERGRADE" + Friend Const BTL_PRT_QUALITYGRADE = "QUALITYGRADE" + Friend Const BTL_PRT_COLOUR = "COLOUR" + Friend Const BTL_PRT_PLANINGLENGTH = "PLANINGLENGTH" + Friend Const BTL_PRT_STARTOFFSET = "STARTOFFSET" + Friend Const BTL_PRT_ENDOFFSET = "ENDOFFSET" + Friend Const BTL_PRT_UID = "UID" + Friend Const BTL_PRT_TRANSFORMATION = "TRANSFORMATION" + Friend Const BTL_PRT_CAMBER = "CAMBER" + Friend Const BTL_PRT_PARTOFFSET = "PARTOFFSET" + Friend Const BTL_PRT_PROCESSINGQUALITY = "PROCESSINGQUALITY" + Friend Const BTL_PRT_RECESS = "RECESS" + Friend Const BTL_PRT_STOREYTYPE = "STOREYTYPE" + Friend Const BTL_PRT_ELEMENTNUM = "ELEMENTNUMBER" + Friend Const BTL_PRT_LAYER = "LAYER" + Friend Const BTL_PRT_MODULENUM = "MODULENUMBER" + 'Friend Const BTL_PRT_USERATTRIBUTE = "USERATTRIBUTE" + Friend Const BTL_PRT_COMMENT = "COMMENT" + Friend Const BTL_PRT_GRAINDIR = "GRAINDIRECTION" + Friend Const BTL_PRT_REFSIDE = "REFERENCESIDE" + Friend Const BTL_PRT_ALIGNMENT = "ALIGNMENT" + Friend Const BTL_PRT_MATERIALTYPE = "MATERIALTYPE" + + ' parametri generici + Friend Const BTL_GEN_PROJNUM = "PROJECTNUMBER" + Friend Const BTL_GEN_PROJNAME = "PROJECTNAME" + Friend Const BTL_GEN_PROJPART = "PROJECTPART" + Friend Const BTL_GEN_PROJGUID = "PROJECTGUID" + Friend Const BTL_GEN_LISTNAME = "LISTNAME" + Friend Const BTL_GEN_CUSTOMER = "CUSTOMER" + Friend Const BTL_GEN_ARCHITECT = "ARCHITECT" + Friend Const BTL_GEN_EDITOR = "EDITOR" + Friend Const BTL_GEN_DELIVDATE = "DELIVERYDATE" + Friend Const BTL_GEN_EXPDATE = "EXPORTDATE" + Friend Const BTL_GEN_EXPTIME = "EXPORTTIME" + Friend Const BTL_GEN_EXPRELEASE = "EXPORTRELEASE" + Friend Const BTL_GEN_LANGUAGE = "LANGUAGE" + Friend Const BTL_GEN_RANGE = "RANGE" + Friend Const BTL_GEN_COMPUTERNAME = "COMPUTERNAME" + Friend Const BTL_GEN_USER = "USER" + Friend Const BTL_GEN_SRCFILE = "SOURCEFILE" + Friend Const BTL_GEN_EXPFILE = "EXPORTFILE" + Friend Const BTL_GEN_USERATTRIBUTE = "USERATTRIBUTE" + + Friend Const PROCESSINGS As String = "Processings" + Friend Const OUTLINE As String = "Outline" + Friend Const BTL_FTR_GRP As String = "GRP" + Friend Const BTL_FTR_PRC As String = "PRC" + Friend Const BTL_FTR_DO As String = "DO" + Friend Const BTL_FTR_SIDE As String = "SIDE" + Friend Const BTL_FTR_NAME As String = "NAME" + Friend Const BTL_FTR_DES As String = "DES" + Friend Const BTL_FTR_PRID As String = "PRID" + Friend Const BTL_FTR_FRAME As String = "FRAME" + + ' parametri machgroup grezzi + Friend Const MGR_RPT_ID As String = "ID" + Friend Const MGR_RPT_L As String = "L" + Friend Const MGR_RPT_W As String = "W" + Friend Const MGR_RPT_H As String = "H" + Friend Const MGR_RPT_WASTE As String = "WASTE" + Friend Const MGR_RPT_USAGE As String = "USAGE" + Friend Const MGR_RPT_STARTCUT As String = "STARTCUT" + Friend Const MGR_RPT_MATERIAL As String = "MATERIAL" + + Friend Const MGR_PRT_PDN As String = "PDN" + Friend Const MGR_PRT_L As String = "L" + Friend Const MGR_PRT_W As String = "W" + Friend Const MGR_PRT_H As String = "H" + Friend Const MGR_PRT_DES As String = "DES" + Friend Const MGR_PRT_STARTCUT As String = "STARTCUT" + Friend Const MGR_PRT_MATERIAL As String = "MATERIAL" + + Friend Const MGR_FTR_GRP As String = "GRP" + Friend Const MGR_FTR_PRC As String = "PRC" + Friend Const MGR_FTR_DO As String = "DO" + Friend Const MGR_FTR_SIDE As String = "SIDE" + Friend Const MGR_FTR_NAME As String = "NAME" + Friend Const MGR_FTR_DES As String = "DES" + Friend Const MGR_FTR_PRID As String = "PRID" + Friend Const MGR_FTR_FRAME As String = "FRAME" + + ' parametri creazione barre + Friend Const MGR_RPT_BARLEN As String = "BARLEN" + Friend Const MGR_RPT_BARHEIGHT As String = "BARHEIGHT" + Friend Const MGR_RPT_BARWIDTH As String = "BARWIDTH" + Friend Const MGR_RPT_PANELLEN As String = "PANELLEN" + Friend Const MGR_RPT_PANELWIDTH As String = "PANELWIDTH" + Friend Const MGR_RPT_PANELHEIGHT As String = "PANELHEIGHT" + Friend Const MGR_RPT_PART As String = "PART" + + ' parametri errori integration + Friend Const ITG_CUTID As String = "CUTID" + Friend Const ITG_TASKID As String = "TASKID" + Friend Const ITG_PROJ_ERR As String = "PROJ_ERR" + Friend Const ITG_PROJ_MSG As String = "PROJ_MSG" + Friend Const ITG_PROJ_ROT As String = "PROJ_ROT" + Friend Const ITG_PROJ_FALL As String = "PROJ_FALL" + Friend Const ITG_PROJ_TIME As String = "PROJ_TIME" + + ' parametri errori integration + Friend Const ITG_PROD_ERR As String = "PROD_ERR" + Friend Const ITG_PROD_MSG As String = "PROD_MSG" + Friend Const ITG_PROD_ROT As String = "PROD_ROT" + Friend Const ITG_PROD_TIME As String = "PROD_TIME" + + ' parametri errori integration + Friend Const DUPLO_TODELETE As String = "DUPLO_TODELETE" + + ' parametri warehouse + Friend Const WRH_BEAM As String = "BEAM" + Friend Const WRH_WALL As String = "WALL" + Friend Const WRH_CURRENT As String = "Current" + Friend Const WRH_STARTOFFSET As String = "StartOffset" + Friend Const WRH_OFFSET As String = "Offset" + Friend Const WRH_L As String = "L" + Friend Const WRH_KERF As String = "Kerf" + Friend Const WRH_S As String = "S" + +End Module diff --git a/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj b/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj new file mode 100644 index 00000000..cc5b0e32 --- /dev/null +++ b/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj @@ -0,0 +1,129 @@ + + + + + Debug + AnyCPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1} + Library + EgtBEAMWALL.Core + EgtBEAMWALL.Core + 512 + Windows + v4.0 + true + + + true + full + true + true + bin\Debug\ + EgtBEAMWALL.Core.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + EgtBEAMWALL.Core.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\..\..\EgtProg\DllD32\EgtUILib.dll + + + ..\..\..\EgtProg\DllD32\EgtWPFLib5.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.Core.dll + + \ No newline at end of file diff --git a/EgtBEAMWALL.Core/Enum.vb b/EgtBEAMWALL.Core/Enum.vb new file mode 100644 index 00000000..635e4bec --- /dev/null +++ b/EgtBEAMWALL.Core/Enum.vb @@ -0,0 +1,6 @@ +Public Enum CalcStates As Integer + NOTCALCULATED = -1 + OK = 0 + WARNING = 1 + ERROR_ = 2 +End Enum diff --git a/EgtBEAMWALL.Core/My Project/Application.Designer.vb b/EgtBEAMWALL.Core/My Project/Application.Designer.vb new file mode 100644 index 00000000..88dd01c7 --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/EgtBEAMWALL.Core/My Project/Application.myapp b/EgtBEAMWALL.Core/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/EgtBEAMWALL.Core/My Project/AssemblyInfo.vb b/EgtBEAMWALL.Core/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..920a6cf5 --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/EgtBEAMWALL.Core/My Project/Resources.Designer.vb b/EgtBEAMWALL.Core/My Project/Resources.Designer.vb new file mode 100644 index 00000000..f8728e8c --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("EgtBEAMWALL.Core.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/EgtBEAMWALL.Core/My Project/Resources.resx b/EgtBEAMWALL.Core/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/EgtBEAMWALL.Core/My Project/Settings.Designer.vb b/EgtBEAMWALL.Core/My Project/Settings.Designer.vb new file mode 100644 index 00000000..06ae7162 --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.EgtBEAMWALL.Core.My.MySettings + Get + Return Global.EgtBEAMWALL.Core.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/EgtBEAMWALL.Core/My Project/Settings.settings b/EgtBEAMWALL.Core/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/EgtBEAMWALL.Core/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/EgtBEAMWALL.Core/MyMachGroup.vb b/EgtBEAMWALL.Core/MyMachGroup.vb new file mode 100644 index 00000000..f0b36a90 --- /dev/null +++ b/EgtBEAMWALL.Core/MyMachGroup.vb @@ -0,0 +1,166 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports System.Windows.Input +Imports System.Windows.Media +Imports EgtUILib +Imports EgtWPFLib5 + +Public MustInherit Class MyMachGroup + Inherits MachGroup + + Protected m_nMachineType As MachineType + Public ReadOnly Property nMachineType As MachineType + Get + Return m_nMachineType + End Get + End Property + Public Sub SetMachineType(nMachineType As MachineType) + m_nMachineType = nMachineType + End Sub + + Protected m_dL As Double + Public Property dL As Double + Get + Return m_dL + End Get + Set(value As Double) + m_dL = value + End Set + End Property + + Protected m_dW As Double + Public Property dW As Double + Get + Return m_dW + End Get + Set(value As Double) + m_dW = value + End Set + End Property + + Protected m_dH As Double + Public Property dH As Double + Get + Return m_dH + End Get + Set(value As Double) + m_dH = value + End Set + End Property + + Protected m_dMatForPart As Double = 0 + Protected m_dTotMat As Double = 0 + Public ReadOnly Property dUsage As Double + Get + Return If(m_dMatForPart > 0 AndAlso m_dTotMat > 0, m_dMatForPart / m_dTotMat * 100, 0) + End Get + End Property + + Public ReadOnly Property dWaste As Double + Get + Return If(m_dMatForPart > 0 AndAlso m_dTotMat > 0, (m_dTotMat - m_dMatForPart) / m_dTotMat * 100, 0) + End Get + End Property + + Public ReadOnly Property sUsage As String + Get + Return dUsage & "%" + End Get + End Property + + Public ReadOnly Property sWaste As String + Get + Return dWaste & "%" + End Get + End Property + + Protected m_sMATERIAL As String + Public Property sMATERIAL As String + Get + Return m_sMATERIAL + End Get + Set(value As String) + m_sMATERIAL = value + End Set + End Property + + ' lista dei pezzi che sono nel grezzo + Private m_PartList As New ObservableCollection(Of Part) + Public Property PartList As ObservableCollection(Of Part) + Get + Return m_PartList + End Get + Set(value As ObservableCollection(Of Part)) + m_PartList = value + End Set + End Property + + Protected m_SelPart As Part + Public Overridable Property SelPart As Part + Get + Return m_SelPart + End Get + Set(value As Part) + m_SelPart = value + ' seleziono pezzo + EgtDeselectAll() + If Not IsNothing(value) Then EgtSelectObj(SelPart.nPartId) + EgtDraw() + NotifyPropertyChanged("SelPart") + End Set + End Property + + Protected m_nState As CalcStates = -1 + Public ReadOnly Property nState As CalcStates + Get + Return m_nState + End Get + End Property + + Public ReadOnly Property Calc_Background As SolidColorBrush + Get + If m_nState = 0 Then + Return Brushes.Green + ElseIf m_nState < 0 Then + Return Brushes.LightGray + ElseIf m_nState > 0 Then + Return Brushes.Red + End If + End Get + End Property + + Sub New(nId As Integer, sName As String, sMachine As String) + MyBase.New(nId, sName, sMachine) + 'aggiorno lista pezzi + RefreshPartList() + End Sub + + Public MustOverride Sub RefreshPartList() + + Public MustOverride Sub RefreshGroupData() + + Public Overridable Sub DeleteMachGroup() + ' elimino tutte le copie + Dim nRawPartId As Integer = EgtGetFirstRawPart() + Dim nBeamId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nRawPartId <> GDB_ID.NULL + EgtRemovePartFromRawPart(nBeamId) + EgtErase(nBeamId) + nRawPartId = EgtGetNextRawPart(nRawPartId) + nBeamId = EgtGetFirstPartInRawPart(nRawPartId) + End While + ' elimino MachGroup + EgtRemoveMachGroup(Me.Id) + End Sub + + Public Sub CalcMachGroupUpdate() + m_nState = CalcStates.OK + For Each Part In PartList + If Part.nGlobalState > 0 AndAlso m_nState = CalcStates.OK Then + m_nState = CalcStates.ERROR_ + End If + Next + NotifyPropertyChanged("Calc_Background") + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/Part.vb b/EgtBEAMWALL.Core/Part.vb new file mode 100644 index 00000000..683b1a6e --- /dev/null +++ b/EgtBEAMWALL.Core/Part.vb @@ -0,0 +1,350 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports System.Windows.Input +Imports System.Windows.Media +Imports EgtUILib +Imports EgtWPFLib5 + +Public MustInherit Class Part + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Protected m_ParentMachGroup As MyMachGroup + Public ReadOnly Property ParentMachGroup As MyMachGroup + Get + Return m_ParentMachGroup + End Get + End Property + + ' Id geometrico del pezzo + Protected m_nPartId As Integer + Public ReadOnly Property nPartId As Integer + Get + Return m_nPartId + End Get + End Property + Friend Sub SetPartId(nPartId As Integer) + m_nPartId = nPartId + End Sub + ' Info del pezzo + Protected m_nPDN As Integer + Public ReadOnly Property nPDN As Integer + Get + Return m_nPDN + End Get + End Property + + Protected m_sNAM As String + Public ReadOnly Property sNAM As String + Get + Return m_sNAM + End Get + End Property + + Protected m_dL As Double + Public Property dL As Double + Get + Return m_dL + End Get + Set(value As Double) + m_dL = value + End Set + End Property + + Protected m_dW As Double + Public Property dW As Double + Get + Return m_dW + End Get + Set(value As Double) + m_dW = value + End Set + End Property + + Protected m_dH As Double + Public Property dH As Double + Get + Return m_dH + End Get + Set(value As Double) + m_dH = value + End Set + End Property + + Protected m_dPOSX As Double + Public Property sPOSX As String + Get + Return LenToString(m_dPOSX, 3) + End Get + Set(value As String) + StringToLen(value, m_dPOSX) + End Set + End Property + Public Property dPOSX As Double + Get + Return m_dPOSX + End Get + Set(value As Double) + m_dPOSX = value + NotifyPropertyChanged("sPOSX") + End Set + End Property + + Protected m_nCNT As Integer + Public Property nCNT As Integer + Get + Return m_nCNT + End Get + Set(value As Integer) + m_nCNT = value + End Set + End Property + + Protected m_nINVERTED As Integer + Public ReadOnly Property sINVERTED As String + Get + Return m_nINVERTED & "°" + End Get + End Property + Public Sub SetInverted(nInverted As Integer) + m_nINVERTED = nInverted + End Sub + + Protected m_nROTATED As Integer + Public ReadOnly Property sROTATED As String + Get + Return m_nROTATED & "°" + End Get + End Property + Public Sub SetRotated(nRotated As Integer) + m_nROTATED = nRotated + End Sub + + Protected m_sMATERIAL As String + Public Property sMATERIAL As String + Get + Return m_sMATERIAL + End Get + Set(value As String) + m_sMATERIAL = value + End Set + End Property + + Protected m_nGlobalState As CalcStates = -1 + Public ReadOnly Property nGlobalState As CalcStates + Get + Return m_nGlobalState + End Get + End Property + + Protected m_nState As CalcStates = -1 + Public Property nState As CalcStates + Get + Return m_nState + End Get + Set(value As CalcStates) + m_nState = value + End Set + End Property + + Public ReadOnly Property Calc_Background As SolidColorBrush + Get + If m_nGlobalState = 0 Then + Return Brushes.Green + ElseIf m_nGlobalState < 0 Then + Return Brushes.LightGray + ElseIf m_nGlobalState > 0 Then + Return Brushes.Red + End If + End Get + End Property + + Protected m_nCALC_ERR As Integer + Public ReadOnly Property nCALC_ERR As Integer + Get + Return m_nCALC_ERR + End Get + End Property + + Protected m_sCALC_MSG As String = String.Empty + Public ReadOnly Property nCALC_MSG As String + Get + Return m_sCALC_MSG + End Get + End Property + + Protected m_nCALC_ROT As Integer + Public Property nCALC_ROT As Integer + Get + Return m_nCALC_ROT + End Get + Set(value As Integer) + m_nCALC_ROT = value + End Set + End Property + + Protected m_nCALC_FALL As Integer + Public Property nCALC_FALL As Integer + Get + Return m_nCALC_FALL + End Get + Set(value As Integer) + m_nCALC_FALL = value + End Set + End Property + + Protected m_nCALC_TIME As Integer + Public Property nCALC_TIME As Integer + Get + Return m_nCALC_TIME + End Get + Set(value As Integer) + m_nCALC_TIME = value + End Set + End Property + + ' lista delle feature del pezzo + Protected m_FeatureList As ObservableCollection(Of BTLFeature) + Public Property FeatureList As ObservableCollection(Of BTLFeature) + Get + Return m_FeatureList + End Get + Set(value As ObservableCollection(Of BTLFeature)) + m_FeatureList = value + End Set + End Property + + Protected m_SelFeature As BTLFeature + Public Property SelFeature As Core.BTLFeature + Get + Return m_SelFeature + End Get + Set(value As Core.BTLFeature) + m_SelFeature = value + EgtDeselectAll() + If Not IsNothing(value) Then EgtSelectObj(m_SelFeature.nFeatureId) + EgtDraw() + NotifyPropertyChanged("SelFeature") + End Set + End Property + + ' definizione comandi + Private m_cmdDeletePart As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New(nParentMachGroup As MyMachGroup, nPartId As Integer) + m_ParentMachGroup = nParentMachGroup + SetPartId(nPartId) + m_FeatureList = New ObservableCollection(Of BTLFeature) + End Sub + +#End Region ' CONSTRUCTOR + + ' funzione che aggiorna lo stato e gli errori dopo calcolo + Public Sub CalcPartUpdate(bCalc As Boolean, ERR As Integer, ROT As Integer, FALL As Integer, MSG As String) + If Not bCalc Then + nState = CalcStates.NOTCALCULATED + m_nCALC_ERR = 0 + m_nCALC_ROT = 0 + m_nCALC_FALL = 0 + m_sCALC_MSG = "" + Else + m_nCALC_ERR = ERR + m_nCALC_ROT = ROT + m_nCALC_FALL = 0 + m_sCALC_MSG = MSG + If ERR = 0 Then + nState = CalcStates.OK + ElseIf ERR > 1 Then + nState = CalcStates.ERROR_ + ElseIf ERR < 1 Then + nState = CalcStates.NOTCALCULATED + End If + End If + NotifyPropertyChanged("Calc_Background") + End Sub + + ' funzione che aggiorna lo stato e gli errori dopo calcolo + Public Sub CalcFeatureUpdate() + m_nGlobalState = nState + For Each Feature In FeatureList + If Not Feature.bDO Then + + ElseIf Feature.nState < 0 Then + m_nGlobalState = CalcStates.NOTCALCULATED + Exit For + ElseIf Feature.nState > 0 AndAlso m_nGlobalState = CalcStates.OK Then + m_nGlobalState = CalcStates.ERROR_ + End If + Next + NotifyPropertyChanged("Calc_Background") + End Sub + +#Region "COMMANDS" + +#Region "DeletePart" + + ' Returns a command that manage the MainWindow_Unloaded command + Public ReadOnly Property DeletePart_Command() As ICommand + Get + If m_cmdDeletePart Is Nothing Then + m_cmdDeletePart = New Command(AddressOf DeletePart) + End If + Return m_cmdDeletePart + End Get + End Property + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Public Overridable Sub DeletePart() + EgtRemovePartFromRawPart(Me.m_nPartId) + ' elimino pezzo copia + EgtErase(Me.m_nPartId) + ' elimino info pezzo su mach group + Dim sInfo As String = "" + Dim Index As Integer = 1 + Dim sSplitInfo() As String + Dim bFound As Boolean = False + While EgtGetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo) + If Not String.IsNullOrWhiteSpace(sInfo) Then + sSplitInfo = sInfo.Split(","c) + If bFound Then + EgtSetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index - 1, sInfo) + End If + If sSplitInfo(0) = nPartId Then + bFound = True + End If + End If + Index += 1 + End While + If bFound Then + EgtSetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index - 1, "") + End If + ' rimuovo dalla lista pezzi + Index = ParentMachGroup.PartList.IndexOf(Me) + If Index = 0 Then + If ParentMachGroup.PartList.Count > 0 Then + ParentMachGroup.SelPart = ParentMachGroup.PartList(0) + Else + ParentMachGroup.SelPart = Nothing + End If + ElseIf Index = ParentMachGroup.PartList.Count - 1 Then + If ParentMachGroup.PartList.Count > 1 Then + ParentMachGroup.SelPart = ParentMachGroup.PartList(ParentMachGroup.PartList.Count - 2) + Else + ParentMachGroup.SelPart = Nothing + End If + Else + ParentMachGroup.SelPart = ParentMachGroup.PartList(Index - 1) + End If + ParentMachGroup.PartList.Remove(Me) + End Sub + +#End Region ' DeletePart + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Core/SectionXMaterial.vb b/EgtBEAMWALL.Core/SectionXMaterial.vb new file mode 100644 index 00000000..4e8afadf --- /dev/null +++ b/EgtBEAMWALL.Core/SectionXMaterial.vb @@ -0,0 +1,226 @@ +Imports System.Windows +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class SectionXMaterial + Inherits VMBase + + Private Shared m_nType As MachineType + Public Shared Sub SetType(nType As MachineType) + m_nType = nType + End Sub + + Protected m_Material As List(Of String) + Public ReadOnly Property sMaterial As List(Of String) + Get + Return m_Material + End Get + End Property + + Protected m_MaterialForSameSection_List As New List(Of String) + Public Property MaterialForSameSection_List As List(Of String) + Get + Return m_MaterialForSameSection_List + End Get + Set(value As List(Of String)) + m_MaterialForSameSection_List = value + End Set + End Property + + Protected m_SelMaterialForSameSection As String + Public Property SelMaterialForSameSection As String + Get + Return m_SelMaterialForSameSection + End Get + Set(value As String) + m_SelMaterialForSameSection = value + End Set + End Property + + Protected m_dW As Double = 0 + Public ReadOnly Property dW As Double + Get + Return m_dW + End Get + End Property + + Protected m_dH As Double = 0 + Public ReadOnly Property dH As Double + Get + Return m_dH + End Get + End Property + + Protected m_dL As Double = 0 + Public ReadOnly Property dL As Double + Get + Return m_dL + End Get + End Property + + Public ReadOnly Property sSectionXMaterial As String + Get + Dim sAlias As String = String.Empty + For Each sMatItem In sMaterial + sAlias &= sMatItem & ";" + Next + sAlias = sAlias.TrimEnd(";") + If Me = Empty Then + Return "" + ElseIf m_nType = MachineType.BEAM Then + Return LenToString(m_dW, 3) & " x " & LenToString(m_dH, 3) & " " & sAlias + ElseIf m_nType = MachineType.WALL Then + Return LenToString(m_dH, 3) & " " & sAlias + Else Return "" + End If + End Get + End Property + + Shared Operator =(ByVal S1 As SectionXMaterial, ByVal S2 As SectionXMaterial) As Boolean + Return (S1.m_dH = S2.m_dH AndAlso S1.m_dW = S2.m_dW AndAlso S1.m_dL = S2.m_dL AndAlso S1.m_Material.Any(Function(x) S2.m_Material.Any(Function(y) y = x))) + End Operator + + Shared Operator <>(ByVal S1 As SectionXMaterial, ByVal S2 As SectionXMaterial) As Boolean + Return (S1.m_dH <> S2.m_dH OrElse S1.m_dW <> S2.m_dW OrElse S1.m_dL <> S2.m_dL) OrElse Not S1.m_Material.Any(Function(x) S2.m_Material.Any(Function(y) y = x)) + End Operator + + Public Overrides Function Equals(ByVal obj As Object) As Boolean + If TypeOf obj Is SectionXMaterial Then + Return (m_dH = obj.dH AndAlso m_dW = obj.dW AndAlso m_dL = obj.dL AndAlso m_Material.Any(Function(x) DirectCast(obj.sMaterial, List(Of String)).Any(Function(y) y = x))) + End If + Return False + End Function + + Sub New(dW As Double, dH As Double, dL As Double, sMaterial As String) + If m_nType = MachineType.BEAM Then + m_dW = dW + m_dH = dH + ElseIf m_nType = MachineType.WALL Then + m_dH = dH + End If + m_Material = New List(Of String) + Dim sMaterialArray() As String = Split(sMaterial, ";") + For Each sMatItem In sMaterialArray + m_Material.Add(sMatItem) + Next + End Sub + + Public Shared Empty As New SectionXMaterial(-1, -1, -1, "") + +#Region "Import BTL <-> Warehouse" + + Private m_dNewW As Double + Public Property dNewW As Double + Get + Return m_dNewW + End Get + Set(value As Double) + m_dNewW = value + End Set + End Property + + Private m_dNewL As Double + Public Property dNewL As Double + Get + Return m_dNewL + End Get + Set(value As Double) + m_dNewL = value + End Set + End Property + + Private m_Alias_IsEnabled As Boolean + Public Property Alias_IsEnabled As Boolean + Get + Return m_Alias_IsEnabled + End Get + Set(value As Boolean) + m_Alias_IsEnabled = value + End Set + End Property + + Private m_Alias_IsChecked As Boolean + Public Property Alias_IsChecked As Boolean + Get + Return m_Alias_IsChecked + End Get + Set(value As Boolean) + m_Alias_IsChecked = value + If value Then + NewBeam_Visibility = Visibility.Collapsed + NewWall_Visibility = Visibility.Collapsed + Alias_Visibility = Visibility.Visible + Else + If m_nType = MachineType.BEAM Then + NewBeam_Visibility = Visibility.Visible + NewWall_Visibility = Visibility.Collapsed + Else + NewBeam_Visibility = Visibility.Collapsed + NewWall_Visibility = Visibility.Visible + End If + Alias_Visibility = Visibility.Collapsed + End If + End Set + End Property + + Private m_NewBeam_Visibility As Visibility + Public Property NewBeam_Visibility As Visibility + Get + Return m_NewBeam_Visibility + End Get + Set(value As Visibility) + If value <> m_NewBeam_Visibility Then + m_NewBeam_Visibility = value + NotifyPropertyChanged("NewBeam_Visibility") + End If + End Set + End Property + + Private m_NewWall_Visibility As Visibility + Public Property NewWall_Visibility As Visibility + Get + Return m_NewWall_Visibility + End Get + Set(value As Visibility) + If value <> m_NewWall_Visibility Then + m_NewWall_Visibility = value + NotifyPropertyChanged("NewWall_Visibility") + End If + End Set + End Property + + Private m_Alias_Visibility As Visibility + Public Property Alias_Visibility As Visibility + Get + Return m_Alias_Visibility + End Get + Set(value As Visibility) + If value <> m_Alias_Visibility Then + m_Alias_Visibility = value + NotifyPropertyChanged("Alias_Visibility") + End If + End Set + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61604) + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61605) + End Get + End Property + + Public ReadOnly Property H_Msg As String + Get + Return EgtMsg(61606) + End Get + End Property + +#End Region ' Import BTL <-> Warehouse + +End Class + diff --git a/EgtBEAMWALL.Core/Utility/BTLIniFile.vb b/EgtBEAMWALL.Core/Utility/BTLIniFile.vb new file mode 100644 index 00000000..b6fdfe4c --- /dev/null +++ b/EgtBEAMWALL.Core/Utility/BTLIniFile.vb @@ -0,0 +1,173 @@ +'---------------------------------------------------------------------------- +' EgalTech 2017-2017 +'---------------------------------------------------------------------------- +' File : IniFile.vb Data : 08.04.17 Versione : 1.8d1 +' Contenuto : Modulo IniFile per gestione lettura/scrittura da file INI. +' +' +' +' Modifiche : 08.04.17 ES Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Imports System.Collections.ObjectModel +Imports EgtUILib +Imports EgtWPFLib5 + +Public Module BTLIniFile + + Public m_sBTLIniFile As String + + Public Function GetBeamPrivateProfileProcessList(IpGRPType As GRPType, ByRef IpProcessList As ObservableCollection(Of Integer)) As Boolean + Dim PRCList As New ObservableCollection(Of Integer) + Dim sProcess As String = String.Empty + If EgtUILib.GetPrivateProfileString(PROCESSINGS, IpGRPType, String.Empty, sProcess, m_sBTLIniFile) > 0 Then + Dim sProcesses() As String = sProcess.Split(","c) + ' verifico ce ne sia almeno uno + If sProcesses.Count >= 0 Then + ' cancello spazi + For Index = 0 To sProcesses.Count - 1 + sProcesses(Index) = sProcesses(Index).Trim() + Dim nProcess As Integer + Integer.TryParse(sProcesses(Index), nProcess) + PRCList.Add(nProcess) + Next + IpProcessList = PRCList + Return True + End If + End If + Return False + End Function + + Public Function GetBeamPrivateProfileGRPList(IpGRP As Integer, IpPRC As Integer, ByRef IpGRPList As ObservableCollection(Of Integer)) As Boolean + IpGRPList.Clear() + ' ciclo sui tipi di gruppo + Dim sBTLGroup As String = String.Empty + If EgtUILib.GetPrivateProfileString(IpGRP & "." & IpPRC, BTL_FTR_GRP, String.Empty, sBTLGroup, m_sBTLIniFile) > 0 Then + Dim sBTLGroups() As String = sBTLGroup.Split(","c) + ' verifico numero minimo di parametri + If sBTLGroups.Count >= 0 Then + ' cancello spazi + For Index = 0 To sBTLGroups.Count - 1 + sBTLGroups(Index) = sBTLGroups(Index).Trim() + Next + ' creo parametro + For Each Group In sBTLGroups + Dim nGroup As Integer = -1 + Integer.TryParse(Group, nGroup) + If IpGRP = GRPType.L And (nGroup = 0 OrElse nGroup = 3 OrElse nGroup = 4) Then + IpGRPList.Add(nGroup) + ElseIf IpGRP = GRPType.T And (nGroup = 1 OrElse nGroup = 2) Then + IpGRPList.Add(nGroup) + End If + Next + End If + End If + Return IpGRPList.Count > 0 + End Function + + 'Public Function GetBeamPrivateProfileVerifyGRP(IpAppName As String, IpGPRtoVerify As String) As Boolean + ' ' ciclo sui tipi di gruppo + ' Dim sBTLGroup As String = String.Empty + ' If EgtUILib.GetPrivateProfileString(IpAppName, BTL_FTR_GRP, String.Empty, sBTLGroup, m_sBTLIniFile) > 0 Then + ' Dim sBTLGroups() As String = sBTLGroup.Split(","c) + ' ' verifico numero minimo di parametri + ' If sBTLGroups.Count >= 0 Then + ' ' cancello spazi + ' For Index = 0 To sBTLGroups.Count - 1 + ' sBTLGroups(Index) = sBTLGroups(Index).Trim() + ' Next + ' End If + ' Return sBTLGroups.Contains(IpGPRtoVerify) + ' End If + ' Return False + 'End Function + + Public Function CalcBeamPrivateProfileGRP(nGRP As Integer) As Integer + If nGRP = 1 Or nGRP = 2 Then + Return 1 + ElseIf nGRP = 0 Or nGRP = 3 Or nGRP = 4 Then + Return 0 + Else + Return nGRP + End If + End Function + + Public Function GetBeamPrivateProfileName(IpGRP As Integer, IpPRC As Integer, ByRef IpBTLFeature As BTLFeature) As Boolean + Dim sBTLName As String = String.Empty + ' creo lista GRP e leggo nome + If EgtUILib.GetPrivateProfileString(CalcBeamPrivateProfileGRP(IpGRP) & "." & IpPRC, BTL_FTR_NAME, String.Empty, sBTLName, m_sBTLIniFile) > 0 Then + ' verifico numero minimo di parametri + If Not String.IsNullOrEmpty(sBTLName) Then + Dim nNameMsg As Integer + Integer.TryParse(sBTLName, nNameMsg) + IpBTLFeature.SetName(EgtMsg(nNameMsg)) + Return True + End If + End If + Return False + End Function + + Public Function GetBeamPrivateProfileName(IpGRP As Integer, IpPRC As Integer) As String + Dim sBTLName As String = String.Empty + ' creo lista GRP e leggo nome + If EgtUILib.GetPrivateProfileString(CalcBeamPrivateProfileGRP(IpGRP) & "." & IpPRC, BTL_FTR_NAME, String.Empty, sBTLName, m_sBTLIniFile) > 0 Then + ' verifico numero minimo di parametri + If Not String.IsNullOrEmpty(sBTLName) Then + Dim nNameMsg As Integer + Integer.TryParse(sBTLName, nNameMsg) + Return EgtMsg(nNameMsg) + Return True + End If + End If + Return "" + End Function + + Public Function GetBeamPrivateProfileParam(IpGRP As Integer, IpPRC As Integer, IsP As Boolean, IpFeatureParamIndex As String, IpParentFeature As BTLFeature, ByRef IpBTLParam As BTLParam) As Boolean + Dim sBTLParam As String = String.Empty + If EgtUILib.GetPrivateProfileString(CalcBeamPrivateProfileGRP(IpGRP) & "." & IpPRC, If(IsP, "P", "Q") & IpFeatureParamIndex, String.Empty, sBTLParam, m_sBTLIniFile) > 0 Then + Dim sBTLParamParams() As String = sBTLParam.Split(","c) + ' verifico numero minimo di parametri + If sBTLParamParams.Count >= 6 Then + ' cancello spazi + For Index = 0 To sBTLParamParams.Count - 1 + sBTLParamParams(Index) = sBTLParamParams(Index).Trim() + Next + ' creo parametro + If sBTLParamParams(0) = "d" OrElse sBTLParamParams(0) = "l" Then + Dim dMin As Double + Dim dMax As Double + Dim dDefault As Double + StringToDouble(sBTLParamParams(2), dMin) + StringToDouble(sBTLParamParams(3), dMax) + StringToDouble(sBTLParamParams(4), dDefault) + Dim ParamType As BTLParamType + If sBTLParamParams(0) = "d" Then + ParamType = BTLParamType.DOUBLE_ + Else + ParamType = BTLParamType.LENGTH + End If + IpBTLParam = New BTLParam(IpParentFeature, IsP, ParamType, sBTLParamParams(1), dMin, dMax, dDefault, sBTLParamParams(5)) + Return Not IsNothing(IpBTLParam) + ElseIf sBTLParamParams(0) = "s" Then + IpBTLParam = New BTLParam(IpParentFeature, IsP, BTLParamType.STRING_, sBTLParamParams(1), sBTLParamParams(5)) + Return Not IsNothing(IpBTLParam) + ElseIf sBTLParamParams(0) = "c" Then + Dim nMin As Integer + Dim nMax As Integer + Dim nDefault As Integer + Integer.TryParse(sBTLParamParams(2), nMin) + Integer.TryParse(sBTLParamParams(3), nMax) + Integer.TryParse(sBTLParamParams(4), nDefault) + ' recupero lista valori + Dim ValueList As New List(Of String) + IpBTLParam = New BTLParam(IpParentFeature, IsP, BTLParamType.COMBO, sBTLParamParams(1), nMin, nMax, nDefault, sBTLParamParams(5), ValueList) + Return Not IsNothing(IpBTLParam) + End If + End If + End If + Return False + End Function + +End Module diff --git a/EgtBEAMWALL.Core/Utility/Command.vb b/EgtBEAMWALL.Core/Utility/Command.vb new file mode 100644 index 00000000..f64d83b6 --- /dev/null +++ b/EgtBEAMWALL.Core/Utility/Command.vb @@ -0,0 +1,70 @@ +Imports System.Windows.Input + +''' +''' A command whose sole purpose is to +''' relay its functionality to other +''' objects by invoking delegates. The +''' default return value for the CanExecute +''' method is 'true'. +''' +Public Class Command + Implements ICommand + +#Region "Fields" + + Private ReadOnly _execute As Action(Of Object) + Private ReadOnly _canExecute As Predicate(Of Object) + +#End Region ' Fields + +#Region "Constructors" + + ''' + ''' Creates a new command that can always execute. + ''' + ''' The execution logic. + Public Sub New(ByVal execute As Action(Of Object)) + Me.New(execute, Nothing) + End Sub + + ''' + ''' Creates a new command. + ''' + ''' The execution logic. + ''' The execution status logic. + Public Sub New(ByVal execute As Action(Of Object), ByVal canExecute As Predicate(Of Object)) + If execute Is Nothing Then + Throw New ArgumentNullException("execute") + End If + + _execute = execute + _canExecute = canExecute + End Sub + +#End Region ' Constructors + +#Region "ICommand Members" + + _ + Public Function CanExecute(ByVal parameter As Object) As Boolean Implements ICommand.CanExecute + Return If(_canExecute Is Nothing, True, _canExecute(parameter)) + End Function + + Public Custom Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged + AddHandler(ByVal value As EventHandler) + AddHandler CommandManager.RequerySuggested, value + End AddHandler + RemoveHandler(ByVal value As EventHandler) + RemoveHandler CommandManager.RequerySuggested, value + End RemoveHandler + RaiseEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) + End RaiseEvent + End Event + + Public Sub Execute(ByVal parameter As Object) Implements ICommand.Execute + _execute(parameter) + End Sub + +#End Region ' ICommand Members + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Core/Utility/VMBase.vb b/EgtBEAMWALL.Core/Utility/VMBase.vb new file mode 100644 index 00000000..b2d5ce6c --- /dev/null +++ b/EgtBEAMWALL.Core/Utility/VMBase.vb @@ -0,0 +1,12 @@ +Imports System.ComponentModel + +Public Class VMBase + Implements INotifyPropertyChanged + + Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged + + Public Sub NotifyPropertyChanged(propName As String) + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/Wall.vb b/EgtBEAMWALL.Core/Wall.vb new file mode 100644 index 00000000..fb4961cd --- /dev/null +++ b/EgtBEAMWALL.Core/Wall.vb @@ -0,0 +1,47 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class Wall + Inherits Part + + Protected m_dPOSY As Double + Public Property dPOSY As Double + Get + Return m_dPOSY + End Get + Set(value As Double) + m_dPOSY = value + End Set + End Property + + Protected m_dROT As Double + Public Property dROT As Double + Get + Return m_dROT + End Get + Set(value As Double) + m_dROT = value + End Set + End Property + + Protected m_dFLIP As Double + Public Property dFLIP As Double + Get + Return m_dFLIP + End Get + Set(value As Double) + m_dFLIP = value + End Set + End Property + +#Region "CONSTRUCTOR" + + Sub New(nParentMachGroup As MyMachGroup, nPartId As Integer) + MyBase.New(nParentMachGroup, nPartId) + End Sub + +#End Region ' CONSTRUCTOR + +End Class diff --git a/EgtBEAMWALL.Core/WallMachGroup.vb b/EgtBEAMWALL.Core/WallMachGroup.vb new file mode 100644 index 00000000..5711f5b5 --- /dev/null +++ b/EgtBEAMWALL.Core/WallMachGroup.vb @@ -0,0 +1,45 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class WallMachGroup + Inherits MyMachGroup + + Protected m_nRawPartId As Integer = GDB_ID.NULL + Public ReadOnly Property nRawPartId As Integer + Get + Return m_nRawPartId + End Get + End Property + + Sub New(nId As Integer, sName As String, sMachine As String) + MyBase.New(nId, sName, sMachine) + SetMachineType(MachineType.WALL) + m_nRawPartId = EgtGetFirstRawPart() + EgtGetInfo(nId, MGR_RPT_PANELLEN, dL) + EgtGetInfo(nId, MGR_RPT_PANELWIDTH, dW) + EgtGetInfo(nId, MGR_RPT_PANELHEIGHT, dH) + m_dTotMat = dL * dW + For Each Part In PartList + m_dMatForPart += (Part.dL * Part.dW) + Next + End Sub + + Public Overrides Sub RefreshPartList() + m_nRawPartId = EgtGetFirstRawPart() + PartList.Clear() + Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawPartId) + While nPartId <> GDB_ID.NULL + PartList.Add(New Wall(Me, nPartId)) + nPartId = EgtGetNextPartInRawPart(nPartId) + End While + End Sub + + Public Overrides Sub RefreshGroupData() + EgtGetInfo(Id, MGR_RPT_PANELLEN, dL) + EgtGetInfo(Id, MGR_RPT_PANELWIDTH, dW) + EgtGetInfo(Id, MGR_RPT_PANELHEIGHT, dH) + End Sub + +End Class diff --git a/EgtBEAMWALL.DataLayer/App.config b/EgtBEAMWALL.DataLayer/App.config new file mode 100644 index 00000000..e780891a --- /dev/null +++ b/EgtBEAMWALL.DataLayer/App.config @@ -0,0 +1,20 @@ + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.DataLayer/Constants.cs b/EgtBEAMWALL.DataLayer/Constants.cs new file mode 100644 index 00000000..a9bf2060 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Constants.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EgtBEAMWALL.DataLayer +{ + public static class Constants + { + + // Database config + public const string DATABASE_SERV = "127.0.0.1"; + public const string DATABASE_NAME = "EgtBwDb"; + public const string DATABASE_USER = "root"; + public const string DATABASE_PWD = "viacremasca"; + public static int DATABASE_PROCESS_TIMEOUT = 5; + + } +} diff --git a/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs b/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs new file mode 100644 index 00000000..7bb3cea9 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs @@ -0,0 +1,292 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DataLayer.DatabaseModels; + +namespace EgtBEAMWALL.DataLayer.Controllers +{ + public class BTLPartController : IDisposable + { + private DatabaseContext dbCtx; + + public BTLPartController() + { + // Initialize database context + dbCtx = new DatabaseContext(); + } + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + /// + /// Get record by DBId + /// + /// + /// + public BTLPartModel FindByDbId(int PartDbId) + { + return dbCtx + .BTLPartList + .Where(x => x.PartDbId == PartDbId) + .SingleOrDefault(); + } + /// + /// Get record by ExtId + /// + /// + /// + public BTLPartModel FindByPartId(int PartId) + { + return dbCtx + .BTLPartList + .Where(x => x.PartId == PartId) + .SingleOrDefault(); + } + /// + /// Get paginated data from DB (ASC ordered) + /// + /// + /// + /// + public List GetPaginatedAsc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.PartDbId <= PartDbIdStart) + .OrderBy(x => x.PartDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get paginated data from DB (DESC ordered) + /// + /// + /// + /// + public List GetPaginatedDesc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.PartDbId <= PartDbIdStart) + .OrderByDescending(x => x.PartDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get filtered data by ProjectId (ASC ordered) + /// + /// + /// + public List GetByProjectAsc(int ProjDbId) + { + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.ProjDbId == ProjDbId) + .OrderBy(x => x.PartDbId) + .ToList(); + } + /// + /// Get filtered data by ProjectId (DESC ordered) + /// + /// + /// + public List GetByProjectDesc(int ProjDbId) + { + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.ProjDbId == ProjDbId) + .OrderByDescending(x => x.PartDbId) + .ToList(); + } + + /// + /// Create multiple (empty) BTLPart record associated to Project + /// + /// + /// + /// + public List CreateBaseObj(int ProjDbId, List rawListData) + { + List partData = new List(); + + foreach (var item in rawListData) + { + BTLPartModel newItem = new BTLPartModel() { ProjDbId = ProjDbId, PartId = item }; + partData.Add(newItem); + } + + try + { + // Add to database + dbCtx.BTLPartList.AddRange(partData); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + + return partData; + } + + + /// + /// Create multiple BTLPart record associated to Project + /// + /// + /// + /// + public List Create(int ProjID, List partData) + { + // se è adv mode --> uso TUTTI i dati + if (DbManager.AdvDataModel) + { + try + { + // Add to database + dbCtx.BTLPartList.AddRange(partData); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + return partData; + } + // se non adv --> faccio solo copia degli id... + else + { + List partIdList = new List(); + foreach (var item in partData) + { + partIdList.Add(item.PartId); + } + return CreateBaseObj(ProjID, partIdList); + } + } + + /// + /// Update single BTLPart + /// + /// + /// + public bool Update(BTLPartModel updItem) + { + bool done = false; + var item2del = dbCtx + .BTLPartList + .Where(x => x.PartDbId == updItem.PartDbId) + .SingleOrDefault(); + try + { + // update, vers 1... + dbCtx.Entry(item2del).CurrentValues.SetValues(updItem); + + //// update, vers 2 + //dbCtx.BTLPartList.Remove(item2del); + //dbCtx.BTLPartList.Add(updItem); + + // Commit changes + dbCtx.SaveChanges(); + done = true; + } + catch + { } + return done; + } + + /// + /// Delete single BTLPart + /// + /// + /// + public bool Delete(int PartDbId) + { + bool done = false; + var item2del = dbCtx + .BTLPartList + .Where(x => x.PartDbId == PartDbId) + .SingleOrDefault(); + try + { + // Add to database + dbCtx.BTLPartList.Remove(item2del); + // Commit changes + dbCtx.SaveChanges(); + done = true; + } + catch + { } + return done; + } + /// + /// Delete BTLPart by project + /// + /// + /// + public bool DeleteByProject(int ProjDbId) + { + bool done = false; + var items2del = dbCtx + .BTLPartList + .Where(x => x.ProjDbId == ProjDbId); + try + { + // Add to database + dbCtx.BTLPartList.RemoveRange(items2del); + // Commit changes + dbCtx.SaveChanges(); + done = true; + } + catch + { } + return done; + } + + /// + /// Conversion of base class to DB model class + /// + /// + /// + public BTLPartModel Convert(Core.BTLPart corePart) + { + BTLPartModel answ = new BTLPartModel(); + if (corePart != null) + { + answ = new BTLPartModel() + { + PartId = corePart.nPartId, + PDN = corePart.nPDN, + DO = corePart.bDO, + NAM = corePart.sNAM, + W = corePart.dW, + L = corePart.dL, + H = corePart.dH, + MAT = corePart.sMATERIAL, + CNT = corePart.nCNT, + TBP = corePart.nTBP, + DON = corePart.nDON, + ROT = corePart.nROT, + GRP = corePart.sGRP, + UNT = corePart.nUNT, + CALC_State = (int)corePart.nState + }; + } + return answ; + } + + } +} diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs new file mode 100644 index 00000000..778431d3 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DataLayer.DatabaseModels; + +namespace EgtBEAMWALL.DataLayer.Controllers +{ + public class ProdController : IDisposable + { + private DatabaseContext dbCtx; + + public ProdController() + { + // Initialize database context + dbCtx = new DatabaseContext(); + } + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + /// + /// Get record by RawPartDbId + /// + /// + /// + public ProdModel FindByRawPartDbId(int RawPartDbId) + { + var rawPart = dbCtx + .RawPartList + .Where(x => x.RawPartDbId == RawPartDbId) + .SingleOrDefault(); + + return FindByProdDbId(rawPart.ProdDbId); + } + /// + /// Get record by RawPartId + /// + /// + /// + public ProdModel FindByRawPartId(int RawPartId) + { + var rawPart = dbCtx + .RawPartList + .Where(x => x.RawPartId == RawPartId) + .SingleOrDefault(); + + return FindByProdDbId(rawPart.ProdDbId); + } + /// + /// Get record by ProdDbId + /// + /// + /// + public ProdModel FindByProdDbId(int ProdDbId) + { + return dbCtx + .ProdList + .Where(x => x.ProdDbId == ProdDbId) + .SingleOrDefault(); + } + /// + /// Get record by ProdId + /// + /// + /// + public ProdModel FindByProdId(int ProdId) + { + return dbCtx + .ProdList + .Where(x => x.ProdId == ProdId) + .SingleOrDefault(); + } + /// + /// Get paginated data from DB (ASC ordered) + /// + /// + /// + /// + public List GetPaginatedAsc(int ProdDbIdStart, int numRecord) + { + int numEnd = ProdDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .ProdList + .Where(x => x.ProdDbId <= ProdDbIdStart) + .OrderBy(x => x.ProdDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get paginated data from DB (DESC ordered) + /// + /// + /// + /// + public List GetPaginatedDesc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .ProdList + .Where(x => x.ProdDbId <= PartDbIdStart) + .OrderByDescending(x => x.ProdDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get filtered data by ProdectId (ASC ordered) + /// + /// + /// + public List GetByProdAsc(int ProdDbId) + { + // retrieve + return dbCtx + .ProdList + .Where(x => x.ProdDbId == ProdDbId) + .OrderBy(x => x.ProdDbId) + .ToList(); + } + /// + /// Get filtered data by ProdectId (DESC ordered) + /// + /// + /// + public List GetByProdDesc(int ProdDbId) + { + // retrieve + return dbCtx + .ProdList + .Where(x => x.ProdDbId == ProdDbId) + .OrderByDescending(x => x.ProdDbId) + .ToList(); + } + + /// + /// Create record on DB + /// + /// + /// + /// + public ProdModel Create(int newProdId, string Description) + { + ProdModel newProd = new ProdModel() { ProdId = newProdId, Description = Description }; + + try + { + // Add to database + dbCtx.ProdList.Add(newProd); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + + return newProd; + } + + + } +} diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs new file mode 100644 index 00000000..3cb72efc --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DataLayer.DatabaseModels; + +namespace EgtBEAMWALL.DataLayer.Controllers +{ + public class ProjController : IDisposable + { + private DatabaseContext dbCtx; + + public ProjController() + { + // Initialize database context + dbCtx = new DatabaseContext(); + } + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + /// + /// Get record by ProjDbId + /// + /// + /// + public ProjModel FindByProjDbId(int ProjDbId) + { + return dbCtx + .ProjList + .Where(x => x.ProjDbId == ProjDbId) + .SingleOrDefault(); + } + /// + /// Get record by ProjId + /// + /// + /// + public ProjModel FindByProjId(int ProjId) + { + return dbCtx + .ProjList + .Where(x => x.ProjId == ProjId) + .SingleOrDefault(); + } + /// + /// Get paginated data from DB (ASC ordered) + /// + /// + /// + /// + public List GetPaginatedAsc(int ProjDbIdStart, int numRecord) + { + int numEnd = ProjDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProjDbId <= ProjDbIdStart) + .OrderBy(x => x.ProjDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get paginated data from DB (DESC ordered) + /// + /// + /// + /// + public List GetPaginatedDesc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProjDbId <= PartDbIdStart) + .OrderByDescending(x => x.ProjDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get filtered data by ProjectId (ASC ordered) + /// + /// + /// + public List GetByProdAsc(int ProdDbId) + { + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProdDbId == ProdDbId) + .OrderBy(x => x.ProdDbId) + .ToList(); + } + /// + /// Get filtered data by ProjectId (DESC ordered) + /// + /// + /// + public List GetByProdDesc(int ProdDbId) + { + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProdDbId == ProdDbId) + .OrderByDescending(x => x.ProdDbId) + .ToList(); + } + + /// + /// Create record on DB + /// + /// + /// + /// + public ProjModel Create(int newProjId, string newBTLFileName) + { + ProjModel newProj = new ProjModel() { ProjId=newProjId, BTLFileName=newBTLFileName }; + + try + { + // Add to database + dbCtx.ProjList.Add(newProj); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + + return newProj; + } + + + } +} diff --git a/EgtBEAMWALL.DataLayer/Controllers/RawPartController.cs b/EgtBEAMWALL.DataLayer/Controllers/RawPartController.cs new file mode 100644 index 00000000..8f9e8922 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Controllers/RawPartController.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DataLayer.DatabaseModels; + +namespace EgtBEAMWALL.DataLayer.Controllers +{ + public class RawPartController : IDisposable + { + private DatabaseContext dbCtx; + + public RawPartController() + { + // Initialize database context + dbCtx = new DatabaseContext(); + } + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + /// + /// Get record by RawPartDbId + /// + /// + /// + public RawPartModel FindByRawPartDbId(int RawPartDbId) + { + return dbCtx + .RawPartList + .Where(x => x.RawPartDbId == RawPartDbId) + .SingleOrDefault(); + } + /// + /// Get record by RawPartId + /// + /// + /// + public RawPartModel FindByRawPartId(int RawPartId) + { + return dbCtx + .RawPartList + .Where(x => x.RawPartId == RawPartId) + .SingleOrDefault(); + } + /// + /// Get paginated data from DB (ASC ordered) + /// + /// + /// + /// + public List GetPaginatedAsc(int RawPartDbIdStart, int numRecord) + { + int numEnd = RawPartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .RawPartList + .Where(x => x.RawPartDbId <= RawPartDbIdStart) + .OrderBy(x => x.RawPartDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get paginated data from DB (DESC ordered) + /// + /// + /// + /// + public List GetPaginatedDesc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .RawPartList + .Where(x => x.RawPartDbId <= PartDbIdStart) + .OrderByDescending(x => x.RawPartDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get filtered data by RawPartectId (ASC ordered) + /// + /// + /// + public List GetByProdAsc(int ProdDbId) + { + // retrieve + return dbCtx + .RawPartList + .Where(x => x.ProdDbId == ProdDbId) + .OrderBy(x => x.ProdDbId) + .ToList(); + } + /// + /// Get filtered data by RawPartectId (DESC ordered) + /// + /// + /// + public List GetByProdDesc(int ProdDbId) + { + // retrieve + return dbCtx + .RawPartList + .Where(x => x.ProdDbId == ProdDbId) + .OrderByDescending(x => x.ProdDbId) + .ToList(); + } + + /// + /// Create record on DB + /// + /// + /// + /// + public RawPartModel Create(int newRawPartId, string description) + { + RawPartModel newRawPart = new RawPartModel() { RawPartId=newRawPartId, Description=description, State= RawPartState.ND }; + + try + { + // Add to database + dbCtx.RawPartList.Add(newRawPart); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + + return newRawPart; + } + + + } +} diff --git a/EgtBEAMWALL.DataLayer/DatabaseContext.cs b/EgtBEAMWALL.DataLayer/DatabaseContext.cs new file mode 100644 index 00000000..f01dadcb --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DatabaseContext.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Data.Entity; +using System.Data.Entity.Migrations; +using MySql.Data.Entity; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DataLayer.DatabaseModels; +using EgtBEAMWALL.DataLayer.Migrations; +using System.ServiceProcess; +//using EgtBEAMWALL.DataLayer.Migrations; +//using EgtBEAMWALL.DataLayer.Controllers; + +namespace EgtBEAMWALL.DataLayer +{ + + [DbConfigurationType(typeof(MySqlEFConfiguration))] + public class DatabaseContext : DbContext + { + /// + /// BTLParts management + /// + public DbSet BTLPartList { get; set; } + /// + /// Parts management + /// + public DbSet ProdList { get; set; } + /// + /// Parts management + /// + public DbSet ProjList { get; set; } + /// + /// Parts management + /// + public DbSet RawPartList { get; set; } + /// + /// Parts management + /// + public DbSet PartList { get; set; } + +#if false + /// + /// Db data mode + /// + public static bool AdvDataModel { get; set; } = false; +#endif + + //providerName="System.Data.EntityClient" + + + public static string CONNECTION_STRING = $"server={Constants.DATABASE_SERV};port=3306;database={Constants.DATABASE_NAME};uid={Constants.DATABASE_USER};pwd={Constants.DATABASE_PWD};"; + + public DatabaseContext() : base(CONNECTION_STRING) + { + } + + public static DatabaseContext Create() + { + return new DatabaseContext(); + } + + private static string getDbServiceName() + { + ServiceController[] services = ServiceController.GetServices(); + var service = services.FirstOrDefault(s => s.ServiceName == "MariaDB"); + if (service != null) + return service.DisplayName; + + service = services.FirstOrDefault(s => s.ServiceName == "MySQL"); + if (service != null) + return service.DisplayName; + + return ""; + + } + + public static bool SetUpDbConnectionAndDbConfig() + { + try + { + String serviceName = getDbServiceName(); + if (serviceName.Equals("")) + { + return false; + } + + + ServiceController service = new ServiceController(serviceName); + try + { + TimeSpan timeout = TimeSpan.FromSeconds(Constants.DATABASE_PROCESS_TIMEOUT); + service.WaitForStatus(ServiceControllerStatus.Running, timeout); + } + catch (Exception ex) + { + return false; + } + + + + System.Data.Entity.Database.SetInitializer(null); + var migrator = new DbMigrator(new Configuration()); + + if (migrator.GetPendingMigrations().Any()) + { + // Run migrations and seed. + migrator.Update(); + } + + } + catch (Exception ex) + { + return false; + } + + return true; + } + + } +} \ No newline at end of file diff --git a/EgtBEAMWALL.DataLayer/DatabaseModels/BTLPartModel.cs b/EgtBEAMWALL.DataLayer/DatabaseModels/BTLPartModel.cs new file mode 100644 index 00000000..cb470ae9 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DatabaseModels/BTLPartModel.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DataLayer.DatabaseModels +{ + /// + /// Tabella di gestione dei PROTOTIPI dal file BTL (part + quantità) + /// + [Table("BTLPartList")] + public class BTLPartModel + { + /// + /// Chiave univoca + /// + [Key, Column("BTLPartDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int PartDbId { get; set; } + + /// + /// PartId dal programma + /// + [Column("BTLPartId")] + public int PartId { get; set; } + + [Column("BTLPart_PDN")] + public int PDN { get; set; } = 0; + + [Column("BTLPart_DO")] + public bool DO { get; set; } = false; + + [Column("BTLPart_NAM")] + public string NAM { get; set; } = ""; + + [Column("BTLPart_W")] + public double W { get; set; } = 0; + + [Column("BTLPart_L")] + public double L { get; set; } = 0; + + [Column("BTLPart_H")] + public double H { get; set; } = 0; + + [Column("BTLPart_MAT")] + public string MAT { get; set; } = ""; + + /// + /// Quantità richiesta + /// + [Column("BTLPart_CNT")] + public int CNT { get; set; } = 0; + + [Column("BTLPart_TBP")] + public int TBP { get; set; } = 0; + + [Column("BTLPart_DON")] + public int DON { get; set; } = 0; + + [Column("BTLPart_ROT")] + public int ROT { get; set; } = 0; + + [Column("BTLPart_GRP")] + public string GRP { get; set; } = ""; + + [Column("BTLPart_UNT")] + public int UNT { get; set; } = 0; + + [Column("BTLPart_CalcState")] + public int CALC_State { get; set; } = -1; + + [Column("ProjDbId")] + public int ProjDbId { get; set; } + + [ForeignKey("ProjDbId")] + public ProjModel Project { get; set; } + + } +} diff --git a/EgtBEAMWALL.DataLayer/DatabaseModels/PartModel.cs b/EgtBEAMWALL.DataLayer/DatabaseModels/PartModel.cs new file mode 100644 index 00000000..8b3771a1 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DatabaseModels/PartModel.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DataLayer.DatabaseModels +{ + /// + /// Tabelal delle singole istsanze prodotte\ + /// + [Table("PartList")] + public class PartModel + { + [Key, Column("PartDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int PartDbId { get; set; } + + [Column("PartId")] + public int PartId { get; set; } + + [Column("Part_PDN")] + public int PDN { get; set; } = 0; + + [Column("Part_NAM")] + public string NAM { get; set; } = ""; + + [Column("Part_W")] + public double W { get; set; } = 0; + + [Column("Part_L")] + public double L { get; set; } = 0; + + [Column("Part_H")] + public double H { get; set; } = 0; + + [Column("Part_MAT")] + public string MAT { get; set; } = ""; + + [Column("Part_ROT")] + public int ROT { get; set; } = 0; + + [Column("Part_GRP")] + public string GRP { get; set; } = ""; + + [Column("Part_CalcState")] + public int CALC_State { get; set; } = -1; + + /// + /// Stato della singola Part (da enum) + /// + [Column("Part_State")] + public PartState State { get; set; } = PartState.ND; + + [Column("BTLPartDbId")] + public int BTLPartDbId { get; set; } + + [ForeignKey("BTLPartDbId")] + public BTLPartModel BTLPart { get; set; } + + [Column("RawPartDbId")] + public int? RawPartDbId { get; set; } + + [ForeignKey("RawPartDbId")] + public virtual RawPartModel RawPart { get; set; } + + } +} diff --git a/EgtBEAMWALL.DataLayer/DatabaseModels/ProdModel.cs b/EgtBEAMWALL.DataLayer/DatabaseModels/ProdModel.cs new file mode 100644 index 00000000..9705aa61 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DatabaseModels/ProdModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DataLayer.DatabaseModels +{ + /// + /// Tabella deiu raggruppamenti PROJ in forma di PROD + /// + [Table("ProdList")] + public class ProdModel + { + [Key, Column("ProdDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ProdDbId { get; set; } + + [Column("ProdId")] + public int ProdId { get; set; } + + [Column("Prod_Description")] + public string Description { get; set; } = ""; + + [Column("Prod_Lock")] + public bool Locked { get; set; } = false; + + } +} diff --git a/EgtBEAMWALL.DataLayer/DatabaseModels/ProjModel.cs b/EgtBEAMWALL.DataLayer/DatabaseModels/ProjModel.cs new file mode 100644 index 00000000..f5a1a33f --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DatabaseModels/ProjModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DataLayer.DatabaseModels +{ + /// + /// Tabella dei PROJ caricati dal BTL + /// + [Table("ProjList")] + public class ProjModel + { + [Key, Column("ProjDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ProjDbId { get; set; } + + [Column("ProjId")] + public int ProjId { get; set; } + + [Column("Proj_BTLFileName")] + public string BTLFileName { get; set; } = ""; + + [Column("ProdDbId")] + public int? ProdDbId { get; set; } + + [ForeignKey("ProdDbId")] + public virtual ProdModel Prod { get; set; } + } +} diff --git a/EgtBEAMWALL.DataLayer/DatabaseModels/RawPartModel.cs b/EgtBEAMWALL.DataLayer/DatabaseModels/RawPartModel.cs new file mode 100644 index 00000000..37349d29 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DatabaseModels/RawPartModel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DataLayer.DatabaseModels +{ + /// + /// Tabella dei grezzi + /// + [Table("RawPartList")] + public class RawPartModel + { + [Key, Column("RawPartDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int RawPartDbId { get; set; } + + [Column("RawPartId")] + public int RawPartId { get; set; } + + [Column("RawPart_Descript")] + public string Description { get; set; } = ""; + + [Column("RawPart_State")] + public RawPartState State { get; set; } = RawPartState.ND; + + [Column("RawPart_Assign")] + public string Assign { get; set; } = ""; + + [Column("ProdDbId")] + public int ProdDbId { get; set; } + + [ForeignKey("ProdDbId")] + public ProdModel Prod { get; set; } + } +} diff --git a/EgtBEAMWALL.DataLayer/DbManager.cs b/EgtBEAMWALL.DataLayer/DbManager.cs new file mode 100644 index 00000000..105c2f82 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/DbManager.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EgtBEAMWALL.DataLayer +{ + public class DbManager + { + public static bool AdvDataModel { get; set; } = false; + + public DbManager() + { + } + + public Controllers.ProjController ProjCtr = new Controllers.ProjController(); + public Controllers.BTLPartController BtlPartCtr = new Controllers.BTLPartController(); + + } +} diff --git a/EgtBEAMWALL.DataLayer/EgtBEAMWALL.DataLayer.csproj b/EgtBEAMWALL.DataLayer/EgtBEAMWALL.DataLayer.csproj new file mode 100644 index 00000000..aadab368 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/EgtBEAMWALL.DataLayer.csproj @@ -0,0 +1,99 @@ + + + + + Debug + AnyCPU + {24D7760E-662A-47E4-B729-B70126C24A31} + Library + Properties + EgtBEAMWALL.DataLayer + EgtBEAMWALL.DataLayer + v4.0 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.0.0\lib\net40\EntityFramework.dll + + + ..\packages\EntityFramework.6.0.0\lib\net40\EntityFramework.SqlServer.dll + + + ..\packages\MySql.Data.6.9.12\lib\net40\MySql.Data.dll + + + ..\packages\MySql.Data.Entity.6.9.12\lib\net40\MySql.Data.Entity.EF6.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 202103031811160_InitDb.cs + + + + + + + + + + + {f22835a1-83d8-4334-91bb-baaeb9cf59b1} + EgtBEAMWALL.Core + + + + + 202103031811160_InitDb.cs + + + + + copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.DataLayer.dll + + \ No newline at end of file diff --git a/EgtBEAMWALL.DataLayer/Enums.cs b/EgtBEAMWALL.DataLayer/Enums.cs new file mode 100644 index 00000000..32741785 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Enums.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EgtBEAMWALL.DataLayer +{ + + /// + /// Stati ammessi per le PARTS da tagliare + /// + public enum PartState + { + ND = -1, + RawAssigned = 0, + WIP = 1, + Produced = 2, + Scrapped = 3 + } + + /// + /// Stati ammessi per le RawParts + /// + public enum RawPartState + { + ND = -1, + Assigned = 0, + Wip = 1, + Produced = 2, + Scrapped = 3 + } +} diff --git a/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.Designer.cs b/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.Designer.cs new file mode 100644 index 00000000..e486f803 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.Designer.cs @@ -0,0 +1,29 @@ +// +namespace EgtBEAMWALL.DataLayer.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.0.0-20911")] + public sealed partial class InitDb : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(InitDb)); + + string IMigrationMetadata.Id + { + get { return "202103031811160_InitDb"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.cs b/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.cs new file mode 100644 index 00000000..44a5967f --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.cs @@ -0,0 +1,119 @@ +namespace EgtBEAMWALL.DataLayer.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class InitDb : DbMigration + { + public override void Up() + { + CreateTable( + "dbo.BTLPartList", + c => new + { + BTLPartDbId = c.Int(nullable: false, identity: true), + BTLPartId = c.Int(nullable: false), + BTLPart_PDN = c.Int(nullable: false), + BTLPart_DO = c.Boolean(nullable: false), + BTLPart_NAM = c.String(unicode: false), + BTLPart_W = c.Double(nullable: false), + BTLPart_L = c.Double(nullable: false), + BTLPart_H = c.Double(nullable: false), + BTLPart_MAT = c.String(unicode: false), + BTLPart_CNT = c.Int(nullable: false), + BTLPart_TBP = c.Int(nullable: false), + BTLPart_DON = c.Int(nullable: false), + BTLPart_ROT = c.Int(nullable: false), + BTLPart_GRP = c.String(unicode: false), + BTLPart_UNT = c.Int(nullable: false), + BTLPart_State = c.Int(nullable: false), + ProjDbId = c.Int(nullable: false), + }) + .PrimaryKey(t => t.BTLPartDbId) + .ForeignKey("dbo.ProjList", t => t.ProjDbId, cascadeDelete: true) + .Index(t => t.ProjDbId); + + CreateTable( + "dbo.ProjList", + c => new + { + ProjDbId = c.Int(nullable: false, identity: true), + ProjId = c.Int(nullable: false), + Proj_BTLFileName = c.String(unicode: false), + ProdDbId = c.Int(), + }) + .PrimaryKey(t => t.ProjDbId) + .ForeignKey("dbo.ProdList", t => t.ProdDbId) + .Index(t => t.ProdDbId); + + CreateTable( + "dbo.ProdList", + c => new + { + ProdDbId = c.Int(nullable: false, identity: true), + ProdId = c.Int(nullable: false), + Prod_Description = c.String(unicode: false), + Prod_Lock = c.Boolean(nullable: false), + }) + .PrimaryKey(t => t.ProdDbId); + + CreateTable( + "dbo.PartList", + c => new + { + PartDbId = c.Int(nullable: false, identity: true), + PartId = c.Int(nullable: false), + Part_PDN = c.Int(nullable: false), + Part_NAM = c.String(unicode: false), + Part_W = c.Double(nullable: false), + Part_L = c.Double(nullable: false), + Part_H = c.Double(nullable: false), + Part_MAT = c.String(unicode: false), + Part_ROT = c.Int(nullable: false), + Part_GRP = c.String(unicode: false), + Part_State = c.Int(nullable: false), + BTLPartDbId = c.Int(nullable: false), + RawPartDbId = c.Int(), + }) + .PrimaryKey(t => t.PartDbId) + .ForeignKey("dbo.BTLPartList", t => t.BTLPartDbId, cascadeDelete: true) + .ForeignKey("dbo.RawPartList", t => t.RawPartDbId) + .Index(t => t.BTLPartDbId) + .Index(t => t.RawPartDbId); + + CreateTable( + "dbo.RawPartList", + c => new + { + RawPartDbId = c.Int(nullable: false, identity: true), + RawPartId = c.Int(nullable: false), + RawPart_Descript = c.String(unicode: false), + RawPart_Lock = c.Boolean(nullable: false), + ProdDbId = c.Int(nullable: false), + }) + .PrimaryKey(t => t.RawPartDbId) + .ForeignKey("dbo.ProdList", t => t.ProdDbId, cascadeDelete: true) + .Index(t => t.ProdDbId); + + } + + public override void Down() + { + DropForeignKey("dbo.PartList", "RawPartDbId", "dbo.RawPartList"); + DropForeignKey("dbo.RawPartList", "ProdDbId", "dbo.ProdList"); + DropForeignKey("dbo.PartList", "BTLPartDbId", "dbo.BTLPartList"); + DropForeignKey("dbo.BTLPartList", "ProjDbId", "dbo.ProjList"); + DropForeignKey("dbo.ProjList", "ProdDbId", "dbo.ProdList"); + DropIndex("dbo.PartList", new[] { "RawPartDbId" }); + DropIndex("dbo.RawPartList", new[] { "ProdDbId" }); + DropIndex("dbo.PartList", new[] { "BTLPartDbId" }); + DropIndex("dbo.BTLPartList", new[] { "ProjDbId" }); + DropIndex("dbo.ProjList", new[] { "ProdDbId" }); + DropTable("dbo.RawPartList"); + DropTable("dbo.PartList"); + DropTable("dbo.ProdList"); + DropTable("dbo.ProjList"); + DropTable("dbo.BTLPartList"); + } + } +} diff --git a/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.resx b/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.resx new file mode 100644 index 00000000..a4259707 --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Migrations/202103031811160_InitDb.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1czW7jNhC+F+g7CDoWqJ3sYoF2Ye/CsZNNUDsJ4mRzDBiRdtTVjyvRafJsPfSR+gqlZEkWxR+RIp3Ei73FIvlxODPifBxx8t8//w4+P4WB84iS1I+joXvYO3AdFHkx9KPl0F3jxa+/uZ8//fzT4BiGT87Xst/7rB8ZGaVD9wHj1cd+P/UeUAjSXuh7SZzGC9zz4rAPYNx/d3Dwe//wsI8IhEuwHGdwtY6wH6L8B/k5jiMPrfAaBLMYoiAtnpOWeY7qnIMQpSvgoaF7vMRHx6PZ7Wg67U0ABlPwjBLXGQU+IMLMUbBwHRBFMQaYiPrxJkVznMTRcr4iD0Bw/bxCpN8CBCkqlvBx2111NQfvstX0twM7acOt1klWekw0gp8z8fLVDt2j6+klSHCukXpP0vcP9Ew9II8uk3iFEvx8hRbF+Gzw5P4Muk6fHt1vDq8GMyMzcYbuWYTfv3Od83UQgPsAVdqrqXmO4wR9QRFKAEbwEmCMEqLNM4jyZTEycGZsn68FY3JuBjC5KMcfxXGAQKSNcD6alRDE6cgr5Doz8DRF0RI/DF3yp+uc+E8Ilk8K0JvIJ28cGYSTdesct+UMk3hNJNOWcWo4/tRw/Gx0vXMdjc+vzVzh+ujS1JcMnfHqwnAJX64ud67nG1M9z8n2gQxf+yT+U2WzaqCcg0d/me9dHDzkYde5QkHenj74q01g6dW35Luq40kSh1dx0Niyy/a7ebxOvGyRsaTTNUiWCNNSDvrbmCCNFBlI9zBR6U87TChq3mKYIDOahgmi/hM/QNmPnb8f5CfkaEjDFSHXDyuD3226bD2QbmF8r9Fs6nXQxOtgZ6/j6XS3XgdNvW6CUi/xVxuquGOvm8beNwT1uIy61X9Q0hekpD8I5dsglHvBxiyQqYKbdOBTTYWBvwVAqsGvEIUf/yr+VPWqhcBmIxsFmR68QCgTrlhei3BVL55wRaNEuLKHUZQuQDpv2ZQhdXdtsRfscOMuJv3eI3Z3ZmRMP+s+xTBQppHxcLaHjoeP0jT2/Fyk5vFnIwu9uuMIOnJqvDEtRauJidcB9leB7xEJhu4vjNKEsOVSaFjIhT3o9Q4ZZPLqoSTzdBCMidZxAvwIs++pH3n+CgRSIRqjtIh4ZoBqlmbLBK1QlL2OUtWaTl/N0th12jQ06Nd8RO463AO9yNLy0/3W3lTiVsOTpIkBFTc9bKp8cBFNUIAwckbeJr09BqkHILsJkJcNWvBD2RIU3YGbjNDyRpmdTIV4AZ9kyY1w6xEznZq3dHFFMUNS9PPXd0XhEpRcQEB59HZFkXlUJKCY+Kv4IRvlRd4iCflbb6GIqIYritmCSoh9fT8Uyv9i0Vlonj0I0Oxhqn3LYk5W1jbD5olM0b0t8jyRKCqmlBzlOu5rDU1bEMK6S20OEWQMJiNQUh7uAAb3IEXZc/TEOlU2Zo4wvRdP/ZTYfHsq4YZBxotoqIxbCHBqtK4dBIpBoCKIeEXqyymsKcCh34kGVM1etHrqx8paJ/6nj6YDtR73qhXUbcH4YevxjoaBPBjKJUlPheXzvy+ySmg/tqgfXGorofxcohPpQUVBwR00w8n4cXxDzpwVuXN9ASraEHNlNdV20AYnAcNqo4W/KTK42hqol12iEDFj281bw0m4ynyDSyQUqUR332hSBzW9SrRR5seq0Fa1DfqbW3PFg0FfcL1uMAOrlR8ta9ftiifOfHPXbvzrXP9iW7jB6Hsp535bJW01E44TsESNVjI1kfTET1JchmrXGcOQ6aYYyMvZ2HjO2q4MYuWY7O/NOO7VQzr+sxSogDkhqwwzDpVnt9mdQTDcya5AggAkwu+h4zhYh5HCoVEOJoDSBMq+d3JQ7vIGdZzsJh4PJnuujpJ/POXB5A3qOLd8lFsdjCkfY6qDccrHONXByD+W8lDyBnWc/IYdDydvUMfJL9rxcPIGHY8ReF7eoI6Tf+jl4eQN6jj5914eTt6gjnMj0vONnp6Lb8M8pKJJ4y2v8qN1OHHWNAtBjV2QOfcx2y6Ti6F3cqV9vuKf5pv89nCmv8NLxtpTsQyJh6OHQl2aa0LdUa1aokHuIgUJp9f0I2jPj3iX5lT9SDTWnoplSDwcPRTqo3oT6o5q1YitxddzBi9reEtuZI9zmhBOa2zTFtW0wDO7kEyGHlrghsbE0JgVWqCEXfggw5uskKYujInDdLrRHOowZeGURWW+63jSlPir7Vb1rIT5hiW+hpYDtu1Z8uG2Nd6CJ0CzFAnLRFHZwTQSlniiYLgn7IxJdzW7VLNXaa9GemtQpJraS0yZ3NOmi+uQ1T/6MMs7zZ7nfwW5f/fyP8eBTxa87TEDkb9AKb6Ov6Fo6H7ofWiUqHYoF+2nKQw4OTWLNaOSra39tifn8rCf6aT1Pme3S8qNWbqB3NWu6JvAbGtH7+M46AxTu+8fxNEyT2nWsFTuktbSUxsg2O1afS1FZQXn1BJO7bq/qYpqZaImtq8Vi5q5kBVPrJUqmMDUChZM1XxjR81UeUMXoG36RBVj3yowd7LdltkiM8XTSSIzx9qSEK5MLMS+1TTuyo7Q2I6NJI25HQteqhw7961QcTemNKY/NriPLcZiha5Y4SpWiIotlmIjmtsK5XYCsOiAYF5baC8CvLV6uZ3sH0yJnIEZaokKMx+jExUGh6kWeqARVExqzcprmJ0LwTh3ELtWq3WtKRN+qlInP06nOrJ9uJquVTumaUKrZQv8i5sGJWtmJYqvUwj2fVV+dTLkjpyKL8iu3Unbti0FVfrVD99dGZdm0NqRO9FFA50LyPYl5LV8GHtzUa/lHrWpIduY0KvsNdo2sl5ptUelVezF7aYxucVVhf1aqqs2H+LI0fw+Jh6w4fOy0gpe+ZVoplobb5pLUTELrzpLMgeUz8EviuAVbwnnkKtLWVf0a9pS3MWbSVbX8ALVX7QRGjfolEq+mGImfiXbm6nz0hRcwihF9QlvsJCrk+CioMK9JvcG67VM3Jv3XrOXbN5gWVYnwXdkaY3qK/baCYm5tf9/TqJ+6i+3ENl/Q4+QR0Xbqs9ZtIjLyN+QqOzSyIbNEAaQhOJRgv0F8DBp9lCa5v/I6isI1qTLcXiP4Fl0scarNSZLRuF9QP2brYw8yObPS8xomQcX+Sei1MYSiJg+WQK6iI7WfgAruU84mTwBRMZKigRqZkucJVKXzxXSeRwpAhXqq8jUNQpXAQFLL6I5eERi2dp1SGtsMPHBMgFhWmBsx5OfxP1g+PTpf0/YPpzBXwAA + + + dbo + + \ No newline at end of file diff --git a/EgtBEAMWALL.DataLayer/Migrations/Configuration.cs b/EgtBEAMWALL.DataLayer/Migrations/Configuration.cs new file mode 100644 index 00000000..9c526a4a --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Migrations/Configuration.cs @@ -0,0 +1,31 @@ +namespace EgtBEAMWALL.DataLayer.Migrations +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Migrations; + using System.Linq; + + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = false; + } + + protected override void Seed(EgtBEAMWALL.DataLayer.DatabaseContext context) + { + // This method will be called after migrating to the latest version. + + // You can use the DbSet.AddOrUpdate() helper extension method + // to avoid creating duplicate seed data. E.g. + // + // context.People.AddOrUpdate( + // p => p.FullName, + // new Person { FullName = "Andrew Peters" }, + // new Person { FullName = "Brice Lambson" }, + // new Person { FullName = "Rowan Miller" } + // ); + // + } + } +} diff --git a/EgtBEAMWALL.DataLayer/Properties/AssemblyInfo.cs b/EgtBEAMWALL.DataLayer/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..bd9659fc --- /dev/null +++ b/EgtBEAMWALL.DataLayer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EgtBEAMWALL.DataLayer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EgtBEAMWALL.DataLayer")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("24d7760e-662a-47e4-b729-b70126c24a31")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2.2.12.1")] +[assembly: AssemblyFileVersion("2.2.12.1")] diff --git a/EgtBEAMWALL.DataLayer/packages.config b/EgtBEAMWALL.DataLayer/packages.config new file mode 100644 index 00000000..9b33c92a --- /dev/null +++ b/EgtBEAMWALL.DataLayer/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.DbDataLayer/App.config b/EgtBEAMWALL.DbDataLayer/App.config new file mode 100644 index 00000000..e6ff48ed --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/App.config @@ -0,0 +1,29 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.DbDataLayer/Constants.cs b/EgtBEAMWALL.DbDataLayer/Constants.cs new file mode 100644 index 00000000..5b058676 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Constants.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EgtBEAMWALL.DbDataLayer +{ + public static class Constants + { + + // Database config + public const string DATABASE_SERV = "127.0.0.1"; + public const string DATABASE_NAME = "EgtBwDb"; + public const string DATABASE_USER = "root"; + public const string DATABASE_PWD = "viacremasca"; + public static int DATABASE_PROCESS_TIMEOUT = 5; + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/Controllers/BTLPartController.cs b/EgtBEAMWALL.DbDataLayer/Controllers/BTLPartController.cs new file mode 100644 index 00000000..08a36cb2 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Controllers/BTLPartController.cs @@ -0,0 +1,292 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DbDataLayer.DatabaseModels; + +namespace EgtBEAMWALL.DbDataLayer.Controllers +{ + public class BTLPartController : IDisposable + { + private DatabaseContext dbCtx; + + public BTLPartController() + { + // Initialize database context + dbCtx = new DatabaseContext(); + } + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + /// + /// Get record by Id + /// + /// + /// + public BTLPartModel FindByDbId(int PartDbId) + { + return dbCtx + .BTLPartList + .Where(x => x.PartDbId == PartDbId) + .SingleOrDefault(); + } + /// + /// Get record by ExtId + /// + /// + /// + public BTLPartModel FindByPartId(int PartId) + { + return dbCtx + .BTLPartList + .Where(x => x.PartId == PartId) + .SingleOrDefault(); + } + /// + /// Get paginated data from DB (ASC ordered) + /// + /// + /// + /// + public List GetPaginatedAsc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.PartDbId <= PartDbIdStart) + .OrderBy(x => x.PartDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get paginated data from DB (DESC ordered) + /// + /// + /// + /// + public List GetPaginatedDesc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.PartDbId <= PartDbIdStart) + .OrderByDescending(x => x.PartDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get filtered data by ProjectId (ASC ordered) + /// + /// + /// + public List GetByProjectAsc(int ProjDbId) + { + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.ProjDbId == ProjDbId) + .OrderBy(x => x.PartDbId) + .ToList(); + } + /// + /// Get filtered data by ProjectId (DESC ordered) + /// + /// + /// + public List GetByProjectDesc(int ProjDbId) + { + // retrieve + return dbCtx + .BTLPartList + .Where(x => x.ProjDbId == ProjDbId) + .OrderByDescending(x => x.PartDbId) + .ToList(); + } + + /// + /// Create multiple (empty) Part record associated to Project + /// + /// + /// + /// + public List CreateBaseObj(int ProjDbId, List rawListData) + { + List partData = new List(); + + foreach (var item in rawListData) + { + BTLPartModel newItem = new BTLPartModel() { ProjDbId = ProjDbId, PartId = item }; + partData.Add(newItem); + } + + try + { + // Add to database + dbCtx.BTLPartList.AddRange(partData); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + + return partData; + } + + + /// + /// Create multipole Part record associated to Project + /// + /// + /// + /// + public List Create(int ProjID, List partData) + { + // se è adv mode --> uso TUTTI i dati + if (DbManager.AdvDataModel) + { + try + { + // Add to database + dbCtx.BTLPartList.AddRange(partData); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + return partData; + } + // se non adv --> faccio solo copia degli id... + else + { + List partIdList = new List(); + foreach (var item in partData) + { + partIdList.Add(item.PartId); + } + return CreateBaseObj(ProjID, partIdList); + } + } + + /// + /// Delete single Part + /// + /// + /// + public bool Update(BTLPartModel updItem) + { + bool done = false; + var item2del = dbCtx + .BTLPartList + .Where(x => x.PartDbId == updItem.PartDbId) + .SingleOrDefault(); + try + { + // update, vers 1... + dbCtx.Entry(item2del).CurrentValues.SetValues(updItem); + + //// update, vers 2 + //dbCtx.BTLPartList.Remove(item2del); + //dbCtx.BTLPartList.Add(updItem); + + // Commit changes + dbCtx.SaveChanges(); + done = true; + } + catch + { } + return done; + } + + /// + /// Delete single Part + /// + /// + /// + public bool Delete(int PartDbId) + { + bool done = false; + var item2del = dbCtx + .BTLPartList + .Where(x => x.PartDbId == PartDbId) + .SingleOrDefault(); + try + { + // Add to database + dbCtx.BTLPartList.Remove(item2del); + // Commit changes + dbCtx.SaveChanges(); + done = true; + } + catch + { } + return done; + } + /// + /// Delete Part by project + /// + /// + /// + public bool DeleteByProject(int ProjDbId) + { + bool done = false; + var items2del = dbCtx + .BTLPartList + .Where(x => x.ProjDbId == ProjDbId); + try + { + // Add to database + dbCtx.BTLPartList.RemoveRange(items2del); + // Commit changes + dbCtx.SaveChanges(); + done = true; + } + catch + { } + return done; + } + + /// + /// COnversion of base class to DB model class + /// + /// + /// + public BTLPartModel Convert(Core.BTLPart corePart) + { + BTLPartModel answ = new BTLPartModel(); + if (corePart != null) + { + answ = new BTLPartModel() + { + PartId = corePart.nPartId, + PDN = corePart.nPDN, + DO = corePart.bDO, + NAM = corePart.sNAM, + W = corePart.dW, + L = corePart.dL, + H = corePart.dH, + MAT = corePart.sMATERIAL, + CNT = corePart.nCNT, + TBP = corePart.nTBP, + DON = corePart.nDON, + ROT = corePart.nROT, + GRP = corePart.sGRP, + UNT = corePart.nUNT, + State = (int)corePart.nState + }; + } + return answ; + } + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/Controllers/ProjController.cs b/EgtBEAMWALL.DbDataLayer/Controllers/ProjController.cs new file mode 100644 index 00000000..5a50f6d1 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Controllers/ProjController.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DbDataLayer.DatabaseModels; + +namespace EgtBEAMWALL.DbDataLayer.Controllers +{ + public class ProjController : IDisposable + { + private DatabaseContext dbCtx; + + public ProjController() + { + // Initialize database context + dbCtx = new DatabaseContext(); + } + + public void Dispose() + { + // Clear database context + dbCtx.Dispose(); + } + /// + /// Get record by ProjDbId + /// + /// + /// + public ProjModel FindByProjDbId(int ProjDbId) + { + return dbCtx + .ProjList + .Where(x => x.ProjDbId == ProjDbId) + .SingleOrDefault(); + } + /// + /// Get record by ProjId + /// + /// + /// + public ProjModel FindByProjId(int ProjId) + { + return dbCtx + .ProjList + .Where(x => x.ProjId == ProjId) + .SingleOrDefault(); + } + /// + /// Get paginated data from DB (ASC ordered) + /// + /// + /// + /// + public List GetPaginatedAsc(int ProjDbIdStart, int numRecord) + { + int numEnd = ProjDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProjDbId <= ProjDbIdStart) + .OrderBy(x => x.ProjDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get paginated data from DB (DESC ordered) + /// + /// + /// + /// + public List GetPaginatedDesc(int PartDbIdStart, int numRecord) + { + int numEnd = PartDbIdStart - numRecord; + // check numEnd + if (numEnd < 0) + numEnd = 0; + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProjDbId <= PartDbIdStart) + .OrderByDescending(x => x.ProjDbId) + .Take(numRecord) + .ToList(); + } + /// + /// Get filtered data by ProjectId (ASC ordered) + /// + /// + /// + public List GetByProdAsc(int ProdDbId) + { + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProdDbId == ProdDbId) + .OrderBy(x => x.ProdDbId) + .ToList(); + } + /// + /// Get filtered data by ProjectId (DESC ordered) + /// + /// + /// + public List GetByProdDesc(int ProdDbId) + { + // retrieve + return dbCtx + .ProjList + .Where(x => x.ProdDbId == ProdDbId) + .OrderByDescending(x => x.ProdDbId) + .ToList(); + } + + /// + /// Create record on DB + /// + /// + /// + /// + public ProjModel Create(int newProjId, string newBTLFileName) + { + ProjModel newProj = new ProjModel() { ProjId=newProjId, BTLFileName=newBTLFileName }; + + try + { + // Add to database + dbCtx.ProjList.Add(newProj); + // Commit changes + dbCtx.SaveChanges(); + } + catch + { } + + return newProj; + } + + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/DatabaseContext.cs b/EgtBEAMWALL.DbDataLayer/DatabaseContext.cs new file mode 100644 index 00000000..73109274 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DatabaseContext.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Data.Entity; +using System.Data.Entity.Migrations; +using MySql.Data.Entity; +using System.Linq; +using System.Text; +using EgtBEAMWALL.DbDataLayer.DatabaseModels; +using EgtBEAMWALL.DbDataLayer.Migrations; +using System.ServiceProcess; +//using EgtBEAMWALL.DataLayer.Migrations; +//using EgtBEAMWALL.DataLayer.Controllers; + +namespace EgtBEAMWALL.DbDataLayer +{ + + [DbConfigurationType(typeof(MySqlEFConfiguration))] + public class DatabaseContext : DbContext + { + /// + /// BTLParts management + /// + public DbSet BTLPartList { get; set; } + /// + /// Parts management + /// + public DbSet ProdList { get; set; } + /// + /// Parts management + /// + public DbSet ProjList { get; set; } + /// + /// Parts management + /// + public DbSet RawPartList { get; set; } + /// + /// Parts management + /// + public DbSet PartList { get; set; } + +#if false + /// + /// Db data mode + /// + public static bool AdvDataModel { get; set; } = false; +#endif + + //providerName="System.Data.EntityClient" + + + public static string CONNECTION_STRING = $"server={Constants.DATABASE_SERV};port=3306;database={Constants.DATABASE_NAME};uid={Constants.DATABASE_USER};pwd={Constants.DATABASE_PWD};"; + + public DatabaseContext() : base(CONNECTION_STRING) + { + } + + public static DatabaseContext Create() + { + return new DatabaseContext(); + } + + private static string getDbServiceName() + { + ServiceController[] services = ServiceController.GetServices(); + var service = services.FirstOrDefault(s => s.ServiceName == "MariaDB"); + if (service != null) + return service.DisplayName; + + service = services.FirstOrDefault(s => s.ServiceName == "MySQL"); + if (service != null) + return service.DisplayName; + + return ""; + + } + + public static bool SetUpDbConnectionAndDbConfig() + { + try + { + String serviceName = getDbServiceName(); + if (serviceName.Equals("")) + { + return false; + } + + + ServiceController service = new ServiceController(serviceName); + try + { + TimeSpan timeout = TimeSpan.FromSeconds(Constants.DATABASE_PROCESS_TIMEOUT); + service.WaitForStatus(ServiceControllerStatus.Running, timeout); + } + catch (Exception ex) + { + return false; + } + + + + System.Data.Entity.Database.SetInitializer(null); + var migrator = new DbMigrator(new Configuration()); + + if (migrator.GetPendingMigrations().Any()) + { + // Run migrations and seed. + migrator.Update(); + } + + } + catch (Exception ex) + { + return false; + } + + return true; + } + + } +} \ No newline at end of file diff --git a/EgtBEAMWALL.DbDataLayer/DatabaseModels/BTLPartModel.cs b/EgtBEAMWALL.DbDataLayer/DatabaseModels/BTLPartModel.cs new file mode 100644 index 00000000..2e9b2281 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DatabaseModels/BTLPartModel.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DbDataLayer.DatabaseModels +{ + [Table("BTLPartList")] + public class BTLPartModel + { + [Key, Column("BTLPartDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int PartDbId { get; set; } + + [Column("BTLPartId")] + public int PartId { get; set; } + + [Column("BTLPart_PDN")] + public int PDN { get; set; } = 0; + + [Column("BTLPart_DO")] + public bool DO { get; set; } = false; + + [Column("BTLPart_NAM")] + public string NAM { get; set; } = ""; + + [Column("BTLPart_W")] + public double W { get; set; } = 0; + + [Column("BTLPart_L")] + public double L { get; set; } = 0; + + [Column("BTLPart_H")] + public double H { get; set; } = 0; + + [Column("BTLPart_MAT")] + public string MAT { get; set; } = ""; + + [Column("BTLPart_CNT")] + public int CNT { get; set; } = 0; + + [Column("BTLPart_TBP")] + public int TBP { get; set; } = 0; + + [Column("BTLPart_DON")] + public int DON { get; set; } = 0; + + [Column("BTLPart_ROT")] + public int ROT { get; set; } = 0; + + [Column("BTLPart_GRP")] + public string GRP { get; set; } = ""; + + [Column("BTLPart_UNT")] + public int UNT { get; set; } = 0; + + [Column("BTLPart_State")] + public int State { get; set; } = -1; + + [Column("ProjDbId")] + public int ProjDbId { get; set; } + + [ForeignKey("ProjDbId")] + public ProjModel Project { get; set; } + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/DatabaseModels/PartModel.cs b/EgtBEAMWALL.DbDataLayer/DatabaseModels/PartModel.cs new file mode 100644 index 00000000..e1dcb230 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DatabaseModels/PartModel.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DbDataLayer.DatabaseModels +{ + [Table("PartList")] + public class PartModel + { + [Key, Column("PartDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int PartDbId { get; set; } + + [Column("PartId")] + public int PartId { get; set; } + + [Column("Part_PDN")] + public int PDN { get; set; } = 0; + + [Column("Part_NAM")] + public string NAM { get; set; } = ""; + + [Column("Part_W")] + public double W { get; set; } = 0; + + [Column("Part_L")] + public double L { get; set; } = 0; + + [Column("Part_H")] + public double H { get; set; } = 0; + + [Column("Part_MAT")] + public string MAT { get; set; } = ""; + + [Column("Part_ROT")] + public int ROT { get; set; } = 0; + + [Column("Part_GRP")] + public string GRP { get; set; } = ""; + + [Column("Part_State")] + public int State { get; set; } = -1; + + [Column("BTLPartDbId")] + public int BTLPartDbId { get; set; } + + [ForeignKey("BTLPartDbId")] + public BTLPartModel BTLPart { get; set; } + + [Column("RawPartDbId")] + public int? RawPartDbId { get; set; } + + [ForeignKey("RawPartDbId")] + public virtual RawPartModel RawPart { get; set; } + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/DatabaseModels/ProdModel.cs b/EgtBEAMWALL.DbDataLayer/DatabaseModels/ProdModel.cs new file mode 100644 index 00000000..4f32564b --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DatabaseModels/ProdModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DbDataLayer.DatabaseModels +{ + [Table("ProdList")] + public class ProdModel + { + [Key, Column("ProdDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ProdDbId { get; set; } + + [Column("ProdId")] + public int ProdId { get; set; } + + [Column("Prod_Description")] + public string Description { get; set; } = ""; + + [Column("Prod_Lock")] + public bool Locked { get; set; } = false; + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/DatabaseModels/ProjModel.cs b/EgtBEAMWALL.DbDataLayer/DatabaseModels/ProjModel.cs new file mode 100644 index 00000000..f6cf5573 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DatabaseModels/ProjModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DbDataLayer.DatabaseModels +{ + [Table("ProjList")] + public class ProjModel + { + [Key, Column("ProjDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ProjDbId { get; set; } + + [Column("ProjId")] + public int ProjId { get; set; } + + [Column("Proj_BTLFileName")] + public string BTLFileName { get; set; } = ""; + + [Column("ProdDbId")] + public int? ProdDbId { get; set; } + + [ForeignKey("ProdDbId")] + public virtual ProdModel Prod { get; set; } + } +} diff --git a/EgtBEAMWALL.DbDataLayer/DatabaseModels/RawPartModel.cs b/EgtBEAMWALL.DbDataLayer/DatabaseModels/RawPartModel.cs new file mode 100644 index 00000000..1795e833 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DatabaseModels/RawPartModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EgtBEAMWALL.DbDataLayer.DatabaseModels +{ + [Table("RawPartList")] + public class RawPartModel + { + [Key, Column("RawPartDbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int RawPartDbId { get; set; } + + [Column("RawPartId")] + public int RawPartId { get; set; } + + [Column("RawPart_Descript")] + public string Description { get; set; } = ""; + + [Column("RawPart_Lock")] + public bool Locked { get; set; } = false; + + [Column("ProdDbId")] + public int ProdDbId { get; set; } + + [ForeignKey("ProdDbId")] + public ProdModel Prod { get; set; } + } +} diff --git a/EgtBEAMWALL.DbDataLayer/DbManager.cs b/EgtBEAMWALL.DbDataLayer/DbManager.cs new file mode 100644 index 00000000..59f802f8 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/DbManager.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EgtBEAMWALL.DbDataLayer +{ + public class DbManager + { + public static bool AdvDataModel { get; set; } = false; + + public DbManager() + { + } + + public Controllers.ProjController ProjCtr = new Controllers.ProjController(); + public Controllers.BTLPartController BtlPartCtr = new Controllers.BTLPartController(); + + } +} diff --git a/EgtBEAMWALL.DbDataLayer/EgtBEAMWALL.DbDataLayer.csproj b/EgtBEAMWALL.DbDataLayer/EgtBEAMWALL.DbDataLayer.csproj new file mode 100644 index 00000000..e055a694 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/EgtBEAMWALL.DbDataLayer.csproj @@ -0,0 +1,113 @@ + + + + + + Debug + AnyCPU + {5F1CDE84-FD6A-4107-968C-ECC4D64F8043} + Library + Properties + EgtBEAMWALL.DbDataLayer + EgtBEAMWALL.DbDataLayer + v4.5.2 + 512 + true + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\MySql.Data.6.10.9\lib\net452\MySql.Data.dll + + + ..\packages\MySql.Data.Entity.6.10.9\lib\net452\MySql.Data.Entity.EF6.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 202103031756343_InitDb.cs + + + + + + + + + + + {f22835a1-83d8-4334-91bb-baaeb9cf59b1} + EgtBEAMWALL.Core + + + + + 202103031756343_InitDb.cs + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.Designer.cs b/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.Designer.cs new file mode 100644 index 00000000..3353fa06 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.Designer.cs @@ -0,0 +1,29 @@ +// +namespace EgtBEAMWALL.DbDataLayer.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.4.4")] + public sealed partial class InitDb : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(InitDb)); + + string IMigrationMetadata.Id + { + get { return "202103031756343_InitDb"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.cs b/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.cs new file mode 100644 index 00000000..65807de8 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.cs @@ -0,0 +1,119 @@ +namespace EgtBEAMWALL.DbDataLayer.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class InitDb : DbMigration + { + public override void Up() + { + CreateTable( + "dbo.BTLPartList", + c => new + { + BTLPartDbId = c.Int(nullable: false, identity: true), + BTLPartId = c.Int(nullable: false), + BTLPart_PDN = c.Int(nullable: false), + BTLPart_DO = c.Boolean(nullable: false), + BTLPart_NAM = c.String(unicode: false), + BTLPart_W = c.Double(nullable: false), + BTLPart_L = c.Double(nullable: false), + BTLPart_H = c.Double(nullable: false), + BTLPart_MAT = c.String(unicode: false), + BTLPart_CNT = c.Int(nullable: false), + BTLPart_TBP = c.Int(nullable: false), + BTLPart_DON = c.Int(nullable: false), + BTLPart_ROT = c.Int(nullable: false), + BTLPart_GRP = c.String(unicode: false), + BTLPart_UNT = c.Int(nullable: false), + BTLPart_State = c.Int(nullable: false), + ProjDbId = c.Int(nullable: false), + }) + .PrimaryKey(t => t.BTLPartDbId) + .ForeignKey("dbo.ProjList", t => t.ProjDbId, cascadeDelete: true) + .Index(t => t.ProjDbId); + + CreateTable( + "dbo.ProjList", + c => new + { + ProjDbId = c.Int(nullable: false, identity: true), + ProjId = c.Int(nullable: false), + Proj_BTLFileName = c.String(unicode: false), + ProdDbId = c.Int(), + }) + .PrimaryKey(t => t.ProjDbId) + .ForeignKey("dbo.ProdList", t => t.ProdDbId) + .Index(t => t.ProdDbId); + + CreateTable( + "dbo.ProdList", + c => new + { + ProdDbId = c.Int(nullable: false, identity: true), + ProdId = c.Int(nullable: false), + Prod_Description = c.String(unicode: false), + Prod_Lock = c.Boolean(nullable: false), + }) + .PrimaryKey(t => t.ProdDbId); + + CreateTable( + "dbo.PartList", + c => new + { + PartDbId = c.Int(nullable: false, identity: true), + PartId = c.Int(nullable: false), + Part_PDN = c.Int(nullable: false), + Part_NAM = c.String(unicode: false), + Part_W = c.Double(nullable: false), + Part_L = c.Double(nullable: false), + Part_H = c.Double(nullable: false), + Part_MAT = c.String(unicode: false), + Part_ROT = c.Int(nullable: false), + Part_GRP = c.String(unicode: false), + Part_State = c.Int(nullable: false), + BTLPartDbId = c.Int(nullable: false), + RawPartDbId = c.Int(), + }) + .PrimaryKey(t => t.PartDbId) + .ForeignKey("dbo.BTLPartList", t => t.BTLPartDbId, cascadeDelete: true) + .ForeignKey("dbo.RawPartList", t => t.RawPartDbId) + .Index(t => t.BTLPartDbId) + .Index(t => t.RawPartDbId); + + CreateTable( + "dbo.RawPartList", + c => new + { + RawPartDbId = c.Int(nullable: false, identity: true), + RawPartId = c.Int(nullable: false), + RawPart_Descript = c.String(unicode: false), + RawPart_Lock = c.Boolean(nullable: false), + ProdDbId = c.Int(nullable: false), + }) + .PrimaryKey(t => t.RawPartDbId) + .ForeignKey("dbo.ProdList", t => t.ProdDbId, cascadeDelete: true) + .Index(t => t.ProdDbId); + + } + + public override void Down() + { + DropForeignKey("dbo.PartList", "RawPartDbId", "dbo.RawPartList"); + DropForeignKey("dbo.RawPartList", "ProdDbId", "dbo.ProdList"); + DropForeignKey("dbo.PartList", "BTLPartDbId", "dbo.BTLPartList"); + DropForeignKey("dbo.BTLPartList", "ProjDbId", "dbo.ProjList"); + DropForeignKey("dbo.ProjList", "ProdDbId", "dbo.ProdList"); + DropIndex("dbo.RawPartList", new[] { "ProdDbId" }); + DropIndex("dbo.PartList", new[] { "RawPartDbId" }); + DropIndex("dbo.PartList", new[] { "BTLPartDbId" }); + DropIndex("dbo.ProjList", new[] { "ProdDbId" }); + DropIndex("dbo.BTLPartList", new[] { "ProjDbId" }); + DropTable("dbo.RawPartList"); + DropTable("dbo.PartList"); + DropTable("dbo.ProdList"); + DropTable("dbo.ProjList"); + DropTable("dbo.BTLPartList"); + } + } +} diff --git a/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.resx b/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.resx new file mode 100644 index 00000000..ba5a2127 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Migrations/202103031756343_InitDb.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1d224juRF9D5B/aPRjMCvZM1ggMaRd2JK9Y0SyDcveyZtBN2lNZ/uidFMTG0G+LA/5pPxC2FeRzUuTTcqWB4t5kUTykCwWWaeKLM///vPfyc/PceR9Q1kepsnUPx4d+R5KghSGyXrqb/HTD3/2f/7pj3+YnMP42fu1qfepqEdaJvnU/4rx5mQ8zoOvKAb5KA6DLM3TJzwK0ngMYDr+eHT0l/Hx8RgRCJ9ged7kdpvgMEblF/J1liYB2uAtiJYpRFFe/05KViWqdwVilG9AgKb++RqfnZ8uv5wuFqP54xxgsAAvKPO90ygEZDgrFD35HkiSFANMBntyn6MVztJkvdqQH0B097JBpN4TiHJUT+JkV113Pkcfi/mMdw0bqGCb4zQ2BDz+VAto3G0+SMx+K0AiwnMiavxSzLoU49Q/u1vcgAyXova9bocnsygrKkslPSo+PYIcVWs1ouE+eJJGH1rdISpW/PvgzbYR3mZomqAtzgBperN9jMLgr+jlLv0NJdNkG0X0RMhUSBnzA/npJks3KMMvt+ipnl4xmPnjJfS9Mdt63G3eNuZaVgK4TPCnj753RQYCHiPU6gwlrBVOM/QLSlAGMII3AGOUkSW/hKiUOjcGQY/9/fVgzK/sAObXTfuzNI0QSIwRrk6XDQTZauTo8L0leF6gZI2/Tn3y0fcuwmcEm19q0PskJCcNaYSzbW8fX5oe5inRE2Q8xoVl+8+W7Zend3uX0ezqzk4V7s5ubHXJUhlvry2n8Mvtzd7lfG8r5xU5PpDlts/Sv+scVh2UK/AtXJdnlwAPBdj3blFUludfw01lTpkj/qGteJGl8W0adSxKU/6wSrdZUEwyVVS6A9kaYXaUk/HOZCkNWQHiyoq1WAdhwtq1NTZhmlrh0ISRHm1NGFGNizBCxZe9713yFQokZLBNoHCPtAr0UFXZ7Q62hNsXnWLbHQEd7gh4SDsCDt4RovXe746AtjtijvIgCzeVB7DnHbFIg98QNOOA+hrp0NP43c14z27G707CYTgJ74JhOyDINd8cwJG7AgP/lADpkoZ6KGLe0HLithZFHbqFPHvgaogIhGpw9fR6BtfWEg2uLlQMrqlhxW5qEFfmhIY7BIvC6JmpUZEr6R7tSt3p9052hpNKa6+C1lHOseAKuQ3I1zDZgKd5ngZhOaSux12NhZ3deQI9tcdTLS3jLZElJtsp3JANREYw9f/ECU0K20yFhYVC2KPR6JhDJlsPZYWmg2hGpE42c5hgfp+GSRBuQKQcRKeVkQ9TLEDbS7dkjjYoKbajUrS23be9dE6dPglNxpSOqFVHGEOSrbQ6oLRbb/YqQ1+TlLEoHTU97op8cp3MUYQw8k6D6tpnBvIAQP4QIJsNOtBD1RQ01UEYYzLSRtU62Q7iFXSS517So0dOxChtGaKKcgKnqedvr4rSKWipgITymJ2KsuXRGQHjKLyJHvJWXqYtCpO/0xaWJ+uropwt6JjYt9dD6fhfzTpLl+cdGGje1+s/sjjHz9lh2HUYNdXbIc+TDUVnKRWu3MBzrSNpB4NwrlKVE0HaYNICZY1zVzvdxe/oGQv89ntSWLnuee3DddWjwF0hzJ7XizAnaDvPRWgqOU1joQr+IcGhqF8/CJSDQE0Q+Yz0p1OvuASH3TcdKGpNWfHQridVSXzr1VWyXpewnQG9Fpyu9rqALAwUwTBqS2pqTF987c0Lod+10XduqJkweq6QidKZ0RDwAMkIgpYC3VCza01+TU9ARxpyPq0n2gHSEARpeGn0cDxNlkfNgdnsCoHIWd1+do0gZqzSDSHZ0KQbw3WjSy/05KqQRhNDa81fWzYZV49Y6x8mY8lr18kSbDZhsqZev9a/eKvq6evsh5X5c9C4whgHueBVaDvatiecZmCNOqWkazLSizDLcWPOfW8GY65a19hLzFXTG2/P+bVrjFjTpvhctZOF+RkGwBOlGuiCzDMumFYZA+fPBklzr3iTDCKQSS91Z2m0jRMN11INJoEyBCoubQUoD2WBPk7xRFQEU/yuj1LeAItgygJ9nC9ilC8mGAsxxsIE47MY47MJRnnjK0IpC/RxyqefIpyyQB+nfAEqwikLTDRGonllgT5OeVstwikL9HHKS2sRTlmgj3Mvk/O9mZzrC24RUl1ksMvbKCoNJ4+tFkaocwpy3iF38HIRG/Ys1zrpWwbq4pjfOWjmZ7yirTshq5BEOGYozJvJLtQDU2o0NCicpCQw9ZaaBF1qErTQJFlbd0JWIYlwzFCY6/cu1ANTamBf63t2Dq8oOCRFcsk8bWinM87pinA6YJtDqCZHEh0wRGt6aM0NHRDDIayQY09OqNMQ3iTgO8PIDuNSOfC1mCg5jacMn7/ZeUVHJ1wcWUxQ2PzUUjd3LfMePAmaI2vYhIyaCrbWsMGTGcR3wtG4wFe3Stt7GwDrBLomddCpP/ebi0JVVXyPzP5bCIsI1PJl9Y+ofOk5Kj/OopBMeFdjCZLwCeW4eqrp/zj6sZM5fjhZ3OM8h5EgaCdL5WbXTOvJqeLM7H9yKnhgHRai7n1UOuwhd6eXYSAPVBqDDcwuZ/oxTaPBMFRORJQm6+qCdIel86CVin5VQHBY6gEVAXOC89kRDpUSYSsiKj3aZu2pJGk7FXKiiVQ6hw0MldRhK+Z7N2JmUkCGAO1iMxQG9/rgMoHoeer/q2x04l3+7aFp98G7zojFOPGOvH87S4cTB55eOy14L+d0E8OyWzE2dGWnkTtSZKwBUKUBfN8DMnSHKYCjLNh9KQC0VoBOxMleAWqCrW2tB6S2DlnKwbTrVTiXPeFywbZccSQnBMkJO3JCjVzxIhf8wRV5cGPyZS6JxplPNTUw/PwQBIl4ukOgmu7B8shDNW+TnriXc4vLSByiRXykx0632UiPhdu4Lz5jYAVtcgKbp7CDE/YE70CHZhUOzf2TXhTqszVvUL7fe0ghMMrxM1xCp+kl4sezFqmFdqmkb5Ow931l6A1ayD0plXgg+1Yn47XtSXwzz1L57tLtDI3WntSJTdwYnOj3Xkxez5XkwVm9nrfstgvZx4Te5KwxXiPnGXHvKAWOfzzfXUxhglu9fj0ZbtUV6NSHjynRgIrPq9JbRClwsp6oMlE3N7KEIlGGnKIPqO5DnJgiSqCT9qEWl7as2G3ak2An6kmVW/IKGXjsInTeL2ql3XEJZeJswoPJtTMcuIJRyjJEDjCZbtDAZUZF+ETxAHPmbNRbtK/5500HmBo3aOB7WmmDDDj+wQ+xudR/CUGsfh6udxDFfxCRoICxtm2dy+QpbSx/Z0RNlU4YbYkwgMQUn2Y4fAIBJsUByvPyD479CqItqXIePyJ4mVxv8WaLyZRR/Bgxfw6tIA+q/ss0P3bMk+vyTit3MQUyzJBMAV0nZ9swgu24LwSRPAlEwUrqyGuxlriIwK5fWqSrNNEEqsXXkqk7FG8iApZfJyvwDQ0Z232OFmgNgpeb+tmWHKR/IVixT+YhWGcgzmuMXXvylegwjJ9/+j/V9lSRGWUAAA== + + + dbo + + \ No newline at end of file diff --git a/EgtBEAMWALL.DbDataLayer/Migrations/Configuration.cs b/EgtBEAMWALL.DbDataLayer/Migrations/Configuration.cs new file mode 100644 index 00000000..6995f10a --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Migrations/Configuration.cs @@ -0,0 +1,23 @@ +namespace EgtBEAMWALL.DbDataLayer.Migrations +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Migrations; + using System.Linq; + + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = false; + } + + protected override void Seed(EgtBEAMWALL.DbDataLayer.DatabaseContext context) + { + // This method will be called after migrating to the latest version. + + // You can use the DbSet.AddOrUpdate() helper extension method + // to avoid creating duplicate seed data. + } + } +} diff --git a/EgtBEAMWALL.DbDataLayer/Properties/AssemblyInfo.cs b/EgtBEAMWALL.DbDataLayer/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..3a3d3149 --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EgtBEAMWALL.DbDataLayer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EgtBEAMWALL.DbDataLayer")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5f1cde84-fd6a-4107-968c-ecc4d64f8043")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EgtBEAMWALL.DbDataLayer/packages.config b/EgtBEAMWALL.DbDataLayer/packages.config new file mode 100644 index 00000000..ffa9838d --- /dev/null +++ b/EgtBEAMWALL.DbDataLayer/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/Application.xaml b/EgtBEAMWALL.Supervisor/Application.xaml new file mode 100644 index 00000000..0f83d48e --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Application.xaml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/Application.xaml.vb b/EgtBEAMWALL.Supervisor/Application.xaml.vb new file mode 100644 index 00000000..5b871242 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Application.xaml.vb @@ -0,0 +1,14 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + Protected Overrides Sub OnStartup(e As StartupEventArgs) + MyBase.OnStartup(e) + ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose + ' Creo la View principale + Me.MainWindow = New MainWindowV + ' Mostro la View principale + Me.MainWindow.Show() + End Sub + +End Class diff --git a/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj b/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj new file mode 100644 index 00000000..6e88f917 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj @@ -0,0 +1,201 @@ + + + + Debug + AnyCPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + EgtBEAMWALL.Supervisor + EgtBEAMWALL.Supervisor + v4.0 + Custom + true + + + AnyCPU + true + full + true + true + true + bin\Debug\ + EgtBEAMWALL.Supervisor.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + AnyCPU + pdbonly + false + false + true + false + true + bin\Release\ + EgtBEAMWALL.Supervisor.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x64\Debug\ + EgtBEAMWALL.Supervisor.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x64 + MinimumRecommendedRules.ruleset + + + true + bin\x64\Release\ + EgtBEAMWALL.Supervisor.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x64 + MinimumRecommendedRules.ruleset + + + true + true + true + bin\x86\Debug\ + EgtBEAMWALL.Supervisor.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x86 + MinimumRecommendedRules.ruleset + + + true + bin\x86\Release\ + EgtBEAMWALL.Supervisor.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x86 + MinimumRecommendedRules.ruleset + + + + ..\..\..\EgtProg\DllD32\EgtUILib.dll + + + ..\..\..\EgtProg\DllD32\EgtWPFLib5.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + Dictionary.xaml + + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindowV.xaml + Code + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + {f22835a1-83d8-4334-91bb-baaeb9cf59b1} + EgtBEAMWALL.Core + + + {24d7760e-662a-47e4-b729-b70126c24a31} + EgtBEAMWALL.DataLayer + + + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowV.xaml b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowV.xaml new file mode 100644 index 00000000..51775bf8 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowV.xaml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowV.xaml.vb b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowV.xaml.vb new file mode 100644 index 00000000..e63255af --- /dev/null +++ b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowV.xaml.vb @@ -0,0 +1,3 @@ +Class MainWindowV + +End Class diff --git a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb new file mode 100644 index 00000000..8a0d5d46 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb @@ -0,0 +1,37 @@ +Imports EgtBEAMWALL.Core + +Public Class MainWindowVM + + Private m_MachGroupList As New List(Of MyMachGroup) + Public Property MachGroupList As List(Of MyMachGroup) + Get + Return m_MachGroupList + End Get + Set(value As List(Of MyMachGroup)) + m_MachGroupList = value + End Set + End Property + + Private m_SelMachGroup As MyMachGroup + Public Property SelMachGroup As MyMachGroup + Get + Return m_SelMachGroup + End Get + Set(value As MyMachGroup) + m_SelMachGroup = value + End Set + End Property + +#Region "CONSTRUCTOR" + + Sub New() + '' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM + 'Map.BeginInit(Me) + '' Creo Model della MainWindow + 'm_MainWindowM = New MainWindowM + m_MachGroupList.Add(New beammachgroup(43, "Mach7", "Essetre-FAST")) + End Sub + +#End Region ' CONSTRUCTOR + +End Class diff --git a/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb b/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..1941705e --- /dev/null +++ b/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/EgtBEAMWALL.Supervisor/My Project/MyExtensions/MyWpfExtension.vb b/EgtBEAMWALL.Supervisor/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 00000000..22f84b7d --- /dev/null +++ b/EgtBEAMWALL.Supervisor/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return CType(Global.System.Windows.Application.Current, Application) + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/My Project/Resources.Designer.vb b/EgtBEAMWALL.Supervisor/My Project/Resources.Designer.vb new file mode 100644 index 00000000..b22e10f7 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("$safeprojectname$.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/EgtBEAMWALL.Supervisor/My Project/Resources.resx b/EgtBEAMWALL.Supervisor/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/EgtBEAMWALL.Supervisor/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/My Project/Settings.Designer.vb b/EgtBEAMWALL.Supervisor/My Project/Settings.Designer.vb new file mode 100644 index 00000000..4fc18d52 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.EgtBEAMWALL.Supervisor.My.MySettings + Get + Return Global.EgtBEAMWALL.Supervisor.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/EgtBEAMWALL.Supervisor/My Project/Settings.settings b/EgtBEAMWALL.Supervisor/My Project/Settings.settings new file mode 100644 index 00000000..40ed9fdb --- /dev/null +++ b/EgtBEAMWALL.Supervisor/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/Resources/EgtBEAMWALL.ico b/EgtBEAMWALL.Supervisor/Resources/EgtBEAMWALL.ico new file mode 100644 index 00000000..90d62965 Binary files /dev/null and b/EgtBEAMWALL.Supervisor/Resources/EgtBEAMWALL.ico differ diff --git a/EgtBEAMWALL.Supervisor/Resources/TreeView/Folder.png b/EgtBEAMWALL.Supervisor/Resources/TreeView/Folder.png new file mode 100644 index 00000000..2c1339d0 Binary files /dev/null and b/EgtBEAMWALL.Supervisor/Resources/TreeView/Folder.png differ diff --git a/EgtBEAMWALL.Supervisor/Utility/Command.vb b/EgtBEAMWALL.Supervisor/Utility/Command.vb new file mode 100644 index 00000000..476e71f6 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Utility/Command.vb @@ -0,0 +1,68 @@ + +''' +''' A command whose sole purpose is to +''' relay its functionality to other +''' objects by invoking delegates. The +''' default return value for the CanExecute +''' method is 'true'. +''' +Public Class Command + Implements ICommand + +#Region "Fields" + + Private ReadOnly _execute As Action(Of Object) + Private ReadOnly _canExecute As Predicate(Of Object) + +#End Region ' Fields + +#Region "Constructors" + + ''' + ''' Creates a new command that can always execute. + ''' + ''' The execution logic. + Public Sub New(ByVal execute As Action(Of Object)) + Me.New(execute, Nothing) + End Sub + + ''' + ''' Creates a new command. + ''' + ''' The execution logic. + ''' The execution status logic. + Public Sub New(ByVal execute As Action(Of Object), ByVal canExecute As Predicate(Of Object)) + If execute Is Nothing Then + Throw New ArgumentNullException("execute") + End If + + _execute = execute + _canExecute = canExecute + End Sub + +#End Region ' Constructors + +#Region "ICommand Members" + + _ + Public Function CanExecute(ByVal parameter As Object) As Boolean Implements ICommand.CanExecute + Return If(_canExecute Is Nothing, True, _canExecute(parameter)) + End Function + + Public Custom Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged + AddHandler(ByVal value As EventHandler) + AddHandler CommandManager.RequerySuggested, value + End AddHandler + RemoveHandler(ByVal value As EventHandler) + RemoveHandler CommandManager.RequerySuggested, value + End RemoveHandler + RaiseEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) + End RaiseEvent + End Event + + Public Sub Execute(ByVal parameter As Object) Implements ICommand.Execute + _execute(parameter) + End Sub + +#End Region ' ICommand Members +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/Utility/Dictionary.xaml b/EgtBEAMWALL.Supervisor/Utility/Dictionary.xaml new file mode 100644 index 00000000..d4e5a379 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Utility/Dictionary.xaml @@ -0,0 +1,646 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/Utility/Dictionary.xaml.vb b/EgtBEAMWALL.Supervisor/Utility/Dictionary.xaml.vb new file mode 100644 index 00000000..fef4e3b7 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Utility/Dictionary.xaml.vb @@ -0,0 +1,30 @@ +Public Class OmagOFFICEDictionary + + Public Shared ReadOnly MySceneHostVM As String = "MySceneHostVM" + +#Region "Colors" + + Private m_Omag_Red As SolidColorBrush = Brushes.Red + Public ReadOnly Property Omag_Red As SolidColorBrush + Get + Return m_Omag_Red + End Get + End Property + + Private Shared m_Button_Static_Background As SolidColorBrush = New BrushConverter().ConvertFrom("#FFDDDDDD") + Public Shared ReadOnly Property Button_Static_Background As SolidColorBrush + Get + Return m_Button_Static_Background + End Get + End Property + + Private Shared m_TabControl_Header_Background As LinearGradientBrush = Application.Current.FindResource("TabItem.Static.Background") + Public Shared ReadOnly Property TabControl_Header_Background As LinearGradientBrush + Get + Return m_TabControl_Header_Background + End Get + End Property + +#End Region ' Colors + +End Class diff --git a/EgtBEAMWALL.Supervisor/Utility/VMBase.vb b/EgtBEAMWALL.Supervisor/Utility/VMBase.vb new file mode 100644 index 00000000..b2d5ce6c --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Utility/VMBase.vb @@ -0,0 +1,12 @@ +Imports System.ComponentModel + +Public Class VMBase + Implements INotifyPropertyChanged + + Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged + + Public Sub NotifyPropertyChanged(propName As String) + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/AddFeatureWnd/AddFeatureWndV.vb b/EgtBEAMWALL.ViewerOptimizer/AddFeatureWnd/AddFeatureWndV.vb new file mode 100644 index 00000000..35d7d688 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/AddFeatureWnd/AddFeatureWndV.vb @@ -0,0 +1,18 @@ +Public Class AddFeatureWndV + + Private WithEvents m_AddFeatureWndVM As AddFeatureWndVM + + Sub New(Owner As Window, AddFeatureWndVM As AddFeatureWndVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + Me.DataContext = AddFeatureWndVM + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_AddFeatureWndVM = AddFeatureWndVM + End Sub + + Private Sub CloseWindow(bDialogResult As Boolean) Handles m_AddFeatureWndVM.m_CloseWindow + Me.DialogResult = bDialogResult + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/AddFeatureWnd/AddFeatureWndV.xaml b/EgtBEAMWALL.ViewerOptimizer/AddFeatureWnd/AddFeatureWndV.xaml new file mode 100644 index 00000000..1be62179 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/AddFeatureWnd/AddFeatureWndV.xaml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..b380aec2 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml.vb @@ -0,0 +1,5 @@ +Public Class ConfigurationPageV + Private Sub ScrollViewer_Scroll(sender As Object, e As Primitives.ScrollEventArgs) + + End Sub +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb new file mode 100644 index 00000000..c2d6b9d3 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -0,0 +1,321 @@ +Imports System.Collections.ObjectModel +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class ConfigurationPageVM + + ' flag modifica parametri Macchina + Friend bModifyMachParam As Boolean + + ' Definizione comandi + Private m_cmdSave As ICommand + + Private m_ConfigMachTableList As New ObservableCollection(Of MachTable) + Public Property ConfigMachTableList As ObservableCollection(Of MachTable) + Get + Return m_ConfigMachTableList + End Get + Set(value As ObservableCollection(Of MachTable)) + m_ConfigMachTableList = value + End Set + End Property + +#Region "Constuctor" + + Sub New() + ' imposto riferimento in Map + Map.SetRefConfigurationPageVM(Me) + ' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione + ConfigMachTableList = CurrentMachine.MachTableList + End Sub + +#End Region ' Constuctor + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf Save) + End If + Return m_cmdSave + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub Save() + WriteMachParams() + End Sub + +#End Region ' SaveCommand + +#Region "Methods" + + ' funzione che scrive i parametri modificati sul file INI + Public Sub WriteMachParams() + For Each MachTableItem In ConfigMachTableList + For Each MachParamItem In MachTableItem.MachParamList + If MachParamItem.IsModified Then + Dim sMachParamType As String = String.Empty + Select Case MachParamItem.nType + Case MachParamType.DOUBLE_ + sMachParamType = "d" + Case MachParamType.STRING_ + sMachParamType = "s" + Case MachParamType.LENGTH + sMachParamType = "l" + End Select + Dim MachParamString As String = sMachParamType & "," & MachParamItem.sName & "," & MachParamItem.sValue & "," & MachParamItem.sDescription + Dim bOk = WriteMachPrivateProfileString(MachParamItem.nParentTable, MachParamItem.nParamIndex, MachParamString) + If Not bOk Then + MessageBox.Show("Errore nella scrittura di un parametro Macchina", "Error") + Return + End If + MachParamItem.IsModifiedReset() + End If + Next + Next + End Sub + + ' funzione che verifica la modifica dei parametri e ne chiede il salvataggio + Friend Function VerifyConfigPageModification() As Boolean + For Each MachTableItem In ConfigMachTableList + For Each MachParamItem In MachTableItem.MachParamList + If MachParamItem.IsModified Then + If MessageBox.Show("Salvare le modifiche apportate ai parametri Macchina?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' salvo parametri Macchina + Save() + Else + ' se da non salvare + CreateMachParams() + Return False + End If + End If + Next + Next + Return True + End Function + + ' funzione che verifica l'inserimento della password quando si edita un parametro Macchina + Friend Function VerifyConfigPagePassword() As Boolean + ' Display message, title, and default value. + Dim sPwdInput = InputBox("Inserire Password: ", "Richiesta Pwd") + ' Lettura PWD dall'INI e confronto + Dim sPwdIni As String = String.Empty + If GetMainPrivateProfileString(S_MACH, K_PASSWORD, "", sPwdIni) <> 0 Then + If sPwdIni = sPwdInput Then Return True + End If + Return False + End Function + +#End Region ' Methods + +End Class + +Public Class MachParam + Inherits VMBase + + ' table a cui appartiene il parametro + Private m_nParentTable As Integer + Friend ReadOnly Property nParentTable As Integer + Get + Return m_nParentTable + End Get + End Property + + ' indice del parametro + Private m_nParamIndex As Integer + Friend ReadOnly Property nParamIndex As Integer + Get + Return m_nParamIndex + End Get + End Property + + ' tipo della variabile + Private m_nType As MachParamType + Friend ReadOnly Property nType As MachParamType + Get + Return m_nType + End Get + End Property + + ' parametri da struttura + Private m_sName As String + Public Property sName As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + ' parametri da geometria + Private m_IsModifiedValue As Boolean = False + Private m_dValue As Double + Private m_sValue As String + Public Property sValue As String + Get + Select Case nType + Case MachParamType.DOUBLE_ + Return DoubleToString(m_dValue, 3) + Case MachParamType.LENGTH + Return LenToString(m_dValue, 3) + Case Else ' stringhe + Return m_sValue + End Select + Return If(nType = MachParamType.LENGTH, LenToString(m_dValue, 3), DoubleToString(m_dValue, 3)) + End Get + Set(value As String) + Dim dNewValue As Double + ' verifico se valore immesso è diverso dall'originale + If nParentTable > 0 Then + Dim sOrigValue As String = String.Empty + Dim dOrigValue As Double + MachParamIniFile.GetMachPrivateProfileParamValue(nParentTable, nParamIndex, sOrigValue) + ' trasformo valori + Select Case nType + Case MachParamType.DOUBLE_ + StringToDouble(value, dNewValue) + StringToDouble(sOrigValue, dOrigValue) + Case MachParamType.LENGTH + StringToLen(value, dNewValue) + StringToLen(sOrigValue, dOrigValue) + Case Else + ' per string non faccio nulla + End Select + m_IsModifiedValue = dNewValue <> dOrigValue + End If + ' se valore immesso è diverso e password non inserita + If m_IsModifiedValue AndAlso Not Map.refConfigurationPageVM.bModifyMachParam Then + Map.refConfigurationPageVM.bModifyMachParam = Map.refConfigurationPageVM.VerifyConfigPagePassword() + If Not Map.refConfigurationPageVM.bModifyMachParam Then + NotifyPropertyChanged("sValue") + m_IsModifiedValue = False + Return + End If + End If + + Select Case nType + Case MachParamType.DOUBLE_, MachParamType.LENGTH + UpdateParamValue(dNewValue, "") + Case Else + UpdateParamValue(0, value) + End Select + End Set + End Property + Public Property dValue As Double + Get + Return m_dValue + End Get + Set(value As Double) + m_dValue = value + NotifyPropertyChanged("sValue") + End Set + End Property + + ' descrizione del parametro + Private m_sDescription As String + Public Property sDescription As String + Get + Return m_sDescription + End Get + Set(value As String) + m_sDescription = value + End Set + End Property + + Private Sub StdInit(nParentTable As Integer, nParamIndex As Integer, Type As MachParamType, sName As String, sDescription As String) + m_nParentTable = nParentTable + m_nParamIndex = nParamIndex + m_nType = Type + m_sName = sName + Dim nDescription As Integer + If IsNumeric(sDescription) AndAlso Integer.TryParse(sDescription, nDescription) Then + m_sDescription = EgtMsg(sDescription) + Else + m_sDescription = sDescription + End If + End Sub + + ' new per double e length + Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, dValue As Double, sDescription As String) + StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription) + m_dValue = dValue 'sValue = DoubleToString(dValue, 3) + End Sub + + ' new per stringhe + Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, sDescription As String) + StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription) + End Sub + + ' new per parametro vuoto + Sub New(nType As MachParamType, nParamIndex As Integer, sParamName As String) + StdInit(Nothing, nParamIndex, nType, sParamName, "") + End Sub + + Friend Sub UpdateParamValue(dNewValue As Double, sNewValue As String, Optional bDraw As Boolean = True) + Select Case nType + Case MachParamType.DOUBLE_, MachParamType.LENGTH + m_dValue = dNewValue + Case MachParamType.STRING_ + m_sValue = sNewValue + End Select + End Sub + + Public ReadOnly Property IsModified() As Boolean + Get + Return m_IsModifiedValue + End Get + End Property + + Public Sub IsModifiedReset() + m_IsModifiedValue = False + End Sub + +End Class + +Public Class MachTable + Inherits VMBase + + ' nome della table + Private m_sName As String + Public Property sName As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + Private m_MachParamList As New ObservableCollection(Of MachParam) + Public Property MachParamList As ObservableCollection(Of MachParam) + Get + Return m_MachParamList + End Get + Set(value As ObservableCollection(Of MachParam)) + m_MachParamList = value + End Set + End Property + + Sub New(Name As String, ParamList As ObservableCollection(Of MachParam)) + sName = Name + MachParamList = ParamList + End Sub + +End Class + +' Tipo parametro nel file di configurazione Macchina +Public Enum MachParamType As Integer + DOUBLE_ = 1 + STRING_ = 2 + COMBO = 3 + LENGTH = 4 + CHECKBOX = 5 +End Enum diff --git a/EgtBEAMWALL.ViewerOptimizer/Constants/ConstBeam.vb b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstBeam.vb new file mode 100644 index 00000000..b1642789 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstBeam.vb @@ -0,0 +1,257 @@ +Public Module ConstBeam + + Public Enum BTLParamType As Integer + DOUBLE_ = 1 + STRING_ = 2 + COMBO = 3 + LENGTH = 4 + CHECKBOX = 5 + End Enum + + Public Enum BTLPartParam As Integer + NULL = 0 + PDN = 1 + NAM = 2 + GRP = 3 + End Enum + + Public Enum GRPType As Integer + L = 0 + T = 1 + End Enum + + Enum MachineType As Integer + NULL = 0 + BEAM = 1 + WALL = 2 + End Enum + + Enum CalcStates As Integer + NOTCALCULATED = -1 + OK = 0 + WARNING = 1 + ERROR_ = 2 + End Enum + + Public Enum Range As Integer + STANDARD = 1 + EXTENDED = 2 + End Enum + + Public Enum PartOffset_RefSideFixClamp As Integer + INACTIVE = 0 + REFSIDE1 = 1 + REFSIDE2 = 2 + REFSIDE3 = 3 + REFSIDE4 = 4 + End Enum + + Public Enum ProcessingQuality As Integer + AUTOMATIC = 1 + VISIBLE = 2 + FAST = 3 + End Enum + + Public Enum Recess As Integer + AUTOMATIC = 1 + MANUAL = 2 + End Enum + + Public Enum StoreyType As Integer + CEILING = 1 + ROOF = 2 + WALL = 3 + End Enum + + Public Enum AlignmentLocation As Integer + INACTIV = 0 + BR = 1 + TR = 2 + BA = 3 + TA = 4 + HC = 5 + VC = 6 + AC = 7 + End Enum + + Public Enum AlignmentEndtype As Integer + R = 1 + A = 2 + D = 3 + End Enum + + Public Enum MaterialType As Integer + INACTIV = 0 + BA = 1 + CL = 2 + MT = 3 + ME_ = 4 + GB = 5 + GF = 6 + IN_ = 7 + SH = 8 + FB = 9 + PB = 10 + PL = 11 + End Enum + + Public Enum MoveDirections As Integer + UP = -1 + DOWN = 1 + End Enum + + Public Const BTLFEATURES_FILE_NAME As String = "BTLFeatures.ini" + + 'Public Const S_GENERAL As String = "General" + 'Public Const K_DEBUG As String = "Debug" + + ' Tipo di progetto + Public Enum ProjectType As Integer + PROJ = 1 + PROD = 2 + End Enum + + Friend Const PROJ As String = "PROJ" + Friend Const FILENAMESEPARATOR As Char = "^"c + Friend Const BTLINFO As String = "BtlInfo" + + ' info parametri BTL + Friend Const BTL_PRT_PDN As String = "PDN" + Friend Const BTL_PRT_DO As String = "DO" + Friend Const BTL_PRT_NAM As String = "NAM" + Friend Const BTL_PRT_L As String = "L" + Friend Const BTL_PRT_W As String = "W" + Friend Const BTL_PRT_H As String = "H" + Friend Const BTL_PRT_CNT As String = "CNT" + Friend Const BTL_PRT_ROTATED As String = "ROTATED" + Friend Const BTL_PRT_INVERTED As String = "INVERTED" + Friend Const BTL_PRT_MATERIAL As String = "MATERIAL" + ' parametri pezzo + Friend Const BTL_PRT_SINGLEMEMBERNUM = "SINGLEMEMBERNUMBER" + Friend Const BTL_PRT_ASSEMBLYNUM = "ASSEMBLYNUMBER" + Friend Const BTL_PRT_ORDERNUM = "ORDERNUMBER" + Friend Const BTL_PRT_DESIGNATION = "DESIGNATION" + Friend Const BTL_PRT_ANNOTATION = "ANNOTATION" + Friend Const BTL_PRT_STOREY = "STOREY" + Friend Const BTL_PRT_GROUP = "GROUP" + Friend Const BTL_PRT_PACKAGE = "PACKAGE" + Friend Const BTL_PRT_TIMBERGRADE = "TIMBERGRADE" + Friend Const BTL_PRT_QUALITYGRADE = "QUALITYGRADE" + Friend Const BTL_PRT_COLOUR = "COLOUR" + Friend Const BTL_PRT_PLANINGLENGTH = "PLANINGLENGTH" + Friend Const BTL_PRT_STARTOFFSET = "STARTOFFSET" + Friend Const BTL_PRT_ENDOFFSET = "ENDOFFSET" + Friend Const BTL_PRT_UID = "UID" + Friend Const BTL_PRT_TRANSFORMATION = "TRANSFORMATION" + Friend Const BTL_PRT_CAMBER = "CAMBER" + Friend Const BTL_PRT_PARTOFFSET = "PARTOFFSET" + Friend Const BTL_PRT_PROCESSINGQUALITY = "PROCESSINGQUALITY" + Friend Const BTL_PRT_RECESS = "RECESS" + Friend Const BTL_PRT_STOREYTYPE = "STOREYTYPE" + Friend Const BTL_PRT_ELEMENTNUM = "ELEMENTNUMBER" + Friend Const BTL_PRT_LAYER = "LAYER" + Friend Const BTL_PRT_MODULENUM = "MODULENUMBER" + 'Friend Const BTL_PRT_USERATTRIBUTE = "USERATTRIBUTE" + Friend Const BTL_PRT_COMMENT = "COMMENT" + Friend Const BTL_PRT_GRAINDIR = "GRAINDIRECTION" + Friend Const BTL_PRT_REFSIDE = "REFERENCESIDE" + Friend Const BTL_PRT_ALIGNMENT = "ALIGNMENT" + Friend Const BTL_PRT_MATERIALTYPE = "MATERIALTYPE" + + ' parametri generici + Friend Const BTL_GEN_PROJNUM = "PROJECTNUMBER" + Friend Const BTL_GEN_PROJNAME = "PROJECTNAME" + Friend Const BTL_GEN_PROJPART = "PROJECTPART" + Friend Const BTL_GEN_PROJGUID = "PROJECTGUID" + Friend Const BTL_GEN_LISTNAME = "LISTNAME" + Friend Const BTL_GEN_CUSTOMER = "CUSTOMER" + Friend Const BTL_GEN_ARCHITECT = "ARCHITECT" + Friend Const BTL_GEN_EDITOR = "EDITOR" + Friend Const BTL_GEN_DELIVDATE = "DELIVERYDATE" + Friend Const BTL_GEN_EXPDATE = "EXPORTDATE" + Friend Const BTL_GEN_EXPTIME = "EXPORTTIME" + Friend Const BTL_GEN_EXPRELEASE = "EXPORTRELEASE" + Friend Const BTL_GEN_LANGUAGE = "LANGUAGE" + Friend Const BTL_GEN_RANGE = "RANGE" + Friend Const BTL_GEN_COMPUTERNAME = "COMPUTERNAME" + Friend Const BTL_GEN_USER = "USER" + Friend Const BTL_GEN_SRCFILE = "SOURCEFILE" + Friend Const BTL_GEN_EXPFILE = "EXPORTFILE" + Friend Const BTL_GEN_USERATTRIBUTE = "USERATTRIBUTE" + + Friend Const PROCESSINGS As String = "Processings" + Friend Const OUTLINE As String = "Outline" + Friend Const BTL_FTR_GRP As String = "GRP" + Friend Const BTL_FTR_PRC As String = "PRC" + Friend Const BTL_FTR_DO As String = "DO" + Friend Const BTL_FTR_SIDE As String = "SIDE" + Friend Const BTL_FTR_NAME As String = "NAME" + Friend Const BTL_FTR_DES As String = "DES" + Friend Const BTL_FTR_PRID As String = "PRID" + Friend Const BTL_FTR_FRAME As String = "FRAME" + + ' parametri machgroup grezzi + Friend Const MGR_RPT_ID As String = "ID" + Friend Const MGR_RPT_L As String = "L" + Friend Const MGR_RPT_W As String = "W" + Friend Const MGR_RPT_H As String = "H" + Friend Const MGR_RPT_WASTE As String = "WASTE" + Friend Const MGR_RPT_USAGE As String = "USAGE" + Friend Const MGR_RPT_STARTCUT As String = "STARTCUT" + Friend Const MGR_RPT_MATERIAL As String = "MATERIAL" + + Friend Const MGR_PRT_PDN As String = "PDN" + Friend Const MGR_PRT_L As String = "L" + Friend Const MGR_PRT_W As String = "W" + Friend Const MGR_PRT_H As String = "H" + Friend Const MGR_PRT_DES As String = "DES" + Friend Const MGR_PRT_STARTCUT As String = "STARTCUT" + Friend Const MGR_PRT_MATERIAL As String = "MATERIAL" + + Friend Const MGR_FTR_GRP As String = "GRP" + Friend Const MGR_FTR_PRC As String = "PRC" + Friend Const MGR_FTR_DO As String = "DO" + Friend Const MGR_FTR_SIDE As String = "SIDE" + Friend Const MGR_FTR_NAME As String = "NAME" + Friend Const MGR_FTR_DES As String = "DES" + Friend Const MGR_FTR_PRID As String = "PRID" + Friend Const MGR_FTR_FRAME As String = "FRAME" + + ' parametri creazione barre + Friend Const MGR_RPT_BARLEN As String = "BARLEN" + Friend Const MGR_RPT_BARHEIGHT As String = "BARHEIGHT" + Friend Const MGR_RPT_BARWIDTH As String = "BARWIDTH" + Friend Const MGR_RPT_PANELLEN As String = "PANELLEN" + Friend Const MGR_RPT_PANELWIDTH As String = "PANELWIDTH" + Friend Const MGR_RPT_PANELHEIGHT As String = "PANELHEIGHT" + Friend Const MGR_RPT_PART As String = "PART" + + ' parametri errori integration + Friend Const ITG_CUTID As String = "CUTID" + Friend Const ITG_TASKID As String = "TASKID" + Friend Const ITG_PROJ_ERR As String = "PROJ_ERR" + Friend Const ITG_PROJ_MSG As String = "PROJ_MSG" + Friend Const ITG_PROJ_ROT As String = "PROJ_ROT" + Friend Const ITG_PROJ_FALL As String = "PROJ_FALL" + Friend Const ITG_PROJ_TIME As String = "PROJ_TIME" + + ' parametri errori integration + Friend Const ITG_PROD_ERR As String = "PROD_ERR" + Friend Const ITG_PROD_MSG As String = "PROD_MSG" + Friend Const ITG_PROD_ROT As String = "PROD_ROT" + Friend Const ITG_PROD_TIME As String = "PROD_TIME" + + ' parametri errori integration + Friend Const DUPLO_TODELETE As String = "DUPLO_TODELETE" + + ' parametri warehouse + Friend Const WRH_BEAM As String = "BEAM" + Friend Const WRH_WALL As String = "WALL" + Friend Const WRH_CURRENT As String = "Current" + Friend Const WRH_STARTOFFSET As String = "StartOffset" + Friend Const WRH_OFFSET As String = "Offset" + Friend Const WRH_L As String = "L" + Friend Const WRH_KERF As String = "Kerf" + Friend Const WRH_S As String = "S" + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/Constants/ConstGen.vb b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstGen.vb new file mode 100644 index 00000000..d80608c0 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstGen.vb @@ -0,0 +1,87 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2017 +'---------------------------------------------------------------------------- +' File : ConstGen.vb Data : 10.04.17 Versione : 1.8d1 +' Contenuto : Modulo costanti generali. +' +' +' +' Modifiche : 10.04.17 DS Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Module ConstGen + + ' File con direttorio radice dei dati + Public Const DAT_FILE_NAME As String = "DataRoot.Ini" + Public Const S_DATA As String = "Data" + Public Const K_DATAROOT As String = "DataRoot" + + ' File con dati di licenza + Public Const LIC_FILE_NAME As String = "EgtBEAMWALL.lic" + Public Const S_LICENCE As String = "Licence" + Public Const K_KEY As String = "Key" + Public Const K_NESTKEY As String = "NestKey" + + ' Pagine del programma + Public Enum Pages As Integer + VIEW = 0 + MACHINING = 1 + SUPERVISOR = 2 + CONFIG = 3 + End Enum + + ' Abilitazioni licenza + Friend Enum KEY_OPT As UInteger + CUT_BASE = 1 ' Prodotto OmagCUT + MAN_MANIP = 2 + AUTO_MANIP = 4 + MAN_PHOTO = 8 + AUTO_PHOTO = 16 + AUTO_NESTING = 32 + ENABLE_MILL = 64 + PROCUCTION_LINE = 128 + OFFICE_BASE = 256 ' Prodotto OmagOFFICE + VM_MULTI = 512 + UNDER_CUT = 1024 + CSV_SIMPLE = 2048 + PHOTO_BASE = 4096 ' Prodotto OmagPHOTO + TRF_IMPORT = 8192 + MOVE_PARTS = 16384 + IMPORT_SLABDXF = 32768 + CURVED_FRAME = 65536 + ENABLE_WJ = 131072 + End Enum + + ' File di log generale + Public Const GENLOG_FILE_NAME As String = "EgtBEAMWALLLog#.txt" + + ' Sottodirettorio di configurazione + Public Const CONF_DIR As String = "Config" + ' Sottodirettorio delle risorse + Public Const RES_DIR As String = "Resources" + ' Sottodirettorio temporaneo + Public Const TEMP_DIR As String = "Temp" + ' Sottodirettorio per Cam automatico + Public Const PROJS_DIR As String = "Projs" + ' Sottodirettorio per Csv automatico + Public Const PRODS_DIR As String = "Prods" + ' Sottodirettorio per Macro + Public Const MACRO_DIR As String = "Macro" + ' Sottodirettorio per Magazzino + Public Const WAREHOUSE_DIR As String = "Warehouse" + ' Sottodirettorio per lavorazioni travi + Public Const BEAM_DIR As String = "Beam" + ' Sottodirettorio per lavorazioni pareti + Public Const WALL_DIR As String = "Wall" + ' Sottodirettorio di default per il salvataggio con nome + Public Const SAVE_DFL_NAMEDIR As String = "MyProjects" + ' Sottodirettorio di default per le macchine + Public Const MACHINES_DFL_DIR As String = "Machines" + ' Sottodirettorio di default per toolmakers + Public Const TOOLMAKERS_DFL_DIR As String = "ToolMakers" + ' Nome file Lua con le funzioni di attrezzaggio + Public Const SETUP_LUA As String = "SetUp.lua" + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/Constants/ConstIni.vb b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstIni.vb new file mode 100644 index 00000000..957af8cf --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstIni.vb @@ -0,0 +1,112 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2015 +'---------------------------------------------------------------------------- +' File : ConstIni.vb Data : 12.02.15 Versione : 1.6b3 +' Contenuto : Modulo costanti sezione e chiavi per file Ini. +' +' +' +' Modifiche : 12.02.15 DS Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Module ConstIni + + Public Const INI_FILE_NAME As String = "EgtBEAMWALL.ini" + + Public Const S_GENERAL As String = "General" + Public Const K_DEBUG As String = "Debug" + Public Const K_LICENCE As String = "Licence" + Public Const K_USERLEVEL As String = "UserLevel" + Public Const K_MAXINST As String = "MaxInstances" + Public Const K_INSTANCES As String = "Instances" + Public Const K_COMMANDLOG As String = "CommandLog" + Public Const K_MESSAGESDIR As String = "MessagesDir" + Public Const K_MESSAGES As String = "Messages" + Public Const K_WINPLACE As String = "WinPlace" + Public Const K_MMUNITS As String = "MmUnits" + Public Const K_LASTPROJ As String = "LastProj" + Public Const K_AUTOLOADLASTPROJ As String = "AutoLoadLastProj" + Public Const K_LASTIMPDIR As String = "LastImpDir" + Public Const K_PROJSINDEX As String = "ProjsIndex" + Public Const K_PRODSINDEX As String = "ProdsIndex" + Public Const K_SUPPORT As String = "Support" + Public Const K_WAREHOUSE As String = "Warehouse" + + Public Const S_LANGUAGES As String = "Languages" + Public Const K_LANGUAGE As String = "Language" + + Public Const S_LUA As String = "Lua" + Public Const K_LIBSDIR As String = "LibsDir" + Public Const K_BASELIB As String = "BaseLib" + + Public Const S_GEOMDB As String = "GeomDB" + Public Const K_DEFAULTFONT As String = "DefaultFont" + Public Const K_NFEFONTDIR As String = "NfeFontDir" + Public Const K_DEFAULTCOLOR As String = "DefaultColor" + Public Const K_SAVETYPE As String = "SaveType" + + Public Const S_OPENGL As String = "OpenGL" + Public Const K_DOUBLEBUFFER As String = "DoubleBuffer" + Public Const K_COLORBITS As String = "ColorBits" + Public Const K_DEPTHBITS As String = "DepthBits" + Public Const K_DRIVER As String = "Driver" + + Public Const S_SCENE As String = "Scene" + Public Const K_BACKTOP As String = "BackTop" + Public Const K_BACKBOTTOM As String = "BackBottom" + Public Const K_SHOWGFRAME As String = "ShowGFrame" + Public Const K_MARK As String = "Mark" + Public Const K_SELSURF As String = "SelSurf" + Public Const K_SHOWMODE As String = "ShowMode" + Public Const K_CURVEDIR As String = "CurveDir" + Public Const K_SHOWTRIAADV As String = "ShowTriaAdv" + Public Const K_SHOWZMAP As String = "ShowZmap" + Public Const K_TEXMAXLINPIX As String = "TextureMaxLinPixels" + Public Const K_ZOOMWIN As String = "ZoomWin" + Public Const K_DISTLINE As String = "DistLine" + + Public Const S_GRID As String = "Grid" + Public Const K_SHOWGRID As String = "ShowGrid" + Public Const K_SHOWFRAME As String = "ShowFrame" + Public Const K_SNAPSTEP As String = "SnapStep" + Public Const K_SNAPSTEPINCH As String = "SnapStepInch" + Public Const K_MINLINESSTEP As String = "MinLineSStep" + Public Const K_MAJLINESSTEP As String = "MajLineSStep" + Public Const K_EXTSSTEP As String = "ExtSStep" + Public Const K_MINLNCOLOR As String = "MinLnColor" + Public Const K_MAJLNCOLOR As String = "MajLnColor" + + Public Const S_IMPORT As String = "Import" + Public Const K_BTLFLAG As String = "BtlFlag" + + Public Const S_MACH As String = "Mach" + Public Const K_MACHINESDIR As String = "MachinesDir" + Public Const K_TOOLMAKERSDIR As String = "ToolMakersDir" + Public Const K_CURRMACH As String = "CurrMach" + Public Const K_PASSWORD As String = "Password" + + Public Const S_SIMUL As String = "Simul" + Public Const K_SLIDERX As String = "SliderX" + Public Const K_SLIDERVAL As String = "SliderVal" + + Public Const S_BEAM As String = "Beam" + Public Const K_CALCPATH As String = "CalcPath" + Public Const K_BEAMBASEDIR As String = "BaseDir" + Public Const K_BEAMBWEEXEC As String = "BweExec" + + Public Const S_WALL As String = "Wall" + Public Const K_WALLBASEDIR As String = "BaseDir" + Public Const K_WALLBWEEXEC As String = "BweExec" + + Public Const S_NEST As String = "Nest" + Public Const K_NESTDIR As String = "NestDir" + Public Const K_NESTEXEC As String = "NestExec" + + Public Const S_BEAMWALL As String = "BeamWall" + Public Const K_BEAMWALLENABLE As String = "BtlEnable" + Public Const K_BEAMWALLBASEDIR As String = "BaseDir" + Public Const K_BEAMWALLBUTTON As String = "Button" + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/Constants/ConstMachIni.vb b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstMachIni.vb new file mode 100644 index 00000000..dbd4d542 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstMachIni.vb @@ -0,0 +1,8 @@ +Module ConstMachIni + + Public Const MACH_INI_FILE_NAME As String = "MachData.ini" + + Public Const K_BEAM As String = "Beam" + Public Const K_NAME As String = "Name" + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/Constants/ConstMsg.vb b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstMsg.vb new file mode 100644 index 00000000..61cab73a --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstMsg.vb @@ -0,0 +1,54 @@ +Module ConstMsg + + Public Const MSG_SETUPERRORS As Integer = 5000 + 1470 + + Public Const MSG_MISSINGKEYWD As Integer = 10100 + Public Const MSG_NUMERICKEYBOARDWD As Integer = 10200 + Public Const MSG_MESSAGEBOX As Integer = 15000 + Public Const MSG_EGTSAVEFILEDIALOG As Integer = 30000 + + Public Const MSG_OMAGCUT As Integer = 90000 + Public Const MSG_GENERAL As Integer = MSG_OMAGCUT + Public Const MSG_WORKINPROGRESSPAGEUC As Integer = MSG_OMAGCUT + 100 + Public Const MSG_DIRECTCUTPAGEUC As Integer = MSG_OMAGCUT + 200 + Public Const MSG_MANUALAXESMOVEPAGEUC As Integer = MSG_OMAGCUT + 220 + Public Const MSG_CADCUTPAGEUC As Integer = MSG_OMAGCUT + 300 + Public Const MSG_NESTPAGEUC As Integer = MSG_OMAGCUT + 330 + Public Const MSG_SPLITPAGEUC As Integer = MSG_OMAGCUT + 340 + Public Const MSG_MOVERAWPAGEUC As Integer = MSG_OMAGCUT + 360 + Public Const MSG_DRAWPAGEUC As Integer = MSG_OMAGCUT + 380 + Public Const MSG_COMPONENTPAGEUC As Integer = MSG_OMAGCUT + 400 + Public Const MSG_IMPORTPAGEUC As Integer = MSG_OMAGCUT + 450 + Public Const MSG_OPENPAGEUC As Integer = MSG_OMAGCUT + 490 + Public Const MSG_RAWPARTPAGEUC As Integer = MSG_OMAGCUT + 500 + Public Const MSG_CHOOSEMACHININGPAGEUC As Integer = MSG_OMAGCUT + 535 + Public Const MSG_SIMULATIONPAGEUC As Integer = MSG_OMAGCUT + 550 + Public Const MSG_FRAMECUTPAGEUC As Integer = MSG_OMAGCUT + 600 + Public Const MSG_MACHINEPAGEUC As Integer = MSG_OMAGCUT + 700 + Public Const MSG_TOOLSDBPAGEUC As Integer = MSG_OMAGCUT + 720 + Public Const MSG_MACHININGSDBPAGEUC As Integer = MSG_OMAGCUT + 760 + Public Const MSG_COMBOBOXPARAM As Integer = MSG_OMAGCUT + 800 + Public Const MSG_ALARMSPAGEUC As Integer = MSG_OMAGCUT + 900 + Public Const MSG_MACHINECNPAGEUC As Integer = MSG_OMAGCUT + 950 + Public Const MSG_OPTIONSPAGEUC As Integer = MSG_OMAGCUT + 980 + Public Const MSG_EGTMSGBOX As Integer = MSG_OMAGCUT + 1100 + Public Const MSG_CSVPAGEUC As Integer = MSG_OMAGCUT + 1200 + + Public Const MSG_OMAGOFFICE As Integer = 91400 + Public Const MSG_OPTIONPANEL As Integer = MSG_OMAGOFFICE + Public Const MSG_MYMACHININGDBWINDOW As Integer = MSG_OMAGOFFICE + 50 + Public Const MSG_TOPCMDBAR As Integer = MSG_OMAGOFFICE + 100 + Public Const MSG_RAWPARTTAB As Integer = MSG_OMAGOFFICE + 150 + Public Const MSG_VEINMATCHING As Integer = MSG_OMAGOFFICE + 200 + Public Const MSG_GENERIC As Integer = MSG_OMAGOFFICE + 250 + + Public Const MSG_EGTWPFLIB5 As Integer = 30000 + Public Const MSG_TOPCOMMANDBAR As Integer = MSG_EGTWPFLIB5 + 500 + Public Const MSG_GRIDVIEWPANEL As Integer = MSG_EGTWPFLIB5 + 800 + Public Const MSG_TOOLDB As Integer = MSG_EGTWPFLIB5 + 1000 + Public Const MSG_TOOLDBERRORS As Integer = MSG_EGTWPFLIB5 + 1100 + Public Const MSG_MACHININGDB As Integer = MSG_EGTWPFLIB5 + 1200 + Public Const MSG_MACHININGDBERRORS As Integer = MSG_EGTWPFLIB5 + 1400 + Public Const MSG_SIMULATION As Integer = MSG_EGTWPFLIB5 + 1600 + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/Constants/ConstWarehouseIni.vb b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstWarehouseIni.vb new file mode 100644 index 00000000..d48e42de --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Constants/ConstWarehouseIni.vb @@ -0,0 +1,16 @@ +Module ConstWarehouseIni + + Public Const WH_BASIC_INI_FILE_NAME As String = "Basic.ini" + Public Const WH_MEDIUM_INI_FILE_NAME As String = "Medium.ini" + + 'Public Const S_BEAM As String = "Beam" + 'Public Const S_WALL As String = "Wall" + Public Const K_CURRENTL As String = "CurrentL" + Public Const K_CURRENTS As String = "CurrentS" + Public Const K_STARTOFFSET As String = "StartOffset" + Public Const K_KERF As String = "Kerf" + Public Const K_OFFSET As String = "Offset" + Public Const K_L As String = "L" + Public Const K_S As String = "S" + +End Module diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj new file mode 100644 index 00000000..c24707b7 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -0,0 +1,547 @@ + + + + + Debug + AnyCPU + {57291955-F9C4-4466-8D53-476D43BA3659} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + EgtBEAMWALL.ViewerOptimizer + EgtBEAMWALL.ViewerOptimizer + v4.0 + Custom + true + + + + + AnyCPU + true + full + true + true + true + bin\Debug\ + EgtBEAMWALL.ViewerOptimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + AnyCPU + pdbonly + false + false + true + false + true + bin\Release\ + EgtBEAMWALL.ViewerOptimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x64\Debug\ + EgtBEAMWALL.ViewerOptimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x64 + MinimumRecommendedRules.ruleset + + + true + bin\x64\Release\ + EgtBEAMWALL.ViewerOptimizer.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x64 + MinimumRecommendedRules.ruleset + + + true + true + true + bin\x86\Debug\ + EgtBEAMWALL.ViewerOptimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x86 + MinimumRecommendedRules.ruleset + + + true + bin\x86\Release\ + EgtBEAMWALL.ViewerOptimizer.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x86 + MinimumRecommendedRules.ruleset + + + Resources\EgtBEAMWALL.ico + + + + ..\..\..\EgtProg\DllD32\EgtUILib.dll + + + ..\..\..\EgtProg\DllD32\EgtWPFLib5.dll + + + ..\packages\EntityFramework.6.4.4\lib\net40\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.4\lib\net40\EntityFramework.SqlServer.dll + + + + + + + + + + + + 4.0 + + + + + + + + + MSBuild:Compile + Designer + + + AddSectionXMaterialWndV.xaml + + + + + + WarehouseWndV.xaml + + + + + MacroFeatureWndV.xaml + + + + AddFeatureWndV.xaml + + + + AddPartWndV.xaml + + + + AddRawPartWndV.xaml + + + + BTLDataWndV.xaml + + + + PartParametersV.xaml + + + + ChangeParameterWndV.xaml + + + + ConfigurationPageV.xaml + + + + + MachinePanelV.xaml + + + + OpenProjectFileDialogV.xaml + + + + OptimizePanelV.xaml + + + + PartManagerV.xaml + + + + ProdManagerV.xaml + + + + + ProjectV.xaml + + + + ProjManagerV.xaml + + + + + SceneHostV.xaml + + + + + ShowPanelV.xaml + + + StatusBarV.xaml + + + + TopPanelV.xaml + + + + + + Dictionary.xaml + + + + + + + + ViewPanelV.xaml + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + BottomPanelV.xaml + + + + + + FeatureListV.xaml + + + ParameterListV.xaml + + + PartInRawPartListV.xaml + + + PartListV.xaml + + + RawPartListV.xaml + + + + + + + + FeatureManagerV.xaml + + + + InstrumentPanelV.xaml + + + + LeftPanelV.xaml + + + + + MainMenuV.xaml + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + + + + + + MainWindowV.xaml + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f22835a1-83d8-4334-91bb-baaeb9cf59b1} + EgtBEAMWALL.Core + + + {24d7760e-662a-47e4-b729-b70126c24a31} + EgtBEAMWALL.DataLayer + + + + + + + + + + + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.ViewerOptimizerR32.exe +IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.ViewerOptimizerD32.exe +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.ViewerOptimizerR64.exe +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.ViewerOptimizerD64.exe + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerV.xaml new file mode 100644 index 00000000..ed68e73a --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerV.xaml @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerV.xaml.vb new file mode 100644 index 00000000..a0048d10 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class FeatureManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerVM.vb new file mode 100644 index 00000000..5092535c --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/FeatureManager/FeatureManagerVM.vb @@ -0,0 +1,3 @@ +Public Class FeatureManagerVM + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml new file mode 100644 index 00000000..a89b81ed --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml.vb new file mode 100644 index 00000000..b8adb880 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class InstrumentPanelV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb new file mode 100644 index 00000000..bb15c9e7 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb @@ -0,0 +1,299 @@ +Imports System.Collections.ObjectModel +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class MyInstrumentPanelVM + Inherits InstrumentPanelVM + + ' Definizione comandi + Private m_cmdData As ICommand + Private m_cmdChangeParameter As ICommand + Private m_cmdVerify As ICommand + Private m_cmdSimulate As ICommand + + Public Overrides Function OnPostGetDistIsChecked() As Boolean + Map.refSceneHostVM.MainScene.SetStatusNull() + Return True + End Function + +#Region "COMMANDS" + +#Region "Data" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Data_Command As ICommand + Get + If m_cmdData Is Nothing Then + m_cmdData = New Command(AddressOf Data) + End If + Return m_cmdData + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Data() + Dim BTLDataWnd As New BTLDataWndV(Application.Current.MainWindow, New BTLDataWndVM()) + BTLDataWnd.ShowDialog() + End Sub + +#End Region ' Data + +#Region "ChangeParameter" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property ChangeParameter_Command As ICommand + Get + If m_cmdChangeParameter Is Nothing Then + m_cmdChangeParameter = New Command(AddressOf ChangeParameter) + End If + Return m_cmdChangeParameter + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub ChangeParameter() + Dim ChangeParameterWndVM As New ChangeParameterWndVM + Dim ChangeParameterWnd As New ChangeParameterWndV(Application.Current.MainWindow, ChangeParameterWndVM) + If ChangeParameterWnd.ShowDialog() Then + ' faccio passare pezzi + If Not IsNothing(ChangeParameterWndVM.SelParam) Then + For Each Part In Map.refProjectVM.BTLStructure.PartList + For Each Feature In Part.FeatureList.Where(Function(x) x.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso CalcBeamPrivateProfileGRP(x.nSelGRP) = ChangeParameterWndVM.SelPRC.nGRP) + If ChangeParameterWndVM.SelParam.nType = BTLParamType.CHECKBOX AndAlso Feature.bDO = ChangeParameterWndVM.SelParam.bActualValue Then + Feature.bDO = ChangeParameterWndVM.SelParam.bNewValue + Else + Dim ParamList As ObservableCollection(Of Core.BTLParam) + If ChangeParameterWndVM.SelParam.bIsP Then + ParamList = Feature.PParamList + Else + ParamList = Feature.QParamList + End If + For Each Param In ParamList.Where(Function(x) x.sName = ChangeParameterWndVM.SelParam.sName) + Select Case Param.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + If Param.dValue = ChangeParameterWndVM.SelParam.dActualValue Then + DirectCast(Param, BTLParam).UpdateParamValue(ChangeParameterWndVM.SelParam.dNewValue, "") + ' rinfresco valori parametri feature correntemente selezionata + If Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) AndAlso + Not IsNothing(Map.refProjectVM.BTLStructure.SelPart.SelFeature) AndAlso + Map.refProjectVM.BTLStructure.SelPart.SelFeature Is Feature Then + Param.NotifyPropertyChanged("sValue") + End If + End If + Case BTLParamType.STRING_ + If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then + DirectCast(Param, BTLParam).UpdateParamValue(0, ChangeParameterWndVM.SelParam.sNewValue) + ' rinfresco valori parametri feature correntemente selezionata + If Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) AndAlso + Not IsNothing(Map.refProjectVM.BTLStructure.SelPart.SelFeature) AndAlso + Map.refProjectVM.BTLStructure.SelPart.SelFeature.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso + Map.refProjectVM.BTLStructure.SelPart.SelFeature.nSelGRP = ChangeParameterWndVM.SelPRC.nGRP Then + Param.NotifyPropertyChanged("sValue") + End If + End If + End Select + Next + End If + Next + '' faccio passare feature + 'For Each Feature In Part.FeatureList + ' If Feature.nPRC = ChangeParameterWndVM.SelPRC.nPRC Then + ' For Each Param In Feature.PParamList + ' If Param.sName = ChangeParameterWndVM.SelParam.sName Then + ' Select Case Param.nType + ' Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + ' If Param.dValue = ChangeParameterWndVM.SelParam.dActualValue Then + ' Param.dValue = ChangeParameterWndVM.SelParam.dValue + ' End If + ' Case BTLParamType.STRING_ + ' If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then + ' Param.sValue = ChangeParameterWndVM.SelParam.sValue + ' End If + ' End Select + ' End If + ' Next + ' End If + 'Next + Next + End If + End If + End Sub + +#End Region ' ChangeParameter + +#Region "Verify" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Verify_Command As ICommand + Get + If m_cmdVerify Is Nothing Then + m_cmdVerify = New Command(AddressOf Verify) + End If + Return m_cmdVerify + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Verify() + Dim Calc As New CalcIntegration + Dim BarList() As CalcIntegration.Bar + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) Then + Dim TempBarList(Map.refProjectVM.BTLStructure.PartList.Count - 1) As CalcIntegration.Bar + For PartIndex = 0 To Map.refProjectVM.BTLStructure.PartList.Count - 1 + Dim CurrPart As BTLPart = Map.refProjectVM.BTLStructure.PartList(PartIndex) + Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrPart.nPartId, + .nBarType = ProjectType.PROJ, + .bBarOk = True} + Select Case CurrPart.nState + Case Core.CalcStates.OK + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(PartIndex) = Bar + Next + BarList = TempBarList + ElseIf Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) Then + Dim TempBarList(0) As CalcIntegration.Bar + Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructure.SelPart.nPartId, + .nBarType = ProjectType.PROJ, + .bBarOk = True} + Select Case Map.refProjectVM.BTLStructure.SelPart.nState + Case Core.CalcStates.OK + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + Calc.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) Then + Dim TempBarList(Map.refMachGroupPanelVM.MachGroupList.Count - 1) As CalcIntegration.Bar + For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupList.Count - 1 + Dim CurrPart As MyMachGroup = Map.refMachGroupPanelVM.MachGroupList(PartIndex) + Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrPart.Id, + .nBarType = ProjectType.PROD, + .bBarOk = True} + Select Case CurrPart.nState + Case Core.CalcStates.OK + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(PartIndex) = Bar + Next + BarList = TempBarList + ElseIf Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim TempBarList(0) As CalcIntegration.Bar + Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refMachGroupPanelVM.SelectedMachGroup.Id, + .nBarType = ProjectType.PROD, + .bBarOk = True} + Dim SelMachGroup As MyMachGroup = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, MyMachGroup) + Select Case SelMachGroup.nState + Case Core.CalcStates.OK + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End If + End Sub + + Private Sub ManageCalc(dProgress As Double, sProgress As String, ByRef bCancel As Boolean) + If dProgress = 0 Then + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True) + Map.refMyStatusBarVM.SetStopProgress_IsActive(True) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True) + Map.refMyStatusBarVM.SetOutputMessage(sProgress) + Map.refMyStatusBarVM.SetStopProgress_IsActive(True) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True) + ElseIf dProgress = 1 Then + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False) + Map.refMyStatusBarVM.SetStopProgress_IsActive(False) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False) + Map.refMyStatusBarVM.SetOutputMessage(sProgress, 3) + End If + bCancel = Map.refMyStatusBarVM.bStopProgress + Map.refMyStatusBarVM.SetLoadingProgress(dProgress * 100) + Map.refMyStatusBarVM.SetOutputMessage(sProgress) + End Sub + +#End Region ' Verify + +#Region "Simulate" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Simulate_Command As ICommand + Get + If m_cmdSimulate Is Nothing Then + m_cmdSimulate = New Command(AddressOf Simulate) + End If + Return m_cmdSimulate + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Simulate() + Dim Calc As New CalcIntegration + Dim BarList() As CalcIntegration.Bar + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) Then + Dim TempBarList(0) As CalcIntegration.Bar + Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructure.SelPart.nPartId, + .nBarType = ProjectType.PROJ, + .bBarOk = True, + .nCmdType = CalcIntegration.CmdType.SIMULATE} + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + Calc.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim TempBarList(0) As CalcIntegration.Bar + Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refMachGroupPanelVM.SelectedMachGroup.Id, + .nBarType = ProjectType.PROD, + .bBarOk = True, + .nCmdType = CalcIntegration.CmdType.SIMULATE} + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End If + End Sub + +#End Region ' Simulate + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb b/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb new file mode 100644 index 00000000..2b2c934e --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb @@ -0,0 +1,456 @@ +Imports System.IO +Imports System.Threading +Imports System.Globalization +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class CalcIntegration + + Private _thread As System.Threading.Thread + + Public Enum CmdType As Integer + GENERATE = 0 + MODIFY = 1 + SIMULATE = 2 + CHECK = 3 + CHECKGEN = 4 + POINT_CLOUD = 5 + RAWPART = 6 + End Enum + + Public Class Bar + 'Public piInfo As PatternInfo + Public nBarState As Integer + Public nBarId As Integer + Public sBarPath As String + Public bBarOk As Boolean + Public nCmdType As Integer + Public nBarType As ProjectType + End Class + + Private Structure MyProc + Public bEnable As Boolean + Public Proc As Process + Public nBar As Integer + End Structure + + Public Sub New() + End Sub + + Delegate Sub CallbackDlg(dProgress As Double, sProgress As String, ByRef bCancel As Boolean) + + Public Sub Run(vBar As Bar(), sProjDirPath As String, callback As CallbackDlg) + _thread = New Thread(Sub() + DoJob(vBar, sProjDirPath, callback) + End Sub) + _thread.Start() + End Sub + + Private Shared Sub DoJob(vBar As Bar(), sProjDirPath As String, callback As CallbackDlg) + Dim bCancel As Boolean = False + callback(0, "Init", bCancel) + + ' creo progetti a seconda del tipo + For Each Bar In vBar + If Bar.nBarType = ProjectType.PROJ Then + Bar.sBarPath = CreateNewProjectFromPart(Bar.nBarId, sProjDirPath) + ElseIf Bar.nBarType = ProjectType.PROD Then + Bar.sBarPath = CreateNewProjectFromMachGroup(Bar.nBarId, sProjDirPath) + End If + Next + + callback(0.1, "", bCancel) + + Dim ExePath As String = String.Empty + GetMainPrivateProfileString(S_BEAM, K_CALCPATH, "", ExePath) + ' Numero di barre + Dim numBars As Integer = vBar.Count + If numBars = 0 Then Return + + ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) + Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, Map.refMainWindowVM.MainWindowM.GetMaxInstances()) + + ' Frazione di avanzamento del lavoro (in piu) + Dim dProgress As Double = 0 + 'indice incremento progress durante calcolo barra + Dim nPgsCurrBar As Integer = 0 + Dim nPgsClock As Integer = 0 + + + ' Lancio in parallelo più processi (senza superare il numero di core logici presenti) + Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {} + For j As Integer = 0 To nMaxThread - 1 + vProc(j).nBar = -1 + vProc(j).bEnable = True + Next + + ' Processo i Btl in parallelo + Dim nCurrBar As Integer = 0 + Dim nDoneBar As Integer = 0 + Dim nShiftBar As Integer = 0 + Dim nActProc As Integer = 0 + + While nCurrBar < numBars + nShiftBar OrElse nActProc > 0 + + For j As Integer = 0 To nMaxThread - 1 + If Not vProc(j).bEnable Then Continue For + Dim bDone As Boolean = False + + If vProc(j).nBar = -1 Then + + If nCurrBar < numBars + nShiftBar Then + + If vBar(nCurrBar).bBarOk Then + vProc(j).Proc = New Process() + vProc(j).Proc.StartInfo.FileName = ExePath + vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " & + """" & Map.refMachinePanelVM.SelectedMachine.nType & """ " & + """" & Map.refMachinePanelVM.SelectedMachine.Name & """ " & vBar(nCurrBar).nCmdType + vProc(j).Proc.StartInfo.UseShellExecute = False + + If vProc(j).Proc.Start() Then + vProc(j).nBar = nCurrBar + nCurrBar += 1 + nActProc += 1 + End If + Else + If vBar(nCurrBar).nCmdType = CmdType.CHECK OrElse vBar(nCurrBar).nCmdType = CmdType.CHECKGEN Then ProcessResults(vBar(nCurrBar)) + bDone = True + nCurrBar += 1 + End If + End If + Else + + If vProc(j).Proc.HasExited Then + ' se terminato con successo + If vProc(j).Proc.ExitCode = 0 Then + ' salvo il risultato + If vBar(vProc(j).nBar).nCmdType = CmdType.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdType.CHECKGEN Then ProcessResults(vBar(vProc(j).nBar)) + bDone = True + vProc(j).nBar = -1 + nActProc -= 1 + ' se superato il numero di processi eseguibili in parallelo + ElseIf vProc(j).Proc.ExitCode = 1 Then + ' aggiungo il pezzo in coda + If numBars + nShiftBar < numBars + nMaxThread Then + vBar(numBars + nShiftBar) = vBar(vProc(j).nBar) + nShiftBar += 1 + End If + ' disabilito il processo + vProc(j).bEnable = False + vProc(j).nBar = -1 + nActProc -= 1 + ' altrimenti (errore generico di esecuzione) + Else + ' salvo il risultato + If vBar(vProc(j).nBar).nCmdType = CmdType.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdType.CHECKGEN Then ProcessResults(vBar(vProc(j).nBar)) + bDone = True + vProc(j).nBar = -1 + nActProc -= 1 + End If + Else + vProc(j).Proc.Refresh() + End If + End If + + If bDone Then + ' Dialog con Progress Bar + nDoneBar += 1 + dProgress = 1 / numBars * nDoneBar + Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) + callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel) + + If bCancel Then + ' fine + callback(1, "", bCancel) + Return + End If + nPgsCurrBar = 0 + nPgsClock = 0 + Else + If nPgsClock >= 100 AndAlso nPgsCurrBar < 149 Then + nPgsCurrBar += 1 + dProgress = 1 / numBars * nDoneBar + 1 / numBars / 150 * nPgsCurrBar + Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) + callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel) + nPgsClock = 0 + End If + End If + nPgsClock += 1 + Thread.Sleep(1) + Next + + ' Verifico che i processi non siano andati tutti in errore + Dim bAllKO As Boolean = True + + For j As Integer = 0 To nMaxThread - 1 + If vProc(j).bEnable Then bAllKO = False + Next + + If bAllKO Then + MessageBox.Show("Execution error (all processes are disabled)") + Exit While + End If + + Thread.Sleep(10) + End While + + Thread.Sleep(300) + + ' fine + callback(1, "Done", bCancel) + Map.refMyStatusBarVM.ResetStopProgress() + End Sub + + Private Shared Function CreateNewProjectFromPart(nPartId As Integer, sProjDirPath As String) As String + + ' Aggiorno identificativi per segnalazione errori + UpdateCutIdAndTaskId(nPartId) + + ' Disabilito segnalazione modificato + Dim bOldEnableModified As Boolean = EgtGetEnableModified() + If bOldEnableModified Then EgtDisableModified() + + ' Recupero visibilita' pezzo e lo imposto a visibile + Dim nOldPartMode As Integer + EgtGetMode(nPartId, nOldPartMode) + EgtSetMode(nPartId, GDB_MD.STD) + + ' Salvo pezzo nel suo progetto + Dim bOk As Boolean = False + Dim nPDN As Integer = 0 + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + Dim sPartFilePath As String = sProjDirPath & "\" & nPDN.ToString() & ".bwe" + bOk = EgtSaveObjToFile(nPartId, sPartFilePath, NGE.BIN) + + ' Ripristino visibilita' pezzo + EgtSetMode(nPartId, nOldPartMode) + + ' Ripristino stato segnalazione modifica + If bOldEnableModified Then EgtEnableModified() + + Return If(bOk, sPartFilePath, String.Empty) + End Function + + Private Shared Function CreateNewProjectFromMachGroup(nMachGroupId As Integer, sProjDirPath As String) As String + + ' Aggiorno identificativi per segnalazione errori + Dim nOldMachGroup As Integer = EgtGetCurrMachGroup() + If nMachGroupId <> nOldMachGroup Then EgtSetCurrMachGroup(nMachGroupId) + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + If EgtVerifyRawPartPhase(nRawId, 1) Then + Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId) + While nPartId <> GDB_ID.NULL + UpdateCutIdAndTaskId(nPartId) + nPartId = EgtGetNextPartInRawPart(nPartId) + End While + End If + nRawId = EgtGetNextRawPart(nRawId) + End While + If nMachGroupId <> nOldMachGroup Then + If nOldMachGroup <> GDB_ID.NULL Then + EgtSetCurrMachGroup(nOldMachGroup) + Else + EgtResetCurrMachGroup() + End If + End If + + ' Salvo gruppo di lavorazione nel suo progetto + Dim sMachGroupFilePath As String = sProjDirPath & "\" & nMachGroupId.ToString() & ".bwe" + If EgtSaveObjToFile(nMachGroupId, sMachGroupFilePath, NGE.BIN) Then + Return sMachGroupFilePath + End If + Return String.Empty + End Function + + Private Shared Function UpdateCutIdAndTaskId(nPartId As Integer) As Boolean + ' Assegno Id a CutId per calcoli + EgtSetInfo(nPartId, "CUTID", nPartId, True) + ' Assegno TASKID alle feature per calcoli + Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS) + Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId) + While nFeatureId <> GDB_ID.NULL + ' verifico che sia una feature + Dim nGRP As Integer + If EgtGetInfo( nFeatureId, BTL_FTR_GRP, nGRP) Then + ' assegno TASKID alla feature per calcoli + EgtSetInfo( nFeatureId, "TASKID", nFeatureId, True) + End If + nFeatureId = EgtGetNext( nFeatureId) + End While + Return True + End Function + + Private Shared Sub ProcessResults( Bar As Bar) + + Dim BtlPath As String = Bar.sBarPath + 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 + + Dim nErr As Integer = 0 + Dim sMsg As String = "" + Dim dRot As Double = 0 + Dim nFall As Integer = 0 + Dim dPartRot As Double = 0 + Dim dTotRot As Double = 0 + Dim cutId As Integer = 0 + Dim taskId As Integer = 0 + Dim prevCutId As Integer = GDB_ID.NULL + Dim currBTLPart As BTLPart + Dim currPart As Core.Part + + Dim lines As String() = System.IO.File.ReadAllLines( ResPath) + For Each line As String In lines + + If line.StartsWith("ERR=") Then + Dim nVal As Integer? = GetVal(line, "ERR") + nErr = (If(nVal IsNot Nothing, nVal.Value, 0)) + sMsg = "" + dRot = 0 + cutId = 0 + taskId = 0 + ElseIf line.StartsWith("ROT=") Then + Dim nVal As Integer? = GetVal(line, "ROT") + Dim nRot As Integer = (If(nVal IsNot Nothing, nVal.Value, 0)) + dRot = Math.Abs(((4 - nRot) Mod 4) * 90) + dPartRot = Math.Max(dPartRot, dRot) + dTotRot = Math.Max(dTotRot, dRot) + ElseIf line.StartsWith("CUTID=") Then + Dim nVal As Integer? = GetVal(line, "CUTID") + cutId = (If(nVal IsNot Nothing, nVal.Value, 0)) + If cutId <> prevCutId Then + ' aggiornamento globale pezzo precedente + If prevCutId <> GDB_ID.NULL Then + EgtSetInfo(prevCutId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_ROT, ITG_PROD_ROT), dTotRot, True) + dTotRot = 0 + End If + ' aggiornamento risultati in struttura BTL + If Bar.nBarType = ProjectType.PROJ Then + ' cerco pezzo in btl structure da id + For Each Part In Map.refProjectVM.BTLStructure.PartList + If Part.nPartId = cutId Then + currBTLPart = Part + End If + Next + ElseIf Bar.nBarType = ProjectType.PROD Then + For Each MachGroup As Core.MyMachGroup In Map.refMachGroupPanelVM.MachGroupList + For Each Part In MachGroup.PartList + If Part.nPartId = cutId Then + currPart = Part + End If + Next + Next + End If + prevCutId = cutId + End If + + ElseIf line.StartsWith("TASKID=") Then + Dim nVal As Integer? = GetVal(line, "TASKID") + taskId = (If(nVal IsNot Nothing, nVal.Value, 0)) + ' se taskid diverso da zero, errore feature + If taskId <> 0 Then + EgtSetInfo(taskId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_ERR, ITG_PROD_ERR), nErr, True) + EgtSetInfo(taskId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_MSG, ITG_PROD_MSG), sMsg, True) + EgtSetInfo(taskId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_ROT, ITG_PROD_ROT), dRot, True) + ' aggiornamento risultati in struttura BTL + If Bar.nBarType = ProjectType.PROJ Then + ' cerco task in btl structure da id + If Not IsNothing(currBTLPart) Then + For Each Feature In currBTLPart.FeatureList + If Feature.nFeatureId = taskId Then + DirectCast(Feature, BTLFeature).CalcFeatureUpdate(True, nErr, dRot, nFall, sMsg) + End If + Next + End If + ElseIf Bar.nBarType = ProjectType.PROD Then + ' cerco task in MachGroupList da id + If Not IsNothing(currPart) Then + For Each Feature In currPart.FeatureList + If Feature.nFeatureId = taskId Then + DirectCast(Feature, BTLFeature).CalcFeatureUpdate(True, nErr, dRot, nFall, sMsg) + End If + Next + End If + End If + ' se taskid uguale a zero, errore pezzo + ElseIf cutId <> 0 Then + EgtSetInfo(cutId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_ERR, ITG_PROD_ERR), nErr, True) + EgtSetInfo(cutId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_MSG, ITG_PROD_MSG), sMsg, True) + ' aggiorno in struttura btl + If Bar.nBarType = ProjectType.PROJ Then + If Not IsNothing(currBTLPart) Then currBTLPart.CalcPartUpdate(True, nErr, dRot, nFall, sMsg) + ElseIf Bar.nBarType = ProjectType.PROD Then + If Not IsNothing(currPart) Then currPart.CalcPartUpdate(True, nErr, dRot, nFall, sMsg) + End If + End If + ElseIf line.StartsWith("FALL=") Then + Dim nVal As Integer? = GetVal(line, "FALL") + If Not IsNothing(nVal) Then + nFall = nVal + Else + nFall = 0 + 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 + 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 + sMsg = line + End If + Next + + Else + bErrors = True + nLastErr = 25 + sLastMsg = "Execution Error" + End If + + ' aggiornamento risultati in struttura BTL + If Bar.nBarType = ProjectType.PROJ Then + ' cerco pezzo in btl structure da id + For Each Part In Map.refProjectVM.BTLStructure.PartList + If Part.nPartId = Bar.nBarId Then + ' leggo errori da geometria e li aggiorno in struttura btl + DirectCast(Part, BTLPart).CalcFeatureUpdate() + ' aggiungo nota che indica macchina + + End If + Next + ElseIf Bar.nBarType = ProjectType.PROD Then + ' cerco pezzo in MachGroupList da id + For Each MachGroup As Core.MyMachGroup In Map.refMachGroupPanelVM.MachGroupList + If MachGroup.Id = Bar.nBarId Then + For Each Part In MachGroup.PartList + ' leggo errori da geometria e li aggiorno in struttura btl + DirectCast(Part, Core.Part).CalcFeatureUpdate() + Next + MachGroup.CalcMachGroupUpdate() + End If + Next + End If + + End Sub + + 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 + + If Not Integer.TryParse(sParts(1), nVal) Then + Return Nothing + Else + Return nVal + End If + End Function + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs b/EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs new file mode 100644 index 00000000..b0caff72 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +class Constants +{ + // Le seguenti costanti stringa sono parti di testo del file BTL di output + public const string VERSION = "VERSION: BTL V10.6" ; + public const string BUILD = "BUILD: \"10600\"" ; + public const string GENERAL = "[GENERAL]" ; + public const string PART = "[PART]" ; + public const string PROJECT_NUMBER = "PROJECTNUMBER: " ; + public const string SCALE_UNIT = "SCALEUNIT: " ; + public const string SINGLE_MEMBER_NUMBER = "SINGLEMEMBERNUMBER: " ; + public const string DESIGNATION = "DESIGNATION: " ; + public const string COUNT = "COUNT: " ; + public const string LENGTH = "LENGTH: " ; + public const string HEIGHT = "HEIGHT: " ; + public const string WIDTH = "WIDTH: " ; + public const string OUTLINE_KEY = "OUTLINE: "; + public const string APERTURE_KEY = "APERTURE: "; + public const string SIDE = "SIDE: "; + public const string PROCESS_KEY = "PROCESSKEY: "; + public const string PROCESS_PARAMETERS = "PROCESSPARAMETERS: " ; + public const string REFERENCE_PLANE = "REFERENCEPLANE: " ; + public const string PROCESS_IDENT = "PROCESSIDENT: " ; + public const string PROCESS = "PROCESS: " ; + public const string COMMENT = "COMMENT: " ; + public const string USERATTRIBUTE = "USERATTRIBUTE: " ; + public const string EIGHT_ZEROS = "00000000" ; + + // Numero di cifre decimali dei valori dei parametri BTL + public const int scaleUnit = 2 ; + + // Allungamento della barra per pezzi singoli da Vista + public const double BarMaxLenForAdd = 2000 ; + public const double BarAddLen = 2000 ; + + // Sovramateriale di testa per travi singole di Vista + public const double HeadOverMat = 10 ; + + // Sovramateriale per pareti singole di Vista + public const double PanelOverMat = 10 ; + + // Id base per punti di contorni liberi + public const int FcBaseId = 10000 ; +} \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs b/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs new file mode 100644 index 00000000..3d9124d6 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs @@ -0,0 +1,1284 @@ +using System; +using System.Windows.Forms; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Globalization ; +using ib.essetre.integration; +using ib.essetre.integration.egaltech; + +public class Generator : ib.essetre.integration.IGenerator +{ + private System.Threading.Thread _thread ; + private static DataSet _ds = new DataSet() ; + private static string _SqlConnectionStr = "" ; + + private struct Bar + { + public PatternInfo piInfo ; + public int nBarState ; + public string sBtlPath ; + public bool bBtlOk ; + } + + private struct MyProc + { + public bool bEnable ; + public Process Proc ; + public int nBar ; + } + + //------------------------------------------------------------------------------------------------------------- + public Generator() + { + } + + //------------------------------------------------------------------------------------------------------------- + public void Run(InOutParameters parameters, ICallBack callback) + { + _thread = new Thread(() => DoJob( parameters, callback)) ; + _thread.Start() ; + } + + private delegate void dDoJob( InOutParameters parameters, ICallBack callback) ; + + // Proj + // Creo progetto barra da pezzo + private static void CreateRawPartProjectFromPart(integer nPartId) + { + EgtNew + } + + //------------------------------------------------------------------------------------------------------------- + // campo data ultima modifica nel DATABASE [lastModified] + private static void DoJob( InOutParameters parameters, ICallBack callback) + { + bool bCancel = false ; + callback.Progress( 0, "Init", ref bCancel) ; + + // creo progetti per ogni barra + + + + _SqlConnectionStr = parameters.ConnectionString ; + + String ExePath = GetExePath( parameters) ; + String DataDir = GetDataDir( parameters) ; + + // Numero di barre + int numBars = parameters.Patterns.Length ; + if ( numBars == 0) + return ; + + // Se modalità Cloud, allora conta solo la prima barra + bool bCloud = ( parameters.UIMode == InOutParameters.UIModes.CLOUD) ; + if ( bCloud) + numBars = 1 ; + + // Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) + int nMaxThread = Math.Min( Environment.ProcessorCount, GetMaxInstances( parameters)) ; + + // Frazione di avanzamento del lavoro (in pu) + double dProgress = 0 ; + + // Genero i Btl di tutte le barre + Bar[] vBar = new Bar[ numBars + nMaxThread] ; + for ( int i = 0; i < numBars; i++) { + + PatternInfo pattInfo = parameters.Patterns[i] ; + + BTL btlObject = new BTL() ; + + // Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project, + // se invece è FALSE viene eseguita la query sulle tabelle Production + string sql = "" ; + if ( pattInfo.IsFromProject) { + sql = "SELECT E.projectId, " + + "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " + + "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " + + "P.flagDeleted, P.[group], [key], face, edge, des, " + + "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + + "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + + "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + + "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " + + "E.inverted, E.rotated, 0 doneTime, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " + + "FROM dbo.vw_Process AS P " + + "RIGHT OUTER JOIN dbo.vw_Element AS E " + + "ON P.projectId=E.projectId AND P.elementId=E.elementId " + + "WHERE E.projectId = @firstId AND E.elementId = @secondId" ; + } + else { + sql = "SELECT vw_Cut.productionId, " + + "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " + + "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " + + "vw_Task.flagDeleted, [group], [key], face, edge, des, " + + "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + + "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + + "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + + "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " + + "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " + + "FROM dbo.vw_Task " + + "RIGHT OUTER JOIN dbo.vw_Cut " + + "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " + + "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId" ; + } + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using (SqlCommand cmd = new SqlCommand( sql, cn)) { + cmd.Parameters.Add( "@firstId", SqlDbType.Int) ; + cmd.Parameters.Add( "@secondId", SqlDbType.Int) ; + if ( pattInfo.IsFromProject) { + cmd.Parameters["@firstId"].Value = pattInfo.ProjectId ; + cmd.Parameters["@secondId"].Value = pattInfo.ElementId ; + } + else { + cmd.Parameters["@firstId"].Value = pattInfo.ProductionId ; + cmd.Parameters["@secondId"].Value = pattInfo.PatternId ; + } + var dataAdapter = new SqlDataAdapter( cmd) ; + + // Lettura DB e riempimento DataSet + _ds.Clear() ; + dataAdapter.Fill( _ds) ; + } + } + + // Verifica parametro isFromProject: nel caso Ordine viene ottenuta la lista dei Process, + // nel caso Produzione viene ottenuta la lista dei Task + if ( pattInfo.IsFromProject) + GetListaProcesses( btlObject) ; + else + GetListaTasks( btlObject) ; + + // Recupero lo stato della barra + int nBarState = 0 ; + if ( ! pattInfo.IsFromProject) + nBarState = GetBarStateP( btlObject.patternId, btlObject.productionId) ; + + // Dialog con Progress Bar + dProgress += 0.1 / numBars ; + string sProg = ( dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) ; + callback.Progress( (float) dProgress, + " Progress: " + sProg + "%" + "\n", + ref bCancel) ; + if ( bCancel) { + callback.Done( parameters) ; //fine + return ; + } + + // Scrittura del file BTL + // Path completa del nome del file da salvare + string BtlPath = GetBtlPath( DataDir, pattInfo) ; + bool BtlOk = btlObject.WriteIntoFile( BtlPath, pattInfo.IsFromProject) ; + + // Se modalità cloud, scrittura del file di punti + bool bErrOnCloud = false ; + if ( bCloud) { + if ( pattInfo.Cloud != null) { + using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".pnt"), false)) { + for ( int j = 0 ; j < pattInfo.Cloud.Count() ; j++) { + double dPosX = - pattInfo.Cloud[j].Y ; + double dPosY = pattInfo.Cloud[j].X ; + string sPosX = dPosX.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; + string sPosY = dPosY.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; + tw.WriteLine( sPosX + " " + sPosY) ; + } + } + } + else { + BtlOk = false ; + bErrOnCloud = true ; + } + } + + // Se scrittura Btl non riuscita + if ( ! BtlOk) { + // scrivo direttamente il file di errore + int ErrCutId = ( pattInfo.IsFromProject ? pattInfo.ElementId : pattInfo.PatternId) ; + using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".txt"), false)) { + tw.WriteLine( "ERR=10") ; + tw.WriteLine( bErrOnCloud ? "Cloud without points" : "BTL without processes") ; + tw.WriteLine( "CUTID=" + ErrCutId.ToString()) ; + tw.WriteLine( "TASKID=0") ; + } + // elimino eventuale file Cn già presente + if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN) { + string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; + if ( File.Exists( CncPath)) + File.Delete( CncPath) ; + } + } + // altrimenti + else { + // cancello eventuale file di errore già presente + string TxtPath = Path.ChangeExtension( BtlPath, ".txt") ; + if ( File.Exists( TxtPath)) + File.Delete( TxtPath) ; + } + + // Salvo dati + vBar[i].piInfo = pattInfo ; + vBar[i].nBarState = nBarState ; + vBar[i].sBtlPath = BtlPath ; + vBar[i].bBtlOk = BtlOk ; + } + + // Lancio in parallelo più processi (senza superare il numero di core logici presenti) + MyProc[] vProc = new MyProc[nMaxThread] ; + for ( int j = 0 ; j < nMaxThread ; ++ j) { + vProc[j].nBar = -1 ; + vProc[j].bEnable = true ; + } + + // Processo i Btl in parallelo + int nCurrBar = 0 ; + int nDoneBar = 0 ; + int nShiftBar = 0 ; + int nActProc = 0 ; + while ( nCurrBar < numBars + nShiftBar || nActProc > 0) { + for ( int j = 0 ; j < nMaxThread ; ++ j) { + if ( ! vProc[j].bEnable) + continue ; + bool bDone = false ; + if ( vProc[j].nBar == -1) { + if ( nCurrBar < numBars + nShiftBar) { + if ( vBar[nCurrBar].bBtlOk) { + vProc[j].Proc = new Process() ; + vProc[j].Proc.StartInfo.FileName = ExePath ; + int nMode = (int)parameters.UIMode ; + if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN && vBar[nCurrBar].nBarState != 0) + nMode = 4 ; + vProc[j].Proc.StartInfo.Arguments = "\"" + vBar[nCurrBar].sBtlPath + "\" " + parameters.MachineName + " " + nMode.ToString() ; + vProc[j].Proc.StartInfo.UseShellExecute = false ; + if ( vProc[j].Proc.Start()) { + vProc[j].nBar = nCurrBar ; + nCurrBar ++ ; + nActProc ++ ; + } + } + else { + ProcessResults( vBar[nCurrBar].sBtlPath, vBar[nCurrBar].piInfo, parameters.UIMode) ; + bDone = true ; + nCurrBar ++ ; + } + } + } + else { + if ( vProc[j].Proc.HasExited) { + // se terminato con successo + if ( vProc[j].Proc.ExitCode == 0) { + // salvo il risultato + ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; + bDone = true ; + vProc[j].nBar = -1 ; + nActProc -- ; + } + // se superato il numero di processi eseguibili in parallelo + else if ( vProc[j].Proc.ExitCode == 1) { + // aggiungo il pezzo in coda + if ( numBars + nShiftBar < numBars + nMaxThread) { + vBar[numBars + nShiftBar] = vBar[vProc[j].nBar] ; + nShiftBar ++ ; + } + // disabilito il processo + vProc[j].bEnable = false ; + vProc[j].nBar = -1 ; + nActProc -- ; + } + // altrimenti (errore generico di esecuzione) + else { + // salvo il risultato + ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; + bDone = true ; + vProc[j].nBar = -1 ; + nActProc -- ; + } + } + else + vProc[j].Proc.Refresh() ; + } + if ( bDone) { + // Dialog con Progress Bar + dProgress += ( 0.9 / numBars) ; + nDoneBar ++ ; + string sProg = ( dProgress * 100 ).ToString("F1", CultureInfo.InvariantCulture) ; + callback.Progress((float)dProgress, + " Progress: " + sProg + "%" + "\n" + + " Count: " + nDoneBar + " / " + numBars, + ref bCancel); + if ( bCancel ) { + callback.Done( parameters) ; // fine + return ; + } + } + Thread.Sleep( 1) ; + } + // Verifico che i processi non siano andati tutti in errore + bool bAllKO = true ; + for ( int j = 0 ; j < nMaxThread ; ++ j) { + if ( vProc[j].bEnable) + bAllKO = false ; + } + if ( bAllKO) { + MessageBox.Show( "Execution error (all processes are disabled)") ; + break ; + } + Thread.Sleep( 10) ; + } + + callback.Progress( 1, "End", ref bCancel) ; + Thread.Sleep( 300) ; + + callback.Done( parameters) ; // fine + } + + //------------------------------------------------------------------------------------------------------------- + public void Abort() + { + //non implementata al momento + } + + //------------------------------------------------------------------------------------------------------------- + private static void ProcessResults( string BtlPath, PatternInfo pattInfo, InOutParameters.UIModes UIMode) + { + if ( UIMode == InOutParameters.UIModes.SHOWUI || UIMode == InOutParameters.UIModes.SIMULAZIONE) + return ; + bool bErrors = false ; + int nLastErr = 0 ; + string sLastMsg = "" ; + int nCurrCutId = 0 ; + Dictionary dctErr = new Dictionary() ; + Dictionary dctRot = new Dictionary() ; + int nTotTime = 0 ; + if ( File.Exists( Path.ChangeExtension( BtlPath, ".txt"))) { + int nErr = 0 ; + string sMsg = "" ; + double dRot = 0 ; + int cutId = 0 ; + int taskId = 0 ; + string[] lines = System.IO.File.ReadAllLines( Path.ChangeExtension( BtlPath, ".txt")) ; + foreach ( string line in lines) { + if ( line.StartsWith( "ERR=")) { + int? nVal = GetVal(line, "ERR") ; + nErr = ( nVal != null ? nVal.Value : 0) ; + sMsg = "" ; + cutId = 0 ; + taskId = 0 ; + } + else if ( line.StartsWith( "ROT=")) { + int? nVal = GetVal( line, "ROT") ; + int nRot = ( nVal != null ? nVal.Value : 0) ; + dRot = (( 4 - nRot) % 4) * 90 ; + } + else if ( line.StartsWith( "CUTID=")) { + int? nVal = GetVal( line, "CUTID") ; + cutId = ( nVal != null ? nVal.Value : 0) ; + if ( cutId != nCurrCutId) { + nCurrCutId = cutId ; + dctErr.Clear() ; + dctRot.Clear() ; + } + } + else if ( line.StartsWith( "TASKID=")) { + int? nVal = GetVal( line, "TASKID") ; + taskId = ( nVal != null ? nVal.Value : 0) ; + PatternInfo.Results resExe = PatternInfo.Results.OK ; + if ( nErr == 22) { + resExe = PatternInfo.Results.COLLISION ; + bErrors = true ; + // se non assegnata a feature la dichiaro globale + if ( cutId == 0 || taskId == 0) { + nLastErr = nErr ; + sLastMsg = sMsg ; + } + } + else if ( nErr > 0) { + resExe = PatternInfo.Results.WARNING ; + bErrors = true ; + // se non assegnata a feature la dichiaro globale + if ( cutId == 0 || taskId == 0) { + nLastErr = nErr ; + sLastMsg = sMsg ; + } + } + // gestione errore per feature identificata + if ( taskId != 0) { + // verifiche per feature con più parti + if ( dctErr.TryGetValue( taskId, out PatternInfo.Results resCurrExe)) { + if ( resExe > resCurrExe) { + dctErr[taskId] = resExe ; + pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; + } + } + else { + dctErr[taskId] = resExe ; + pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; + } + } + // altrimenti per feature generica + else { + pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; + } + // gestione rotazione per feature identificata + if ( taskId != 0) { + // verifiche per feature con più parti + if ( dctRot.TryGetValue( taskId, out double dCurrRot)) { + if ( Math.Abs( dRot) > 1) { + if ( Math.Abs( dCurrRot) < 1) + dctRot[taskId] = dRot ; + } + else { + dRot = dCurrRot ; + } + } + else { + dctRot.Add( taskId, dRot) ; + } + } + // imposto la rotazione + if ( pattInfo.IsFromProject) + pattInfo.SetProcessInfoChosen( cutId, taskId, dRot, 0, false) ; + else + pattInfo.SetTaskInfoChosen( cutId, taskId, dRot, 0, false) ; + } + else if ( line.StartsWith( "TIME=")) { + int? nVal = GetVal( line, "TIME") ; + nTotTime = ( nVal != null ? nVal.Value : 0) ; + } + else if ( ! string.IsNullOrWhiteSpace( line) && line != "---") + sMsg = line ; + } + } + else { + bErrors = true ; + nLastErr = 25 ; + sLastMsg = "Execution Error" ; + } + pattInfo.IsDone = true ; + if ( ! bErrors) { + pattInfo.Result = PatternInfo.Results.OK ; + pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; + } + else { + // Sezione oltre i limiti + if ( nLastErr == 17) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING ; + pattInfo.Message = sLastMsg ; + } + // Errore nel calcolo lavorazione o movimento carrelli + else if ( nLastErr == 19) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Collisione non assegnata ad una feature + else if ( nLastErr == 22) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION ; + pattInfo.Message = sLastMsg ; + } + // Extra corsa assi + else if ( nLastErr == 23) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Carri che scivolano sulla trave + else if ( nLastErr == 24) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Errore generico + else if ( nLastErr == 25) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Altro + else { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; + } + } + pattInfo.EstimatedTime = nTotTime ; + + // Lettura OutputFilename e scrittura nel parametro stringa Iso (caso UIModes.HIDDEN) + if ( ! bErrors && + ( UIMode == InOutParameters.UIModes.HIDDEN || UIMode == InOutParameters.UIModes.CLOUD)) { + + string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; + if ( File.Exists( CncPath)) { + string lines = System.IO.File.ReadAllText(CncPath) ; + pattInfo.Iso = lines ; + pattInfo.Result = PatternInfo.Results.OK ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK ; + } + else { + pattInfo.Iso = "" ; + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + } + } + } + + //------------------------------------------------------------------------------------------------------------- + // Il seguente metodo prende i record visualizzati in ds (Caso: Produzione) e li carica in un oggetto BTL + public static void GetListaTasks( BTL btlObject) + { + DataTable dTab = _ds.Tables[0] ; + Int32 listaTasksCount = dTab.Rows.Count ; + if ( listaTasksCount == 0) + return ; + + DataRow dRow0 = dTab.Rows[0] ; + btlObject.projectNumber = dRow0["projectId"].ToString() ; + btlObject.barLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.barLoad90 = GetBarLoad90P( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( CultureInfo.InvariantCulture) ; + btlObject.panelLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.panelWidth = GetBarWidthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.productionId = (int)dRow0["productionId"] ; + btlObject.patternId = (int)dRow0["patternId"] ; + btlObject.parts = new List() ; + + List ListaCutParts = GetListaCutIdP() ; + + for ( int c = 0 ; c < ListaCutParts.Count ; c++) { + + BTL.Part readPart = new BTL.Part() ; + + bool bFirst = true ; + for ( int f = 0; f < listaTasksCount; f++) { + + DataRow dRowF = dTab.Rows[f] ; + if ( (int)dRowF["cutId"] != ListaCutParts[c]) + continue ; + + if ( bFirst) { + readPart.singleMemberNumber = GetElementSN( (int)dRowF["elementId"], (int)dRowF["projectId"]) ; + readPart.count = "1" ; + readPart.length = dRowF["length"].ToString() ; + readPart.height = dRowF["height"].ToString() ; + readPart.width = dRowF["width"].ToString() ; + readPart.x = (double)dRowF["x"] ; + readPart.z = (double)dRowF["z"] ; + readPart.inverted = (double)dRowF["inverted"] ; + readPart.rotated = (double)dRowF["rotated"] ; + readPart.cutId = (int)dRowF["cutId"] ; + bFirst = false ; + readPart.features = new List() ; + } + + if ( string.IsNullOrEmpty( dRowF["taskId"].ToString())) + continue ; + + BTL.Feature readFeature = new BTL.Feature() { + taskId = dRowF["taskId"].ToString(), + processKey = dRowF["group"].ToString() + + "-" + dRowF["key"].ToString().Substring( 1, 3) + + "-" + dRowF["face"].ToString(), + designation = dRowF["des"].ToString(), + processIdent = dRowF["processIdent"].ToString(), + sag1 = dRowF["sag1"].ToString(), + text = dRowF["text"].ToString(), + process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", + processParameters = new List( 46) { + dRowF["p01"].ToString(), + dRowF["p02"].ToString(), + dRowF["p03"].ToString(), + dRowF["p04"].ToString(), + dRowF["p05"].ToString(), + dRowF["p06"].ToString(), + dRowF["p07"].ToString(), + dRowF["p08"].ToString(), + dRowF["p09"].ToString(), + dRowF["p10"].ToString(), + dRowF["p11"].ToString(), + dRowF["p12"].ToString(), + dRowF["p13"].ToString(), + dRowF["p14"].ToString(), + dRowF["p15"].ToString(), + dRowF["p16"].ToString(), + dRowF["p17"].ToString(), + dRowF["p18"].ToString(), + dRowF["p19"].ToString(), + dRowF["p20"].ToString(), + dRowF["p21"].ToString(), + dRowF["p22"].ToString(), + dRowF["p23"].ToString(), + dRowF["p24"].ToString(), + dRowF["p25"].ToString(), + dRowF["p26"].ToString(), + dRowF["q01"].ToString(), + dRowF["q02"].ToString(), + dRowF["q03"].ToString(), + dRowF["q04"].ToString(), + dRowF["q05"].ToString(), + dRowF["q06"].ToString(), + dRowF["q07"].ToString(), + dRowF["q08"].ToString(), + dRowF["q09"].ToString(), + dRowF["q10"].ToString(), + dRowF["q11"].ToString(), + dRowF["q12"].ToString(), + dRowF["q13"].ToString(), + dRowF["q14"].ToString(), + dRowF["q15"].ToString(), + dRowF["q16"].ToString(), + dRowF["q17"].ToString(), + dRowF["q18"].ToString(), + dRowF["q19"].ToString(), + dRowF["q20"].ToString() + }, + processReference = new List( 9) { + dRowF["ox"].ToString(), + dRowF["oy"].ToString(), + dRowF["oz"].ToString(), + dRowF["xx"].ToString(), + dRowF["xy"].ToString(), + dRowF["xz"].ToString(), + dRowF["yx"].ToString(), + dRowF["yy"].ToString(), + dRowF["yz"].ToString() + }, + } ; + readPart.features.Add( readFeature) ; + } + btlObject.parts.Add( readPart) ; + } + // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut + btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; + } + + //------------------------------------------------------------------------------------------------------------- + private static int? GetVal( string sText, string sKey) + { + string[] sParts = sText.Split( new Char[] { '=' }) ; + if ( string.Compare( sParts[0], sKey) != 0) + return null ; + if ( ! int.TryParse( sParts[1], out int nVal)) + return null ; + else + return nVal ; + } + + //------------------------------------------------------------------------------------------------------------- + // Il seguente metodo prende i record visualizzati in ds (Caso: Ordine) e li carica in un oggetto BTL + public static void GetListaProcesses( BTL btlObject) + { + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount == 0) { + btlObject.parts = null ; + return ; + } + + DataRow dRow0 = dTab.Rows[0] ; + btlObject.projectNumber = dRow0["projectId"].ToString() ; + btlObject.barLength = GetBarLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.barLoad90 = "0" ; + btlObject.panelLength = GetPanelLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.panelWidth = GetPanelWidthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.projectId = (int)dRow0["projectId"] ; + btlObject.elementId = (int)dRow0["elementId"] ; + btlObject.parts = new List() ; + + List ListaCutParts = new List( 1) ; + ListaCutParts.Add( (int)dRow0["elementId"]) ; + + for ( int c = 0 ; c < ListaCutParts.Count ; c++) { + + BTL.Part readPart = new BTL.Part() ; + + bool bFirst = true ; + for ( int f = 0 ; f < listaProcessesCount ; f++) { + + DataRow dRowF = dTab.Rows[f] ; + if ( (int)dRowF["elementId"] != ListaCutParts[c]) + continue ; + + if ( bFirst) { + readPart.singleMemberNumber = GetElementSN( (int)dRow0["elementId"], (int)dRow0["projectId"]) ; + readPart.count = "1" ; + readPart.length = dRowF["length"].ToString() ; + readPart.height = dRowF["height"].ToString() ; + readPart.width = dRowF["width"].ToString() ; + readPart.x = Constants.HeadOverMat ; + readPart.z = Constants.HeadOverMat ; + readPart.inverted = (double)dRowF["inverted"] ; + readPart.rotated = (double)dRowF["rotated"] ; + readPart.elementId = (int)dRowF["elementId"] ; + bFirst = false ; + readPart.features = new List() ; + } + + if ( string.IsNullOrEmpty( dRowF["processId"].ToString())) + continue ; + + BTL.Feature readFeature = new BTL.Feature() { + processId = dRowF["processId"].ToString(), + processKey = dRowF["group"].ToString() + + "-" + dRowF["key"].ToString().Substring( 1, 3) + + "-" + dRowF["face"].ToString(), + designation = dRowF["des"].ToString(), + processIdent = dRowF["processIdent"].ToString(), + sag1 = dRowF["sag1"].ToString(), + text = dRowF["text"].ToString(), + process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", + processParameters = new List( 46) { + dRowF["p01"].ToString(), + dRowF["p02"].ToString(), + dRowF["p03"].ToString(), + dRowF["p04"].ToString(), + dRowF["p05"].ToString(), + dRowF["p06"].ToString(), + dRowF["p07"].ToString(), + dRowF["p08"].ToString(), + dRowF["p09"].ToString(), + dRowF["p10"].ToString(), + dRowF["p11"].ToString(), + dRowF["p12"].ToString(), + dRowF["p13"].ToString(), + dRowF["p14"].ToString(), + dRowF["p15"].ToString(), + dRowF["p16"].ToString(), + dRowF["p17"].ToString(), + dRowF["p18"].ToString(), + dRowF["p19"].ToString(), + dRowF["p20"].ToString(), + dRowF["p21"].ToString(), + dRowF["p22"].ToString(), + dRowF["p23"].ToString(), + dRowF["p24"].ToString(), + dRowF["p25"].ToString(), + dRowF["p26"].ToString(), + dRowF["q01"].ToString(), + dRowF["q02"].ToString(), + dRowF["q03"].ToString(), + dRowF["q04"].ToString(), + dRowF["q05"].ToString(), + dRowF["q06"].ToString(), + dRowF["q07"].ToString(), + dRowF["q08"].ToString(), + dRowF["q09"].ToString(), + dRowF["q10"].ToString(), + dRowF["q11"].ToString(), + dRowF["q12"].ToString(), + dRowF["q13"].ToString(), + dRowF["q14"].ToString(), + dRowF["q15"].ToString(), + dRowF["q16"].ToString(), + dRowF["q17"].ToString(), + dRowF["q18"].ToString(), + dRowF["q19"].ToString(), + dRowF["q20"].ToString() + }, + processReference = new List( 9) { + dRowF["ox"].ToString(), + dRowF["oy"].ToString(), + dRowF["oz"].ToString(), + dRowF["xx"].ToString(), + dRowF["xy"].ToString(), + dRowF["xz"].ToString(), + dRowF["yx"].ToString(), + dRowF["yy"].ToString(), + dRowF["yz"].ToString() + }, + } ; + readPart.features.Add( readFeature) ; + } + btlObject.parts.Add( readPart) ; + } + // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut + btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; + } + + //------------------------------------------------------------------------------------------------------------- + // Il seguente metodo si connette al DB per estrarre tramite una query i cutId della tabella vw_Cut + // aventi patternId e ProductionId che corrispondono a quelli passati come argomento + private static List GetListaCutIdP() + { + List ListaCutId = new List() ; + + DataTable dTab = _ds.Tables[0] ; + int listaTasksCount = dTab.Rows.Count ; + for ( int f = 0 ; f < listaTasksCount ; f++) { + int nCut = (int) dTab.Rows[f]["cutId"] ; + if ( ! ListaCutId.Contains( nCut)) + ListaCutId.Add( nCut) ; + } + + return ListaCutId ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera il singlemembernumber dell'Elemento (colonna "sn") + private static string GetElementSN( int ElementId, int ProjectId) + { + string SN = "000" ; + + string sqlElementSN = "SELECT sn " + + "FROM dbo.vw_Element " + + "WHERE elementId = @firstId " + + "AND projectId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlElementSN, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = ElementId ; + sqlCommand.Parameters["@secondId"].Value = ProjectId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + SN = Convert.ToString( reader["sn"]) ; + } + } + } + + return SN ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza della barra nel caso Produzione (colonna "l") + private static double GetBarLengthP( int patternId, int productionId) + { + double barLength = 0 ; + + string sqlBarLength = "SELECT l " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barLength = Convert.ToDouble( reader["l"]) ; + } + } + } + + return barLength ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la larghezza della barra nel caso Produzione (colonna "w") + private static double GetBarWidthP( int patternId, int productionId) + { + double barWidth = 0 ; + + string sqlBarWidth = "SELECT w " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarWidth, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barWidth = Convert.ToDouble( reader["w"]) ; + } + } + } + + return barWidth ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera il flag di carico con rotazione di 90° nel caso Produzione (colonna "load90") + private static int GetBarLoad90P( int patternId, int productionId) + { + int nLoad90 = 0 ; + + string sqlBarLength = "SELECT load90 " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + nLoad90 = Convert.ToInt32( reader["load90"]) ; + } + } + } + + return nLoad90 ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera lo stato della barra nel caso Produzione (colonna "state") + private static int GetBarStateP( int patternId, int productionId) + { + int barState = 16 ; + + string sqlBarLength = "SELECT state " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barState = Convert.ToInt32( reader["state"]) ; + } + } + } + + return barState ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza della barra nel caso Ordine (colonna "length", ovvero la lunghezza della singola trave) + // a cui aggiungiamo un valore fisso (es. 2000) + private static double GetBarLengthO( int elementId, int projectId) + { + double barLength = 0 ; + + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount > 0) { + double beamLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; + if ( beamLength < Constants.BarMaxLenForAdd) + barLength = beamLength + Constants.BarAddLen ; + else + barLength = beamLength + 2 * Constants.HeadOverMat ; + } + + return barLength ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza del pannello nel caso Ordine (colonna "length", ovvero la lunghezza della singola parete) + // a cui aggiungiamo un valore fisso (es. 200) + private static double GetPanelLengthO( int elementId, int projectId) + { + double panelLength = 0 ; + + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount > 0) { + double wallLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; + panelLength = wallLength + 2 * Constants.PanelOverMat ; + } + + return panelLength ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza del pannello nel caso Ordine (colonna "width", ovvero la larghezza della singola parete) + // a cui aggiungiamo un valore fisso (es. 200) + private static double GetPanelWidthO( int elementId, int projectId) + { + double panelWidth = 0 ; + + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount > 0) { + double wallWidth = Convert.ToDouble( dTab.Rows[0]["width"]) ; + panelWidth = wallWidth + 2 * Constants.PanelOverMat ; + } + + return panelWidth ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce la path di esecuzione di EgtCam5 + private static String GetExePath( InOutParameters parameters) + { + return parameters.Read( "EGALTECH", "PATH_EXE", "") ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce il direttorio per i file con i dati macchina + private static String GetDataDir( InOutParameters parameters) + { + String DataDir = parameters.Read( "EGALTECH", "DIR_DATA", "") ; + // Se la directory non esiste viene creata + DirectoryInfo di = new DirectoryInfo( DataDir) ; + if ( ! di.Exists) + di.Create() ; + return DataDir ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce la path completa per il file BTL + private static String GetBtlPath( String DataDir, PatternInfo pattInfo) + { + String BtlDir, BtlName ; + // Se progetto + if ( pattInfo.IsFromProject) { + BtlDir = Path.Combine( DataDir, "Projs", pattInfo.ProjectId.ToString( "D4")) ; + BtlName = "Part_" + pattInfo.ProjectId.ToString() + "_" + pattInfo.ElementId.ToString() + ".btl" ; + } + // altrimenti produzione + else { + BtlDir = Path.Combine( DataDir, "Prods", pattInfo.ProductionId.ToString( "D4")) ; + BtlName = "Bar_" + pattInfo.ProductionId.ToString() + "_" + pattInfo.PatternId.ToString() + ".btl" ; + } + // Se la directory non esiste viene creata + DirectoryInfo di = new DirectoryInfo( BtlDir) ; + if ( ! di.Exists) + di.Create() ; + // restituisco la path completa + return Path.Combine( BtlDir, BtlName) ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce il massimo numero di istanze di EgtCAM5 eseguibili contemporaneamente + private static int GetMaxInstances( InOutParameters parameters) + { + String sMaxInst = parameters.Read( "EGALTECH", "MaxInstances", "1") ; + if ( ! int.TryParse( sMaxInst, out int nVal)) + return 1 ; + else + return Math.Max( nVal, 1) ; + } + + //------------------------------------------------------------------------------------------------------------- + // Visualizzazione finestra gestione DB utensili + public bool ShowTools( InOutParameters parameters) + { + // Recupero dati + string ExePath = GetExePath( parameters) ; + string DataDir = GetDataDir( parameters) ; + string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; + // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo + Process process = new Process() ; + process.StartInfo.FileName = ExePath ; + process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 11" ; + process.StartInfo.UseShellExecute = false ; + process.Start() ; + // Attendo il termine del processo + while ( ! process.HasExited) { + process.Refresh() ; + Thread.Sleep( 50) ; + } + return true ; + } + + //------------------------------------------------------------------------------------------------------------- + // Visualizzazione finestra gestione DB lavorazioni + public bool ShowJobs( InOutParameters parameters) + { + // Recupero dati + string ExePath = GetExePath( parameters) ; + string DataDir = GetDataDir( parameters) ; + string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; + // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo + Process process = new Process() ; + process.StartInfo.FileName = ExePath ; + process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 12" ; + process.StartInfo.UseShellExecute = false ; + process.Start() ; + // Attendo il termine del processo + while ( ! process.HasExited) { + process.Refresh() ; + Thread.Sleep( 50) ; + } + return true ; + } + + //------------------------------------------------------------------------------------------------------------- + // Aggiornamento dati macchina + public bool UpdateMachine( InOutParameters parameters) + { + GetMachineParams( parameters) ; + + return true ; + } + + //------------------------------------------------------------------------------------------------------------- + // Dati utensili e macchina + //------------------------------------------------------------------------------------------------------------- + // Import della funzione di sistema per la scrittura su file INI + [DllImport("kernel32", CharSet = CharSet.Unicode)] + static extern long WritePrivateProfileString( string Section, string Key, string Value, string FilePath) ; + + //------------------------------------------------------------------------------------------------------------- + // Scrive il file Essetre-[MachineName].data che riporta i parametri macchina del DB + private static void GetMachineParams( InOutParameters parameters) + { + // Direttorio di scrittura del file + String DataDir = GetDataDir( parameters) ; + + // Path del file di dati e sua cancellazione se già esiste + string DataName = "Essetre-" + parameters.MachineName + ".data" ; + string DataPath = Path.Combine( DataDir, DataName) ; + if ( File.Exists( DataPath)) + File.Delete( DataPath) ; + + // Preparazione interrogazione per Offsets del DB + _SqlConnectionStr = parameters.ConnectionString ; + DataSet dsOffsets = new DataSet() ; + + string sqlOffsets = "SELECT [group], [key], [value] " + + "FROM [ESSETRE].[dbo].[vw_MachineParam] " + + "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand cmd = new SqlCommand(sqlOffsets, cn)) { + cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; + cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; + var dataAdapter = new SqlDataAdapter( cmd) ; + // Lettura DB e riempimento DataSet + dsOffsets.Clear() ; + dataAdapter.Fill(dsOffsets) ; + } + } + + // Preparazione interrogazione per Trave del DB + _SqlConnectionStr = parameters.ConnectionString ; + DataSet dsTrave = new DataSet() ; + + string sqlTrave = "SELECT [group], [key], [value] " + + "FROM [ESSETRE].[dbo].[vw_MachineParam] " + + "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand cmd = new SqlCommand( sqlTrave, cn)) { + cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; + cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; + var dataAdapter = new SqlDataAdapter( cmd) ; + // Lettura DB e riempimento DataSet + dsTrave.Clear() ; + dataAdapter.Fill( dsTrave) ; + } + } + + // Preparazione interrogazione per Dati Utente del DB + _SqlConnectionStr = parameters.ConnectionString; + DataSet dsUser = new DataSet(); + + string sqlUser = "SELECT [group], [key], [value] " + + "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " + + "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId"; + + // Connessione al DB ed esecuzione query + using (SqlConnection cn = new SqlConnection(_SqlConnectionStr)) + { + cn.Open(); + using (SqlCommand cmd = new SqlCommand(sqlUser, cn)) + { + cmd.Parameters.Add("@ConfigId", SqlDbType.Int); + cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId; + var dataAdapter = new SqlDataAdapter(cmd); + // Lettura DB e riempimento DataSet + dsUser.Clear(); + dataAdapter.Fill(dsUser); + } + } + + // Apro file + using ( var tw = new StreamWriter( DataPath, false)) { + + // Scrittura intestazione + tw.WriteLine( "-- " + DataPath) ; + tw.WriteLine( "") ; + + // Scrittura dei dati di Offsets + tw.WriteLine( "local Offsets = {") ; + foreach ( DataTable table in dsOffsets.Tables) { + foreach ( DataRow row in table.Rows) { + String Key = row["key"].ToString() ; + String Value = row["value"].ToString() ; + tw.WriteLine( " " + Key + "=" + Value + ",") ; + } + } + tw.WriteLine( " Zzz=1") ; + tw.WriteLine( "}") ; + tw.WriteLine( "") ; + + // Scrittura dei dati di Trave + tw.WriteLine( "local Trave = {") ; + foreach ( DataTable table in dsTrave.Tables) { + foreach ( DataRow row in table.Rows) { + String Key = row["key"].ToString() ; + String Value = row["value"].ToString() ; + tw.WriteLine( " " + Key + "=" + Value + ",") ; + } + } + tw.WriteLine( " Zzz=1") ; + tw.WriteLine( "}") ; + tw.WriteLine( "") ; + + // Scrittura dei dati di Utente + tw.WriteLine("local User = {"); + foreach (DataTable table in dsUser.Tables) + { + foreach (DataRow row in table.Rows) + { + String Group = row["group"].ToString(); + String Key = row["key"].ToString(); + String Value = row["value"].ToString(); + tw.WriteLine(" " + Group + "_" + Key + "=" + Value + ","); + } + } + tw.WriteLine(" Zzz=1"); + tw.WriteLine("}"); + tw.WriteLine(""); + + // Scrittura tabella da restituire + tw.WriteLine( "local Machine = { Offsets=Offsets, Trave=Trave, User=User}") ; + + tw.WriteLine( "return Machine") ; + } + } + + //------------------------------------------------------------------------------------------------------------- + // Indica direttori e file per backup + public void CollectFile( InOutParameters parameters, FileCollector collector) + { + // Direttori notevoli + String sRoot = parameters.Read( "EGALTECH", "DIR_EGT", "C:\\TechnoEssetre7\\EgalTech") ; + String sBeamDir = "EgtCAM5\\Beam" ; + String sMachDir = "EgtCAM5\\Machines\\Essetre-" + parameters.MachineName ; + // Impostazione + collector.SetRoot(sRoot) ; + collector.AddDirectory(Path.Combine(sRoot, sBeamDir)) ; + collector.AddDirectory(Path.Combine(sRoot, sMachDir)) ; + } + +} diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs b/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs new file mode 100644 index 00000000..f8b3417b --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs @@ -0,0 +1,1276 @@ +using System; +using System.Windows.Forms; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Globalization ; +using ib.essetre.integration; +using ib.essetre.integration.egaltech; + +namespace ib.essetre.integration.egaltech +{ + public class Generator : ib.essetre.integration.IGenerator + { + private System.Threading.Thread _thread ; + private static DataSet _ds = new DataSet() ; + private static string _SqlConnectionStr = "" ; + + private struct Bar + { + public PatternInfo piInfo ; + public int nBarState ; + public string sBtlPath ; + public bool bBtlOk ; + } + + private struct MyProc + { + public bool bEnable ; + public Process Proc ; + public int nBar ; + } + + //------------------------------------------------------------------------------------------------------------- + public Generator() + { + } + + //------------------------------------------------------------------------------------------------------------- + public void Run(InOutParameters parameters, ICallBack callback) + { + _thread = new Thread(() => DoJob( parameters, callback)) ; + _thread.Start() ; + } + + private delegate void dDoJob( InOutParameters parameters, ICallBack callback) ; + + //------------------------------------------------------------------------------------------------------------- + // campo data ultima modifica nel DATABASE [lastModified] + private static void DoJob( InOutParameters parameters, ICallBack callback) + { + bool bCancel = false ; + callback.Progress( 0, "Init", ref bCancel) ; + + _SqlConnectionStr = parameters.ConnectionString ; + + String ExePath = GetExePath( parameters) ; + String DataDir = GetDataDir( parameters) ; + + // Numero di barre + int numBars = parameters.Patterns.Length ; + if ( numBars == 0) + return ; + + // Se modalità Cloud, allora conta solo la prima barra + bool bCloud = ( parameters.UIMode == InOutParameters.UIModes.CLOUD) ; + if ( bCloud) + numBars = 1 ; + + // Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) + int nMaxThread = Math.Min( Environment.ProcessorCount, GetMaxInstances( parameters)) ; + + // Frazione di avanzamento del lavoro (in pu) + double dProgress = 0 ; + + // Genero i Btl di tutte le barre + Bar[] vBar = new Bar[ numBars + nMaxThread] ; + for ( int i = 0; i < numBars; i++) { + + PatternInfo pattInfo = parameters.Patterns[i] ; + + BTL btlObject = new BTL() ; + + // Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project, + // se invece è FALSE viene eseguita la query sulle tabelle Production + string sql = "" ; + if ( pattInfo.IsFromProject) { + sql = "SELECT E.projectId, " + + "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " + + "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " + + "P.flagDeleted, P.[group], [key], face, edge, des, " + + "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + + "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + + "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + + "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " + + "E.inverted, E.rotated, 0 doneTime, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " + + "FROM dbo.vw_Process AS P " + + "RIGHT OUTER JOIN dbo.vw_Element AS E " + + "ON P.projectId=E.projectId AND P.elementId=E.elementId " + + "WHERE E.projectId = @firstId AND E.elementId = @secondId" ; + } + else { + sql = "SELECT vw_Cut.productionId, " + + "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " + + "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " + + "vw_Task.flagDeleted, [group], [key], face, edge, des, " + + "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + + "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + + "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + + "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " + + "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " + + "FROM dbo.vw_Task " + + "RIGHT OUTER JOIN dbo.vw_Cut " + + "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " + + "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId" ; + } + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using (SqlCommand cmd = new SqlCommand( sql, cn)) { + cmd.Parameters.Add( "@firstId", SqlDbType.Int) ; + cmd.Parameters.Add( "@secondId", SqlDbType.Int) ; + if ( pattInfo.IsFromProject) { + cmd.Parameters["@firstId"].Value = pattInfo.ProjectId ; + cmd.Parameters["@secondId"].Value = pattInfo.ElementId ; + } + else { + cmd.Parameters["@firstId"].Value = pattInfo.ProductionId ; + cmd.Parameters["@secondId"].Value = pattInfo.PatternId ; + } + var dataAdapter = new SqlDataAdapter( cmd) ; + + // Lettura DB e riempimento DataSet + _ds.Clear() ; + dataAdapter.Fill( _ds) ; + } + } + + // Verifica parametro isFromProject: nel caso Ordine viene ottenuta la lista dei Process, + // nel caso Produzione viene ottenuta la lista dei Task + if ( pattInfo.IsFromProject) + GetListaProcesses( btlObject) ; + else + GetListaTasks( btlObject) ; + + // Recupero lo stato della barra + int nBarState = 0 ; + if ( ! pattInfo.IsFromProject) + nBarState = GetBarStateP( btlObject.patternId, btlObject.productionId) ; + + // Dialog con Progress Bar + dProgress += 0.1 / numBars ; + string sProg = ( dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) ; + callback.Progress( (float) dProgress, + " Progress: " + sProg + "%" + "\n", + ref bCancel) ; + if ( bCancel) { + callback.Done( parameters) ; //fine + return ; + } + + // Scrittura del file BTL + // Path completa del nome del file da salvare + string BtlPath = GetBtlPath( DataDir, pattInfo) ; + bool BtlOk = btlObject.WriteIntoFile( BtlPath, pattInfo.IsFromProject) ; + + // Se modalità cloud, scrittura del file di punti + bool bErrOnCloud = false ; + if ( bCloud) { + if ( pattInfo.Cloud != null) { + using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".pnt"), false)) { + for ( int j = 0 ; j < pattInfo.Cloud.Count() ; j++) { + double dPosX = - pattInfo.Cloud[j].Y ; + double dPosY = pattInfo.Cloud[j].X ; + string sPosX = dPosX.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; + string sPosY = dPosY.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; + tw.WriteLine( sPosX + " " + sPosY) ; + } + } + } + else { + BtlOk = false ; + bErrOnCloud = true ; + } + } + + // Se scrittura Btl non riuscita + if ( ! BtlOk) { + // scrivo direttamente il file di errore + int ErrCutId = ( pattInfo.IsFromProject ? pattInfo.ElementId : pattInfo.PatternId) ; + using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".txt"), false)) { + tw.WriteLine( "ERR=10") ; + tw.WriteLine( bErrOnCloud ? "Cloud without points" : "BTL without processes") ; + tw.WriteLine( "CUTID=" + ErrCutId.ToString()) ; + tw.WriteLine( "TASKID=0") ; + } + // elimino eventuale file Cn già presente + if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN) { + string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; + if ( File.Exists( CncPath)) + File.Delete( CncPath) ; + } + } + // altrimenti + else { + // cancello eventuale file di errore già presente + string TxtPath = Path.ChangeExtension( BtlPath, ".txt") ; + if ( File.Exists( TxtPath)) + File.Delete( TxtPath) ; + } + + // Salvo dati + vBar[i].piInfo = pattInfo ; + vBar[i].nBarState = nBarState ; + vBar[i].sBtlPath = BtlPath ; + vBar[i].bBtlOk = BtlOk ; + } + + // Lancio in parallelo più processi (senza superare il numero di core logici presenti) + MyProc[] vProc = new MyProc[nMaxThread] ; + for ( int j = 0 ; j < nMaxThread ; ++ j) { + vProc[j].nBar = -1 ; + vProc[j].bEnable = true ; + } + + // Processo i Btl in parallelo + int nCurrBar = 0 ; + int nDoneBar = 0 ; + int nShiftBar = 0 ; + int nActProc = 0 ; + while ( nCurrBar < numBars + nShiftBar || nActProc > 0) { + for ( int j = 0 ; j < nMaxThread ; ++ j) { + if ( ! vProc[j].bEnable) + continue ; + bool bDone = false ; + if ( vProc[j].nBar == -1) { + if ( nCurrBar < numBars + nShiftBar) { + if ( vBar[nCurrBar].bBtlOk) { + vProc[j].Proc = new Process() ; + vProc[j].Proc.StartInfo.FileName = ExePath ; + int nMode = (int)parameters.UIMode ; + if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN && vBar[nCurrBar].nBarState != 0) + nMode = 4 ; + vProc[j].Proc.StartInfo.Arguments = "\"" + vBar[nCurrBar].sBtlPath + "\" " + parameters.MachineName + " " + nMode.ToString() ; + vProc[j].Proc.StartInfo.UseShellExecute = false ; + if ( vProc[j].Proc.Start()) { + vProc[j].nBar = nCurrBar ; + nCurrBar ++ ; + nActProc ++ ; + } + } + else { + ProcessResults( vBar[nCurrBar].sBtlPath, vBar[nCurrBar].piInfo, parameters.UIMode) ; + bDone = true ; + nCurrBar ++ ; + } + } + } + else { + if ( vProc[j].Proc.HasExited) { + // se terminato con successo + if ( vProc[j].Proc.ExitCode == 0) { + // salvo il risultato + ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; + bDone = true ; + vProc[j].nBar = -1 ; + nActProc -- ; + } + // se superato il numero di processi eseguibili in parallelo + else if ( vProc[j].Proc.ExitCode == 1) { + // aggiungo il pezzo in coda + if ( numBars + nShiftBar < numBars + nMaxThread) { + vBar[numBars + nShiftBar] = vBar[vProc[j].nBar] ; + nShiftBar ++ ; + } + // disabilito il processo + vProc[j].bEnable = false ; + vProc[j].nBar = -1 ; + nActProc -- ; + } + // altrimenti (errore generico di esecuzione) + else { + // salvo il risultato + ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; + bDone = true ; + vProc[j].nBar = -1 ; + nActProc -- ; + } + } + else + vProc[j].Proc.Refresh() ; + } + if ( bDone) { + // Dialog con Progress Bar + dProgress += ( 0.9 / numBars) ; + nDoneBar ++ ; + string sProg = ( dProgress * 100 ).ToString("F1", CultureInfo.InvariantCulture) ; + callback.Progress((float)dProgress, + " Progress: " + sProg + "%" + "\n" + + " Count: " + nDoneBar + " / " + numBars, + ref bCancel); + if ( bCancel ) { + callback.Done( parameters) ; // fine + return ; + } + } + Thread.Sleep( 1) ; + } + // Verifico che i processi non siano andati tutti in errore + bool bAllKO = true ; + for ( int j = 0 ; j < nMaxThread ; ++ j) { + if ( vProc[j].bEnable) + bAllKO = false ; + } + if ( bAllKO) { + MessageBox.Show( "Execution error (all processes are disabled)") ; + break ; + } + Thread.Sleep( 10) ; + } + + callback.Progress( 1, "End", ref bCancel) ; + Thread.Sleep( 300) ; + + callback.Done( parameters) ; // fine + } + + //------------------------------------------------------------------------------------------------------------- + public void Abort() + { + //non implementata al momento + } + + //------------------------------------------------------------------------------------------------------------- + private static void ProcessResults( string BtlPath, PatternInfo pattInfo, InOutParameters.UIModes UIMode) + { + if ( UIMode == InOutParameters.UIModes.SHOWUI || UIMode == InOutParameters.UIModes.SIMULAZIONE) + return ; + bool bErrors = false ; + int nLastErr = 0 ; + string sLastMsg = "" ; + int nCurrCutId = 0 ; + Dictionary dctErr = new Dictionary() ; + Dictionary dctRot = new Dictionary() ; + int nTotTime = 0 ; + if ( File.Exists( Path.ChangeExtension( BtlPath, ".txt"))) { + int nErr = 0 ; + string sMsg = "" ; + double dRot = 0 ; + int cutId = 0 ; + int taskId = 0 ; + string[] lines = System.IO.File.ReadAllLines( Path.ChangeExtension( BtlPath, ".txt")) ; + foreach ( string line in lines) { + if ( line.StartsWith( "ERR=")) { + int? nVal = GetVal(line, "ERR") ; + nErr = ( nVal != null ? nVal.Value : 0) ; + sMsg = "" ; + cutId = 0 ; + taskId = 0 ; + } + else if ( line.StartsWith( "ROT=")) { + int? nVal = GetVal( line, "ROT") ; + int nRot = ( nVal != null ? nVal.Value : 0) ; + dRot = (( 4 - nRot) % 4) * 90 ; + } + else if ( line.StartsWith( "CUTID=")) { + int? nVal = GetVal( line, "CUTID") ; + cutId = ( nVal != null ? nVal.Value : 0) ; + if ( cutId != nCurrCutId) { + nCurrCutId = cutId ; + dctErr.Clear() ; + dctRot.Clear() ; + } + } + else if ( line.StartsWith( "TASKID=")) { + int? nVal = GetVal( line, "TASKID") ; + taskId = ( nVal != null ? nVal.Value : 0) ; + PatternInfo.Results resExe = PatternInfo.Results.OK ; + if ( nErr == 22) { + resExe = PatternInfo.Results.COLLISION ; + bErrors = true ; + // se non assegnata a feature la dichiaro globale + if ( cutId == 0 || taskId == 0) { + nLastErr = nErr ; + sLastMsg = sMsg ; + } + } + else if ( nErr > 0) { + resExe = PatternInfo.Results.WARNING ; + bErrors = true ; + // se non assegnata a feature la dichiaro globale + if ( cutId == 0 || taskId == 0) { + nLastErr = nErr ; + sLastMsg = sMsg ; + } + } + // gestione errore per feature identificata + if ( taskId != 0) { + // verifiche per feature con più parti + if ( dctErr.TryGetValue( taskId, out PatternInfo.Results resCurrExe)) { + if ( resExe > resCurrExe) { + dctErr[taskId] = resExe ; + pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; + } + } + else { + dctErr[taskId] = resExe ; + pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; + } + } + // altrimenti per feature generica + else { + pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; + } + // gestione rotazione per feature identificata + if ( taskId != 0) { + // verifiche per feature con più parti + if ( dctRot.TryGetValue( taskId, out double dCurrRot)) { + if ( Math.Abs( dRot) > 1) { + if ( Math.Abs( dCurrRot) < 1) + dctRot[taskId] = dRot ; + } + else { + dRot = dCurrRot ; + } + } + else { + dctRot.Add( taskId, dRot) ; + } + } + // imposto la rotazione + if ( pattInfo.IsFromProject) + pattInfo.SetProcessInfoChosen( cutId, taskId, dRot, 0, false) ; + else + pattInfo.SetTaskInfoChosen( cutId, taskId, dRot, 0, false) ; + } + else if ( line.StartsWith( "TIME=")) { + int? nVal = GetVal( line, "TIME") ; + nTotTime = ( nVal != null ? nVal.Value : 0) ; + } + else if ( ! string.IsNullOrWhiteSpace( line) && line != "---") + sMsg = line ; + } + } + else { + bErrors = true ; + nLastErr = 25 ; + sLastMsg = "Execution Error" ; + } + pattInfo.IsDone = true ; + if ( ! bErrors) { + pattInfo.Result = PatternInfo.Results.OK ; + pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; + } + else { + // Sezione oltre i limiti + if ( nLastErr == 17) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING ; + pattInfo.Message = sLastMsg ; + } + // Errore nel calcolo lavorazione o movimento carrelli + else if ( nLastErr == 19) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Collisione non assegnata ad una feature + else if ( nLastErr == 22) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION ; + pattInfo.Message = sLastMsg ; + } + // Extra corsa assi + else if ( nLastErr == 23) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Carri che scivolano sulla trave + else if ( nLastErr == 24) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Errore generico + else if ( nLastErr == 25) { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + pattInfo.Message = sLastMsg ; + } + // Altro + else { + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; + } + } + pattInfo.EstimatedTime = nTotTime ; + + // Lettura OutputFilename e scrittura nel parametro stringa Iso (caso UIModes.HIDDEN) + if ( ! bErrors && + ( UIMode == InOutParameters.UIModes.HIDDEN || UIMode == InOutParameters.UIModes.CLOUD)) { + + string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; + if ( File.Exists( CncPath)) { + string lines = System.IO.File.ReadAllText(CncPath) ; + pattInfo.Iso = lines ; + pattInfo.Result = PatternInfo.Results.OK ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK ; + } + else { + pattInfo.Iso = "" ; + pattInfo.Result = PatternInfo.Results.ERROR ; + pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; + } + } + } + + //------------------------------------------------------------------------------------------------------------- + // Il seguente metodo prende i record visualizzati in ds (Caso: Produzione) e li carica in un oggetto BTL + public static void GetListaTasks( BTL btlObject) + { + DataTable dTab = _ds.Tables[0] ; + Int32 listaTasksCount = dTab.Rows.Count ; + if ( listaTasksCount == 0) + return ; + + DataRow dRow0 = dTab.Rows[0] ; + btlObject.projectNumber = dRow0["projectId"].ToString() ; + btlObject.barLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.barLoad90 = GetBarLoad90P( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( CultureInfo.InvariantCulture) ; + btlObject.panelLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.panelWidth = GetBarWidthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.productionId = (int)dRow0["productionId"] ; + btlObject.patternId = (int)dRow0["patternId"] ; + btlObject.parts = new List() ; + + List ListaCutParts = GetListaCutIdP() ; + + for ( int c = 0 ; c < ListaCutParts.Count ; c++) { + + BTL.Part readPart = new BTL.Part() ; + + bool bFirst = true ; + for ( int f = 0; f < listaTasksCount; f++) { + + DataRow dRowF = dTab.Rows[f] ; + if ( (int)dRowF["cutId"] != ListaCutParts[c]) + continue ; + + if ( bFirst) { + readPart.singleMemberNumber = GetElementSN( (int)dRowF["elementId"], (int)dRowF["projectId"]) ; + readPart.count = "1" ; + readPart.length = dRowF["length"].ToString() ; + readPart.height = dRowF["height"].ToString() ; + readPart.width = dRowF["width"].ToString() ; + readPart.x = (double)dRowF["x"] ; + readPart.z = (double)dRowF["z"] ; + readPart.inverted = (double)dRowF["inverted"] ; + readPart.rotated = (double)dRowF["rotated"] ; + readPart.cutId = (int)dRowF["cutId"] ; + bFirst = false ; + readPart.features = new List() ; + } + + if ( string.IsNullOrEmpty( dRowF["taskId"].ToString())) + continue ; + + BTL.Feature readFeature = new BTL.Feature() { + taskId = dRowF["taskId"].ToString(), + processKey = dRowF["group"].ToString() + + "-" + dRowF["key"].ToString().Substring( 1, 3) + + "-" + dRowF["face"].ToString(), + designation = dRowF["des"].ToString(), + processIdent = dRowF["processIdent"].ToString(), + sag1 = dRowF["sag1"].ToString(), + text = dRowF["text"].ToString(), + process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", + processParameters = new List( 46) { + dRowF["p01"].ToString(), + dRowF["p02"].ToString(), + dRowF["p03"].ToString(), + dRowF["p04"].ToString(), + dRowF["p05"].ToString(), + dRowF["p06"].ToString(), + dRowF["p07"].ToString(), + dRowF["p08"].ToString(), + dRowF["p09"].ToString(), + dRowF["p10"].ToString(), + dRowF["p11"].ToString(), + dRowF["p12"].ToString(), + dRowF["p13"].ToString(), + dRowF["p14"].ToString(), + dRowF["p15"].ToString(), + dRowF["p16"].ToString(), + dRowF["p17"].ToString(), + dRowF["p18"].ToString(), + dRowF["p19"].ToString(), + dRowF["p20"].ToString(), + dRowF["p21"].ToString(), + dRowF["p22"].ToString(), + dRowF["p23"].ToString(), + dRowF["p24"].ToString(), + dRowF["p25"].ToString(), + dRowF["p26"].ToString(), + dRowF["q01"].ToString(), + dRowF["q02"].ToString(), + dRowF["q03"].ToString(), + dRowF["q04"].ToString(), + dRowF["q05"].ToString(), + dRowF["q06"].ToString(), + dRowF["q07"].ToString(), + dRowF["q08"].ToString(), + dRowF["q09"].ToString(), + dRowF["q10"].ToString(), + dRowF["q11"].ToString(), + dRowF["q12"].ToString(), + dRowF["q13"].ToString(), + dRowF["q14"].ToString(), + dRowF["q15"].ToString(), + dRowF["q16"].ToString(), + dRowF["q17"].ToString(), + dRowF["q18"].ToString(), + dRowF["q19"].ToString(), + dRowF["q20"].ToString() + }, + processReference = new List( 9) { + dRowF["ox"].ToString(), + dRowF["oy"].ToString(), + dRowF["oz"].ToString(), + dRowF["xx"].ToString(), + dRowF["xy"].ToString(), + dRowF["xz"].ToString(), + dRowF["yx"].ToString(), + dRowF["yy"].ToString(), + dRowF["yz"].ToString() + }, + } ; + readPart.features.Add( readFeature) ; + } + btlObject.parts.Add( readPart) ; + } + // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut + btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; + } + + //------------------------------------------------------------------------------------------------------------- + private static int? GetVal( string sText, string sKey) + { + string[] sParts = sText.Split( new Char[] { '=' }) ; + if ( string.Compare( sParts[0], sKey) != 0) + return null ; + if ( ! int.TryParse( sParts[1], out int nVal)) + return null ; + else + return nVal ; + } + + //------------------------------------------------------------------------------------------------------------- + // Il seguente metodo prende i record visualizzati in ds (Caso: Ordine) e li carica in un oggetto BTL + public static void GetListaProcesses( BTL btlObject) + { + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount == 0) { + btlObject.parts = null ; + return ; + } + + DataRow dRow0 = dTab.Rows[0] ; + btlObject.projectNumber = dRow0["projectId"].ToString() ; + btlObject.barLength = GetBarLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.barLoad90 = "0" ; + btlObject.panelLength = GetPanelLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.panelWidth = GetPanelWidthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; + btlObject.projectId = (int)dRow0["projectId"] ; + btlObject.elementId = (int)dRow0["elementId"] ; + btlObject.parts = new List() ; + + List ListaCutParts = new List( 1) ; + ListaCutParts.Add( (int)dRow0["elementId"]) ; + + for ( int c = 0 ; c < ListaCutParts.Count ; c++) { + + BTL.Part readPart = new BTL.Part() ; + + bool bFirst = true ; + for ( int f = 0 ; f < listaProcessesCount ; f++) { + + DataRow dRowF = dTab.Rows[f] ; + if ( (int)dRowF["elementId"] != ListaCutParts[c]) + continue ; + + if ( bFirst) { + readPart.singleMemberNumber = GetElementSN( (int)dRow0["elementId"], (int)dRow0["projectId"]) ; + readPart.count = "1" ; + readPart.length = dRowF["length"].ToString() ; + readPart.height = dRowF["height"].ToString() ; + readPart.width = dRowF["width"].ToString() ; + readPart.x = Constants.HeadOverMat ; + readPart.z = Constants.HeadOverMat ; + readPart.inverted = (double)dRowF["inverted"] ; + readPart.rotated = (double)dRowF["rotated"] ; + readPart.elementId = (int)dRowF["elementId"] ; + bFirst = false ; + readPart.features = new List() ; + } + + if ( string.IsNullOrEmpty( dRowF["processId"].ToString())) + continue ; + + BTL.Feature readFeature = new BTL.Feature() { + processId = dRowF["processId"].ToString(), + processKey = dRowF["group"].ToString() + + "-" + dRowF["key"].ToString().Substring( 1, 3) + + "-" + dRowF["face"].ToString(), + designation = dRowF["des"].ToString(), + processIdent = dRowF["processIdent"].ToString(), + sag1 = dRowF["sag1"].ToString(), + text = dRowF["text"].ToString(), + process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", + processParameters = new List( 46) { + dRowF["p01"].ToString(), + dRowF["p02"].ToString(), + dRowF["p03"].ToString(), + dRowF["p04"].ToString(), + dRowF["p05"].ToString(), + dRowF["p06"].ToString(), + dRowF["p07"].ToString(), + dRowF["p08"].ToString(), + dRowF["p09"].ToString(), + dRowF["p10"].ToString(), + dRowF["p11"].ToString(), + dRowF["p12"].ToString(), + dRowF["p13"].ToString(), + dRowF["p14"].ToString(), + dRowF["p15"].ToString(), + dRowF["p16"].ToString(), + dRowF["p17"].ToString(), + dRowF["p18"].ToString(), + dRowF["p19"].ToString(), + dRowF["p20"].ToString(), + dRowF["p21"].ToString(), + dRowF["p22"].ToString(), + dRowF["p23"].ToString(), + dRowF["p24"].ToString(), + dRowF["p25"].ToString(), + dRowF["p26"].ToString(), + dRowF["q01"].ToString(), + dRowF["q02"].ToString(), + dRowF["q03"].ToString(), + dRowF["q04"].ToString(), + dRowF["q05"].ToString(), + dRowF["q06"].ToString(), + dRowF["q07"].ToString(), + dRowF["q08"].ToString(), + dRowF["q09"].ToString(), + dRowF["q10"].ToString(), + dRowF["q11"].ToString(), + dRowF["q12"].ToString(), + dRowF["q13"].ToString(), + dRowF["q14"].ToString(), + dRowF["q15"].ToString(), + dRowF["q16"].ToString(), + dRowF["q17"].ToString(), + dRowF["q18"].ToString(), + dRowF["q19"].ToString(), + dRowF["q20"].ToString() + }, + processReference = new List( 9) { + dRowF["ox"].ToString(), + dRowF["oy"].ToString(), + dRowF["oz"].ToString(), + dRowF["xx"].ToString(), + dRowF["xy"].ToString(), + dRowF["xz"].ToString(), + dRowF["yx"].ToString(), + dRowF["yy"].ToString(), + dRowF["yz"].ToString() + }, + } ; + readPart.features.Add( readFeature) ; + } + btlObject.parts.Add( readPart) ; + } + // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut + btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; + } + + //------------------------------------------------------------------------------------------------------------- + // Il seguente metodo si connette al DB per estrarre tramite una query i cutId della tabella vw_Cut + // aventi patternId e ProductionId che corrispondono a quelli passati come argomento + private static List GetListaCutIdP() + { + List ListaCutId = new List() ; + + DataTable dTab = _ds.Tables[0] ; + int listaTasksCount = dTab.Rows.Count ; + for ( int f = 0 ; f < listaTasksCount ; f++) { + int nCut = (int) dTab.Rows[f]["cutId"] ; + if ( ! ListaCutId.Contains( nCut)) + ListaCutId.Add( nCut) ; + } + + return ListaCutId ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera il singlemembernumber dell'Elemento (colonna "sn") + private static string GetElementSN( int ElementId, int ProjectId) + { + string SN = "000" ; + + string sqlElementSN = "SELECT sn " + + "FROM dbo.vw_Element " + + "WHERE elementId = @firstId " + + "AND projectId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlElementSN, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = ElementId ; + sqlCommand.Parameters["@secondId"].Value = ProjectId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + SN = Convert.ToString( reader["sn"]) ; + } + } + } + + return SN ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza della barra nel caso Produzione (colonna "l") + private static double GetBarLengthP( int patternId, int productionId) + { + double barLength = 0 ; + + string sqlBarLength = "SELECT l " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barLength = Convert.ToDouble( reader["l"]) ; + } + } + } + + return barLength ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la larghezza della barra nel caso Produzione (colonna "w") + private static double GetBarWidthP( int patternId, int productionId) + { + double barWidth = 0 ; + + string sqlBarWidth = "SELECT w " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarWidth, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barWidth = Convert.ToDouble( reader["w"]) ; + } + } + } + + return barWidth ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera il flag di carico con rotazione di 90° nel caso Produzione (colonna "load90") + private static int GetBarLoad90P( int patternId, int productionId) + { + int nLoad90 = 0 ; + + string sqlBarLength = "SELECT load90 " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + nLoad90 = Convert.ToInt32( reader["load90"]) ; + } + } + } + + return nLoad90 ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera lo stato della barra nel caso Produzione (colonna "state") + private static int GetBarStateP( int patternId, int productionId) + { + int barState = 16 ; + + string sqlBarLength = "SELECT state " + + "FROM dbo.vw_Pattern " + + "WHERE patternId = @firstId " + + "AND productionId = @secondId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { + sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; + sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; + sqlCommand.Parameters["@firstId"].Value = patternId ; + sqlCommand.Parameters["@secondId"].Value = productionId ; + SqlDataReader reader = sqlCommand.ExecuteReader() ; + while ( reader.Read()) { + barState = Convert.ToInt32( reader["state"]) ; + } + } + } + + return barState ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza della barra nel caso Ordine (colonna "length", ovvero la lunghezza della singola trave) + // a cui aggiungiamo un valore fisso (es. 2000) + private static double GetBarLengthO( int elementId, int projectId) + { + double barLength = 0 ; + + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount > 0) { + double beamLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; + if ( beamLength < Constants.BarMaxLenForAdd) + barLength = beamLength + Constants.BarAddLen ; + else + barLength = beamLength + 2 * Constants.HeadOverMat ; + } + + return barLength ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza del pannello nel caso Ordine (colonna "length", ovvero la lunghezza della singola parete) + // a cui aggiungiamo un valore fisso (es. 200) + private static double GetPanelLengthO( int elementId, int projectId) + { + double panelLength = 0 ; + + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount > 0) { + double wallLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; + panelLength = wallLength + 2 * Constants.PanelOverMat ; + } + + return panelLength ; + } + + //------------------------------------------------------------------------------------------------------------- + // Recupera la lunghezza del pannello nel caso Ordine (colonna "width", ovvero la larghezza della singola parete) + // a cui aggiungiamo un valore fisso (es. 200) + private static double GetPanelWidthO( int elementId, int projectId) + { + double panelWidth = 0 ; + + DataTable dTab = _ds.Tables[0] ; + int listaProcessesCount = dTab.Rows.Count ; + if ( listaProcessesCount > 0) { + double wallWidth = Convert.ToDouble( dTab.Rows[0]["width"]) ; + panelWidth = wallWidth + 2 * Constants.PanelOverMat ; + } + + return panelWidth ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce la path di esecuzione di EgtCam5 + private static String GetExePath( InOutParameters parameters) + { + return parameters.Read( "EGALTECH", "PATH_EXE", "") ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce il direttorio per i file con i dati macchina + private static String GetDataDir( InOutParameters parameters) + { + String DataDir = parameters.Read( "EGALTECH", "DIR_DATA", "") ; + // Se la directory non esiste viene creata + DirectoryInfo di = new DirectoryInfo( DataDir) ; + if ( ! di.Exists) + di.Create() ; + return DataDir ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce la path completa per il file BTL + private static String GetBtlPath( String DataDir, PatternInfo pattInfo) + { + String BtlDir, BtlName ; + // Se progetto + if ( pattInfo.IsFromProject) { + BtlDir = Path.Combine( DataDir, "Projs", pattInfo.ProjectId.ToString( "D4")) ; + BtlName = "Part_" + pattInfo.ProjectId.ToString() + "_" + pattInfo.ElementId.ToString() + ".btl" ; + } + // altrimenti produzione + else { + BtlDir = Path.Combine( DataDir, "Prods", pattInfo.ProductionId.ToString( "D4")) ; + BtlName = "Bar_" + pattInfo.ProductionId.ToString() + "_" + pattInfo.PatternId.ToString() + ".btl" ; + } + // Se la directory non esiste viene creata + DirectoryInfo di = new DirectoryInfo( BtlDir) ; + if ( ! di.Exists) + di.Create() ; + // restituisco la path completa + return Path.Combine( BtlDir, BtlName) ; + } + + //------------------------------------------------------------------------------------------------------------- + // Restituisce il massimo numero di istanze di EgtCAM5 eseguibili contemporaneamente + private static int GetMaxInstances( InOutParameters parameters) + { + String sMaxInst = parameters.Read( "EGALTECH", "MaxInstances", "1") ; + if ( ! int.TryParse( sMaxInst, out int nVal)) + return 1 ; + else + return Math.Max( nVal, 1) ; + } + + //------------------------------------------------------------------------------------------------------------- + // Visualizzazione finestra gestione DB utensili + public bool ShowTools( InOutParameters parameters) + { + // Recupero dati + string ExePath = GetExePath( parameters) ; + string DataDir = GetDataDir( parameters) ; + string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; + // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo + Process process = new Process() ; + process.StartInfo.FileName = ExePath ; + process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 11" ; + process.StartInfo.UseShellExecute = false ; + process.Start() ; + // Attendo il termine del processo + while ( ! process.HasExited) { + process.Refresh() ; + Thread.Sleep( 50) ; + } + return true ; + } + + //------------------------------------------------------------------------------------------------------------- + // Visualizzazione finestra gestione DB lavorazioni + public bool ShowJobs( InOutParameters parameters) + { + // Recupero dati + string ExePath = GetExePath( parameters) ; + string DataDir = GetDataDir( parameters) ; + string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; + // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo + Process process = new Process() ; + process.StartInfo.FileName = ExePath ; + process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 12" ; + process.StartInfo.UseShellExecute = false ; + process.Start() ; + // Attendo il termine del processo + while ( ! process.HasExited) { + process.Refresh() ; + Thread.Sleep( 50) ; + } + return true ; + } + + //------------------------------------------------------------------------------------------------------------- + // Aggiornamento dati macchina + public bool UpdateMachine( InOutParameters parameters) + { + GetMachineParams( parameters) ; + + return true ; + } + + //------------------------------------------------------------------------------------------------------------- + // Dati utensili e macchina + //------------------------------------------------------------------------------------------------------------- + // Import della funzione di sistema per la scrittura su file INI + [DllImport("kernel32", CharSet = CharSet.Unicode)] + static extern long WritePrivateProfileString( string Section, string Key, string Value, string FilePath) ; + + //------------------------------------------------------------------------------------------------------------- + // Scrive il file Essetre-[MachineName].data che riporta i parametri macchina del DB + private static void GetMachineParams( InOutParameters parameters) + { + // Direttorio di scrittura del file + String DataDir = GetDataDir( parameters) ; + + // Path del file di dati e sua cancellazione se già esiste + string DataName = "Essetre-" + parameters.MachineName + ".data" ; + string DataPath = Path.Combine( DataDir, DataName) ; + if ( File.Exists( DataPath)) + File.Delete( DataPath) ; + + // Preparazione interrogazione per Offsets del DB + _SqlConnectionStr = parameters.ConnectionString ; + DataSet dsOffsets = new DataSet() ; + + string sqlOffsets = "SELECT [group], [key], [value] " + + "FROM [ESSETRE].[dbo].[vw_MachineParam] " + + "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand cmd = new SqlCommand(sqlOffsets, cn)) { + cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; + cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; + var dataAdapter = new SqlDataAdapter( cmd) ; + // Lettura DB e riempimento DataSet + dsOffsets.Clear() ; + dataAdapter.Fill(dsOffsets) ; + } + } + + // Preparazione interrogazione per Trave del DB + _SqlConnectionStr = parameters.ConnectionString ; + DataSet dsTrave = new DataSet() ; + + string sqlTrave = "SELECT [group], [key], [value] " + + "FROM [ESSETRE].[dbo].[vw_MachineParam] " + + "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId" ; + + // Connessione al DB ed esecuzione query + using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { + cn.Open() ; + using ( SqlCommand cmd = new SqlCommand( sqlTrave, cn)) { + cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; + cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; + var dataAdapter = new SqlDataAdapter( cmd) ; + // Lettura DB e riempimento DataSet + dsTrave.Clear() ; + dataAdapter.Fill( dsTrave) ; + } + } + + // Preparazione interrogazione per Dati Utente del DB + _SqlConnectionStr = parameters.ConnectionString; + DataSet dsUser = new DataSet(); + + string sqlUser = "SELECT [group], [key], [value] " + + "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " + + "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId"; + + // Connessione al DB ed esecuzione query + using (SqlConnection cn = new SqlConnection(_SqlConnectionStr)) + { + cn.Open(); + using (SqlCommand cmd = new SqlCommand(sqlUser, cn)) + { + cmd.Parameters.Add("@ConfigId", SqlDbType.Int); + cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId; + var dataAdapter = new SqlDataAdapter(cmd); + // Lettura DB e riempimento DataSet + dsUser.Clear(); + dataAdapter.Fill(dsUser); + } + } + + // Apro file + using ( var tw = new StreamWriter( DataPath, false)) { + + // Scrittura intestazione + tw.WriteLine( "-- " + DataPath) ; + tw.WriteLine( "") ; + + // Scrittura dei dati di Offsets + tw.WriteLine( "local Offsets = {") ; + foreach ( DataTable table in dsOffsets.Tables) { + foreach ( DataRow row in table.Rows) { + String Key = row["key"].ToString() ; + String Value = row["value"].ToString() ; + tw.WriteLine( " " + Key + "=" + Value + ",") ; + } + } + tw.WriteLine( " Zzz=1") ; + tw.WriteLine( "}") ; + tw.WriteLine( "") ; + + // Scrittura dei dati di Trave + tw.WriteLine( "local Trave = {") ; + foreach ( DataTable table in dsTrave.Tables) { + foreach ( DataRow row in table.Rows) { + String Key = row["key"].ToString() ; + String Value = row["value"].ToString() ; + tw.WriteLine( " " + Key + "=" + Value + ",") ; + } + } + tw.WriteLine( " Zzz=1") ; + tw.WriteLine( "}") ; + tw.WriteLine( "") ; + + // Scrittura dei dati di Utente + tw.WriteLine("local User = {"); + foreach (DataTable table in dsUser.Tables) + { + foreach (DataRow row in table.Rows) + { + String Group = row["group"].ToString(); + String Key = row["key"].ToString(); + String Value = row["value"].ToString(); + tw.WriteLine(" " + Group + "_" + Key + "=" + Value + ","); + } + } + tw.WriteLine(" Zzz=1"); + tw.WriteLine("}"); + tw.WriteLine(""); + + // Scrittura tabella da restituire + tw.WriteLine( "local Machine = { Offsets=Offsets, Trave=Trave, User=User}") ; + + tw.WriteLine( "return Machine") ; + } + } + + //------------------------------------------------------------------------------------------------------------- + // Indica direttori e file per backup + public void CollectFile( InOutParameters parameters, FileCollector collector) + { + // Direttori notevoli + String sRoot = parameters.Read( "EGALTECH", "DIR_EGT", "C:\\TechnoEssetre7\\EgalTech") ; + String sBeamDir = "EgtCAM5\\Beam" ; + String sMachDir = "EgtCAM5\\Machines\\Essetre-" + parameters.MachineName ; + // Impostazione + collector.SetRoot(sRoot) ; + collector.AddDirectory(Path.Combine(sRoot, sBeamDir)) ; + collector.AddDirectory(Path.Combine(sRoot, sMachDir)) ; + } + + } +} diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb b/EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb new file mode 100644 index 00000000..b25d3637 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb @@ -0,0 +1,1211 @@ +Imports System +Imports System.Windows.Forms +Imports System.Collections.Generic +Imports System.Data +Imports System.Data.SqlClient +Imports System.Diagnostics +Imports System.IO +Imports System.Linq +Imports System.Runtime.InteropServices +Imports System.Text +Imports System.Threading +Imports System.Threading.Tasks +Imports System.Globalization +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class CalcIntegration + + Private _thread As System.Threading.Thread + Private Shared _ds As DataSet = New DataSet() + Private Shared _SqlConnectionStr As String = "" + + Public Enum CmdType As Integer + GENERATE = 0 + MODIFY = 1 + SIMULATE = 2 + CHECK = 3 + CHECKGEN = 4 + POINT_CLOUD = 5 + RAWPART = 6 + End Enum + + Public Class Bar + 'Public piInfo As PatternInfo + Public nBarState As Integer + Public nBarId As Integer + Public sBarPath As String + Public bBarOk As Boolean + Public nCmdType As Integer + Public nBarType As ProjectType + End Class + + Private Structure MyProc + Public bEnable As Boolean + Public Proc As Process + Public nBar As Integer + End Structure + + Public Sub New() + End Sub + + Public Sub Run(vBar As Bar(), sProjDirPath As String, callback As Action(Of Double, String, Boolean)) 'ByVal parameters As InOutParameters, ByVal callback As ICallBack) + _thread = New Thread(Sub() + DoJob(vBar, sProjDirPath, callback) + End Sub) ',parameters, callback)) + _thread.Start() + End Sub + + 'Private Delegate Sub dDoJob(ByVal parameters As InOutParameters, ByVal callback As ICallBack) + + Private Shared Function CreateNewProjectFromPart(nPartId As Integer, sProjDirPath As String) As String + ' assegno Id a CutId per calcoli + EgtSetInfo(nPartId, "CUTID", nPartId) + ' assegno TASKID alla feature per calcoli + Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS) + Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId) + While nFeatureId <> GDB_ID.NULL + ' verifico che sia una feature + Dim nGRP As Integer + If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then + ' assegno TASKID alla feature per calcoli + EgtSetInfo(nFeatureId, "TASKID", nFeatureId) + End If + nFeatureId = EgtGetNext(nFeatureId) + End While + + ' recupero visibilita' pezzo e lo imposto a visibile + Dim nPartMode As Integer + EgtGetMode(nPartId, nPartMode) + EgtSetMode(nPartId, GDB_MD.STD) + + ' salvo pezzo nel suo progetto + Dim bOk As Boolean = False + Dim nPDN As Integer = 0 + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + Dim sPartFilePath As String = sProjDirPath & "/" & nPDN & ".bwe" + bOk = EgtSaveObjToFile(nPartId, sPartFilePath, NGE.BIN) + + 'ripristino visibilita' pezzo + EgtSetMode(nPartId, nPartMode) + Return If(bOk, sPartFilePath, String.Empty) + End Function + + Private Shared Function CreateNewProjectFromMachGroup(nMachGroupId As Integer, sProjDirPath As String) As String + Dim sMachGroupFilePath As String = sProjDirPath & "\" & nMachGroupId & ".bwe" + ' salvo gruppo di lavorazione nel suo progetto + If EgtSaveObjToFile(nMachGroupId, sMachGroupFilePath, NGE.BIN) Then + Return sMachGroupFilePath + End If + Return String.Empty + End Function + + Private Shared Sub DoJob(vBar As Bar(), sProjDirPath As String, callback As Action(Of Double, String, Boolean)) ', parameters As InOutParameters, callback As ICallBack) + Dim bCancel As Boolean = False + callback(0, "Init", bCancel) + + ' creo progetti a seconda del tipo + For Each Bar In vBar + If Bar.nBarType = ProjectType.PROJ Then + Bar.sBarPath = CreateNewProjectFromPart(Bar.nBarId, sProjDirPath) + ElseIf Bar.nBarType = ProjectType.PROD Then + Bar.sBarPath = CreateNewProjectFromMachGroup(Bar.nBarId, sProjDirPath) + End If + Next + + callback(0.1, "", bCancel) + + '_SqlConnectionStr = parameters.ConnectionString + Dim ExePath As String = String.Empty + GetMainPrivateProfileString(S_BEAM, K_CALCPATH, "", ExePath) + 'Dim DataDir As String = GetDataDir(parameters) + ' Numero di barre + Dim numBars As Integer = vBar.Count + If numBars = 0 Then Return + '' Se modalità Cloud, allora conta solo la prima barra + 'Dim bCloud As Boolean = (parameters.UIMode = InOutParameters.UIModes.CLOUD) + 'If bCloud Then numBars = 1 + + ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) + Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, Map.refMainWindowVM.MainWindowM.GetMaxInstances()) + + ' Frazione di avanzamento del lavoro (in pu) + Dim dProgress As Double = 0 + '' Genero i Btl di tutte le barre + 'Dim vBar As Bar() = New Bar(numBars + nMaxThread - 1) {} + + 'For i As Integer = 0 To numBars - 1 + ' Dim pattInfo As PatternInfo = parameters.Patterns(i) + ' Dim btlObject As BTL = New BTL() + ' ' Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project, + ' ' se invece è FALSE viene eseguita la query sulle tabelle Production + + ' Dim sql As String = "" + + ' If pattInfo.IsFromProject Then + ' sql = "SELECT E.projectId, " & "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " & "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " & "P.flagDeleted, P.[group], [key], face, edge, des, " & "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " & "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " & "ox, oy, oz, xx, xy, xz, yx, yy, yz, " & "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " & "E.inverted, E.rotated, 0 doneTime, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " & "FROM dbo.vw_Process AS P " & "RIGHT OUTER JOIN dbo.vw_Element AS E " & "ON P.projectId=E.projectId AND P.elementId=E.elementId " & "WHERE E.projectId = @firstId AND E.elementId = @secondId" + ' Else + ' sql = "SELECT vw_Cut.productionId, " & "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " & "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " & "vw_Task.flagDeleted, [group], [key], face, edge, des, " & "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " & "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " & "ox, oy, oz, xx, xy, xz, yx, yy, yz, " & "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " & "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " & "FROM dbo.vw_Task " & "RIGHT OUTER JOIN dbo.vw_Cut " & "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " & "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId" + ' End If + + ' ' Connessione al DB ed esecuzione query + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using cmd As SqlCommand = New SqlCommand(sql, cn) + ' cmd.Parameters.Add("@firstId", SqlDbType.Int) + ' cmd.Parameters.Add("@secondId", SqlDbType.Int) + + ' If pattInfo.IsFromProject Then + ' cmd.Parameters("@firstId").Value = pattInfo.ProjectId + ' cmd.Parameters("@secondId").Value = pattInfo.ElementId + ' Else + ' cmd.Parameters("@firstId").Value = pattInfo.ProductionId + ' cmd.Parameters("@secondId").Value = pattInfo.PatternId + ' End If + + ' Dim dataAdapter = New SqlDataAdapter(cmd) + ' ' Lettura DB e riempimento DataSet + ' _ds.Clear() + ' dataAdapter.Fill(_ds) + ' End Using + ' End Using + + ' ' Verifica parametro isFromProject nel caso Ordine viene ottenuta la lista dei Process, + ' ' nel caso Produzione viene ottenuta la lista dei Task + ' If pattInfo.IsFromProject Then + ' GetListaProcesses(btlObject) + ' Else + ' GetListaTasks(btlObject) + ' End If + + ' ' Recupero lo stato della barra + ' Dim nBarState As Integer = 0 + ' If Not pattInfo.IsFromProject Then nBarState = GetBarStateP(btlObject.patternId, btlObject.productionId) + ' ' Dialog con Progress Bar + ' dProgress += 0.1 / numBars + ' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) + ' callback.Progress(CSng(dProgress), " Progress: " & sProg & "%" & vbLf, bCancel) + + ' If bCancel Then + ' callback.Done(parameters) + ' Return + ' End If + + ' ' Scrittura del file BTL + ' ' Path completa del nome del file da salvare + ' Dim BtlPath As String = GetBtlPath(DataDir, pattInfo) + ' Dim BtlOk As Boolean = btlObject.WriteIntoFile(BtlPath, pattInfo.IsFromProject) + ' ' Se modalità cloud, scrittura del file di punti + ' Dim bErrOnCloud As Boolean = False + + ' If bCloud Then + + ' If pattInfo.Cloud IsNot Nothing Then + + ' Using tw = New StreamWriter(Path.ChangeExtension(BtlPath, ".pnt"), False) + + ' For j As Integer = 0 To pattInfo.Cloud.Count() - 1 + ' Dim dPosX As Double = -pattInfo.Cloud(j).Y + ' Dim dPosY As Double = pattInfo.Cloud(j).X + ' Dim sPosX As String = dPosX.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) + ' Dim sPosY As String = dPosY.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) + ' tw.WriteLine(sPosX & " " & sPosY) + ' Next + ' End Using + ' Else + ' BtlOk = False + ' bErrOnCloud = True + ' End If + ' End If + ' ' Se scrittura Btl non riuscita + ' If Not BtlOk Then + ' ' scrivo direttamente il file di errore + ' Dim ErrCutId As Integer = (If(pattInfo.IsFromProject, pattInfo.ElementId, pattInfo.PatternId)) + + ' Using tw = New StreamWriter(Path.ChangeExtension(BtlPath, ".txt"), False) + ' tw.WriteLine("ERR=10") + ' tw.WriteLine(If(bErrOnCloud, "Cloud without points", "BTL without processes")) + ' tw.WriteLine("CUTID=" & ErrCutId.ToString()) + ' tw.WriteLine("TASKID=0") + ' End Using + ' ' elimino eventuale file Cn già presente + ' If parameters.UIMode = InOutParameters.UIModes.HIDDEN Then + ' Dim CncPath As String = Path.ChangeExtension(BtlPath, ".cnc") + ' If File.Exists(CncPath) Then File.Delete(CncPath) + ' End If + ' ' altrimenti + ' Else + ' ' cancello eventuale file di errore già presente + ' Dim TxtPath As String = Path.ChangeExtension(BtlPath, ".txt") + ' If File.Exists(TxtPath) Then File.Delete(TxtPath) + ' End If + ' ' Salvo dati + ' vBar(i).piInfo = pattInfo + ' vBar(i).nBarState = nBarState + ' vBar(i).sBtlPath = BtlPath + ' vBar(i).bBtlOk = BtlOk + 'Next + + ' Lancio in parallelo più processi (senza superare il numero di core logici presenti) + Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {} + For j As Integer = 0 To nMaxThread - 1 + vProc(j).nBar = -1 + vProc(j).bEnable = True + Next + + ' Processo i Btl in parallelo + Dim nCurrBar As Integer = 0 + Dim nDoneBar As Integer = 0 + Dim nShiftBar As Integer = 0 + Dim nActProc As Integer = 0 + + While nCurrBar < numBars + nShiftBar OrElse nActProc > 0 + + For j As Integer = 0 To nMaxThread - 1 + If Not vProc(j).bEnable Then Continue For + Dim bDone As Boolean = False + + If vProc(j).nBar = -1 Then + + If nCurrBar < numBars + nShiftBar Then + + If vBar(nCurrBar).bBarOk Then + vProc(j).Proc = New Process() + vProc(j).Proc.StartInfo.FileName = ExePath + 'Dim nMode As Integer = CInt(parameters.UIMode) + 'If parameters.UIMode = InOutParameters.UIModes.HIDDEN AndAlso vBar(nCurrBar).nBarState <> 0 Then nMode = 4 + vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " & """" & Map.refMachinePanelVM.SelectedMachine.nType & """ " & + """" & Map.refMachinePanelVM.SelectedMachine.Name & """ " & vBar(nCurrBar).nCmdType + vProc(j).Proc.StartInfo.UseShellExecute = False + + If vProc(j).Proc.Start() Then + vProc(j).nBar = nCurrBar + nCurrBar += 1 + nActProc += 1 + End If + Else + ProcessResults(vBar(nCurrBar)) ', vBar(nCurrBar).piInfo, parameters.UIMode) + bDone = True + nCurrBar += 1 + End If + End If + Else + + If vProc(j).Proc.HasExited Then + ' se terminato con successo + If vProc(j).Proc.ExitCode = 0 Then + ' salvo il risultato + ProcessResults(vBar(vProc(j).nBar)) ', vBar(vProc(j).nBar).piInfo, parameters.UIMode) + bDone = True + vProc(j).nBar = -1 + nActProc -= 1 + ' se superato il numero di processi eseguibili in parallelo + ElseIf vProc(j).Proc.ExitCode = 1 Then + ' aggiungo il pezzo in coda + If numBars + nShiftBar < numBars + nMaxThread Then + vBar(numBars + nShiftBar) = vBar(vProc(j).nBar) + nShiftBar += 1 + End If + ' disabilito il processo + vProc(j).bEnable = False + vProc(j).nBar = -1 + nActProc -= 1 + ' altrimenti (errore generico di esecuzione) + Else + ' salvo il risultato + ProcessResults(vBar(vProc(j).nBar)) ', parameters.UIMode) + bDone = True + vProc(j).nBar = -1 + nActProc -= 1 + End If + Else + vProc(j).Proc.Refresh() + End If + End If + + If bDone Then + ' Dialog con Progress Bar + dProgress += (0.9 / numBars) + nDoneBar += 1 + Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) + callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel) + + If bCancel Then + ' fine + callback(1, "", bCancel) + Return + End If + End If + + Thread.Sleep(1) + Next + + ' Verifico che i processi non siano andati tutti in errore + Dim bAllKO As Boolean = True + + For j As Integer = 0 To nMaxThread - 1 + If vProc(j).bEnable Then bAllKO = False + Next + + If bAllKO Then + MessageBox.Show("Execution error (all processes are disabled)") + Exit While + End If + + Thread.Sleep(10) + End While + + 'callback.Progress(1, "End", bCancel) + Thread.Sleep(300) + ' fine + callback(1, "Done", bCancel) + End Sub + + 'Public Sub Abort() + 'End Sub + + Private Shared Sub ProcessResults(ByVal Bar As Bar) ' , ByVal pattInfo As PatternInfo, ByVal UIMode As InOutParameters.UIModes) + 'If UIMode = InOutParameters.UIModes.SHOWUI OrElse UIMode = InOutParameters.UIModes.SIMULAZIONE Then Return + Dim BtlPath As String = Bar.sBarPath + Dim bErrors As Boolean = False + Dim nLastErr As Integer = 0 + Dim sLastMsg As String = "" + Dim nCurrCutId As Integer = 0 + 'Dim dctErr As Dictionary(Of Integer, PatternInfo.Results) = New Dictionary(Of Integer, PatternInfo.Results)() + 'Dim dctRot As Dictionary(Of Integer, Double) = New Dictionary(Of Integer, Double)() + Dim nTotTime As Integer = 0 + 'Dim resCurrExe As PatternInfo.Results = Nothing, dCurrRot As Double = Nothing + + If File.Exists(Path.ChangeExtension(BtlPath, ".txt")) Then + Dim nErr As Integer = 0 + Dim sMsg As String = "" + Dim dRot As Double = 0 + Dim cutId As Integer = 0 + Dim prevCutId As Integer = GDB_ID.NULL + Dim currBTLPart As BTLPart + Dim taskId As Integer = 0 + Dim lines As String() = System.IO.File.ReadAllLines(Path.ChangeExtension(BtlPath, ".txt")) + + For Each line As String In lines + + If line.StartsWith("ERR=") Then + Dim nVal As Integer? = GetVal(line, "ERR") + nErr = (If(nVal IsNot Nothing, nVal.Value, 0)) + sMsg = "" + cutId = 0 + taskId = 0 + ElseIf line.StartsWith("ROT=") Then + Dim nVal As Integer? = GetVal(line, "ROT") + Dim nRot As Integer = (If(nVal IsNot Nothing, nVal.Value, 0)) + dRot = ((4 - nRot) Mod 4) * 90 + ElseIf line.StartsWith("CUTID=") Then + Dim nVal As Integer? = GetVal(line, "CUTID") + cutId = (If(nVal IsNot Nothing, nVal.Value, 0)) + If cutId <> prevCutId Then + ' aggiornamento globale pezzo precedente + If cutId <> GDB_ID.NULL AndAlso cutId <> 0 Then + 'currBTLPart.CalcGlobalUpdate() + End If + ' aggiornamento risultati in struttura BTL + If Bar.nBarType = ProjectType.PROJ Then + ' cerco pezzo in btl structure da id + For Each Part In Map.refProjectVM.BTLStructure.PartList + If Part.nPartId = cutId Then + currBTLPart = Part + End If + Next + End If + End If + prevCutId = cutId + + 'If cutId <> nCurrCutId Then + ' nCurrCutId = cutId + ' dctErr.Clear() + ' dctRot.Clear() + 'End If + ElseIf line.StartsWith("TASKID=") Then + Dim nVal As Integer? = GetVal(line, "TASKID") + taskId = (If(nVal IsNot Nothing, nVal.Value, 0)) + 'Dim resExe As PatternInfo.Results = PatternInfo.Results.OK + + 'If nErr = 22 Then + ' resExe = PatternInfo.Results.COLLISION + ' bErrors = True + + ' If cutId = 0 OrElse taskId = 0 Then + ' nLastErr = nErr + ' sLastMsg = sMsg + ' End If + 'ElseIf nErr > 0 Then + ' resExe = PatternInfo.Results.WARNING + ' bErrors = True + + ' If cutId = 0 OrElse taskId = 0 Then + ' nLastErr = nErr + ' sLastMsg = sMsg + ' End If + 'End If + + 'se taskid diverso da zero, errore feature + If taskId <> 0 Then + EgtSetInfo(taskId, ITG_ERR, nErr) + EgtSetInfo(taskId, ITG_MSG, sMsg) + EgtSetInfo(taskId, ITG_ROT, dRot) + ' aggiornamento risultati in struttura BTL + If Bar.nBarType = ProjectType.PROJ Then + ' cerco task in btl structure da id + If Not IsNothing(currBTLPart) Then + For Each Feature In currBTLPart.FeatureList + If Feature.nFeatureId = taskId Then + Feature.CalcFeatureUpdate(True, nErr, dRot, sMsg) + End If + Next + End If + End If + + 'se taskid uguale a zero, errore pezzo + Else + EgtSetInfo(cutId, ITG_ERR, nErr) + EgtSetInfo(cutId, ITG_MSG, sMsg) + EgtSetInfo(cutId, ITG_ROT, dRot) + ' aggiorno in struttura btl + If Not IsNothing(currBTLPart) Then currBTLPart.CalcPartUpdate(True, nErr, dRot, sMsg) + + End If + + + 'If taskId <> 0 Then + + ' If dctErr.TryGetValue(taskId, resCurrExe) Then + + ' If resExe > resCurrExe Then + ' dctErr(taskId) = resExe + ' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg) + ' End If + ' Else + ' dctErr(taskId) = resExe + ' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg) + ' End If + 'Else + ' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg) + 'End If + + 'If taskId <> 0 Then + + ' If dctRot.TryGetValue(taskId, dCurrRot) Then + + ' If Math.Abs(dRot) > 1 Then + ' If Math.Abs(dCurrRot) < 1 Then dctRot(taskId) = dRot + ' Else + ' dRot = dCurrRot + ' End If + ' Else + ' dctRot.Add(taskId, dRot) + ' End If + 'End If + + 'If pattInfo.IsFromProject Then + ' pattInfo.SetProcessInfoChosen(cutId, taskId, dRot, 0, False) + 'Else + ' pattInfo.SetTaskInfoChosen(cutId, taskId, dRot, 0, False) + 'End If + ElseIf line.StartsWith("TIME=") Then + Dim nVal As Integer? = GetVal(line, "TIME") + nTotTime = (If(nVal IsNot Nothing, nVal.Value, 0)) + EgtSetInfo(cutId, ITG_TIME, nTotTime) + ElseIf Not String.IsNullOrWhiteSpace(line) AndAlso line <> "---" Then + sMsg = line + End If + Next + Else + bErrors = True + nLastErr = 25 + sLastMsg = "Execution Error" + End If + + ' aggiornamento risultati in struttura BTL + If Bar.nBarType = ProjectType.PROJ Then + ' cerco pezzo in btl structure da id + For Each Part In Map.refProjectVM.BTLStructure.PartList + If Part.nPartId = Bar.nBarId Then + ' leggo errori da geometria e li aggiorno in struttura btl + Part.CalcFeatureUpdate() + End If + Next + + End If + + 'pattInfo.IsDone = True + + 'If Not bErrors Then + ' pattInfo.Result = PatternInfo.Results.OK + ' pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY + 'Else + + ' If nLastErr = 17 Then + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING + ' pattInfo.Message = sLastMsg + ' ElseIf nLastErr = 19 Then + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR + ' pattInfo.Message = sLastMsg + ' ElseIf nLastErr = 22 Then + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION + ' pattInfo.Message = sLastMsg + ' ElseIf nLastErr = 23 Then + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR + ' pattInfo.Message = sLastMsg + ' ElseIf nLastErr = 24 Then + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR + ' pattInfo.Message = sLastMsg + ' ElseIf nLastErr = 25 Then + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR + ' pattInfo.Message = sLastMsg + ' Else + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY + ' End If + 'End If + + 'pattInfo.EstimatedTime = nTotTime + + 'If Not bErrors AndAlso (UIMode = InOutParameters.UIModes.HIDDEN OrElse UIMode = InOutParameters.UIModes.CLOUD) Then + ' Dim CncPath As String = Path.ChangeExtension(BtlPath, ".cnc") + + ' If File.Exists(CncPath) Then + ' Dim lines As String = System.IO.File.ReadAllText(CncPath) + ' pattInfo.Iso = lines + ' pattInfo.Result = PatternInfo.Results.OK + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK + ' Else + ' pattInfo.Iso = "" + ' pattInfo.Result = PatternInfo.Results.[ERROR] + ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR + ' End If + 'End If + End Sub + + 'Public Shared Sub GetListaTasks(ByVal btlObject As BTL) + ' Dim dTab As DataTable = _ds.Tables(0) + ' Dim listaTasksCount As Int32 = dTab.Rows.Count + ' If listaTasksCount = 0 Then Return + ' Dim dRow0 As DataRow = dTab.Rows(0) + ' btlObject.projectNumber = dRow0("projectId").ToString() + ' btlObject.barLength = GetBarLengthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture) + ' btlObject.barLoad90 = GetBarLoad90P(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString(CultureInfo.InvariantCulture) + ' btlObject.panelLength = GetBarLengthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture) + ' btlObject.panelWidth = GetBarWidthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture) + ' btlObject.productionId = CInt(dRow0("productionId")) + ' btlObject.patternId = CInt(dRow0("patternId")) + ' btlObject.parts = New List(Of BTL.Part)() + ' Dim ListaCutParts As List(Of Integer) = GetListaCutIdP() + + ' For c As Integer = 0 To ListaCutParts.Count - 1 + ' Dim readPart As BTL.Part = New BTL.Part() + ' Dim bFirst As Boolean = True + + ' For f As Integer = 0 To listaTasksCount - 1 + ' Dim dRowF As DataRow = dTab.Rows(f) + ' If CInt(dRowF("cutId")) <> ListaCutParts(c) Then Continue For + + ' If bFirst Then + ' readPart.singleMemberNumber = GetElementSN(CInt(dRowF("elementId")), CInt(dRowF("projectId"))) + ' readPart.count = "1" + ' readPart.length = dRowF("length").ToString() + ' readPart.height = dRowF("height").ToString() + ' readPart.width = dRowF("width").ToString() + ' readPart.x = CDbl(dRowF("x")) + ' readPart.z = CDbl(dRowF("z")) + ' readPart.inverted = CDbl(dRowF("inverted")) + ' readPart.rotated = CDbl(dRowF("rotated")) + ' readPart.cutId = CInt(dRowF("cutId")) + ' bFirst = False + ' readPart.features = New List(Of BTL.Feature)() + ' End If + + ' If String.IsNullOrEmpty(dRowF("taskId").ToString()) Then Continue For + ' Dim readFeature As BTL.Feature = New BTL.Feature() With { + ' .taskId = dRowF("taskId").ToString(), + ' .processKey = dRowF("group").ToString() & "-" & dRowF("key").ToString().Substring(1, 3) & "-" & dRowF("face").ToString(), + ' .designation = dRowF("des").ToString(), + ' .processIdent = dRowF("processIdent").ToString(), + ' .sag1 = dRowF("sag1").ToString(), + ' .Text = dRowF("text").ToString(), + ' .Process = If((Convert.ToInt16(dRowF("enabled")) = 1), "YES", "NO"), + ' .processParameters = New List(Of String)(46) From { + ' dRowF("p01").ToString(), + ' dRowF("p02").ToString(), + ' dRowF("p03").ToString(), + ' dRowF("p04").ToString(), + ' dRowF("p05").ToString(), + ' dRowF("p06").ToString(), + ' dRowF("p07").ToString(), + ' dRowF("p08").ToString(), + ' dRowF("p09").ToString(), + ' dRowF("p10").ToString(), + ' dRowF("p11").ToString(), + ' dRowF("p12").ToString(), + ' dRowF("p13").ToString(), + ' dRowF("p14").ToString(), + ' dRowF("p15").ToString(), + ' dRowF("p16").ToString(), + ' dRowF("p17").ToString(), + ' dRowF("p18").ToString(), + ' dRowF("p19").ToString(), + ' dRowF("p20").ToString(), + ' dRowF("p21").ToString(), + ' dRowF("p22").ToString(), + ' dRowF("p23").ToString(), + ' dRowF("p24").ToString(), + ' dRowF("p25").ToString(), + ' dRowF("p26").ToString(), + ' dRowF("q01").ToString(), + ' dRowF("q02").ToString(), + ' dRowF("q03").ToString(), + ' dRowF("q04").ToString(), + ' dRowF("q05").ToString(), + ' dRowF("q06").ToString(), + ' dRowF("q07").ToString(), + ' dRowF("q08").ToString(), + ' dRowF("q09").ToString(), + ' dRowF("q10").ToString(), + ' dRowF("q11").ToString(), + ' dRowF("q12").ToString(), + ' dRowF("q13").ToString(), + ' dRowF("q14").ToString(), + ' dRowF("q15").ToString(), + ' dRowF("q16").ToString(), + ' dRowF("q17").ToString(), + ' dRowF("q18").ToString(), + ' dRowF("q19").ToString(), + ' dRowF("q20").ToString() + ' }, + ' .processReference = New List(Of String)(9) From { + ' dRowF("ox").ToString(), + ' dRowF("oy").ToString(), + ' dRowF("oz").ToString(), + ' dRowF("xx").ToString(), + ' dRowF("xy").ToString(), + ' dRowF("xz").ToString(), + ' dRowF("yx").ToString(), + ' dRowF("yy").ToString(), + ' dRowF("yz").ToString() + ' } + ' } + ' readPart.features.Add(readFeature) + ' Next + + ' btlObject.parts.Add(readPart) + ' Next + + ' btlObject.parts.Sort(Function(p, q) p.x.CompareTo(q.x)) + 'End Sub + + Private Shared Function GetVal(ByVal sText As String, ByVal 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 + + If Not Integer.TryParse(sParts(1), nVal) Then + Return Nothing + Else + Return nVal + End If + End Function + + 'Public Shared Sub GetListaProcesses(ByVal btlObject As BTL) + ' Dim dTab As DataTable = _ds.Tables(0) + ' Dim listaProcessesCount As Integer = dTab.Rows.Count + + ' If listaProcessesCount = 0 Then + ' btlObject.parts = Nothing + ' Return + ' End If + + ' Dim dRow0 As DataRow = dTab.Rows(0) + ' btlObject.projectNumber = dRow0("projectId").ToString() + ' btlObject.barLength = GetBarLengthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture) + ' btlObject.barLoad90 = "0" + ' btlObject.panelLength = GetPanelLengthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture) + ' btlObject.panelWidth = GetPanelWidthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture) + ' btlObject.projectId = CInt(dRow0("projectId")) + ' btlObject.elementId = CInt(dRow0("elementId")) + ' btlObject.parts = New List(Of BTL.Part)() + ' Dim ListaCutParts As List(Of Integer) = New List(Of Integer)(1) + ' ListaCutParts.Add(CInt(dRow0("elementId"))) + + ' For c As Integer = 0 To ListaCutParts.Count - 1 + ' Dim readPart As BTL.Part = New BTL.Part() + ' Dim bFirst As Boolean = True + + ' For f As Integer = 0 To listaProcessesCount - 1 + ' Dim dRowF As DataRow = dTab.Rows(f) + ' If CInt(dRowF("elementId")) <> ListaCutParts(c) Then Continue For + + ' If bFirst Then + ' readPart.singleMemberNumber = GetElementSN(CInt(dRow0("elementId")), CInt(dRow0("projectId"))) + ' readPart.count = "1" + ' readPart.length = dRowF("length").ToString() + ' readPart.height = dRowF("height").ToString() + ' readPart.width = dRowF("width").ToString() + ' readPart.x = Constants.HeadOverMat + ' readPart.z = Constants.HeadOverMat + ' readPart.inverted = CDbl(dRowF("inverted")) + ' readPart.rotated = CDbl(dRowF("rotated")) + ' readPart.elementId = CInt(dRowF("elementId")) + ' bFirst = False + ' readPart.features = New List(Of BTL.Feature)() + ' End If + + ' If String.IsNullOrEmpty(dRowF("processId").ToString()) Then Continue For + ' Dim readFeature As BTL.Feature = New BTL.Feature() With { + ' .processId = dRowF("processId").ToString(), + ' .processKey = dRowF("group").ToString() & "-" & dRowF("key").ToString().Substring(1, 3) & "-" & dRowF("face").ToString(), + ' .designation = dRowF("des").ToString(), + ' .processIdent = dRowF("processIdent").ToString(), + ' .sag1 = dRowF("sag1").ToString(), + ' .Text = dRowF("text").ToString(), + ' .Process = If((Convert.ToInt16(dRowF("enabled")) = 1), "YES", "NO"), + ' .processParameters = New List(Of String)(46) From { + ' dRowF("p01").ToString(), + ' dRowF("p02").ToString(), + ' dRowF("p03").ToString(), + ' dRowF("p04").ToString(), + ' dRowF("p05").ToString(), + ' dRowF("p06").ToString(), + ' dRowF("p07").ToString(), + ' dRowF("p08").ToString(), + ' dRowF("p09").ToString(), + ' dRowF("p10").ToString(), + ' dRowF("p11").ToString(), + ' dRowF("p12").ToString(), + ' dRowF("p13").ToString(), + ' dRowF("p14").ToString(), + ' dRowF("p15").ToString(), + ' dRowF("p16").ToString(), + ' dRowF("p17").ToString(), + ' dRowF("p18").ToString(), + ' dRowF("p19").ToString(), + ' dRowF("p20").ToString(), + ' dRowF("p21").ToString(), + ' dRowF("p22").ToString(), + ' dRowF("p23").ToString(), + ' dRowF("p24").ToString(), + ' dRowF("p25").ToString(), + ' dRowF("p26").ToString(), + ' dRowF("q01").ToString(), + ' dRowF("q02").ToString(), + ' dRowF("q03").ToString(), + ' dRowF("q04").ToString(), + ' dRowF("q05").ToString(), + ' dRowF("q06").ToString(), + ' dRowF("q07").ToString(), + ' dRowF("q08").ToString(), + ' dRowF("q09").ToString(), + ' dRowF("q10").ToString(), + ' dRowF("q11").ToString(), + ' dRowF("q12").ToString(), + ' dRowF("q13").ToString(), + ' dRowF("q14").ToString(), + ' dRowF("q15").ToString(), + ' dRowF("q16").ToString(), + ' dRowF("q17").ToString(), + ' dRowF("q18").ToString(), + ' dRowF("q19").ToString(), + ' dRowF("q20").ToString() + ' }, + ' .processReference = New List(Of String)(9) From { + ' dRowF("ox").ToString(), + ' dRowF("oy").ToString(), + ' dRowF("oz").ToString(), + ' dRowF("xx").ToString(), + ' dRowF("xy").ToString(), + ' dRowF("xz").ToString(), + ' dRowF("yx").ToString(), + ' dRowF("yy").ToString(), + ' dRowF("yz").ToString() + ' } + ' } + ' readPart.features.Add(readFeature) + ' Next + + ' btlObject.parts.Add(readPart) + ' Next + + ' btlObject.parts.Sort(Function(p, q) p.x.CompareTo(q.x)) + 'End Sub + + 'Private Shared Function GetListaCutIdP() As List(Of Integer) + ' Dim ListaCutId As List(Of Integer) = New List(Of Integer)() + ' Dim dTab As DataTable = _ds.Tables(0) + ' Dim listaTasksCount As Integer = dTab.Rows.Count + + ' For f As Integer = 0 To listaTasksCount - 1 + ' Dim nCut As Integer = CInt(dTab.Rows(f)("cutId")) + ' If Not ListaCutId.Contains(nCut) Then ListaCutId.Add(nCut) + ' Next + + ' Return ListaCutId + 'End Function + + 'Private Shared Function GetElementSN(ByVal ElementId As Integer, ByVal ProjectId As Integer) As String + ' Dim SN As String = "000" + ' Dim sqlElementSN As String = "SELECT sn " & "FROM dbo.vw_Element " & "WHERE elementId = @firstId " & "AND projectId = @secondId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using sqlCommand As SqlCommand = New SqlCommand(sqlElementSN, cn) + ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) + ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) + ' sqlCommand.Parameters("@firstId").Value = ElementId + ' sqlCommand.Parameters("@secondId").Value = ProjectId + ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() + + ' While reader.Read() + ' SN = Convert.ToString(reader("sn")) + ' End While + ' End Using + ' End Using + + ' Return SN + 'End Function + + 'Private Shared Function GetBarLengthP(ByVal patternId As Integer, ByVal productionId As Integer) As Double + ' Dim barLength As Double = 0 + ' Dim sqlBarLength As String = "SELECT l " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn) + ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) + ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) + ' sqlCommand.Parameters("@firstId").Value = patternId + ' sqlCommand.Parameters("@secondId").Value = productionId + ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() + + ' While reader.Read() + ' barLength = Convert.ToDouble(reader("l")) + ' End While + ' End Using + ' End Using + + ' Return barLength + 'End Function + + 'Private Shared Function GetBarWidthP(ByVal patternId As Integer, ByVal productionId As Integer) As Double + ' Dim barWidth As Double = 0 + ' Dim sqlBarWidth As String = "SELECT w " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarWidth, cn) + ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) + ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) + ' sqlCommand.Parameters("@firstId").Value = patternId + ' sqlCommand.Parameters("@secondId").Value = productionId + ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() + + ' While reader.Read() + ' barWidth = Convert.ToDouble(reader("w")) + ' End While + ' End Using + ' End Using + + ' Return barWidth + 'End Function + + 'Private Shared Function GetBarLoad90P(ByVal patternId As Integer, ByVal productionId As Integer) As Integer + ' Dim nLoad90 As Integer = 0 + ' Dim sqlBarLength As String = "SELECT load90 " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn) + ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) + ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) + ' sqlCommand.Parameters("@firstId").Value = patternId + ' sqlCommand.Parameters("@secondId").Value = productionId + ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() + + ' While reader.Read() + ' nLoad90 = Convert.ToInt32(reader("load90")) + ' End While + ' End Using + ' End Using + + ' Return nLoad90 + 'End Function + + 'Private Shared Function GetBarStateP(ByVal patternId As Integer, ByVal productionId As Integer) As Integer + ' Dim barState As Integer = 16 + ' Dim sqlBarLength As String = "SELECT state " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn) + ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) + ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) + ' sqlCommand.Parameters("@firstId").Value = patternId + ' sqlCommand.Parameters("@secondId").Value = productionId + ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() + + ' While reader.Read() + ' barState = Convert.ToInt32(reader("state")) + ' End While + ' End Using + ' End Using + + ' Return barState + 'End Function + + 'Private Shared Function GetBarLengthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double + ' Dim barLength As Double = 0 + ' Dim dTab As DataTable = _ds.Tables(0) + ' Dim listaProcessesCount As Integer = dTab.Rows.Count + + ' If listaProcessesCount > 0 Then + ' Dim beamLength As Double = Convert.ToDouble(dTab.Rows(0)("length")) + + ' If beamLength < Constants.BarMaxLenForAdd Then + ' barLength = beamLength + Constants.BarAddLen + ' Else + ' barLength = beamLength + 2 * Constants.HeadOverMat + ' End If + ' End If + + ' Return barLength + 'End Function + + 'Private Shared Function GetPanelLengthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double + ' Dim panelLength As Double = 0 + ' Dim dTab As DataTable = _ds.Tables(0) + ' Dim listaProcessesCount As Integer = dTab.Rows.Count + + ' If listaProcessesCount > 0 Then + ' Dim wallLength As Double = Convert.ToDouble(dTab.Rows(0)("length")) + ' panelLength = wallLength + 2 * Constants.PanelOverMat + ' End If + + ' Return panelLength + 'End Function + + 'Private Shared Function GetPanelWidthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double + ' Dim panelWidth As Double = 0 + ' Dim dTab As DataTable = _ds.Tables(0) + ' Dim listaProcessesCount As Integer = dTab.Rows.Count + + ' If listaProcessesCount > 0 Then + ' Dim wallWidth As Double = Convert.ToDouble(dTab.Rows(0)("width")) + ' panelWidth = wallWidth + 2 * Constants.PanelOverMat + ' End If + + ' Return panelWidth + 'End Function + + 'Private Shared Function GetExePath(ByVal parameters As InOutParameters) As String + ' Return parameters.Read("EGALTECH", "PATH_EXE", "") + 'End Function + + 'Private Shared Function GetDataDir(ByVal parameters As InOutParameters) As String + ' Dim DataDir As String = parameters.Read("EGALTECH", "DIR_DATA", "") + ' Dim di As DirectoryInfo = New DirectoryInfo(DataDir) + ' If Not di.Exists Then di.Create() + ' Return DataDir + 'End Function + + 'Private Shared Function GetBtlPath(ByVal DataDir As String, ByVal pattInfo As PatternInfo) As String + ' Dim BtlDir, BtlName As String + + ' If pattInfo.IsFromProject Then + ' BtlDir = Path.Combine(DataDir, "Projs", pattInfo.ProjectId.ToString("D4")) + ' BtlName = "Part_" & pattInfo.ProjectId.ToString() & "_" + pattInfo.ElementId.ToString() & ".btl" + ' Else + ' BtlDir = Path.Combine(DataDir, "Prods", pattInfo.ProductionId.ToString("D4")) + ' BtlName = "Bar_" & pattInfo.ProductionId.ToString() & "_" + pattInfo.PatternId.ToString() & ".btl" + ' End If + + ' Dim di As DirectoryInfo = New DirectoryInfo(BtlDir) + ' If Not di.Exists Then di.Create() + ' Return Path.Combine(BtlDir, BtlName) + 'End Function + + 'Private Shared Function GetMaxInstances(ByVal parameters As InOutParameters) As Integer + ' Dim sMaxInst As String = parameters.Read("EGALTECH", "MaxInstances", "1") + ' Dim nVal As Integer = Nothing + + ' If Not Integer.TryParse(sMaxInst, nVal) Then + ' Return 1 + ' Else + ' Return Math.Max(nVal, 1) + ' End If + 'End Function + + 'Public Function ShowTools(ByVal parameters As InOutParameters) As Boolean + ' Dim ExePath As String = GetExePath(parameters) + ' Dim DataDir As String = GetDataDir(parameters) + ' Dim BtlPath As String = Path.Combine(DataDir, "QQQ.btl") + ' Dim process As Process = New Process() + ' process.StartInfo.FileName = ExePath + ' process.StartInfo.Arguments = """" & BtlPath & """ " & parameters.MachineName & " 11" + ' process.StartInfo.UseShellExecute = False + ' process.Start() + + ' While Not process.HasExited + ' process.Refresh() + ' Thread.Sleep(50) + ' End While + + ' Return True + 'End Function + + 'Public Function ShowJobs(ByVal parameters As InOutParameters) As Boolean + ' Dim ExePath As String = GetExePath(parameters) + ' Dim DataDir As String = GetDataDir(parameters) + ' Dim BtlPath As String = Path.Combine(DataDir, "QQQ.btl") + ' Dim process As Process = New Process() + ' process.StartInfo.FileName = ExePath + ' process.StartInfo.Arguments = """" & BtlPath & """ " & parameters.MachineName & " 12" + ' process.StartInfo.UseShellExecute = False + ' process.Start() + + ' While Not process.HasExited + ' process.Refresh() + ' Thread.Sleep(50) + ' End While + + ' Return True + 'End Function + + 'Public Function UpdateMachine(ByVal parameters As InOutParameters) As Boolean + ' GetMachineParams(parameters) + ' Return True + 'End Function + + ' + 'Private Shared Function WritePrivateProfileString(ByVal Section As String, ByVal Key As String, ByVal Value As String, ByVal FilePath As String) As Long + + ' Private Shared Sub GetMachineParams(ByVal parameters As InOutParameters) + ' Dim DataDir As String = GetDataDir(parameters) + ' Dim DataName As String = "Essetre-" & parameters.MachineName & ".data" + ' Dim DataPath As String = Path.Combine(DataDir, DataName) + ' If File.Exists(DataPath) Then File.Delete(DataPath) + ' _SqlConnectionStr = parameters.ConnectionString + ' Dim dsOffsets As DataSet = New DataSet() + ' Dim sqlOffsets As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_MachineParam] " & "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using cmd As SqlCommand = New SqlCommand(sqlOffsets, cn) + ' cmd.Parameters.Add("@ConfigId", SqlDbType.Int) + ' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId + ' Dim dataAdapter = New SqlDataAdapter(cmd) + ' dsOffsets.Clear() + ' dataAdapter.Fill(dsOffsets) + ' End Using + ' End Using + + ' _SqlConnectionStr = parameters.ConnectionString + ' Dim dsTrave As DataSet = New DataSet() + ' Dim sqlTrave As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_MachineParam] " & "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using cmd As SqlCommand = New SqlCommand(sqlTrave, cn) + ' cmd.Parameters.Add("@ConfigId", SqlDbType.Int) + ' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId + ' Dim dataAdapter = New SqlDataAdapter(cmd) + ' dsTrave.Clear() + ' dataAdapter.Fill(dsTrave) + ' End Using + ' End Using + + ' _SqlConnectionStr = parameters.ConnectionString + ' Dim dsUser As DataSet = New DataSet() + ' Dim sqlUser As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " & "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId" + + ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) + ' cn.Open() + + ' Using cmd As SqlCommand = New SqlCommand(sqlUser, cn) + ' cmd.Parameters.Add("@ConfigId", SqlDbType.Int) + ' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId + ' Dim dataAdapter = New SqlDataAdapter(cmd) + ' dsUser.Clear() + ' dataAdapter.Fill(dsUser) + ' End Using + ' End Using + + ' Using tw = New StreamWriter(DataPath, False) + ' tw.WriteLine("-- " & DataPath) + ' tw.WriteLine("") + ' tw.WriteLine("local Offsets = {") + + ' For Each table As DataTable In dsOffsets.Tables + + ' For Each row As DataRow In table.Rows + ' Dim Key As String = row("key").ToString() + ' Dim Value As String = row("value").ToString() + ' tw.WriteLine(" " & Key & "=" & Value & ",") + ' Next + ' Next + + ' tw.WriteLine(" Zzz=1") + ' tw.WriteLine("}") + ' tw.WriteLine("") + ' tw.WriteLine("local Trave = {") + + ' For Each table As DataTable In dsTrave.Tables + + ' For Each row As DataRow In table.Rows + ' Dim Key As String = row("key").ToString() + ' Dim Value As String = row("value").ToString() + ' tw.WriteLine(" " & Key & "=" & Value & ",") + ' Next + ' Next + + ' tw.WriteLine(" Zzz=1") + ' tw.WriteLine("}") + ' tw.WriteLine("") + ' tw.WriteLine("local User = {") + + ' For Each table As DataTable In dsUser.Tables + + ' For Each row As DataRow In table.Rows + ' Dim Group As String = row("group").ToString() + ' Dim Key As String = row("key").ToString() + ' Dim Value As String = row("value").ToString() + ' tw.WriteLine(" " & Group & "_" & Key & "=" & Value & ",") + ' Next + ' Next + + ' tw.WriteLine(" Zzz=1") + ' tw.WriteLine("}") + ' tw.WriteLine("") + ' tw.WriteLine("local Machine = { Offsets=Offsets, Trave=Trave, User=User}") + ' tw.WriteLine("return Machine") + ' End Using + 'End Sub + + 'Public Sub CollectFile(ByVal parameters As InOutParameters, ByVal collector As FileCollector) + ' Dim sRoot As String = parameters.Read("EGALTECH", "DIR_EGT", "C:\TechnoEssetre7\EgalTech") + ' Dim sBeamDir As String = "EgtCAM5\Beam" + ' Dim sMachDir As String = "EgtCAM5\Machines\Essetre-" & parameters.MachineName + ' collector.SetRoot(sRoot) + ' collector.AddDirectory(Path.Combine(sRoot, sBeamDir)) + ' collector.AddDirectory(Path.Combine(sRoot, sMachDir)) + 'End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelV.xaml new file mode 100644 index 00000000..7ea3866f --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/LeftPanel/LeftPanelV.xaml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelV.xaml.vb new file mode 100644 index 00000000..b073a2a4 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelV.xaml.vb @@ -0,0 +1,11 @@ +Public Class OptimizePanelV + + Private Sub OptimizeBtn_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + Dim OptimizeBtn = TryCast(sender, FrameworkElement) + + If OptimizeBtn IsNot Nothing Then + OptimizeBtn.ContextMenu.IsOpen = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb new file mode 100644 index 00000000..cf59f380 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb @@ -0,0 +1,204 @@ +Imports System.Collections.ObjectModel +Imports EgtWPFLib5 + +Public Class OptimizePanelVM + + Friend Enum PartType As Integer + MATERIAL = 0 + ALL = 1 + End Enum + + Friend Enum OriginType As Integer + STANDARD = 0 + FROM_BTL = 1 + End Enum + + Private m_PartTypeList As New List(Of IdNameStruct)({New IdNameStruct(PartType.MATERIAL, "Materiale"), + New IdNameStruct(PartType.ALL, "Tutti")}) + Public ReadOnly Property PartTypeList As List(Of IdNameStruct) + Get + Return m_PartTypeList + End Get + End Property + + Private m_SelPartType As IdNameStruct + Public Property SelPartType As IdNameStruct + Get + Return m_SelPartType + End Get + Set(value As IdNameStruct) + m_SelPartType = value + End Set + End Property + + Private m_OriginTypeList As New List(Of IdNameStruct)({New IdNameStruct(OriginType.STANDARD, "Standard"), + New IdNameStruct(OriginType.FROM_BTL, "Da BTL")}) + Public ReadOnly Property OriginTypeList As List(Of IdNameStruct) + Get + Return m_OriginTypeList + End Get + End Property + + Private m_SelOriginType As IdNameStruct + Public Property SelOriginType As IdNameStruct + Get + Return m_SelOriginType + End Get + Set(value As IdNameStruct) + m_SelOriginType = value + End Set + End Property + + + ' Definizione comandi + Private m_cmdOptimize As ICommand + Private m_cmdWarehouse As ICommand + + Sub New() + m_SelPartType = PartTypeList(0) + m_SelOriginType = OriginTypeList(0) + End Sub + +#Region "COMMANDS" + +#Region "Optimize" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Optimize_Command As ICommand + Get + If m_cmdOptimize Is Nothing Then + m_cmdOptimize = New Command(AddressOf Optimize) + End If + Return m_cmdOptimize + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Optimize() + If IsNothing(m_SelPartType) OrElse IsNothing(m_SelOriginType) Then Return + If IsNothing(Map.refProjectVM.BTLStructure.PartList) OrElse Map.refProjectVM.BTLStructure.PartList.Count = 0 Then Return + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + Dim SectionList As New List(Of SParam) + ' se ho selezionato nest per materiale e c'è una sezione selezionata diversa da sezione nulla + If m_SelPartType.Id = PartType.MATERIAL AndAlso Not IsNothing(Map.refProjectVM.BTLStructure.SelSection) AndAlso Map.refProjectVM.BTLStructure.SelSection.dH <> -1 Then + SectionList.Add(New SParam(Map.refProjectVM.BTLStructure.SelSection, 0, 0)) + Else + For Each Section In Map.refProjectVM.BTLStructure.SectionList + If Section.dH = -1 Then Continue For + SectionList.Add(New SParam(Section, 0, 0)) + Next + End If + Dim dRawL As Double = 0 + Dim dRawW As Double = 0 + Dim WhType = GetMainPrivateProfileInt(S_GENERAL, K_WAREHOUSE, 1) + Dim sWarehouseIniPath As String = "" + Dim dOffset As Double = 0 + Dim dStartOffset As Double = 0 + Dim dKerf As Double = 0 + Select Case WhType + Case WarehouseType.BASIC + sWarehouseIniPath = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + ' leggo lunghezza barra + Dim nCurrentL As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_CURRENT & WRH_S, 1, sWarehouseIniPath) + dRawL = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_L & nCurrentL, 0, sWarehouseIniPath) + ' leggo start offset ed offset + dStartOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_STARTOFFSET, 0, sWarehouseIniPath) + dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_OFFSET, 0, sWarehouseIniPath) + ' riporto la stessa lunghezza in tutte le sezioni + For Each Section In SectionList + Section.dL = dRawL + Next + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + Dim nCurrentS As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_WALL, WRH_CURRENT & WRH_S, nCurrentS, sWarehouseIniPath) + Dim sPanelDim As String = "" + Dim sPanelDims() As String + EgtUILib.GenInterface.GetPrivateProfileString(WRH_WALL, WRH_S & nCurrentS, "", sPanelDim, sWarehouseIniPath) + If Not String.IsNullOrWhiteSpace(sPanelDim) Then sPanelDims = sPanelDim.Split(","c) + If Not sPanelDims.Count = 2 OrElse Not StringToDouble(sPanelDims(0), dRawL) OrElse Not StringToDouble(sPanelDims(1), dRawW) Then Return + dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_OFFSET, 0, sWarehouseIniPath) + dKerf = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_KERF, 0, sWarehouseIniPath) + ' riporto le stesse dimensioni in tutte le sezioni + For Each Section In SectionList + Section.dL = dRawL + Section.dW = dRawW + Next + End If + Case WarehouseType.MEDIUM + sWarehouseIniPath = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + ' aggiungo le sezioni con diverse lunghezze in base al warehouse + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + ' leggo lunghezza barra + Dim nCurrentL As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_CURRENT & WRH_S, 1, sWarehouseIniPath) + dRawL = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_L & nCurrentL, 0, sWarehouseIniPath) + ' leggo start offset ed offset + dStartOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_STARTOFFSET, 0, sWarehouseIniPath) + dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_OFFSET, 0, sWarehouseIniPath) + ' riporto la stessa lunghezza in tutte le sezioni + For Each Section In SectionList + Section.dL = dRawL + Next + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + Dim nCurrentS As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_WALL, WRH_CURRENT & WRH_S, nCurrentS, sWarehouseIniPath) + Dim sPanelDim As String = "" + Dim sPanelDims() As String + EgtUILib.GenInterface.GetPrivateProfileString(WRH_WALL, WRH_S & nCurrentS, "", sPanelDim, sWarehouseIniPath) + If Not String.IsNullOrWhiteSpace(sPanelDim) Then sPanelDims = sPanelDim.Split(","c) + If Not sPanelDims.Count = 2 OrElse Not StringToDouble(sPanelDims(0), dRawL) OrElse Not StringToDouble(sPanelDims(1), dRawW) Then Return + dOffset = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_OFFSET, 0, sWarehouseIniPath) + dKerf = EgtUILib.GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_KERF, 0, sWarehouseIniPath) + ' riporto le stesse dimensioni in tutte le sezioni + For Each Section In SectionList + Section.dL = dRawL + Section.dW = dRawW + Next + End If + End Select + ' attivo loading progress + Map.refMyStatusBarVM.StartLoading("Nesting started", True) + For Each Section In SectionList + Dim SectionPartList As New List(Of BTLPart)(Map.refProjectVM.BTLStructure.PartList.Where(Function(x) x.Section = Section.SectXMat).ToList) + ' passo a lua lista id pezzi da nestare + ExecNesting(sLogPath, CurrentMachine.sMachineName, SectionPartList, Section.dL, Section.dW, dStartOffset, dOffset, dKerf) + Next + ' update liste grezzi e pezzi della grafica + Map.refProjectVM.MachGroupPanelVM.InitMachGroupList() + ' disattivo loading progress + Map.refMyStatusBarVM.EndLoading("Nesting completed") + ' seleziono ultimo gruppo + Map.refProjectVM.MachGroupPanelVM.SelLastMachGroup() + End Sub + +#End Region ' Optimize + +#Region "Warehouse" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Warehouse_Command As ICommand + Get + If m_cmdWarehouse Is Nothing Then + m_cmdWarehouse = New Command(AddressOf Warehouse) + End If + Return m_cmdWarehouse + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Warehouse() + Dim WarehouseWnd As New WarehouseWndV(Application.Current.MainWindow, New WarehouseWndVM()) + WarehouseWnd.ShowDialog() + End Sub + +#End Region ' Warehouse + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/PartManager/PartManagerV.xaml b/EgtBEAMWALL.ViewerOptimizer/PartManager/PartManagerV.xaml new file mode 100644 index 00000000..5684568b --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/PartManager/PartManagerV.xaml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml.vb new file mode 100644 index 00000000..74e0c1c0 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProjManagerV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb new file mode 100644 index 00000000..3da25e76 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb @@ -0,0 +1,427 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class ProjManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_CurrProj As ProjectFile + Friend Property CurrProj As ProjectFile + Get + Return m_CurrProj + End Get + Set(value As ProjectFile) + m_CurrProj = value + End Set + End Property + + Private m_IsEnabled As Boolean + Public Property IsEnabled As Boolean + Get + Return m_IsEnabled + End Get + Set(value As Boolean) + If value <> m_IsEnabled Then + m_IsEnabled = value + NotifyPropertyChanged("IsEnabled") + End If + End Set + End Property + + ' indice ultimo progetto + Private m_nLastProjId As Integer + Friend ReadOnly Property nLastProjId As Integer + Get + Return m_nLastProjId + End Get + End Property + + ' Definizione comandi + Private m_cmdNew As ICommand + Private m_cmdOpen As ICommand + Private m_cmdOpenMruFile As ICommand + Private m_cmdSave As ICommand + Private m_cmdSaveAs As ICommand + Private m_cmdExport As ICommand + Private m_cmdDxfOut As ICommand + Private m_cmdImport As ICommand + Private m_cmdGoToProd As ICommand + Private m_cmdSendFeedback As ICommand + +#Region "ToolTip" + + 'Proprietà ToolTip + Public ReadOnly Property NewToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 1) + End Get + End Property + Public ReadOnly Property OpenToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 2) + End Get + End Property + Public ReadOnly Property SaveToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 3) + End Get + End Property + Public ReadOnly Property SaveAsToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 4) + End Get + End Property + Public ReadOnly Property InsertToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 5) + End Get + End Property + Public ReadOnly Property ImportToolTip As String + Get + Return EgtMsg(MSG_TOPCOMMANDBAR + 6) + End Get + End Property + Public ReadOnly Property ExportToolTip As String + Get + Return EgtMsg(91505) 'Esporta in macchina + End Get + End Property + Public ReadOnly Property DxfOutToolTip As String + Get + Return EgtMsg(91506) 'Esporta DXF + End Get + End Property + Public ReadOnly Property OptionsToolTip As String + Get + 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 + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProjManagerVM(Me) + ' Leggo ultimo indice di progetto + m_nLastProjId = GetMainPrivateProfileInt(S_GENERAL, K_PROJSINDEX, 1) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub NewProdFromProj() + ' verifico se progetto modificato, e chiedo se salvare + ProjectFile.VerifyProjectModification(CurrProj, ProjectType.PROJ) + ' creo nuova ottimizzazione + ' leggo indice di ottimizzazione + Dim nProdsIndex As Integer = GetMainPrivateProfileInt(S_GENERAL, K_PRODSINDEX, 1) + Dim sProdsDir As String = refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdsIndex.ToString("0000") + ' creo cartella nuova ottimizzazione + If Not Directory.Exists(sProdsDir) Then + Directory.CreateDirectory(sProdsDir) + Else + Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProdsDir) + 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 + + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim bOk = False + Dim sProdPath As String = sProdsDir & "\" & nProdsIndex.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + 'Map.refSceneHostVM.MainController.OpenProject(sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If bOk Then + ' aggiorno path proj + Map.refProjManagerVM.CurrProj.SetProdId(nProdsIndex) + ' imposto currprod + Map.refProdManagerVM.CurrProd = New ProjectFile(ProjectType.PROD, Path.GetFileNameWithoutExtension(sProdPath)) + ' setto flag nuovo progetto in prod + Map.refProdManagerVM.CurrProd.NewProd = True + End If + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "OpenCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenCommand As ICommand + Get + If m_cmdOpen Is Nothing Then + m_cmdOpen = New Command(AddressOf Open) + End If + Return m_cmdOpen + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Open() + ' verifico se progetto modificato, e chiedo se salvare + ProjectFile.VerifyProjectModification(CurrProj, ProjectType.PROJ) + OpenProject(Nothing) + End Sub + + Friend Sub OpenProject(TempCurrProj As ProjectFile) + ' se la string è vuota + Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing + If IsNothing(TempCurrProj) Then + ' apro dialogo di scelta file + OpenProjectFileDialogVM = New OpenProjectFileDialogVM + Dim OpenFile As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROJ) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + TempCurrProj = OpenProjectFileDialogVM.SelProject + End If + ' se esiste prod prendo quello, altrimenti proj + Dim sFilePath As String = "" + If Not IsNothing(TempCurrProj.nProdId) AndAlso TempCurrProj.nProdId > 0 Then + sFilePath = TempCurrProj.sProdPath + Else + sFilePath = TempCurrProj.sProjPath + End If + If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + m_CurrProj = TempCurrProj + Map.refMainWindowVM.SetTitle(CurrProj.nProjId.ToString("0000") & " - " & CurrProj.BTLFileName & " - EgtBEAMWALL") + Else + MessageBox.Show("Impossibile aprire il file!!") + Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL") + Map.refSceneHostVM.MainController.NewProject() + End If + End Sub + +#End Region ' OpenCommand + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf Save) + End If + Return m_cmdSave + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub Save() + Map.refSceneHostVM.SaveProject() + Map.refMainWindowVM.SetTitle(CurrProj.nProjId.ToString("0000") & " - " & CurrProj.BTLFileName & " - EgtBEAMWALL") + ' se nuovo progetto, incremento l'indice di progetto + If m_CurrProj.NewProj Then + m_nLastProjId = m_nLastProjId + 1 + WriteMainPrivateProfileString(S_GENERAL, K_PROJSINDEX, (m_nLastProjId).ToString()) + m_CurrProj.NewProj = False + + ' bozza salvataggio su DB + Dim DbMan As New DataLayer.DbManager + Dim newDbProj As DataLayer.DatabaseModels.ProjModel + newDbProj = DbMan.ProjCtr.Create(m_CurrProj.nProjId, m_CurrProj.BTLFileName) + + If (False) Then + + ' caso FALSE ADV + DataLayer.DbManager.AdvDataModel = False + + ' creo le parts + Dim BTLPartList As New List(Of DataLayer.DatabaseModels.BTLPartModel) + + For Each part As BTLPart In Map.refProjectVM.BTLStructure.PartList + BTLPartList.Add(New DataLayer.DatabaseModels.BTLPartModel() With {.PartId = part.nPartId}) + Next + + DbMan.BtlPartCtr.Create(newDbProj.ProjDbId, BTLPartList) + Else + DataLayer.DbManager.AdvDataModel = True + + ' creo le parts + Dim BTLPartList As New List(Of DataLayer.DatabaseModels.BTLPartModel) + + For Each part As Core.BTLPart In Map.refProjectVM.BTLStructure.PartList + BTLPartList.Add(DbMan.BtlPartCtr.Convert(part)) + Next + + DbMan.BtlPartCtr.Create(newDbProj.ProjDbId, BTLPartList) + End If + + End If + + + + + End Sub + +#End Region ' SaveCommand + +#Region "Import" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property Import_Command As ICommand + Get + If m_cmdImport Is Nothing Then + m_cmdImport = New Command(AddressOf Import) + End If + Return m_cmdImport + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Sub Import() + ProjectFile.VerifyProjectModification(CurrProj, ProjectType.PROJ) + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() <> True Then Return + ' leggo indice di progetto + Dim nProjId As Integer = GetMainPrivateProfileInt(S_GENERAL, K_PROJSINDEX, 1) + Dim sProjsDir As String = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + ' creo cartella nuovo progetto + If Not Directory.Exists(sProjsDir) Then + Directory.CreateDirectory(sProjsDir) + Else + Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProjsDir) + 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 + + ' copio file BTL + Dim sBtlCopyPath As String = sProjsDir & "\" & Path.GetFileName(BTLDlg.FileName) + Dim bOk = False + Try + File.Copy(BTLDlg.FileName, sBtlCopyPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + ' importo file + If bOk Then + bOk = Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False) + End If + Dim sProjFileName As String = sProjsDir & "\" & nProjId.ToString("0000") & FILENAMESEPARATOR & FILENAMESEPARATOR & Path.GetFileNameWithoutExtension(sBtlCopyPath) & ".nge" + If bOk Then + ' salvo il progetto + bOk = EgtSaveFile(sProjFileName, NGE.BIN) + Else + EgtOutLog("Errore nell'importazione BTL") + End If + If bOk Then + m_CurrProj = New ProjectFile(ProjectType.PROJ, Path.GetFileNameWithoutExtension(sProjFileName)) + m_CurrProj.NewProj = True + Map.refMainWindowVM.SetTitle(CurrProj.nProjId.ToString("0000") & " - " & CurrProj.BTLFileName & " - EgtBEAMWALL") + End If + End Sub + +#End Region ' Import + +#Region "GoToProd" + + ''' + ''' Returns a command that do GoToProd. + ''' + Public ReadOnly Property GoToProd_Command As ICommand + Get + If m_cmdGoToProd Is Nothing Then + m_cmdGoToProd = New Command(AddressOf GoToProd) + End If + Return m_cmdGoToProd + End Get + End Property + + ''' + ''' Execute the GoToProd. This method is invoked by the GoToProd_Command. + ''' + Public Sub GoToProd(ByVal param As Object) + ' verifico se progetto modificato, e chiedo se salvare + If EgtGetModified() Then + If MessageBox.Show("Salvare progetto modificato prima di continuare?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + Map.refSceneHostVM.SaveProject() + Else + ' resetto stato modificato + Map.refSceneHostVM.MainController.ResetModified() + End If + End If + If m_CurrProj.nProdId > 0 Then + 'Map.refSceneHostVM.MainController.OpenProject(m_CurrProj.sProdPath, False) + Map.refProdManagerVM.CurrProd = New ProjectFile(ProjectType.PROD, Path.GetFileNameWithoutExtension(m_CurrProj.sProdPath)) + Else + ' chiedo se aggiungere ad ottimizzazione già presente o creare nuova + Select Case MessageBox.Show("Si: crea nuova ottimizzazione; No: aggiungi ad ottimizzazione già presente", "", MessageBoxButton.YesNoCancel, MessageBoxImage.Information) + Case MessageBoxResult.Yes + ' creo nuova ottimizzazione da progetto corrente + NewProdFromProj() + Case MessageBoxResult.No + ' chiedo in quale ottimizzazione aggiungere il progetto corrente + Dim OpenProjectFileDialogVM As New OpenProjectFileDialogVM + Dim ChooseProdFileDialog As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = ChooseProdFileDialog.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + ' se prod selezionato + If Not IsNothing(OpenProjectFileDialogVM.SelProject.nProdId) AndAlso OpenProjectFileDialogVM.SelProject.nProdId > 0 Then + ' aggiungo proj al prod selezionato + '' DA FARE!!!!!! + End If + + Case MessageBoxResult.Cancel + Return + End Select + End If + ' vado in pagina prod + Map.refMainMenuVM.SetSelPage(Pages.MACHINING, False) + End Sub + +#End Region ' GoToProd + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml new file mode 100644 index 00000000..670c760d --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml.vb new file mode 100644 index 00000000..32a2c3bb --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProjectV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb new file mode 100644 index 00000000..4f3715fb --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb @@ -0,0 +1,155 @@ +Public Class ProjectVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_BTLStructure As BTLStructure + Public Property BTLStructure As BTLStructure + Get + Return m_BTLStructure + End Get + Set(value As BTLStructure) + m_BTLStructure = value + NotifyPropertyChanged("BTLStructure") + End Set + End Property + + Private m_MachGroupPanelVM As New MyMachGroupPanelVM + Public Property MachGroupPanelVM As MyMachGroupPanelVM + Get + Return m_MachGroupPanelVM + End Get + Set(value As MyMachGroupPanelVM) + m_MachGroupPanelVM = value + NotifyPropertyChanged("MachGroupPanelVM") + End Set + End Property + + Private m_LeftPanel_Visibility As Boolean = True + Public Property LeftPanel_Visibility As Visibility + Get + Return If(m_LeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_LeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetLeftPanel_Visibility(IsVisible As Boolean) + m_LeftPanel_Visibility = IsVisible + End Sub + + Private m_TopPanel_Visibility As Boolean = False + Public Property TopPanel_Visibility As Visibility + Get + Return If(m_TopPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_TopPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetTopPanel_Visibility(IsVisible As Boolean) + m_TopPanel_Visibility = IsVisible + End Sub + + Private m_BottomPanel_Visibility As Boolean = True + Public Property BottomPanel_Visibility As Visibility + Get + Return If(m_BottomPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_BottomPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetBottomPanel_Visibility(IsVisible As Boolean) + m_BottomPanel_Visibility = IsVisible + End Sub + + Private m_PartManager_Visibility As Boolean = True + Public Property PartManager_Visibility As Visibility + Get + Return If(m_PartManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_PartManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetPartManager_Visibility(IsVisible As Boolean) + m_PartManager_Visibility = IsVisible + End Sub + + Private m_FeatureManager_Visibility As Boolean = True + Public Property FeatureManager_Visibility As Visibility + Get + Return If(m_FeatureManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FeatureManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFeatureManager_Visibility(IsVisible As Boolean) + m_FeatureManager_Visibility = IsVisible + End Sub + + Private m_ShowBeamPanel_Visibility As Boolean = True + Public Property ShowBeamPanel_Visibility As Visibility + Get + Return If(m_ShowBeamPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ShowBeamPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetShowBeamPanel_Visibility(IsVisible As Boolean) + m_ShowBeamPanel_Visibility = IsVisible + End Sub + + Private m_ProjManager_Visibility As Boolean = True + Public Property ProjManager_Visibility As Visibility + Get + Return If(m_ProjManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProjManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProjManager_Visibility(IsVisible As Boolean) + m_ProjManager_Visibility = IsVisible + End Sub + + Private m_ProdManager_Visibility As Boolean = True + Public Property ProdManager_Visibility As Visibility + Get + Return If(m_ProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProdManager_Visibility(IsVisible As Boolean) + m_ProdManager_Visibility = IsVisible + End Sub + + Friend Sub NotifyAllPanelVisibility() + NotifyPropertyChanged("LeftPanel_Visibility") + NotifyPropertyChanged("TopPanel_Visibility") + NotifyPropertyChanged("BottomPanel_Visibility") + NotifyPropertyChanged("PartManager_Visibility") + NotifyPropertyChanged("FeatureManager_Visibility") + NotifyPropertyChanged("ShowBeamPanel_Visibility") + NotifyPropertyChanged("ProjManager_Visibility") + NotifyPropertyChanged("ProdManager_Visibility") + End Sub + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProjectVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + +End Class + diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFile.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFile.vb new file mode 100644 index 00000000..f2fddca8 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProdFile.vb @@ -0,0 +1,69 @@ +Imports System.IO + +Public Class ProdFile + + 'Private m_nProjId As Integer = 0 + 'Public ReadOnly Property nProjId As Integer + ' Get + ' Return m_nProjId + ' End Get + 'End Property + + 'Friend ReadOnly Property sProjPath As String + ' Get + ' Dim sPath As String = String.Empty + ' If IsNothing(m_nProjId) OrElse m_nProjId = 0 Then Return String.Empty + ' sPath = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & FILENAMESEPARATOR + ' If Not IsNothing(m_nProdId) AndAlso m_nProdId > 0 Then + ' sPath &= nProjId.ToString("0000") + ' End If + ' sPath &= FILENAMESEPARATOR & BTLFileName & ".nge" + ' Return sPath + ' End Get + 'End Property + + Private m_nProdId As Integer = 0 + Public ReadOnly Property nProdId As Integer + Get + Return m_nProdId + End Get + End Property + Friend ReadOnly Property sProdPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_nProdId) OrElse m_nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge" + End Get + End Property + + 'Private m_BTLFileName As String = String.Empty + 'Public ReadOnly Property BTLFileName As String + ' Get + ' Return m_BTLFileName + ' End Get + 'End Property + + Private m_NewProd As Boolean + Friend Property NewProd As Boolean + Get + Return m_NewProd + End Get + Set(value As Boolean) + m_NewProd = value + End Set + End Property + Public ReadOnly Property ProjectFileName As String + Get + Return m_nProdId.ToString("0000") + End Get + End Property + + Sub New(ProdFileName As String) + Integer.TryParse(Path.GetFileNameWithoutExtension(ProdFileName), m_nProdId) + End Sub + + Friend Sub SetProdId(nProdId As Integer) + m_nProdId = nProdId + End Sub + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFile.vb b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFile.vb new file mode 100644 index 00000000..215beb59 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ProjectManager/ProjectFile.vb @@ -0,0 +1,278 @@ +Imports System.IO +Imports EgtUILib + +Public Class ProjectFile + + Private m_nProjectType As ProjectType + Public ReadOnly Property nProjectType As ProjectType + Get + Return m_nProjectType + End Get + End Property + Friend Sub SetProjectType(nProjectType As ProjectType) + m_nProjectType = nProjectType + End Sub + + Private m_nProjId As Integer = 0 + Public ReadOnly Property nProjId As Integer + Get + Return m_nProjId + End Get + End Property + + Friend ReadOnly Property sProjDirPath As String + Get + If IsNothing(m_nProjId) OrElse m_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_nProjId) OrElse m_nProjId = 0 Then Return String.Empty + sPath = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & FILENAMESEPARATOR + If Not IsNothing(m_nProdId) AndAlso m_nProdId > 0 Then + sPath &= nProdId.ToString("0000") + End If + sPath &= FILENAMESEPARATOR & BTLFileName & ".nge" + Return sPath + End Get + End Property + + Private m_nProdId As Integer = 0 + Public ReadOnly Property nProdId As Integer + Get + Return m_nProdId + End Get + End Property + Friend ReadOnly Property sProdDirPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_nProdId) OrElse m_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_nProdId) OrElse m_nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge" + End Get + End Property + + Private m_BTLFileName As String = String.Empty + Public ReadOnly Property BTLFileName As String + Get + Return m_BTLFileName + End Get + End Property + + Private m_NewProj As Boolean + Friend Property NewProj As Boolean + Get + Return m_NewProj + End Get + Set(value As Boolean) + m_NewProj = value + End Set + End Property + + Private m_NewProd As Boolean + Friend Property NewProd As Boolean + Get + Return m_NewProd + End Get + Set(value As Boolean) + m_NewProd = value + End Set + End Property + + ' nome del file mostrato nella finestra OpenProjFileDialog + Public ReadOnly Property OpenFileName As String + Get + If m_nProjectType = ProjectType.PROJ Then + Return m_nProjId.ToString("0000") & " " & BTLFileName + ElseIf m_nProjectType = ProjectType.PROD Then + Return m_nProdId.ToString("0000") + Else + Return "" + End If + End Get + End Property + + 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) + m_nProjectType = nProjectType + If m_nProjectType = ProjectType.PROJ Then + m_nProjId = nProjId + m_nProdId = nProdId + m_BTLFileName = sBTLFileName + ElseIf m_nProjectType = ProjectType.PROD Then + m_nProdId = nProdId + End If + End Sub + + Friend Sub SetProdId(nProdId As Integer) + ' rinomino proj con riferimento a prod + Dim OldPath As String = sProjPath + m_nProdId = nProdId + Dim NewPath As String = sProjPath + File.Move(OldPath, NewPath) + End Sub + + Friend Sub ResetProdId() + SetProdId(0) + End Sub + + ' 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 ProjectFile, 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 = CurrProject.NewProj + sProjectDirPath = CurrProject.sProjDirPath + Else + bNewProject = CurrProject.NewProd + sProjectDirPath = CurrProject.sProdDirPath + End If + ' verifico se progetto modificato, e chiedo se salvare + If (EgtGetModified() Or bNewProject) 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 + Return True + Else + ' se da non salvare e nuovo proj + If bNewProject Then + ' lo elimino + Directory.Delete(sProjectDirPath, True) + If Type = ProjectType.PROD AndAlso CurrProject.m_nProdId = Map.refProjManagerVM.CurrProj.m_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/Resources/EgtBEAMWALL.ico b/EgtBEAMWALL.ViewerOptimizer/Resources/EgtBEAMWALL.ico new file mode 100644 index 00000000..90d62965 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/EgtBEAMWALL.ico differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/InstrumentPanel/Analyze.png b/EgtBEAMWALL.ViewerOptimizer/Resources/InstrumentPanel/Analyze.png new file mode 100644 index 00000000..e322f1d5 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/InstrumentPanel/Analyze.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/InstrumentPanel/GetDist.png b/EgtBEAMWALL.ViewerOptimizer/Resources/InstrumentPanel/GetDist.png new file mode 100644 index 00000000..520e4065 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/InstrumentPanel/GetDist.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/DxfOut.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/DxfOut.png new file mode 100644 index 00000000..85420e4e Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/DxfOut.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Export.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Export.png new file mode 100644 index 00000000..472f5dd9 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Export.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Import.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Import.png new file mode 100644 index 00000000..1e19eab7 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Import.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/New.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/New.png new file mode 100644 index 00000000..78a5a0b3 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/New.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Open.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Open.png new file mode 100644 index 00000000..616c02b0 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Open.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Options.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Options.png new file mode 100644 index 00000000..6fb84bbc Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Options.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Save.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Save.png new file mode 100644 index 00000000..0eca2603 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Save.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/SaveAs.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/SaveAs.png new file mode 100644 index 00000000..1d5cfaef Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/SaveAs.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Send.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Send.png new file mode 100644 index 00000000..a9bcbe4c Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ProjectManager/Send.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowAll.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowAll.png new file mode 100644 index 00000000..37a0de81 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowAll.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowBuilding.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowBuilding.png new file mode 100644 index 00000000..419a9555 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowBuilding.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowSolid.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowSolid.png new file mode 100644 index 00000000..383a95ef Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowBeamPanel/ShowSolid.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingHL.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingHL.png new file mode 100644 index 00000000..8aa5a3ac Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingHL.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingSH.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingSH.png new file mode 100644 index 00000000..0c6690d1 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingSH.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingWF.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingWF.png new file mode 100644 index 00000000..1f2de621 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ShowPanel/RenderingWF.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/TreeView/Folder.png b/EgtBEAMWALL.ViewerOptimizer/Resources/TreeView/Folder.png new file mode 100644 index 00000000..2c1339d0 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/TreeView/Folder.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromBACK.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromBACK.png new file mode 100644 index 00000000..0c2790cd Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromBACK.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromBOTTOM.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromBOTTOM.png new file mode 100644 index 00000000..6a48b645 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromBOTTOM.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromFRONT.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromFRONT.png new file mode 100644 index 00000000..08abc995 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromFRONT.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_NE.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_NE.png new file mode 100644 index 00000000..e0c71baf Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_NE.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_NW.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_NW.png new file mode 100644 index 00000000..203e2903 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_NW.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_SE.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_SE.png new file mode 100644 index 00000000..28910889 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_SE.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_SW.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_SW.png new file mode 100644 index 00000000..909e25e5 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromISO_SW.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromLEFT.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromLEFT.png new file mode 100644 index 00000000..d4a4e85d Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromLEFT.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromRIGHT.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromRIGHT.png new file mode 100644 index 00000000..f182c1a2 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromRIGHT.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromTOP.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromTOP.png new file mode 100644 index 00000000..214358d0 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/LookFromTOP.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomAll.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomAll.png new file mode 100644 index 00000000..e1a27d16 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomAll.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomIn.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomIn.png new file mode 100644 index 00000000..b370a3e0 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomIn.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomOut.png b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomOut.png new file mode 100644 index 00000000..187a1a02 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/ViewPanel/ZoomOut.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb new file mode 100644 index 00000000..b27447b1 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb @@ -0,0 +1,613 @@ +Imports System.Windows.Interop +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MySceneHostVM + Inherits EgtWPFLib5.SceneHostVM + + ' Identificativi per pezzo da selezionare/deselezionare + Private m_nIdToSel As Integer = GDB_ID.NULL + Private m_nIdToDesel As Integer = GDB_ID.NULL + ' Dati movimento + Private m_dMaxStep As Double = 0 + ' Dati per Drag + Private m_nRestRadius As Integer = 3 + Private m_bDrag As Boolean = False + Private m_bDragToStart As Boolean = False + Private m_bVerify As Boolean = False + Private m_bFromParking As Boolean = False + Private m_bDragging As Boolean = False + Private m_locPrev As System.Drawing.Point + Private m_ptPrev As Point3d + Private m_vtTotMove As Vector3d + Private m_dSnapDist As Double = 0 + + + Private bReducedCut As Boolean = False + Private m_bMagnetic As Boolean + + +#Region "CONSTRUCTOR" + + Sub New() + MyBase.New() + AddHandler MainController.OnNewProject, AddressOf OnNewProject + AddHandler MainController.OnOpenProject, AddressOf OnOpenProject + AddHandler MainController.OnSavingProject, AddressOf OnSavingProject + AddHandler MainController.OnSavedProject, AddressOf OnSavedProject + AddHandler MainController.OnImportingProject, AddressOf OnImportingProject + AddHandler MainController.OnImportedProject, AddressOf OnImportedProject + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Overrides Sub InitScene() + InitSceneEvents() + ' Inizializzazione Scena + PreInitializeScene() + ' Se tutto bene + If MainScene.Init() Then 'And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.OFFICE_BASE) Then + PostInitializeScene() + ' Imposto stato gestione mouse diretto della scena a nessuno + MainScene.SetStatusNull() + ' Recupero e imposto handle finestra principale + Dim hMainWnd As IntPtr = New WindowInteropHelper(Application.Current.MainWindow).Handle + EgtSetMainWindowHandle(hMainWnd) + EgtSetCurrentContext(MainScene.GetCtx()) + ' inizializzo gestore travi e pareti + EgtInitBeamMgr(EIB_FL.TS3_POS + EIB_FL.USEUATTR) + ' inizializzo gestore lavorazioni + EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir) + ' Seleziono la macchina impostata nel file ini + Map.refMachinePanelVM.LoadCurrentMachine() + Return + End If + ' Problemi + ' Se manca la chiave + If Map.refMainWindowVM.MainWindowM.nKeyLevel = -1 Or Map.refMainWindowVM.MainWindowM.nKeyLevel = -2 Then + EgtOutLog("Missing Dongle") + ' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma." "Errore" + Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3) + Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1) + MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error) + ' Altrimenti manca la licenza + Else + EgtOutLog("Problems with Licence") + ' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma." "Errore" + Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 5) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 6) + Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1) + If MessageBox.Show(sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then + ' Apro dialogo per richiesta file licenza + Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".lic", + .Filter = "Licences (.lic)|*.lic", + .CheckFileExists = True, + .ValidateNames = True + } + If LicDlg.ShowDialog() = True Then + ' Recupero il direttorio del file + Dim sDir As String = Path.GetDirectoryName(LicDlg.FileName) + ' Se il file non è già nel direttorio di configurazione lo copio + If Not String.Equals(Path.GetFullPath(sDir), Path.GetFullPath(Map.refMainWindowVM.MainWindowM.sConfigDir), StringComparison.OrdinalIgnoreCase) Then + Try + File.Copy(LicDlg.FileName, Path.Combine(Map.refMainWindowVM.MainWindowM.sConfigDir, LicDlg.SafeFileName), True) + Catch ex As Exception + End Try + End If + ' Imposto il nuovo file di licenza nell'Ini + WriteMainPrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName) + End If + End If + End If + ' Chiudo il programma + End + End Sub + + Public Overrides Sub InitSceneEvents() + AddHandler MainScene.OnMouseDownScene, AddressOf OnMouseDownScene + AddHandler MainScene.OnMouseMoveScene, AddressOf OnMouseMoveScene + AddHandler MainScene.OnMouseUpScene, AddressOf OnMouseUpScene + AddHandler MainScene.KeyDown, AddressOf OnKeyDownScene + AddHandler MainScene.OnCursorPos, AddressOf OnCursorPos + AddHandler MainScene.OnShowDistance, AddressOf OnShowDistance + AddHandler MainScene.OnChangedSnapPointType, AddressOf OnChangedSnapPointType + End Sub + + Private Sub PreInitializeScene() + ' imposto colore di default + Dim DefColor As New Color3d(0, 0, 0) + GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor) + MainScene.SetDefaultMaterial(DefColor) + ' imposto colori sfondo + Dim BackTopColor As New Color3d(192, 192, 192) + GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor) + Dim BackBotColor As New Color3d(BackTopColor) + GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor) + MainScene.SetViewBackground(BackTopColor, BackBotColor) + ' imposto colore di evidenziazione + Dim MarkColor As New Color3d(255, 255, 0) + GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor) + MainScene.SetMarkMaterial(MarkColor) + ' imposto colore per superfici selezionate + Dim SelSurfColor As New Color3d(255, 255, 192) + GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor) + MainScene.SetSelSurfMaterial(SelSurfColor) + ' imposto tipo e colore del rettangolo di zoom + Dim bOutline As Boolean = True + Dim ZwColor As New Color3d(0, 0, 0) + GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor) + MainScene.SetZoomWinAttribs(bOutline, ZwColor) + ' imposto colore della linea di distanza + Dim DstLnColor As New Color3d(255, 0, 0) + GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor) + MainScene.SetDistLineMaterial(DstLnColor) + ' imposto parametri OpenGL + Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3) + Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0) + Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32) + Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32) + MainScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits) + End Sub + + Private Sub PostInitializeScene() + ' Impostazioni Controller + MainController.SetScene(MainScene) + ' imposto tipo coordinate + MainScene.SetGridCursorPos(True) + ' modo di visualizzazione + Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING) + ' Map.refShowPanelVM.SetShowMode(DirectCast(nShowMode, SM)) + ' visualizzazione avanzata dei triangoli costituenti le superfici + Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0) + EgtSetShowTriaAdv(bShowTriaAdv) + ' tipo visualizzazione per Zmap + Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1) + EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False) + ' dimensione lineare max in pixel delle textures + Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096) + EgtSetTextureMaxLinPixels(nTxrMaxLinPix) + ' tipo snap point + MainScene.SetSnapPointType(SP.PT_SKETCH) + End Sub + +#End Region ' METHODS + +#Region "ProjectManager" + + Public Overrides Sub NewProject() + EgtSetCurrentContext(MainScene.GetCtx()) + Dim bOk As Boolean = MainController.NewProject() + MainScene.SetStatusNull() + End Sub + + Public Overrides Sub OpenProject(sFilePath As String) + EgtSetCurrentContext(MainScene.GetCtx()) + Dim bOk As Boolean = False + If String.IsNullOrEmpty(sFilePath) Then + ' Recupero cartella dell'ultimo progetto aperto + Dim sDir As String = MainController.GetCurrFile() + If String.IsNullOrWhiteSpace(sDir) Then + GetMainPrivateProfileString(S_MRUFILES, K_FILE, "", sDir) + End If + If Not String.IsNullOrWhiteSpace(sDir) Then + sDir = Path.GetDirectoryName(sDir) + End If + bOk = MainController.OpenProject(sDir) + Else + bOk = MainController.OpenProject(sFilePath, False) + End If + MainScene.SetStatusNull() + End Sub + + Public Overrides Sub SaveProject() + MyBase.SaveProject() + ' Imposto stato gestione mouse diretto della scena a nessuno + MainScene.SetStatusNull() + End Sub + + Public Overrides Sub SaveAsProject() + MyBase.SaveAsProject() + ' Imposto stato gestione mouse diretto della scena a nessuno + MainScene.SetStatusNull() + End Sub + + Public Overrides Sub ImportProject() + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_MRUIMPORT, K_FILE & "1", "", sDir) + If Not String.IsNullOrWhiteSpace(sDir) Then + sDir = Path.GetDirectoryName(sDir) + End If + sDir.TrimEnd("\"c) + MainController.ImportProject(sDir) + End Sub + +#End Region ' ProjectManager + +#Region "EVENTS" + + Private Sub OnNewProject(sender As Object, bOk As Boolean) + Map.refMainWindowVM.SetTitle(" New - EgtBEAMWALL") + Map.refProjectVM.BTLStructure = BTLStructure.Empty + End Sub + + Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean) + ' Procedo a seconda del risultato + If bOk Then + ' leggo struttura BTL + Map.refProjectVM.BTLStructure = BTLStructure.Init() + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM + End If + Map.refProjectVM.BTLStructure.ShowAll() + WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile) + Else + EgtNewFile() + Map.refMainWindowVM.SetTitle(" New - EgtBEAMWALL") + Dim sMsg As String = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file + MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + End If + MainScene.SetStatusNull() + End Sub + + Private Sub OnSavingProject(ByVal sender As Object, sFile As String) + End Sub + + Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) + ' Se salvataggio non riuscito, esco subito + If Not bOk Then + Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file + MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + Return + End If + ' Salvo nome ultimo file + WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile) + End Sub + + Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer) + If nType = FT.BTL Or nType = FT.BTLX Then + nFlag = GetMainPrivateProfileInt(S_IMPORT, K_BTLFLAG, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + Else + MessageBox.Show(Application.Current.MainWindow, EgtMsg(10005), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' File type unknown - Error + End If + End Sub + + Private Sub OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) + WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile)) + If bOk Then + ' leggo struttura BTL + Map.refProjectVM.BTLStructure = BTLStructure.Init() + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 1 + If GetMainPrivateProfileInt(S_GENERAL, K_WAREHOUSE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.CheckExistingSectionXMaterial() + End If + ' scrivo in ogni pezzo identificativo proj + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + ' guardo se esiste info numero progetto a cui appartiene + If Not EgtGetInfo(nPartId, PROJ, Map.refProjManagerVM.nLastProjId) Then + EgtSetInfo(nPartId, PROJ, Map.refProjManagerVM.nLastProjId) + End If + nPartId = EgtGetNextPart(nPartId) + End While + ' mostro tutti i pezzi + Map.refProjectVM.BTLStructure.ShowAll() + Else + Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file + MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If + End Sub + + Private Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs) + If e.Button = Forms.MouseButtons.Middle Then Return + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + If Not IsNothing(Map.refProjectVM.BTLStructure) Then + View_OnMouseDownScene(sender, e) + End If + Case Pages.MACHINING + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As Core.MyMachGroup = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, Core.MyMachGroup) + If SelectedMachGroup.nMachineType = MachineType.WALL Then + Wall_OnMouseDownScene(sender, e) + End If + End If + End Select + End Sub + + Private Sub OnMouseMoveScene(sender As Object, e As Windows.Forms.MouseEventArgs) + If e.Button = Forms.MouseButtons.Middle Then Return + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + If Not IsNothing(Map.refProjectVM.BTLStructure) Then + View_OnMouseMoveScene(sender, e) + End If + Case Pages.MACHINING + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As Core.MyMachGroup = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, Core.MyMachGroup) + If SelectedMachGroup.nMachineType = MachineType.WALL Then + Wall_OnMouseMoveScene(sender, e) + End If + End If + End Select + End Sub + + Private Sub OnMouseUpScene(sender As Object, e As Windows.Forms.MouseEventArgs) + If e.Button = Forms.MouseButtons.Middle Then Return + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + If Not IsNothing(Map.refProjectVM.BTLStructure) Then + View_OnMouseUpScene(sender, e) + End If + Case Pages.MACHINING + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As Core.MyMachGroup = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, Core.MyMachGroup) + If SelectedMachGroup.nMachineType = MachineType.WALL Then + Wall_OnMouseUpScene(sender, e) + End If + End If + End Select + + End Sub + + Private Sub OnKeyDownScene(sender As Object, e As System.Windows.Forms.KeyEventArgs) + End Sub + + Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) + 'Map.refStatusBarVM.SetCurrPos(sCursorPos) + End Sub + + Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String) + Map.refMyStatusBarVM.SetOutputMessage(sDistance) + End Sub + + Private Sub OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP, ByVal bUser As Boolean) + Dim BtnColor As Brush + If bUser Then + BtnColor = New SolidColorBrush(SystemColors.ControlColor) + Else + BtnColor = Brushes.Bisque + End If + 'Select Case nSpType + ' Case SP.PT_SKETCH + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1102), BtnColor) 'Sketch Point + ' Case SP.PT_GRID + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1104), BtnColor) 'Grid Point + ' Case SP.PT_END + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1106), BtnColor) 'End Point + ' Case SP.PT_MID + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1108), BtnColor) 'Mid Point + ' Case SP.CENTER + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1110), BtnColor) 'Center + ' Case SP.CENTROID + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1112), BtnColor) 'Centroid + ' Case SP.PT_NEAR + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1114), BtnColor) 'Near Point + ' Case SP.PT_INTERS + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1116), BtnColor) 'Inters Point + ' Case SP.PT_TANGENT + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1118), BtnColor) 'Tang Point + ' Case SP.PT_PERPENDICULAR + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1120), BtnColor) 'Perp Point + ' Case SP.PT_MINDIST + ' Map.refStatusBarVM.SetSnapPointType(EgtMsg(1122), BtnColor) 'MinDist Point + ' Case Else + ' Map.refStatusBarVM.SetSnapPointType("---", BtnColor) + 'End Select + End Sub + +#End Region ' EVENTS + +#Region "WALL EVENTS" + + Friend Sub Wall_OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs) + ' Per default no drag + m_bDrag = False + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(True, True, True, True, True) + Dim nSel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) + Dim nId As Integer = EgtGetFirstObjInSelWin() + While nId <> GDB_ID.NULL + ' Recupero l'identificativo del pezzo cui appartiene + Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + Dim WallMachGroup As WallMachGroup = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, WallMachGroup) + Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = WallMachGroup.nRawPartId) + If EgtIsPart(nPartId) OrElse EgtIsDuplo(nPartId) OrElse bPartInTable Then + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) + ' Se già selezionato + If nStat = GDB_ST.SEL Then + ' Memorizzo Id da deselezionare + m_nIdToDesel = nPartId + Else + ' Memorizzo Id da selezionare + m_nIdToSel = nPartId + End If + ' Drag possibile + m_bDrag = True + Exit While + End If + nId = EgtGetNextObjInSelWin() + End While + ' Dati per drag + m_locPrev = e.Location + m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev) + m_bDragToStart = m_bDrag + m_bVerify = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Shift) > 0 + m_vtTotMove = Vector3d.NULL() + End Sub + + Friend Sub Wall_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDrag Or m_bDragging Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + 'If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And + ' Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then + ' Return + 'End If + m_bDragToStart = False + End If + ' Determino cosa muovere + Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL) + ' Inizio esecuzione di drag + m_bDragging = True + ' Ricavo il punto corrente in coordinate mondo + Dim ptCurr As Point3d + EgtUnProjectPoint(e.Location, ptCurr) + ' Ricavo il vettore di movimento + Dim vtMove As Vector3d = ptCurr - m_ptPrev + ' Muovo i pezzi selezionati di quanto possibile + If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then + ' Se movimento con sola verifica finale + If m_bVerify Then + Dim x = EgtMove(nMoveId, vtMove) + m_vtTotMove += vtMove + ' altrimenti caso con verifica durante il movimento + Else + '' Aggiorno regioni per nesting + 'UpdateNestRegions() !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + 'EnableReferenceRegion(False) + ' muovo il pezzo + Dim x = EgtMovePartInRawPart(nMoveId, vtMove) 'EgtMovePart(nMoveId, bReducedCut, vtMove) + EgtSaveCollInfo() + ' se movimento risultante nullo, provo con movimento tangente + Dim bTgMoved As Boolean = False + If vtMove.IsSmall() Then + ' riprovo con movimento tangente + Dim vtTgMove As Vector3d = ptCurr - m_ptPrev + EgtTgMovePartOnCollision(nMoveId, bReducedCut, vtTgMove) + bTgMoved = (Not vtTgMove.IsSmall()) + End If + ' se abilitato magnetico (allineamento + snap), lo provo + Dim bAlignMoved As Boolean = False + Dim bSnapMoved As Boolean = False + If m_bMagnetic Then + 'If Not GetLockOnRotation(nMoveId) Then + EgtAlignPartOnCollision(nMoveId, bReducedCut, bAlignMoved) + 'End If + If m_dSnapDist > EPS_SMALL Then + EgtRestoreCollInfo() + EgtMovePartToSnapPointOnCollision(nMoveId, bReducedCut, m_dSnapDist, bSnapMoved) + End If + End If + End If + EgtDraw() + End If + ' Aggiorno il punto precedente + m_ptPrev = ptCurr + ' Terminata esecuzione di drag + m_bDragging = False + End Sub + + Friend Sub Wall_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se eseguito drag + If Not m_bDragToStart Then + ' Se movimento con sola verifica finale + If m_bVerify Then + ' Determino cosa verificare + Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL) + '' Aggiorno regioni per nesting + 'UpdateNestRegions() !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + 'EnableReferenceRegion(False) + ' Eseguo verifica + If EgtVerifyPart(nMoveId, bReducedCut) Then + ' Non superata riporto alla posizione iniziale + Else + EgtMove(nMoveId, -m_vtTotMove) + End If + 'm_bFromParking = False + ' altrimenti caso con verifica durante il movimento + Else + ' Basta reset alla fine + End If + ' Se selezione da eseguire + ElseIf m_nIdToSel <> GDB_ID.NULL Then + ' Eseguo la selezione + EgtSelectObj(m_nIdToSel) + ' Se deselezione da eseguire + ElseIf m_nIdToDesel <> GDB_ID.NULL Then + EgtDeselectObj(m_nIdToDesel) + End If + ' Reset + m_bDrag = False + m_nIdToSel = GDB_ID.NULL + m_nIdToDesel = GDB_ID.NULL + '' Se nessun pezzo selezionato, reset flag posizione selezionati + 'If EgtGetSelectedObjCount() = 0 Then + ' m_nPartPos = PART_POS.NONE_TABLE + 'End If + EgtDraw() + End Sub + +#End Region ' WALL EVENTS + +#Region "VIEW EVENTS" + + Friend Sub View_OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs) + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(True, True, True, True, True) + Dim nSel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) + Dim nId As Integer = EgtGetFirstObjInSelWin() + While nId <> GDB_ID.NULL + ' Recupero l'identificativo del pezzo cui appartiene + Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + If EgtIsPart(nPartId) Then + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) + ' Se già selezionato + If nStat = GDB_ST.SEL Then + ' Memorizzo Id da deselezionare + m_nIdToDesel = nPartId + Else + ' Memorizzo Id da selezionare + m_nIdToSel = nPartId + End If + Exit While + End If + nId = EgtGetNextObjInSelWin() + End While + ' Dati per drag + m_bDragToStart = True + End Sub + + Friend Sub View_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDragToStart Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And + Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then + Return + End If + m_bDragToStart = False + End If + End Sub + + Friend Sub View_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se eseguito drag + If Not m_bDragToStart Then + ' Se selezione da eseguire + ElseIf m_nIdToSel <> GDB_ID.NULL Then + ' Se pezzo da selezionare non è già selezionato + If IsNothing(Map.refProjectVM.BTLStructure.SelPart) OrElse Map.refProjectVM.BTLStructure.SelPart.nPartId <> m_nIdToSel Then + ' Eseguo la selezione + Map.refProjectVM.BTLStructure.SelPart = Map.refProjectVM.BTLStructure.PartList.First(Function(x) x.nPartId = m_nIdToSel) + End If + End If + ' Reset + m_bDrag = False + m_nIdToSel = GDB_ID.NULL + m_nIdToDesel = GDB_ID.NULL + EgtDraw() + End Sub + +#End Region ' VIEW EVENTS + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/SceneHostV.xaml b/EgtBEAMWALL.ViewerOptimizer/SceneHost/SceneHostV.xaml new file mode 100644 index 00000000..7210e7b9 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/SceneHostV.xaml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/SceneHostV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/SceneHost/SceneHostV.xaml.vb new file mode 100644 index 00000000..3bcf798f --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/SceneHostV.xaml.vb @@ -0,0 +1,19 @@ +Imports System.Windows.Interop +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class SceneHostV + + Private m_MySceneHostVM As MySceneHostVM + + Sub New() + ' This call is required by the designer. + InitializeComponent() + ' Assegno al riferimento locale al VM il VM preso dal DataContext + Me.DataContext = New MySceneHostVM + m_MySceneHostVM = DirectCast(Me.DataContext, MySceneHostVM) + m_MySceneHostVM.SetMainScene(MainScene) + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml new file mode 100644 index 00000000..d98edf48 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml.vb new file mode 100644 index 00000000..0375f3ea --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ShowBeamPanelV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb new file mode 100644 index 00000000..1228f61d --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ShowBeamPanel/ShowBeamPanelVM.vb @@ -0,0 +1,142 @@ +Imports EgtUILib + +Public Class ShowBeamPanelVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + +#Region "ToolTip" + + Public ReadOnly Property RenderingWFToolTip As String + Get + Return EgtMsg(MSG_GRIDVIEWPANEL + 1) + End Get + End Property + + Public ReadOnly Property RenderingHLToolTip As String + Get + Return EgtMsg(MSG_GRIDVIEWPANEL + 2) + End Get + End Property + + Public ReadOnly Property RenderingSHToolTip As String + Get + Return EgtMsg(MSG_GRIDVIEWPANEL + 3) + End Get + End Property + + Public ReadOnly Property CurveDirToolTip As String + Get + Return EgtMsg(MSG_GRIDVIEWPANEL + 16) + End Get + End Property + +#End Region + + Private m_bShowAll As Boolean = True + Friend Property bShowAll As Boolean + Get + Return m_bShowAll + End Get + Set(value As Boolean) + m_bShowAll = value + If m_bShowAll Then + m_ShowSolid_IsEnabled = False + m_ShowBuilding_IsEnabled = True + Else + m_ShowSolid_IsEnabled = True + m_ShowBuilding_IsEnabled = False + End If + NotifyPropertyChanged("ShowSolid_IsEnabled") + NotifyPropertyChanged("ShowBuilding_IsEnabled") + End Set + End Property + + Private m_bShowSolid As Boolean + Public Property ShowSolid_IsChecked As Boolean + Get + Return m_bShowSolid + End Get + Set(value As Boolean) + m_bShowSolid = value + If Not IsNothing(Map.refProjectVM.BTLStructure) Then Map.refProjectVM.BTLStructure.ShowSolid() + End Set + End Property + Friend Sub SetShowSolid(bValue As Boolean) + m_bShowSolid = bValue + NotifyPropertyChanged("ShowSolid_IsChecked") + End Sub + + Private m_bShowBuilding As Boolean + Public Property ShowBuilding_IsChecked As Boolean + Get + Return m_bShowBuilding + End Get + Set(value As Boolean) + m_bShowBuilding = value + If Not IsNothing(Map.refProjectVM.BTLStructure) Then Map.refProjectVM.BTLStructure.ShowBuilding() + End Set + End Property + Friend Sub SetShowBuilding(bValue As Boolean) + m_bShowBuilding = bValue + NotifyPropertyChanged("ShowBuilding_IsChecked") + End Sub + + Private m_ShowSolid_IsEnabled As Boolean + Public Property ShowSolid_IsEnabled As Boolean + Get + Return m_ShowSolid_IsEnabled + End Get + Set(value As Boolean) + m_ShowSolid_IsEnabled = value + End Set + End Property + + Private m_ShowBuilding_IsEnabled As Boolean + Public Property ShowBuilding_IsEnabled As Boolean + Get + Return m_ShowBuilding_IsEnabled + End Get + Set(value As Boolean) + m_ShowBuilding_IsEnabled = value + End Set + End Property + + ' Definizione comandi + Private m_cmdShowAll As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + 'Creo riferimento a questa classe in EgtBeamWALL + Map.SetRefShowBeamPanelVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "COMMANDS" + +#Region "ShowAll" + + Public ReadOnly Property ShowAll_Command As ICommand + Get + If m_cmdShowAll Is Nothing Then + m_cmdShowAll = New Command(AddressOf ShowAll) + End If + Return m_cmdShowAll + End Get + End Property + + Public Sub ShowAll() + If Not IsNothing(Map.refProjectVM.BTLStructure) Then + Map.refProjectVM.BTLStructure.ShowAll() + End If + End Sub + +#End Region ' ShowAll + +#End Region ' COMMANDS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowPanel/ShowPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/ShowPanel/ShowPanelV.xaml new file mode 100644 index 00000000..4e4a1ea5 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ShowPanel/ShowPanelV.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ShowPanel/ShowPanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ShowPanel/ShowPanelV.xaml.vb new file mode 100644 index 00000000..98406775 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ShowPanel/ShowPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ShowPanelV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/StatusBar/MyStatusBarVM.vb b/EgtBEAMWALL.ViewerOptimizer/StatusBar/MyStatusBarVM.vb new file mode 100644 index 00000000..fd4c557c --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/StatusBar/MyStatusBarVM.vb @@ -0,0 +1,101 @@ +Imports System.Runtime.InteropServices +Imports System.Threading +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MyStatusBarVM + Inherits EgtWPFLib5.StatusBarVM + + ' Funzioni di callback per output in interfaccia da LUA + Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents) + Private m_OutTextCallback As New OutTextCallback(AddressOf OutText) + + Private m_bStopProgress As Boolean + Friend ReadOnly Property bStopProgress As Boolean + Get + Return m_bStopProgress + End Get + End Property + + ' Definizione comandi + Private m_cmdStopProgress As ICommand + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefStatusBarVM(Me) + ' Installo funzione gestione eventi per lua + EgtSetProcessEvents(m_ProcEventsCallback) + ' Installo funzione output testo su status per lua + EgtSetOutText(m_OutTextCallback) + End Sub + + Friend Sub ResetStopProgress() + m_bStopProgress = False + End Sub + + Public Function OutText(ByRef psText As IntPtr) As Boolean + ' Assegno stringa + OutputMessage = (Marshal.PtrToStringUni(psText)) + ' Costringo ad aggiornare + UpdateUI() + Return True + End Function + + Private Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer + ' Se previsto, imposto progress + If nProg > 0 Then SetLoadingProgress(Math.Min(nProg, 100)) + ' Costringo ad aggiornare + UpdateUI() + ' Eventuale attesa + Thread.Sleep(nPause) + ' Ritorno eventuale stop + If m_bStopProgress Then + m_bStopProgress = False + Return 1 + Else + Return 0 + End If + End Function + + Friend Sub StartLoading(sMessage As String, bIsStop As Boolean) + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True) + Map.refMyStatusBarVM.SetStopProgress_IsActive(bIsStop) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(bIsStop) + Map.refMyStatusBarVM.SetOutputMessage(sMessage) + End Sub + + Friend Sub EndLoading(sMessage As String, Optional nMessageTime As Integer = 3) + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False) + Map.refMyStatusBarVM.SetStopProgress_IsActive(False) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False) + Map.refMyStatusBarVM.SetOutputMessage(sMessage, nMessageTime) + End Sub + +#Region "COMMANDS" + +#Region "StopProgress" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property StopProgress_Command As ICommand + Get + If m_cmdStopProgress Is Nothing Then + m_cmdStopProgress = New Command(AddressOf StopProgress) + End If + Return m_cmdStopProgress + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub StopProgress(ByVal param As Object) + m_bStopProgress = True + End Sub + +#End Region ' StopProgress + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/StatusBar/StatusBarV.xaml b/EgtBEAMWALL.ViewerOptimizer/StatusBar/StatusBarV.xaml new file mode 100644 index 00000000..20d97bc4 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/StatusBar/StatusBarV.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ViewPanel/ViewPanelV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/ViewPanel/ViewPanelV.xaml.vb new file mode 100644 index 00000000..d9dd0b2c --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/ViewPanel/ViewPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ViewPanelV + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndV.xaml b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndV.xaml new file mode 100644 index 00000000..374cccf8 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndV.xaml @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndV.xaml.vb b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndV.xaml.vb new file mode 100644 index 00000000..6b0b6d27 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndV.xaml.vb @@ -0,0 +1,19 @@ +Public Class WarehouseWndV + + Private WithEvents m_WarehouseWndVM As WarehouseWndVM + + Sub New(Owner As Window, WarehouseWndVM As WarehouseWndVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + Me.DataContext = WarehouseWndVM + Me.Tag = Map.refProjectVM.BTLStructure + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_WarehouseWndVM = WarehouseWndVM + End Sub + + Private Sub CloseWindow(bDialogResult As Boolean) Handles m_WarehouseWndVM.m_CloseWindow + Me.DialogResult = bDialogResult + End Sub + +End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb new file mode 100644 index 00000000..8be6bef3 --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/WarehouseWnd/WarehouseWndVM.vb @@ -0,0 +1,1010 @@ +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.Collections.ObjectModel +Imports System.Windows.Forms +Imports EgtBEAMWALL.Core + +Public Class WarehouseWndVM + Inherits VMBase + +#Region "Messages" + + Public ReadOnly Property CurrentS_Msg As String + Get + Select Case Map.refMachinePanelVM.SelectedMachine.nType + Case MachineType.BEAM + Return EgtMsg(61752) + Case MachineType.WALL + Return EgtMsg(61751) + End Select + Return Nothing + End Get + End Property + + Public ReadOnly Property StartOffset_Msg As String + Get + Return EgtMsg(61753) + End Get + End Property + + Public ReadOnly Property Kerf_Msg As String + Get + Return EgtMsg(61754) + End Get + End Property + + Public ReadOnly Property Offset_Msg As String + Get + Return EgtMsg(61755) + End Get + End Property + + Public ReadOnly Property SParams_Msg As String + Get + Select Case Map.refMachinePanelVM.SelectedMachine.nType + Case MachineType.BEAM + Return EgtMsg(61757) + Case MachineType.WALL + Return EgtMsg(61756) + End Select + Return Nothing + End Get + End Property + + Public ReadOnly Property NewParam_Msg As String + Get + Return EgtMsg(61758) + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61759) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61760) + End Get + End Property + + Public ReadOnly Property OkAddParam_Msg As String + Get + Return EgtMsg(61761) + End Get + End Property + + Public ReadOnly Property Save_Msg As String + Get + Return EgtMsg(61762) + End Get + End Property + + Public ReadOnly Property Cancel_Msg As String + Get + Return EgtMsg(61763) + End Get + End Property + + Public ReadOnly Property Error_Msg As String + Get + Return EgtMsg(61764) + End Get + End Property + + Public ReadOnly Property ValueExists_Msg As String + Get + Return EgtMsg(61765) + End Get + End Property + + Public ReadOnly Property IncorrectValue_Msg As String + Get + Return EgtMsg(61766) + End Get + End Property + + Public ReadOnly Property ValuesExist_Msg As String + Get + Return EgtMsg(61767) + End Get + End Property + + Public ReadOnly Property IncorrectValues_Msg As String + Get + Return EgtMsg(61768) + End Get + End Property + + Public ReadOnly Property Attention_Msg As String + Get + Return EgtMsg(61769) + End Get + End Property + + Public ReadOnly Property RemoveCurrent_Msg As String + Get + Return EgtMsg(61770) + End Get + End Property + +#End Region ' Messages + +#Region "FIELDS & PROPERTIES" + + ' Contatore dei parametri L/S rimossi in finestra per successiva rimozione dal file INI + Private m_RemovedParamsCount As Integer = 0 + + Private m_WhType As WarehouseType + Public ReadOnly Property WhType As WarehouseType + Get + Return m_WhType + End Get + End Property + + Private m_dStartOffset As Double + Public Property dStartOffset As Double + Get + Return m_dStartOffset + End Get + Set(value As Double) + m_dStartOffset = value + NotifyPropertyChanged("dStartOffset") + End Set + End Property + + Private m_dKerf As Double + Public Property dKerf As Double + Get + Return m_dKerf + End Get + Set(value As Double) + m_dKerf = value + NotifyPropertyChanged("dKerf") + End Set + End Property + + Private m_dOffset As Double + Public Property dOffset As Double + Get + Return m_dOffset + End Get + Set(value As Double) + m_dOffset = value + NotifyPropertyChanged("dOffset") + End Set + End Property + + Private m_SelCurrentS As SParam + Public Property SelCurrentS As SParam + Get + Return m_SelCurrentS + End Get + Set(value As SParam) + m_SelCurrentS = value + End Set + End Property + + Private m_SParamList As New ObservableCollection(Of SParam) + Public Property SParamList As ObservableCollection(Of SParam) + Get + Return m_SParamList + End Get + Set(value As ObservableCollection(Of SParam)) + m_SParamList = value + End Set + End Property + + Private m_SelSParam As SParam + Public Property SelSParam As SParam + Get + Return m_SelSParam + End Get + Set(value As SParam) + m_SelSParam = value + End Set + End Property + + Private m_sNewW As String + Public Property sNewW As String + Get + Return m_sNewW + End Get + Set(value As String) + m_sNewW = value + NotifyPropertyChanged("sNewW") + End Set + End Property + + Private m_sNewL As String + Public Property sNewL As String + Get + Return m_sNewL + End Get + Set(value As String) + m_sNewL = value + NotifyPropertyChanged("sNewL") + End Set + End Property + + Private m_StartOffset_Visibility As Visibility = Visibility.Collapsed + Public Property StartOffset_Visibility As Visibility + Get + Return m_StartOffset_Visibility + End Get + Set(value As Visibility) + m_StartOffset_Visibility = value + NotifyPropertyChanged("StartOffset_Visibility") + End Set + End Property + + Private m_Kerf_Visibility As Visibility = Visibility.Collapsed + Public Property Kerf_Visibility As Visibility + Get + Return m_Kerf_Visibility + End Get + Set(value As Visibility) + m_Kerf_Visibility = value + NotifyPropertyChanged("Kerf_Visibility") + End Set + End Property + + Private m_Basic_Visibility As Visibility = Visibility.Collapsed + Public Property Basic_Visibility As Visibility + Get + Return m_Basic_Visibility + End Get + Set(value As Visibility) + m_Basic_Visibility = value + NotifyPropertyChanged("Basic_Visibility") + End Set + End Property + + Private m_Medium_Visibility As Visibility = Visibility.Collapsed + Public Property Medium_Visibility As Visibility + Get + Return m_Medium_Visibility + End Get + Set(value As Visibility) + m_Medium_Visibility = value + NotifyPropertyChanged("Medium_Visibility") + End Set + End Property + + Private m_AddRemoveBtns_Visibility As Visibility = Visibility.Collapsed + Public Property AddRemoveBtns_Visibility As Visibility + Get + Return m_AddRemoveBtns_Visibility + End Get + Set(value As Visibility) + m_AddRemoveBtns_Visibility = value + NotifyPropertyChanged("AddRemoveBtns_Visibility") + End Set + End Property + + Private m_NewWallParam_Visibility As Visibility = Visibility.Collapsed + Public Property NewWallParam_Visibility As Visibility + Get + Return m_NewWallParam_Visibility + End Get + Set(value As Visibility) + m_NewWallParam_Visibility = value + NotifyPropertyChanged("NewWallParam_Visibility") + End Set + End Property + + Private m_NewBeamParam_Visibility As Visibility = Visibility.Collapsed + Public Property NewBeamParam_Visibility As Visibility + Get + Return m_NewBeamParam_Visibility + End Get + Set(value As Visibility) + m_NewBeamParam_Visibility = value + NotifyPropertyChanged("NewBeamParam_Visibility") + End Set + End Property + + Friend Event m_CloseWindow(bDialogResult As Boolean) + + ' Definizione comandi + Private m_cmdSave As ICommand + Private m_cmdCancel As ICommand + Private m_cmdAddParam As ICommand + Private m_cmdOkAddParam As ICommand + Private m_cmdCancelAddParam As ICommand + Private m_cmdRemoveParam As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefWarehouseWndVM(Me) + + Dim sValue As String = String.Empty + Dim dValue As Double = 0 + Dim ParamIndex As Integer = 1 + m_WhType = GetMainPrivateProfileInt(S_GENERAL, K_WAREHOUSE, 1) + + Select Case WhType + Case WarehouseType.BASIC + + Basic_Visibility = Visibility.Visible + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + StartOffset_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_BEAM, K_STARTOFFSET, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dStartOffset) + EgtUILib.GetPrivateProfileString(S_BEAM, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dOffset) + + SParamList = New ObservableCollection(Of SParam) + While EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dValue) + SParamList.Add(New SParam(dValue)) + ParamIndex += 1 + End While + + EgtUILib.GetPrivateProfileString(S_BEAM, K_CURRENTL, String.Empty, sValue, sWarehousePath) + SelCurrentS = If(CInt(sValue) > 0 AndAlso CInt(sValue) <= SParamList.Count, SParamList(CInt(sValue) - 1), Nothing) + + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + Kerf_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_WALL, K_KERF, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dKerf) + EgtUILib.GetPrivateProfileString(S_WALL, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dOffset) + + SParamList = New ObservableCollection(Of SParam) + While EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) + + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 2 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dW As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dW) + StringToLen(sParamValues(1), dL) + SParamList.Add(New SParam(dW, dL)) + End If + ParamIndex += 1 + End While + + EgtUILib.GetPrivateProfileString(S_WALL, K_CURRENTS, String.Empty, sValue, sWarehousePath) + SelCurrentS = If(CInt(sValue) > 0 AndAlso CInt(sValue) <= SParamList.Count, SParamList(CInt(sValue) - 1), Nothing) + + End If + AddRemoveBtns_Visibility = Visibility.Visible + + Case WarehouseType.MEDIUM + + Medium_Visibility = Visibility.Visible + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + StartOffset_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_BEAM, K_STARTOFFSET, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dStartOffset) + EgtUILib.GetPrivateProfileString(S_BEAM, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dOffset) + + SParamList = New ObservableCollection(Of SParam) + While EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) + + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 4 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dW) + StringToLen(sParamValues(1), dH) + StringToLen(sParamValues(3), dL) + SParamList.Add(New SParam(New SectionXMaterial(dW, dH, dL, sParamValues(2)), dL)) + End If + ParamIndex += 1 + End While + + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + Kerf_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_WALL, K_KERF, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dKerf) + EgtUILib.GetPrivateProfileString(S_WALL, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLen(sValue, dOffset) + + SParamList = New ObservableCollection(Of SParam) + While EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) + + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 4 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dH As Double = 0 + Dim dW As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dH) + StringToLen(sParamValues(2), dW) + StringToLen(sParamValues(3), dL) + Dim SPar = New SParam(New SectionXMaterial(dW, dH, dL, sParamValues(1)), dW, dL) + SPar.MediumW_Visibility = Visibility.Visible + SParamList.Add(SPar) + End If + ParamIndex += 1 + End While + + End If + + Case WarehouseType.ADVANCED + + ' CASO NON ANCORA PRESENTE + + End Select + + End Sub + +#End Region ' CONSTRUCTOR + +#Region "COMMANDS" + +#Region "Save" + + Public ReadOnly Property Save_Command As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf Save) + End If + Return m_cmdSave + End Get + End Property + + Public Sub Save() + ' Scrivo i valori nell'INI + Dim ParamIndex = 1 + Select Case WhType + Case WarehouseType.BASIC + + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + ' Verifico che i valori siano tutti > 0 + If dStartOffset <= 0 OrElse dOffset <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_BEAM, K_CURRENTL, SParamList.IndexOf(SelCurrentS) + 1, sWarehousePath) + WritePrivateProfileString(S_BEAM, K_STARTOFFSET, LenToString(dStartOffset, 3), sWarehousePath) + WritePrivateProfileString(S_BEAM, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + For Each SPItem In SParamList + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, SParamList(ParamIndex - 1).sValue, sWarehousePath) + ParamIndex += 1 + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedParamsCount + WritePrivateProfileString(S_BEAM, K_L & Index, Nothing, sWarehousePath) + Next + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + ' Verifico che i valori siano tutti > 0 + If dKerf <= 0 OrElse dOffset <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_WALL, K_CURRENTS, SParamList.IndexOf(SelCurrentS) + 1, sWarehousePath) + WritePrivateProfileString(S_WALL, K_KERF, LenToString(dKerf, 3), sWarehousePath) + WritePrivateProfileString(S_WALL, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + For Each SPItem In SParamList + WritePrivateProfileString(S_WALL, K_S & ParamIndex, SParamList(ParamIndex - 1).sValue, sWarehousePath) + ParamIndex += 1 + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedParamsCount + WritePrivateProfileString(S_BEAM, K_S & Index, Nothing, sWarehousePath) + Next + End If + Case WarehouseType.MEDIUM + + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + ' Verifico che i valori siano tutti > 0 + If dStartOffset <= 0 OrElse dOffset <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + For Each SPItem In SParamList + If SParamList(ParamIndex - 1).dL <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ParamIndex += 1 + Next + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_BEAM, K_STARTOFFSET, LenToString(dStartOffset, 3), sWarehousePath) + WritePrivateProfileString(S_BEAM, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + ParamIndex = 1 + For Each SPItem In SParamList + Dim sL As String = String.Empty + sL = LenToString(SParamList(ParamIndex - 1).dL, 3) + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, SParamList(ParamIndex - 1).sValue & "," & sL, sWarehousePath) + ParamIndex += 1 + Next + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + ' Verifico che i valori siano tutti > 0 + If dKerf <= 0 OrElse dOffset <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + For Each SPItem In SParamList + If SParamList(ParamIndex - 1).dW <= 0 OrElse SParamList(ParamIndex - 1).dL <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ParamIndex += 1 + Next + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_WALL, K_KERF, LenToString(dKerf, 3), sWarehousePath) + WritePrivateProfileString(S_WALL, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + ParamIndex = 1 + For Each SPItem In SParamList + Dim sW As String = String.Empty + Dim sL As String = String.Empty + sW = LenToString(SParamList(ParamIndex - 1).dW, 3) + sL = LenToString(SParamList(ParamIndex - 1).dL, 3) + WritePrivateProfileString(S_WALL, K_S & ParamIndex, SParamList(ParamIndex - 1).sValue & "," & sW & "," & sL, sWarehousePath) + ParamIndex += 1 + Next + End If + + Case WarehouseType.ADVANCED + + ' CASO NON ANCORA PRESENTE + + End Select + + RaiseEvent m_CloseWindow(True) + End Sub + +#End Region ' Save + +#Region "Cancel" + + Public ReadOnly Property Cancel_Command As ICommand + Get + If m_cmdCancel Is Nothing Then + m_cmdCancel = New Command(AddressOf Cancel) + End If + Return m_cmdCancel + End Get + End Property + + Public Sub Cancel() + RaiseEvent m_CloseWindow(True) + End Sub + +#End Region ' Cancel + +#Region "AddParam" + + Public ReadOnly Property AddParam_Command As ICommand + Get + If m_cmdAddParam Is Nothing Then + m_cmdAddParam = New Command(AddressOf AddParam) + End If + Return m_cmdAddParam + End Get + End Property + + Public Sub AddParam() + Select Case Map.refMachinePanelVM.SelectedMachine.nType + Case MachineType.BEAM + NewBeamParam_Visibility = Visibility.Visible + Case MachineType.WALL + NewWallParam_Visibility = Visibility.Visible + End Select + End Sub + +#End Region ' AddParam + +#Region "OkAddParam" + + Public ReadOnly Property OkAddParam_Command As ICommand + Get + If m_cmdOkAddParam Is Nothing Then + m_cmdOkAddParam = New Command(AddressOf OkAddParam) + End If + Return m_cmdOkAddParam + End Get + End Property + + Public Sub OkAddParam() + Dim dWValue As Double = 0 + Dim dLValue As Double = 0 + Select Case Map.refMachinePanelVM.SelectedMachine.nType + Case MachineType.BEAM + If Not IsNothing(sNewL) Then StringToLen(sNewL, dLValue) + If dLValue > 0 Then + ' controllo il valore immesso non sia già presente + Dim bExist As Boolean = False + For Each SPItem In SParamList + If SPItem.dL = dLValue Then + bExist = True + Exit For + End If + Next + If bExist Then + MessageBox.Show(ValueExists_Msg, Error_Msg) + Else + SParamList.Add(New SParam(dLValue)) + sNewL = Nothing + NewBeamParam_Visibility = Visibility.Collapsed + End If + Else + MessageBox.Show(IncorrectValue_Msg, Error_Msg) + End If + Case MachineType.WALL + If Not IsNothing(sNewW) Then StringToLen(sNewW, dWValue) + If Not IsNothing(sNewL) Then StringToLen(sNewL, dLValue) + If dWValue > 0 AndAlso dLValue > 0 Then + ' controllo che la coppia di valori immessa non sia già presente + Dim bExist As Boolean = False + For Each SPItem In SParamList + If SPItem.dW = dWValue And SPItem.dL = dLValue Then + bExist = True + Exit For + End If + Next + If bExist Then + MessageBox.Show(ValuesExist_Msg, Error_Msg) + Else + SParamList.Add(New SParam(dWValue, dLValue)) + sNewW = Nothing + sNewL = Nothing + NewWallParam_Visibility = Visibility.Collapsed + End If + Else + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + End If + End Select + End Sub + +#End Region ' OkAddParam + +#Region "CancelAddParam" + + Public ReadOnly Property CancelAddParam_Command As ICommand + Get + If m_cmdCancelAddParam Is Nothing Then + m_cmdCancelAddParam = New Command(AddressOf CancelAddParam) + End If + Return m_cmdCancelAddParam + End Get + End Property + + Public Sub CancelAddParam() + sNewW = Nothing + sNewL = Nothing + NewBeamParam_Visibility = Visibility.Collapsed + NewWallParam_Visibility = Visibility.Collapsed + End Sub + +#End Region ' CancelAddParam + +#Region "RemoveParam" + + Public ReadOnly Property RemoveParam_Command As ICommand + Get + If m_cmdRemoveParam Is Nothing Then + m_cmdRemoveParam = New Command(AddressOf RemoveParam) + End If + Return m_cmdRemoveParam + End Get + End Property + + Public Sub RemoveParam() + If Not IsNothing(SelSParam) Then + If SelSParam.Equals(SelCurrentS) Then + If MessageBox.Show(RemoveCurrent_Msg, Attention_Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then + SParamList.Remove(SelSParam) + m_RemovedParamsCount += 1 + If SParamList.Count > 0 Then + SelCurrentS = SParamList(0) + NotifyPropertyChanged("SelCurrentS") + End If + End If + Return + End If + SParamList.Remove(SelSParam) + m_RemovedParamsCount += 1 + End If + End Sub + +#End Region ' RemoveParam + +#End Region ' COMMANDS + +#Region "METHODS" + + Public Shared Sub CheckExistingSectionXMaterial() + Dim NewSectXMatList As New List(Of SectionXMaterial) + ' Ricavo la lista dei SectionXMaterial presenti in Warehouse + Dim WhSectXMatList As List(Of SectionXMaterial) = GetSectionXMaterialsFromWarehouse() + For Each SectionListItem In Map.refProjectVM.BTLStructure.SectionList + Dim Index As Integer = 0 + Dim bEqual As Boolean = False + ' Confronto l'Item di SectionList con ciascuno di quelli presenti nella Warehouse + For Each SectXMatListItem In WhSectXMatList + If SectionListItem = WhSectXMatList(Index) Then + ' Se l'Item di SectionList equivale ad uno presente nella Warehouse setto bEqual a True ed esco dal For + bEqual = True + Exit For + End If + Index += 1 + Next + ' Se l'Item di SectionList non equivale a nessuno di quelli della Warehouse lo aggiungo alla lista + If Not bEqual Then + NewSectXMatList.Add(SectionListItem) + End If + Next + ' Se nel BTL importato ci sono SectionXMaterial non presenti nell'INI della Warehouse mostro il dialog per la gestione di questi + If NewSectXMatList.Count > 0 Then + Dim AddSectionXMaterialWnd As New AddSectionXMaterialWndV(Application.Current.MainWindow, New AddSectionXMaterialWndVM(NewSectXMatList)) + AddSectionXMaterialWnd.ShowDialog() + End If + End Sub + + Public Shared Function GetSectionXMaterialsFromWarehouse() As List(Of SectionXMaterial) + Dim sValue As String = String.Empty + Dim dValue As Double = 0 + Dim ParamIndex As Integer = 1 + Dim SectXMatList As New List(Of SectionXMaterial) + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + While EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 4 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dW) + StringToLen(sParamValues(1), dH) + StringToLen(sParamValues(3), dL) + SectXMatList.Add(New SectionXMaterial(dW, dH, dL, sParamValues(2))) + End If + ParamIndex += 1 + End While + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + While EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 4 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dH As Double = 0 + Dim dW As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dH) + StringToLen(sParamValues(2), dW) + StringToLen(sParamValues(3), dL) + SectXMatList.Add(New SectionXMaterial(dW, dH, dL, sParamValues(1))) + End If + ParamIndex += 1 + End While + End If + Return SectXMatList + End Function + + Public Shared Function GetSParamFromWarehouse(ParamIndex As Integer) As SParam + Dim nDefault As Integer = 1 + Dim sValue As String = String.Empty + Dim dValue As Double = 0 + Dim WhType As Integer = GetMainPrivateProfileInt(S_GENERAL, K_WAREHOUSE, nDefault) + Select Case WhType + Case WarehouseType.BASIC + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + If EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + StringToLen(sValue, dValue) + Return New SParam(dValue) + ParamIndex += 1 + End If + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + If EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 2 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dW As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dW) + StringToLen(sParamValues(1), dL) + Return New SParam(dW, dL) + End If + End If + End If + Case WarehouseType.MEDIUM + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then + If EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 4 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dW) + StringToLen(sParamValues(1), dH) + StringToLen(sParamValues(3), dL) + Return New SParam(New SectionXMaterial(dW, dH, dL, sParamValues(2)), dL) + End If + End If + ElseIf Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then + If EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 4 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dH As Double = 0 + Dim dW As Double = 0 + Dim dL As Double = 0 + StringToLen(sParamValues(0), dH) + StringToLen(sParamValues(2), dW) + StringToLen(sParamValues(3), dL) + Return New SParam(New SectionXMaterial(dW, dH, dL, sParamValues(1)), dW, dL) + End If + End If + End If + Case WarehouseType.ADVANCED + ' CASO NON ANCORA PRESENTE + End Select + Return Nothing + End Function + +#End Region ' METHODS + +End Class + +Public Class SParam + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61759) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61760) + End Get + End Property + + Private m_SectXMat As SectionXMaterial + Public Property SectXMat As SectionXMaterial + Get + Return m_SectXMat + End Get + Set(value As SectionXMaterial) + m_SectXMat = value + End Set + End Property + + Private m_dW As Double + Public Property dW As Double + Get + Return m_dW + End Get + Set(value As Double) + m_dW = value + End Set + End Property + + Private m_dL As Double + Public Property dL As Double + Get + Return m_dL + End Get + Set(value As Double) + m_dL = value + End Set + End Property + + Public ReadOnly Property sValue As String + Get + Select Case Map.refWarehouseWndVM.WhType + Case WarehouseType.BASIC + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then Return LenToString(dL, 3) + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then Return LenToString(dW, 3) & "," & LenToString(dL, 3) + Case WarehouseType.MEDIUM + Dim sAlias As String = String.Empty + For Each sMatItem In SectXMat.sMaterial + sAlias &= sMatItem & ";" + Next + sAlias = sAlias.TrimEnd(";") + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then Return LenToString(SectXMat.dW, 3) & "," & LenToString(SectXMat.dH, 3) & "," & sAlias + If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.WALL Then Return LenToString(SectXMat.dH, 3) & "," & sAlias + End Select + Return Nothing + End Get + End Property + + Private m_MediumW_Visibility As Visibility = Visibility.Hidden + Public Property MediumW_Visibility As Visibility + Get + Return m_MediumW_Visibility + End Get + Set(value As Visibility) + m_MediumW_Visibility = value + End Set + End Property + + Sub New(W As Double, L As Double) + m_dW = W + m_dL = L + End Sub + + Sub New(L As Double) + m_dL = L + End Sub + + Sub New(SxM As SectionXMaterial, W As Double, L As Double) + m_SectXMat = SxM + m_dW = W + m_dL = L + End Sub + + Sub New(SxM As SectionXMaterial, L As Double) + m_SectXMat = SxM + m_dL = L + End Sub + +End Class + +Public Enum WarehouseType + BASIC = 1 + MEDIUM = 2 + ADVANCED = 3 +End Enum diff --git a/EgtBEAMWALL.ViewerOptimizer/packages.config b/EgtBEAMWALL.ViewerOptimizer/packages.config new file mode 100644 index 00000000..473d6ddf --- /dev/null +++ b/EgtBEAMWALL.ViewerOptimizer/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/EgtBEAMWALL.sln b/EgtBEAMWALL.sln new file mode 100644 index 00000000..1465514f --- /dev/null +++ b/EgtBEAMWALL.sln @@ -0,0 +1,79 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtBEAMWALL.ViewerOptimizer", "EgtBEAMWALL.ViewerOptimizer\EgtBEAMWALL.ViewerOptimizer.vbproj", "{57291955-F9C4-4466-8D53-476D43BA3659}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtBEAMWALL.Supervisor", "EgtBEAMWALL.Supervisor\EgtBEAMWALL.Supervisor.vbproj", "{B71DA327-38C8-4305-BBA1-34F3F3F32405}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgtBEAMWALL.DataLayer", "EgtBEAMWALL.DataLayer\EgtBEAMWALL.DataLayer.csproj", "{24D7760E-662A-47E4-B729-B70126C24A31}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtBEAMWALL.Core", "EgtBEAMWALL.Core\EgtBEAMWALL.Core.vbproj", "{F22835A1-83D8-4334-91BB-BAAEB9CF59B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x64.ActiveCfg = Debug|x64 + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x64.Build.0 = Debug|x64 + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x86.ActiveCfg = Debug|x86 + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x86.Build.0 = Debug|x86 + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|Any CPU.Build.0 = Release|Any CPU + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x64.ActiveCfg = Release|x64 + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x64.Build.0 = Release|x64 + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x86.ActiveCfg = Release|x86 + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x86.Build.0 = Release|x86 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x64.ActiveCfg = Debug|x64 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x64.Build.0 = Debug|x64 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x86.ActiveCfg = Debug|x86 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x86.Build.0 = Debug|x86 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|Any CPU.Build.0 = Release|Any CPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x64.ActiveCfg = Release|x64 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x64.Build.0 = Release|x64 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x86.ActiveCfg = Release|x86 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x86.Build.0 = Release|x86 + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x64.ActiveCfg = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x64.Build.0 = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x86.ActiveCfg = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x86.Build.0 = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|Any CPU.Build.0 = Release|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x64.ActiveCfg = Release|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x64.Build.0 = Release|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x86.ActiveCfg = Release|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x86.Build.0 = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x64.ActiveCfg = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x64.Build.0 = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x86.ActiveCfg = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x86.Build.0 = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|Any CPU.Build.0 = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x64.ActiveCfg = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x64.Build.0 = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x86.ActiveCfg = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {17B3925F-95AB-44F3-9E62-B3C8BD2CB52F} + EndGlobalSection +EndGlobal