Brak opisu
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.

HX-PGS-UPDATE.vb 4.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Imports System.IO
  2. Imports System.Net
  3. Imports System.Net.NetworkInformation
  4. Public Class HX_PGS_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 內網線路 As Boolean : ReadOnly 開發線路 As Boolean
  10. Private Sub Set_清單1()
  11. ftp清單_dgv.DataSource = Nothing : ds2.Clear()
  12. ftp清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  13. ftp清單_dgv.ColumnHeadersHeight = 25
  14. ftp清單_dgv.AllowUserToAddRows = False
  15. SQL_FTP資料夾路徑分配()
  16. da.Fill(ds2) : ftp清單_dgv.DataSource = ds2.Tables(0) : conn.Close()
  17. End Sub
  18. Private Sub IP比對()
  19. '-----------------------IP比對----------------------------------------------------------------------------------------------------------------------------------------------------
  20. 'For Each myIPEndPoint In IPEndPoint
  21. ' If Strings.Left(myIPEndPoint.Address.ToString, 8) = "172.1.1." Then
  22. ' 伺服器區域_cb.Text = "公司內網" : 內網線路 = True
  23. ' Exit For
  24. ' End If
  25. 'Next
  26. 'If 內網線路 = False And 開發線路 = False Then : 伺服器區域_cb.Text = "公司雲端" : End If
  27. 伺服器區域_cb.Text = "公司雲端"
  28. End Sub
  29. Private Sub HX_PGS_UPDATE_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  30. IP比對() : 資料數 = 18
  31. MyModule1.進度條() : If Strings.Left(伺服器區域_cb.Text, 2) = "公司" Then : SQL_連線字串_正式() : Else : SQL_連線字串_測試() : End If
  32. MyModule1.進度條() : SQL_FTP伺服器登入位置()
  33. MyModule1.進度條() : If dr.Read() Then : Target = dr("FTP地址") : FTP帳號 = dr("FTP帳號") : FTP密碼 = dr("FTP密碼") : FTP物理位置 = dr("FTP物理位置") : End If : conn.Close()
  34. MyModule1.進度條() : Set_清單1()
  35. MyModule1.進度條() : Dim HH As String = ""
  36. For i As Integer = 0 To ftp清單_dgv.Rows.Count - 1
  37. If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
  38. If ftp清單_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = ftp清單_dgv("資料夾名稱", i).Value.ToString : End If
  39. Next
  40. MyModule1.進度條() : Target1 = Target & AA(0) & "/"
  41. End Sub
  42. Private Sub HX_PGS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  43. MyModule1.進度條() : Delay(30000)
  44. MyModule1.進度條() : Dim Str As String = Application.StartupPath
  45. MyModule1.進度條() : If File.Exists(Str + "\HX-PGS-ERP-SYS.exe") Then : File.Delete(Str + "\HX-PGS-ERP-SYS.exe") : End If
  46. MyModule1.進度條() : If File.Exists(Str + "\HX01.docx") Then : File.Delete(Str + "\HX01.docx") : End If
  47. MyModule1.進度條() : If File.Exists(Str + "\PGS01.docx") Then : File.Delete(Str + "\PGS01.docx") : End If
  48. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "HX-PGS-ERP-SYS.exe", Str + "\HX-PGS-ERP-SYS.exe")
  49. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "HX01.docx", Str + "\HX01.docx")
  50. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "PGS01.docx", Str + "\PGS01.docx")
  51. MyModule1.進度條()
  52. If File.Exists(Str + "\HX-PGS-Message.exe") Then : Else
  53. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "HX-PGS-Message.exe", Str + "\HX-PGS-Message.exe")
  54. End If
  55. MyModule1.進度條()
  56. If File.Exists(Str + "\Tran.exe") Then : Else
  57. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "Tran.exe", Str + "\Tran.exe")
  58. End If
  59. MyModule1.進度條() : Shell(Str + "\HX-PGS-ERP-SYS.exe", vbNormalFocus)
  60. Me.Close()
  61. End Sub
  62. Private Sub 伺服器區域_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 伺服器區域_cb.SelectedIndexChanged
  63. '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
  64. If 伺服器區域_cb.Text = "公司雲端" Then
  65. 登入人IP = "103.231.201.230,2433"
  66. ElseIf 伺服器區域_cb.Text = "測試雲端" Then
  67. 登入人IP = "106.1.48.106,4567"
  68. ElseIf 伺服器區域_cb.Text = "印尼測試" Then
  69. 登入人IP = "103.231.201.230,2433"
  70. End If
  71. End Sub
  72. Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
  73. Dim time As DateTime = DateTime.Now
  74. Dim Span As Double = Interval * 1234
  75. While ((DateTime.Now.Ticks - time.Ticks) < Span)
  76. Application.DoEvents()
  77. End While
  78. End Sub
  79. End Class