No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Calculator-SYS-UPDATE.vb 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.1.63,2433") = True Then
  23. 登入人IP = "192.168.1.63,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.1.63,2433" Then : Target = "ftp://192.168.1.63:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "192-SQL-"
  37. ElseIf 登入人IP = "36.64.59.26,2433" Then : Target = "ftp://36.64.59.26:2121/" : FTP物理位置 = "C:\FTP\HXPGS\" : TF = "36-SQL-"
  38. ElseIf 登入人IP = "106.1.48.106,4567" Then : Target = "ftp://106.1.48.106:2121/HXPGS/" : FTP物理位置 = "D:\FTP\HXPGS\" : TF = "106-SQL-"
  39. End If : FTP帳號 = "" : FTP密碼 = "" : SQL_連線字串_正式()
  40. Set_清單1()
  41. Dim HH As String = ""
  42. For i As Integer = 0 To ftp清單_dgv.Rows.Count - 1
  43. If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
  44. If ftp清單_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = ftp清單_dgv("資料夾名稱", i).Value.ToString : End If
  45. Next
  46. Target1 = Target & AA(0) & "/"
  47. Me.Text = "SYS-UPDATE..- " & TF
  48. End Sub
  49. Private Sub SYS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  50. 資料數 = 7
  51. MyModule1.進度條() : Delay(30000)
  52. MyModule1.進度條() : Dim Str As String = Application.StartupPath
  53. Timer1.Enabled = True
  54. End Sub
  55. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  56. Dim 已開啟 As Boolean = False
  57. Dim Strs As String = Application.StartupPath
  58. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Calculator-SYS.exe") Then
  59. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  60. ' 判斷是否有符合的Process
  61. For Each process As Process In pro
  62. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  63. 已開啟 = True
  64. End If
  65. Next
  66. If 已開啟 = False Then
  67. Timer1.Enabled = False
  68. MyModule1.進度條() : If File.Exists(Str + "\LANGUAGE_FILE.csv") Then : File.Delete(Str + "\LANGUAGE_FILE.csv") : End If
  69. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "LANGUAGE_FILE.csv", Str + "\LANGUAGE_FILE.csv")
  70. MyModule1.進度條() : If File.Exists(Str + "\Calculator-SYS.exe") Then : File.Delete(Str + "\Calculator-SYS.exe") : End If
  71. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Calculator-SYS.exe", Str + "\Calculator-SYS.exe")
  72. MyModule1.進度條() : Shell(Str + "\Calculator-SYS.exe", vbNormalFocus)
  73. Me.Close()
  74. End If
  75. ElseIf File.Exists(Strs & "\Calculator-SYS.exe") Then
  76. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  77. ' 判斷是否有符合的Process
  78. For Each process As Process In pro
  79. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  80. 已開啟 = True
  81. End If
  82. Next
  83. If 已開啟 = False Then
  84. Timer1.Enabled = False
  85. MyModule1.進度條() : If File.Exists(Str + "\LANGUAGE_FILE.csv") Then : File.Delete(Str + "\LANGUAGE_FILE.csv") : End If
  86. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "LANGUAGE_FILE.csv", Str + "\LANGUAGE_FILE.csv")
  87. MyModule1.進度條() : If File.Exists(Str + "\Calculator-SYS.exe") Then : File.Delete(Str + "\Calculator-SYS.exe") : End If
  88. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Calculator-SYS.exe", Str + "\Calculator-SYS.exe")
  89. MyModule1.進度條() : Shell(Str + "\Calculator-SYS.exe", vbNormalFocus)
  90. Me.Close()
  91. End If
  92. End If
  93. End Sub
  94. Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
  95. Dim time As DateTime = DateTime.Now
  96. Dim Span As Double = Interval * 1234
  97. While ((DateTime.Now.Ticks - time.Ticks) < Span)
  98. Application.DoEvents()
  99. End While
  100. End Sub
  101. End Class