frmUpdate.vb 4.3 KB
Newer Older
leaky114's avatar
22.2.25  
leaky114 已提交
1
Imports System.Windows.Forms
2
'Imports FSLib.App.SimpleUpdater
leaky114's avatar
22.2.25  
leaky114 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Imports System.IO

Public Class frmUpdate

    Const InNewVison As String = "\\Likai-pc\发行版\2011\NewVersion.txt"
    Const ChangeLog As String = "\\Likai-pc\发行版\2011\CHANGELOG"

    Const GitWeb As String = "https://gitcode.net/leaky114/inventoraddin"

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Dim simupdate As String

        Dim DisplayVersion As String
        DisplayVersion = ThisApplication.SoftwareVersion.DisplayVersion

leaky114's avatar
leaky114 已提交
18 19 20 21 22 23 24
        Dim UpdateDownloadUrl As String
        Dim UpdateInfoFileName As String = "Update.xml"
        UpdateDownloadUrl = "\\likai-pc\发行版\更新包\" & DisplayVersion & "\{0}"

        Dim UpdateParameter As String
        UpdateParameter = UpdateDownloadUrl & " " & UpdateInfoFileName

leaky114's avatar
22.2.25  
leaky114 已提交
25 26
        simupdate = My.Application.Info.DirectoryPath & "\simupdater.exe"
        If IsFileExsts(simupdate) = True Then
leaky114's avatar
leaky114 已提交
27
            Process.Start(simupdate, "\\likai-pc\发行版\更新包\2011\{0} update.xml")
leaky114's avatar
22.2.25  
leaky114 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
        Else
            MsgBox("缺失升级程序 simupdater.exe,请到本软件仓库下载。", MsgBoxStyle.OkOnly, "检查更新")
            Process.Start(GitWeb)
        End If

        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub frmUpdate_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try
            Select Case CheckUpdate
                Case "-1"
                    chk检查更新.Checked = False
                Case "1"
                    chk检查更新.Checked = True
            End Select

            Dim fileReader As System.IO.StreamReader
            fileReader = My.Computer.FileSystem.OpenTextFileReader(InNewVison)
            Dim NewVersion As String = Nothing
            NewVersion = fileReader.ReadLine()
            fileReader.Close()

            'MsgBox(NewVersion)

            Dim MyVersion As String = _
            My.Application.Info.Version.Major & "." & _
            My.Application.Info.Version.Minor & "." & _
            Format(My.Application.Info.Version.Build, "00") & "." & _
           Format(My.Application.Info.Version.Revision, "00")

            'MsgBox(MyVersion)

            If NewVersion Is Nothing Then
                'MsgBox("未链接到服务器。", MsgBoxStyle.OkOnly, "检查更新")
                Me.Close()
            Else
                Dim shortMyversion As Long
                Dim shortNewVersion As Long

                shortMyversion = ShortVersion(MyVersion)
                shortNewVersion = ShortVersion(NewVersion)

                If shortNewVersion > shortMyversion Then
                    'MsgBox("InventorAddIn插件" & vbCrLf & "当前版本:" & MyVersion & vbCrLf & "检查到 新版本:" & NewVersion, MsgBoxStyle.OkOnly, " 检查更新")
                    lblLocalVersion.Text = "当前版本:" & MyVersion
                    lblNewVersion.Text = "可更新版:" & NewVersion

                    '读取更新日志
                    Dim readText As String = File.ReadAllText(ChangeLog)
                    txtWhatNew.Text = readText
leaky114's avatar
leaky114 已提交
85
                    'Me.ShowDialog()
leaky114's avatar
22.2.25  
leaky114 已提交
86 87 88 89 90
                Else
                    If IsShowUpdateMsg = True Then
                        MsgBox("当前为最新版。", MsgBoxStyle.OkOnly, "检查更新")
                    End If
                    Me.Close()
leaky114's avatar
leaky114 已提交
91
                End If
leaky114's avatar
22.2.25  
leaky114 已提交
92 93 94

            End If
        Catch ex As Exception
leaky114's avatar
leaky114 已提交
95

leaky114's avatar
22.2.25  
leaky114 已提交
96 97
            'MsgBox(ex.Message)
            'MsgBox("未链接到服务器。", MsgBoxStyle.OkOnly, "检查更新")
leaky114's avatar
leaky114 已提交
98
            Me.Close()
leaky114's avatar
22.2.25  
leaky114 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
        End Try
    End Sub

    Private Sub chk检查更新_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chk检查更新.CheckedChanged
        '启动检查更新
        Select Case chk检查更新.Checked
            Case False
                CheckUpdate = "-1"
            Case True
                CheckUpdate = "1"
        End Select

        My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\InventorTool", "CheckUpdate", CheckUpdate)
    End Sub
End Class