1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- Imports System.IO
- Imports System.Net
- Imports System.Net.NetworkInformation
-
- Public Class HX_PGS_UPDATE
- ReadOnly ds2 As New DataSet
- ReadOnly computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
- ReadOnly IPEndPoint() As EndPoint = computerProperties.GetActiveTcpListeners()
- Dim myIPEndPoint As IPEndPoint
- Dim 內網線路 As Boolean : ReadOnly 開發線路 As Boolean
- Private Sub Set_清單1()
- ftp清單_dgv.DataSource = Nothing : ds2.Clear()
- ftp清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- ftp清單_dgv.ColumnHeadersHeight = 25
- ftp清單_dgv.AllowUserToAddRows = False
- SQL_FTP資料夾路徑分配()
- da.Fill(ds2) : ftp清單_dgv.DataSource = ds2.Tables(0) : conn.Close()
- End Sub
- Private Sub IP比對()
- '-----------------------IP比對----------------------------------------------------------------------------------------------------------------------------------------------------
- 'For Each myIPEndPoint In IPEndPoint
- ' If Strings.Left(myIPEndPoint.Address.ToString, 8) = "172.1.1." Then
- ' 伺服器區域_cb.Text = "公司內網" : 內網線路 = True
- ' Exit For
- ' End If
- 'Next
- 'If 內網線路 = False And 開發線路 = False Then : 伺服器區域_cb.Text = "公司雲端" : End If
- 伺服器區域_cb.Text = "公司雲端"
- End Sub
- Private Sub HX_PGS_UPDATE_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- IP比對() : 資料數 = 18
- MyModule1.進度條() : If Strings.Left(伺服器區域_cb.Text, 2) = "公司" Then : SQL_連線字串_正式() : Else : SQL_連線字串_測試() : End If
- MyModule1.進度條() : SQL_FTP伺服器登入位置()
- MyModule1.進度條() : If dr.Read() Then : Target = dr("FTP地址") : FTP帳號 = dr("FTP帳號") : FTP密碼 = dr("FTP密碼") : FTP物理位置 = dr("FTP物理位置") : End If : conn.Close()
- MyModule1.進度條() : Set_清單1()
- MyModule1.進度條() : Dim HH As String = ""
- For i As Integer = 0 To ftp清單_dgv.Rows.Count - 1
- If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
- If ftp清單_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = ftp清單_dgv("資料夾名稱", i).Value.ToString : End If
- Next
- MyModule1.進度條() : Target1 = Target & AA(0) & "/"
- End Sub
- Private Sub HX_PGS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
- MyModule1.進度條() : Delay(30000)
- MyModule1.進度條() : Dim Str As String = Application.StartupPath
- MyModule1.進度條() : If File.Exists(Str + "\HX-PGS-ERP-SYS.exe") Then : File.Delete(Str + "\HX-PGS-ERP-SYS.exe") : End If
- MyModule1.進度條() : If File.Exists(Str + "\HX01.docx") Then : File.Delete(Str + "\HX01.docx") : End If
- MyModule1.進度條() : If File.Exists(Str + "\PGS01.docx") Then : File.Delete(Str + "\PGS01.docx") : End If
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "HX-PGS-ERP-SYS.exe", Str + "\HX-PGS-ERP-SYS.exe")
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "HX01.docx", Str + "\HX01.docx")
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "PGS01.docx", Str + "\PGS01.docx")
- MyModule1.進度條()
- If File.Exists(Str + "\HX-PGS-Message.exe") Then : Else
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "HX-PGS-Message.exe", Str + "\HX-PGS-Message.exe")
- End If
- MyModule1.進度條()
- If File.Exists(Str + "\Tran.exe") Then : Else
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Tran.exe", Str + "\Tran.exe")
- End If
- MyModule1.進度條() : Shell(Str + "\HX-PGS-ERP-SYS.exe", vbNormalFocus)
- Me.Close()
- End Sub
- Private Sub 伺服器區域_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 伺服器區域_cb.SelectedIndexChanged
- '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
- If 伺服器區域_cb.Text = "公司雲端" Then
- 登入人IP = "103.231.201.230,2433"
- ElseIf 伺服器區域_cb.Text = "測試雲端" Then
- 登入人IP = "106.1.48.106,4567"
- ElseIf 伺服器區域_cb.Text = "印尼測試" Then
- 登入人IP = "103.231.201.230,2433"
- End If
- End Sub
- Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
- Dim time As DateTime = DateTime.Now
- Dim Span As Double = Interval * 1234
- While ((DateTime.Now.Ticks - time.Ticks) < Span)
- Application.DoEvents()
- End While
- End Sub
- End Class
|