123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- Imports System.IO
- Imports System.Net
- Imports System.Net.NetworkInformation
- Public Class C_SYS_UPDATE
- ReadOnly ds2 As New DataSet
- ReadOnly computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
- ReadOnly IPEndPoint() As EndPoint = computerProperties.GetActiveTcpListeners()
- Dim myIPEndPoint As IPEndPoint
- Dim 內網線路, 開發線路, 刪除完成, OK1, OK2, OK3, OK4, OK5, OK6, OK7, OK8, OK9, OK10 As Boolean
- Dim Str As String = Application.StartupPath
- Dim TF As String
- 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比對()
- '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
- If SQL_連線狀態模組2.ConnectTest2("192.168.1.63,2433") = True Then
- 登入人IP = "192.168.1.63,2433"
- Else
- If SQL_連線狀態模組1.ConnectTest1("106.1.48.106,4567") = True Then
- 登入人IP = "106.1.48.106,4567"
- Else
- MsgBox("System error please contact the job administrator!!")
- End If
- End If
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- End Sub
- Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
- IP比對()
- If 登入人IP = "192.168.1.63,2433" Then : Target = "ftp://192.168.1.63:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "192-SQL-"
- ElseIf 登入人IP = "36.64.59.26,2433" Then : Target = "ftp://36.64.59.26:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "36-SQL-"
- ElseIf 登入人IP = "106.1.48.106,4567" Then : Target = "ftp://106.1.48.106:2121/HXPGS/" : FTP物理位置 = "D:\FTP\HXPGS\" : TF = "106-SQL-"
- End If : FTP帳號 = "" : FTP密碼 = "" : SQL_連線字串_正式()
-
- Set_清單1()
- 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
- Target1 = Target & AA(0) & "/"
- Me.Text = "SYS-UPDATE..- " & TF
- End Sub
- Private Sub SYS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
- 資料數 = 7
- MyModule1.進度條() : Delay(30000)
- MyModule1.進度條() : Dim Str As String = Application.StartupPath
- Timer1.Enabled = True
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Dim 已開啟 As Boolean = False
- Dim Strs As String = Application.StartupPath
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Calculator-SYS.exe") Then
- Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
- ' 判斷是否有符合的Process
- For Each process As Process In pro
- If ("YD-ERP-SYS").Equals(process.ProcessName) Then
- 已開啟 = True
- End If
- Next
- If 已開啟 = False Then
- Timer1.Enabled = False
- MyModule1.進度條() : If File.Exists(Str + "\LANGUAGE_FILE.csv") Then : File.Delete(Str + "\LANGUAGE_FILE.csv") : End If
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "LANGUAGE_FILE.csv", Str + "\LANGUAGE_FILE.csv")
- MyModule1.進度條() : If File.Exists(Str + "\Calculator-SYS.exe") Then : File.Delete(Str + "\Calculator-SYS.exe") : End If
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Calculator-SYS.exe", Str + "\Calculator-SYS.exe")
- MyModule1.進度條() : Shell(Str + "\Calculator-SYS.exe", vbNormalFocus)
- Me.Close()
- End If
- ElseIf File.Exists(Strs & "\Calculator-SYS.exe") Then
- Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
- ' 判斷是否有符合的Process
- For Each process As Process In pro
- If ("YD-ERP-SYS").Equals(process.ProcessName) Then
- 已開啟 = True
- End If
- Next
- If 已開啟 = False Then
- Timer1.Enabled = False
- MyModule1.進度條() : If File.Exists(Str + "\LANGUAGE_FILE.csv") Then : File.Delete(Str + "\LANGUAGE_FILE.csv") : End If
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "LANGUAGE_FILE.csv", Str + "\LANGUAGE_FILE.csv")
- MyModule1.進度條() : If File.Exists(Str + "\Calculator-SYS.exe") Then : File.Delete(Str + "\Calculator-SYS.exe") : End If
- MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Calculator-SYS.exe", Str + "\Calculator-SYS.exe")
- MyModule1.進度條() : Shell(Str + "\Calculator-SYS.exe", vbNormalFocus)
- Me.Close()
- End If
- 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
|