Imports System.IO
Imports System.Net
Imports System.Text
Imports Newtonsoft.Json
Imports UTS_Core.UTSModule
Imports UTS_Core.UTSModule.Project
Imports UTS_Core.UTSModule.Station

Public Class ProcessControl

    Private _utsApp As UtsAppForm
    Sub New(utsApp As UtsAppForm)
        _utsApp = utsApp
    End Sub
    Private _isStartUsing As Boolean = False

    '检测前一站是否测试
    Public Function IsFrontStation(station As String, macstr As String) As Boolean
        Dim macconfig As ContJsonPtr = AccessApi2("http://uts-data.com/CommonApi/Get_Sn_Info", "uts_zongqing", macstr, _utsApp.ProcessStation.ParentProject.Index.ToString)
        Dim msstring As String = ""
        If IsNothing(macconfig) Then Return False
        If station.Equals("T1") Then
            Return True
        ElseIf station.Equals("T2") Then
            If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T1")
                MsgBox($"T1:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T3") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T2")
                MsgBox($"T2:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T4") Then
            If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T3")
                MsgBox($"T3:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T5") Then
            If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T4")
                MsgBox($"T4:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T6") Then
            If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T5")
                MsgBox($"T5:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P1") Then
            If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T3")
                MsgBox($"T3:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P2") Then
            If String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("P1")
                MsgBox($"P1:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P3") Then
            If String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("P2")
                MsgBox($"P2:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P4") Then
            If String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("P3")
                MsgBox($"P3:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P5") Then
            If String.IsNullOrEmpty(macconfig.Data.P4) OrElse macconfig.Data.P4.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("P4")
                MsgBox($"P4:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P6") Then
            If String.IsNullOrEmpty(macconfig.Data.P5) OrElse macconfig.Data.P5.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("P5")
                MsgBox($"P5:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        End If
    End Function

    Private Function CboProject_SelectedIndexChanged(thestation As String) As String
        Dim projectInfo As New ProjectInfo(_utsApp.Account.UserId, _utsApp.ProcessStation.ParentProject.Name, ProjectInfo.InitializeModeEnum.LocalDatabaseLoad)

        If IsNothing(projectInfo) Then
            Return "站位信息异常请联系开发者！"
        End If

        For Each station As ProcessStation In projectInfo.Station
            If station.Name.Trim.Equals(thestation.Trim) Then
                Return station.Description
            End If
        Next

        Return "未找到该站位描述."
        ' UpdateProjectStation(_projectInfo.Station)
    End Function


    '检测本站前所有站是否测试
    Public Function IsALLStation(station As String, macstr As String) As Boolean
        If Not _isStartUsing Then Return True
        Dim macconfig As ContJsonPtr = AccessApi2("http://uts-data.com/CommonApi/Get_Sn_Info", "uts_zongqing", macstr, _utsApp.ProcessStation.ParentProject.Index.ToString)
        Dim msstring As String = ""
        Dim asd As String = ""
        If IsNothing(macconfig) Then Return False
        If station.Equals("T1") Then
            Return True
        ElseIf station.Equals("T2") Then
            If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                msstring = CboProject_SelectedIndexChanged("T1")
                MsgBox($"T1:{msstring} 未测试.")
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T3") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                MsgBox(msstring)
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T4") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T5") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = $"T4:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)

                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("T6") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P1") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = msstring & $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T6")
                    msstring = msstring & $"T6:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)

                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P2") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T6")
                    msstring = msstring & $"T6:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P1")
                    msstring = msstring & $"P1:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)

                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P3") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T6")
                    msstring = msstring & $"T6:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P1")
                    msstring = msstring & $"P1:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P2")
                    msstring = msstring & $"P2:{asd} 未测试." & vbCrLf
                End If


                MsgBox(msstring)

                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P4") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T6")
                    msstring = msstring & $"T6:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P1")
                    msstring = msstring & $"P1:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P2")
                    msstring = msstring & $"P2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P3")
                    msstring = msstring & $"P3:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)

                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P5") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P4) OrElse macconfig.Data.P4.Equals("0") Then
                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T6")
                    msstring = msstring & $"T6:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P1")
                    msstring = msstring & $"P1:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P2")
                    msstring = msstring & $"P2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P3")
                    msstring = msstring & $"P3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P4) OrElse macconfig.Data.P4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P4")
                    msstring = msstring & $"P4:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)
                Return False
            Else
                Return True
            End If
        ElseIf station.Equals("P6") Then
            If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P4) OrElse macconfig.Data.P4.Equals("0") OrElse
                String.IsNullOrEmpty(macconfig.Data.P5) OrElse macconfig.Data.P5.Equals("0") Then

                If String.IsNullOrEmpty(macconfig.Data.T1) OrElse macconfig.Data.T1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T1")
                    msstring = msstring & $"T1:{asd} 未测试." & vbCrLf
                End If

                If String.IsNullOrEmpty(macconfig.Data.T2) OrElse macconfig.Data.T2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T2")
                    msstring = msstring & $"T2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T3) OrElse macconfig.Data.T3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T3")
                    msstring = $"T3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T4) OrElse macconfig.Data.T4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T4")
                    msstring = msstring & $"T4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T5) OrElse macconfig.Data.T5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T5")
                    msstring = msstring & $"T5:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.T6) OrElse macconfig.Data.T6.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("T6")
                    msstring = msstring & $"T6:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P1) OrElse macconfig.Data.P1.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P1")
                    msstring = msstring & $"P1:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P2) OrElse macconfig.Data.P2.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P2")
                    msstring = msstring & $"P2:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P3) OrElse macconfig.Data.P3.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P3")
                    msstring = msstring & $"P3:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P4) OrElse macconfig.Data.P4.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P4")
                    msstring = msstring & $"P4:{asd} 未测试." & vbCrLf
                End If
                If String.IsNullOrEmpty(macconfig.Data.P5) OrElse macconfig.Data.P5.Equals("0") Then
                    asd = CboProject_SelectedIndexChanged("P5")
                    msstring = msstring & $"P5:{asd} 未测试." & vbCrLf
                End If

                MsgBox(msstring)

                Return False
            Else
                Return True
            End If
        End If
    End Function



    '本站置位

    Public Sub SetStationflag(thestation As String, macstr As String, isok As String)
        If Not _isStartUsing Then Return
        Dim dic As New Dictionary(Of String, String)

        dic.Add("Barcode"， macstr) '称重值
        dic.Add(thestation， isok)
        'dic.Add("Mars_UnitWeigth"， weightval)
        dic.Add("UpdateTime"， $"{Now:yyyy-MM-dd HH:mm:ss}")
        Dim jsonclass As ContJsonPtr = AccessApi2("http://uts-data.com/CommonApi/Combind_Sn_Info", "uts_zongqing", "Barcode", _utsApp.ProcessStation.ParentProject.Index.ToString， dic)


    End Sub











    Public Function AccessApi2(uart As String, dbName As String, theKey As String， ProjectID As String， Optional dic As Dictionary(Of String, String) = Nothing) As ContJsonPtr

        Dim jsonString As String = String.Empty

        Dim ptr As String = $"Pwd=actop00803&DBName={dbName}&Key={theKey}"
        If Not IsNothing（dic） Then
            ptr = ptr & $"&JsonData={JsonConvert.SerializeObject(dic)}"
        End If
        ptr = ptr & $"&ProjectID={ProjectID}"
        '/http://uts-data.com/CommonApi/Combind_Sn_Info? Pwd%3D%26*$@%23235%26DBName%3Duts_zongqing%26Key%3DBarcode%26Barcode%3D1
        Try
            jsonString = PostData(uart, ptr)
            Console.WriteLine(jsonString)

            If jsonString = Nothing Then
                Return Nothing
            End If
            Dim login As ContJsonPtr = JsonConvert.DeserializeObject(Of ContJsonPtr)(jsonString)
            If login.Message.Contains（"成功"） Then
                Return login
            Else
                Return Nothing
            End If

        Catch ex As Exception
            MsgBox($"{ex.Message}！盒码获取失败请联系管理员")
            Return Nothing
        End Try

    End Function

    Public Shared Function PostData(ByVal url As String, ByVal data As String) As String

        ServicePointManager.Expect100Continue = False
        Dim request As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
        '//Post请求方式
        request.Method = "post"

        '内容类型
        request.ContentType = "application/x-www-form-urlencoded"
        '将URL编码后的字符串转化为字节
        Dim encoding As New UTF8Encoding()
        Dim bys As Byte() = encoding.GetBytes(data)
        '设置请求的 ContentLength 
        request.ContentLength = bys.Length
        '获得请 求流
        Dim newStream As Stream = request.GetRequestStream()
        newStream.Write(bys, 0, bys.Length)
        newStream.Close()
        '获得响应流
        Dim sr As StreamReader = New StreamReader(request.GetResponse().GetResponseStream)
        Return sr.ReadToEnd
    End Function


End Class

Public Class ContJsonPtr
    Public Data As Contjsonrusil
    Public Message As String
End Class
Public Class Contjsonrusil
    Public ID As String

    Public ProjectID As String
    Public Barcode As String
    Public ImportDateTime As Date
    Public UpdateTime As Date
    Public Mars_ColorBox_BarCode As String
    Public Mars_OutBoxCode As String
    Public Mars_MacCodeP As String
    Public Mars_UnitWeigth As String
    Public Label_Print_Cnt As String

    Public T1 As String
    Public T2 As String
    Public T3 As String
    Public T4 As String
    Public T5 As String
    Public T6 As String

    Public P1 As String
    Public P2 As String
    Public P3 As String
    Public P4 As String
    Public P5 As String
    Public P6 As String

End Class


