暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Calculator-SYS-UPDATE.vb 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. Imports System.IO
  2. Imports System.Net
  3. Imports System.Net.NetworkInformation
  4. Public Class C_SYS_UPDATE
  5. ReadOnly ds2 As New DataSet
  6. ReadOnly computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
  7. ReadOnly IPEndPoint() As EndPoint = computerProperties.GetActiveTcpListeners()
  8. Dim myIPEndPoint As IPEndPoint
  9. Dim 內網線路, 開發線路, 刪除完成, OK1, OK2, OK3, OK4, OK5, OK6, OK7, OK8, OK9, OK10 As Boolean
  10. Dim Str As String = Application.StartupPath
  11. Dim TF As String
  12. Private Sub Set_清單1()
  13. ftp清單_dgv.DataSource = Nothing : ds2.Clear()
  14. ftp清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  15. ftp清單_dgv.ColumnHeadersHeight = 25
  16. ftp清單_dgv.AllowUserToAddRows = False
  17. SQL_FTP資料夾路徑分配()
  18. da.Fill(ds2) : ftp清單_dgv.DataSource = ds2.Tables(0) : conn.Close()
  19. End Sub
  20. Private Sub IP比對()
  21. '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
  22. If SQL_連線狀態模組2.ConnectTest2("192.168.0.201,2433") = True Then
  23. 登入人IP = "192.168.0.201,2433"
  24. Else
  25. If SQL_連線狀態模組1.ConnectTest1("106.1.48.106,4567") = True Then
  26. 登入人IP = "106.1.48.106,4567"
  27. Else
  28. MsgBox("System error please contact the job administrator!!")
  29. End If
  30. End If
  31. End Sub
  32. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  33. End Sub
  34. Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  35. IP比對()
  36. If 登入人IP = "192.168.0.201,2433" Then : Target = "ftp://192.168.0.201:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "192-SQL-"
  37. ElseIf 登入人IP = "103.231.201.230,2433" Then : Target = "ftp://103.231.201.230:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "231-SQL-"
  38. ElseIf 登入人IP = "103.144.143.182,2433" Then : Target = "ftp://103.144.143.182:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "144-SQL-"
  39. ElseIf 登入人IP = "106.1.48.106,4567" Then : Target = "ftp://106.1.48.106:2121/HXPGS/" : FTP物理位置 = "D:\FTP\HXPGS\" : TF = "106-SQL-"
  40. End If : FTP帳號 = "" : FTP密碼 = "" : SQL_連線字串_正式()
  41. Set_清單1()
  42. Dim HH As String = ""
  43. For i As Integer = 0 To ftp清單_dgv.Rows.Count - 1
  44. If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
  45. If ftp清單_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = ftp清單_dgv("資料夾名稱", i).Value.ToString : End If
  46. Next
  47. Target1 = Target & AA(0) & "/"
  48. Me.Text = "SYS-UPDATE..- " & TF
  49. End Sub
  50. Private Sub SYS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  51. 資料數 = 7
  52. MyModule1.進度條() : Delay(30000)
  53. MyModule1.進度條() : Dim Str As String = Application.StartupPath
  54. Timer1.Enabled = True
  55. End Sub
  56. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  57. Dim 已開啟 As Boolean = False
  58. Dim Strs As String = Application.StartupPath
  59. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Calculator-SYS.exe") Then
  60. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  61. ' 判斷是否有符合的Process
  62. For Each process As Process In pro
  63. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  64. 已開啟 = True
  65. End If
  66. Next
  67. If 已開啟 = False Then
  68. Timer1.Enabled = False
  69. MyModule1.進度條() : If File.Exists(Str + "\LANGUAGE_FILE.csv") Then : File.Delete(Str + "\LANGUAGE_FILE.csv") : End If
  70. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "LANGUAGE_FILE.csv", Str + "\LANGUAGE_FILE.csv")
  71. MyModule1.進度條() : If File.Exists(Str + "\Calculator-SYS.exe") Then : File.Delete(Str + "\Calculator-SYS.exe") : End If
  72. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Calculator-SYS.exe", Str + "\Calculator-SYS.exe")
  73. MyModule1.進度條() : Shell(Str + "\Calculator-SYS.exe", vbNormalFocus)
  74. Me.Close()
  75. End If
  76. ElseIf File.Exists(Strs & "\Calculator-SYS.exe") Then
  77. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  78. ' 判斷是否有符合的Process
  79. For Each process As Process In pro
  80. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  81. 已開啟 = True
  82. End If
  83. Next
  84. If 已開啟 = False Then
  85. Timer1.Enabled = False
  86. MyModule1.進度條() : If File.Exists(Str + "\LANGUAGE_FILE.csv") Then : File.Delete(Str + "\LANGUAGE_FILE.csv") : End If
  87. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "LANGUAGE_FILE.csv", Str + "\LANGUAGE_FILE.csv")
  88. MyModule1.進度條() : If File.Exists(Str + "\Calculator-SYS.exe") Then : File.Delete(Str + "\Calculator-SYS.exe") : End If
  89. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Calculator-SYS.exe", Str + "\Calculator-SYS.exe")
  90. MyModule1.進度條() : Shell(Str + "\Calculator-SYS.exe", vbNormalFocus)
  91. Me.Close()
  92. End If
  93. End If
  94. End Sub
  95. Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
  96. Dim time As DateTime = DateTime.Now
  97. Dim Span As Double = Interval * 1234
  98. While ((DateTime.Now.Ticks - time.Ticks) < Span)
  99. Application.DoEvents()
  100. End While
  101. End Sub
  102. End Class