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.

SYS-UPDATE.vb 4.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Imports System.IO
  2. Public Class SYS_UPDATE
  3. ReadOnly ds2 As New DataSet
  4. Dim Str As String = Application.StartupPath
  5. Private Sub Set_清單1()
  6. FDT_dgv.DataSource = Nothing : ds2.Clear()
  7. FDT_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  8. FDT_dgv.ColumnHeadersHeight = 25
  9. FDT_dgv.AllowUserToAddRows = False
  10. SQL_FTP資料夾路徑分配()
  11. da.Fill(ds2) : FDT_dgv.DataSource = ds2.Tables(0) : conn.Close()
  12. End Sub
  13. Private Sub SYS_UPDATE_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  14. '-----------------------寫入連線字串-----------------------------------------------------------------------------------------------------------------------------------------------
  15. 登入人IP = "180.218.212.245,4567" : SQL_連線字串_ERP() : 資料數 = 14
  16. MyModule1.進度條() : 伺服器區域_cb.Text = "雅邸" : g_conn_type = 伺服器區域_cb.Text & "伺服器"
  17. '-----------------------系統版本號寫入-----------------------------------------------------------------------------------------------------------------------------------------------
  18. MyModule1.進度條() : SQL_版本號()
  19. MyModule1.進度條() : If dr.Read() Then : 版本號 = dr("系統認證版本號") : End If : conn.Close()
  20. '-----------------------FTP資料夾登入位置宣告--------------------------------------------------------------------------------------------------------------------------------------
  21. MyModule1.進度條() : SQL_FTP伺服器登入位置()
  22. MyModule1.進度條() : If dr.Read() Then : Target = dr("FTP地址") : FTP帳號 = dr("FTP帳號") : FTP密碼 = dr("FTP密碼") : End If : conn.Close()
  23. MyModule1.進度條() : Set_清單1()
  24. MyModule1.進度條() : Dim HH As String = ""
  25. For i As Integer = 0 To FDT_dgv.Rows.Count - 1
  26. If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
  27. If FDT_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = FDT_dgv("資料夾名稱", i).Value.ToString : End If
  28. Next
  29. MyModule1.進度條() : Target1 = Target & AA(0) & "/"
  30. End Sub
  31. Private Sub SYS_UPDATE_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  32. MyModule1.進度條() : Delay(30000)
  33. MyModule1.進度條() : Dim Str As String = Application.StartupPath
  34. MyModule1.進度條() : If File.Exists(Str + "\YD-ERP-SYS - 2021091601.exe") Then : File.Delete(Str + "\YD-ERP-SYS - 2021091601.exe") : End If
  35. Timer1.Enabled = True
  36. End Sub
  37. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  38. Dim 已開啟 As Boolean = False
  39. Dim Strs As String = Application.StartupPath
  40. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\YD-ERP-SYS.exe") Then
  41. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  42. ' 判斷是否有符合的Process
  43. For Each process As Process In pro
  44. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  45. 已開啟 = True
  46. End If
  47. Next
  48. If 已開啟 = False Then
  49. Timer1.Enabled = False
  50. MyModule1.進度條() : If File.Exists(Str + "\YD-ERP-SYS.exe") Then : File.Delete(Str + "\YD-ERP-SYS.exe") : End If
  51. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "YD-ERP-SYS.exe", Str + "\YD-ERP-SYS.exe")
  52. MyModule1.進度條() : Shell(Str + "\YD-ERP-SYS.exe", vbNormalFocus)
  53. Me.Close()
  54. End If
  55. ElseIf File.Exists(Strs & "\YD-ERP-SYS.exe") Then
  56. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  57. ' 判斷是否有符合的Process
  58. For Each process As Process In pro
  59. If ("YD-ERP-SYS").Equals(process.ProcessName) Then
  60. 已開啟 = True
  61. End If
  62. Next
  63. If 已開啟 = False Then
  64. Timer1.Enabled = False
  65. MyModule1.進度條() : If File.Exists(Str + "\YD-ERP-SYS.exe") Then : File.Delete(Str + "\YD-ERP-SYS.exe") : End If
  66. MyModule1.進度條() : My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "YD-ERP-SYS.exe", Str + "\YD-ERP-SYS.exe")
  67. MyModule1.進度條() : Shell(Str + "\YD-ERP-SYS.exe", vbNormalFocus)
  68. Me.Close()
  69. End If
  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