初始化到新仓库

This commit is contained in:
2025-11-18 11:58:00 +08:00
parent 04c258ceb6
commit 164a105213
24 changed files with 172 additions and 87 deletions

View File

@@ -413,101 +413,109 @@ Public Class FrmUpdateConfig
UpdateInstallTip(20, $"Start Get Uts Host")
'获取webService目标地址
Dim remoteIP As IPEndPoint = Nothing
Try
If remoteIP Is Nothing Then
'Dim remoteIP As IPEndPoint = Nothing
'Try
' If remoteIP Is Nothing Then
' remoteIP = New IPEndPoint(Dns.GetHostAddresses("www.uts-data.com")(0), 5980)
' End If
'Catch ex As Exception
' UpdateInstallTip(20, $"Send Heartbeat Packet Fail:{ex.Message}")
' Return False
'End Try
remoteIP = New IPEndPoint(Dns.GetHostAddresses("www.uts-data.com")(0), 5980)
End If
Catch ex As Exception
UpdateInstallTip(20, $"Send Heartbeat Packet Fail:{ex.Message}")
Return False
End Try
'UpdateInstallTip(20, $"remoteIP:{remoteIP.Address }")
'发送获取主机地址命令
Try
Dim packet() As Byte = _webPacker.FillPacket(CByte(UtsWebPacket.Commands.Heartbeat), BitConverter.GetBytes(0))
_udpClient.Send(packet, packet.Length, remoteIP)
Catch ex As Exception
UpdateInstallTip(20, $"Send Heartbeat Packet Fail:{ex.Message}")
Return False
End Try
''发送获取主机地址命令
'Try
' Dim packet() As Byte = _webPacker.FillPacket(CByte(UtsWebPacket.Commands.Heartbeat), BitConverter.GetBytes(0))
' _udpClient.Send(packet, packet.Length, remoteIP)
'Catch ex As Exception
' UpdateInstallTip(20, $"Send Heartbeat Packet Fail:{ex.Message}")
' Return False
'End Try
'UpdateInstallTip(20, $"send")
'等待回复
Dim timeout As Integer = 5 * 1000
Dim lastTime As Date = Now
Dim length As Integer
Dim recvBuf() As Byte = Nothing
Dim recviceIp As New IPEndPoint(IPAddress.Any, 0)
While (Now - lastTime).TotalMilliseconds < timeout
length = _udpClient.Available
If length > 0 Then
recvBuf = _udpClient.Receive(recviceIp)
Exit While
End If
''等待回复
'Dim timeout As Integer = 5 * 1000
'Dim lastTime As Date = Now
'Dim length As Integer
'Dim recvBuf() As Byte = Nothing
'Dim recviceIp As New IPEndPoint(IPAddress.Any, 0)
'While (Now - lastTime).TotalMilliseconds < timeout
' length = _udpClient.Available
' If length > 0 Then
' recvBuf = _udpClient.Receive(recviceIp)
' Exit While
' End If
Threading.Thread.Sleep(1000)
End While
' Threading.Thread.Sleep(1000)
'End While
If recvBuf Is Nothing Then
UpdateInstallTip(20, $"Get Host Fail!")
Return False
End If
'If recvBuf Is Nothing Then
' UpdateInstallTip(20, $"Get Host Fail!")
' Return False
'End If
'UpdateInstallTip(20, $"Rcvd")
''校验
'Try
' _webPacker.CheckPacket(recvBuf)
'Catch ex As Exception
' UpdateInstallTip(20, $"Check Packet Error:{ex.Message}")
' Return False
'End Try
'UpdateInstallTip(20, $"Verfied")
'校验
Try
_webPacker.CheckPacket(recvBuf)
Catch ex As Exception
UpdateInstallTip(20, $"Check Packet Error:{ex.Message}")
Return False
End Try
''处理回复
'Dim cmdByte As Byte = recvBuf(UtsWebPacket.PacketBits.Command)
'处理回复
Dim cmdByte As Byte = recvBuf(UtsWebPacket.PacketBits.Command)
''不是回复心跳包
'If cmdByte <> 1 Then Return False
'不是回复心跳包
If cmdByte <> 1 Then Return False
'Dim type As Integer
'Dim ftpHost As String = ""
'Dim dbHost As String = ""
'For i As Integer = UtsWebPacket.PacketBits.Param + 4 To recvBuf.Count - 1
' type = recvBuf(i)
' length = recvBuf(i + 1)
Dim type As Integer
Dim ftpHost As String = ""
Dim dbHost As String = ""
For i As Integer = UtsWebPacket.PacketBits.Param + 4 To recvBuf.Count - 1
type = recvBuf(i)
length = recvBuf(i + 1)
' If length = 0 Then
' UpdateInstallTip(20, $"Invalid data length!")
' Return False
' End If
If length = 0 Then
UpdateInstallTip(20, $"Invalid data length!")
Return False
End If
' Select Case type
' Case 1 'ftp服务器地址
' ftpHost = Encoding.UTF8.GetString(recvBuf, i + 2, length)
' Case 2 'db服务器地址
' dbHost = Encoding.UTF8.GetString(recvBuf, i + 2, length)
' End Select
' i += length + 1
'Next
Select Case type
Case 1 'ftp服务器地址
ftpHost = Encoding.UTF8.GetString(recvBuf, i + 2, length)
Case 2 'db服务器地址
dbHost = Encoding.UTF8.GetString(recvBuf, i + 2, length)
End Select
i += length + 1
Next
'If String.IsNullOrEmpty(ftpHost) Then
' UpdateInstallTip(20, $"Get FtpHost Fail,Host is null.")
' Return False
'Else
' If String.Compare(UtsRegistry.FtpHost, ftpHost) <> 0 Then
' UtsRegistry.FtpHost = ftpHost '写入注册表
' End If
'End If
If String.IsNullOrEmpty(ftpHost) Then
UpdateInstallTip(20, $"Get FtpHost Fail,Host is null.")
Return False
Else
If String.Compare(UtsRegistry.FtpHost, ftpHost) <> 0 Then
UtsRegistry.FtpHost = ftpHost '写入注册表
End If
End If
If String.IsNullOrEmpty(dbHost) Then
UpdateInstallTip(20, $"Get DbHost Fail,Host is null.")
Return False
Else
If String.Compare(UtsRegistry.DbHost, dbHost) <> 0 Then
UtsRegistry.DbHost = dbHost '写入注册表
End If
End If
'If String.IsNullOrEmpty(dbHost) Then
' UpdateInstallTip(20, $"Get DbHost Fail,Host is null.")
' Return False
'Else
' If String.Compare(UtsRegistry.DbHost, dbHost) <> 0 Then
' UtsRegistry.DbHost = dbHost '写入注册表
' End If
'End If
'//'Momo 2025-09-09 目前先写死服务器地址,后续版本再改为动态获取
Dim ftpHost As String = "ftp.uts-data.com"
Dim dbHost As String = "db.uts-data.com"
UtsRegistry.DbHost = dbHost '写入注册表
UtsRegistry.FtpHost = ftpHost '写入注册表
UpdateInstallTip(20, $"Get Uts Host Success!")
Return True
End Function