'robin de bock 04/08/2017 Public Class ReworkTray Private _nummer As String Private _slots As List(Of Slot) Private reworktrayslotRep As ReworkTraySlotRepository Public Sub New(ByVal slots As List(Of Slot)) _slots = slots _nummer = AutomillingMapper.GeefNieuwTrayNummer End Sub Public Property nummer As String Get Return _nummer End Get Set(ByVal value As String) If value = Nothing Or CInt(value) <= 0 Then Throw New Exception("Ongeldig traynummer") End If _nummer = value End Set End Property Public ReadOnly Property slots As List(Of Slot) Get Return New List(Of Slot)(_slots) End Get End Property Public Function parenVol() As Boolean For Each slot As Slot In _slots If slot.type = SlotType.dubbel Then If (slot.zijkanten Is Nothing OrElse slot.zijkanten.Count <= 0) And (slot.zijkantenSpeciaal Is Nothing OrElse slot.zijkantenSpeciaal.Count <= 0) Then Return False End If End If Next Return True End Function Public Function enkelVol() As Boolean For Each slot As Slot In _slots If slot.type = SlotType.enkel Then If slot.zijkanten Is Nothing OrElse slot.zijkanten.Count <= 0 And (slot.zijkantenSpeciaal Is Nothing OrElse slot.zijkantenSpeciaal.Count <= 0) Then Return False End If End If Next Return True End Function Public Sub voegPaarToe(ByVal paar As Rework()) For Each Slot In slots If Slot.type = SlotType.dubbel Then If Slot.zijkanten Is Nothing OrElse Slot.zijkanten.Count <= 0 Then Dim lijstPaar As New List(Of Rework) lijstPaar.Add(paar(0)) lijstPaar.Add(paar(1)) Slot.voegZijkantToe(lijstPaar) Exit For End If End If Next End Sub Public Sub voegEnkelToe(ByVal enkel As Rework) For Each Slot In slots If Slot.type = SlotType.enkel Then If Slot.zijkanten Is Nothing OrElse Slot.zijkanten.Count <= 0 Then Slot.voegZijkantToe(enkel) Exit For End If End If Next End Sub Public Sub voegPaarToe(ByRef paar As List(Of ArdisData)) For Each Slot In slots If Slot.type = SlotType.dubbel Then If Slot.zijkantenSpeciaal Is Nothing OrElse Slot.zijkantenSpeciaal.Count <= 0 Then Slot.voegZijkantToe(paar) For Each data As ArdisData In paar data.KamerfreesTrayId = _nummer Next Exit For End If End If Next End Sub Public Sub voegEnkelToe(ByRef enkel As List(Of ArdisData)) For Each Slot In slots If Slot.type = SlotType.enkel Then If Slot.zijkantenSpeciaal Is Nothing OrElse Slot.zijkantenSpeciaal.Count <= 0 Then Slot.voegZijkantToe(enkel) For Each data As ArdisData In enkel data.KamerfreesTrayId = _nummer Next Exit For End If End If Next End Sub Public Function geefNietLegeSlots() As List(Of Slot) Dim nietLeeg As New List(Of Slot) For Each slot As Slot In _slots If Not ((slot.zijkanten Is Nothing OrElse slot.zijkanten.Count <= 0) And (slot.zijkantenSpeciaal Is Nothing OrElse slot.zijkantenSpeciaal.Count <= 0)) Then nietLeeg.Add(slot) End If Next Return nietLeeg End Function Public Function geefNietLegeParenSlots() As List(Of Slot) Dim nietLeegEnPaar As New List(Of Slot) For Each slot As Slot In _slots If Not ((slot.zijkanten Is Nothing OrElse slot.zijkanten.Count <= 0) And (slot.zijkantenSpeciaal Is Nothing OrElse slot.zijkantenSpeciaal.Count <= 0)) And slot.type = SlotType.dubbel Then nietLeegEnPaar.Add(slot) End If Next Return nietLeegEnPaar End Function Public Overrides Function ToString() As String Dim returnString As String = "TRAYNUMMER: " & _nummer & vbNewLine Dim teller As Integer = 1 For Each Slot As Slot In slots returnString += "SLOT NUMMER: " & teller & " === " & Slot.ToString + vbNewLine teller += 1 Next Return returnString End Function Public Function geefReworkTrayEnSlotNummerBijBarcode(barcode As String) As String() For Each slot As Slot In geefNietLegeSlots() For Each zijkant As ArdisData In slot.zijkantenSpeciaal If zijkant.PartCalc.Equals(barcode) Then Return {nummer, CStr(slot.nummer)} End If Next Next Return Nothing End Function End Class