以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  我想问下,狐表自带的系统升级功能,那个触发Update1.zip下载是通过什么底层方法?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=176176)

--  作者:chen37280600
--  发布时间:2022/4/2 17:21:00
--  我想问下,狐表自带的系统升级功能,那个触发Update1.zip下载是通过什么底层方法?
我想问下,狐表自带的系统升级功能,那个触发Update1.zip下载是通过什么底层方法
我在网络严格的国企服务器里,部署了一个Nginx网站,开通好tcp端口,可以通过浏览器访问update.txt,可以下载update1.zip

用狐表检查升级,WebRequest请求可以打开update.txt
但是Syscmd.Project.Update()是没效果,没看到下载update1.zip或者update2.zip的进度条

我在感觉Syscmd.Project.Update()并不是通过Http协议去访问下载的,但也绝对不是FTP。难道是狐表自己写原生的socket协议?

想问下有人重写过自己的升级方法的代码吗?分享下帖子

====================================================

以下是我用的升级代码,这些代码在普通阿里云服务器都正常,已经用过60多个项目
\'联网检测更新---
If User.Type <> UserTypeEnum.Developer Then\'根据是否开发者,再检查升级
    Try
        Dim req = System.Net.WebRequest.Create(PublicUpdatePath & "/update.txt") \'PublicUpdatePath是自己定义的升级网址
        Dim pos = req.GetResponse
        Dim stm As System.IO.Stream = pos.GetResponseStream()
        Dim reader As New System.IO.StreamReader(stm)
        Dim str As String = reader.ReadToEnd
        pos.Close
        stm.Close
        reader.close
        
        Dim ary() As String = str.split("|")
        Dim d As Date = ary(0)
        Dim dv As Date = ary(1)
        If PublishDate < d Then
            If MessageBox.show("发现新版本{" & d & "},是否升级?","在线升级提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
                \'备份一下Config文件夹--
                Dim now As String = Format(Date.now, "yyyyMMddHHmmss")
                If FileSys.DirectoryExists(ProjectPath & "Config") Then
                    FileSys.CopyDirectory (ProjectPath & "Config",ProjectPath & "Config备份_" & now, True)
                End If
                \'备份一下Config文件夹--
                
                If dv > ApplicationVertion Then
                    MessageBox.show("本次升级内容较多,请耐心等待" & vbcrlf & vbcrlf & "升级后需要【手动启动软件】!","升级重要提醒",MessageBoxButtons.OK,MessageBoxIcon.Warning)
                End If
                If Syscmd.Project.Update(False,False) =True Then
                    If dv <= ApplicationVertion Then \'小版本更新,可以用自动重启,大版本绝对不能用,会无限升级!
                        Application.ReStart  \'升级成功后重启项目
                    End If
                End If
                Return ""
            Else
                MessageBox.show("旧版程序运行过程中,可能会有报错,请尽快升级","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
            End If
        Else \'无需升级,正常启动
            \'继续执行Try组合后的代码
        End If
    Catch ex As exception
        \'MessageBox.Show("联网检测更新失败,将以当前版本运行")
    End Try
End If
\'联网检测更新---
[此贴子已经被作者于2022/4/2 17:21:34编辑过]

--  作者:chen37280600
--  发布时间:2022/4/6 9:22:00
--  
顶一下这个问题,遇到麻烦
--  作者:有点蓝
--  发布时间:2022/4/6 10:29:00
--  
已反馈
--  作者:有点蓝
--  发布时间:2022/4/6 10:57:00
--  
升级用的其实是这里的功能:http://www.foxtable.com/webhelp/topics/1402.htm,开发人员说其实也是使用的.net的那套东西,并没有自己写socket。

我使用DownloadFile测试了一下,
Network.DownloadFile("http://aaa.bbb.com/update/update.txt", "c:\\update.txt")
下载update.txt返回这样的内容
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.21.6</center>
</body>
</html>

应该是nginx里做了转发到https导致的。网上查了一下,需要直接使用https,DownloadFile默认情况下使用https会出错,这样用就正常了
Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls11 
Network.DownloadFile("https://aaa.bbb.com/update/update.txt", "c:\\update.txt")

于是测试了一下升级这样用:
Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls11 
Syscmd.Project.Update()

结果可以正常升级,楼主试试

--  作者:chen37280600
--  发布时间:2022/4/21 11:24:00
--  
oh~我发现啥问题了,自己的错,用了新的升级路径变量,却忘了覆盖给狐表的升级方法里。补上下面红色这句,不是https的问题,谢谢官方的关心



\'联网检测更新---
If User.Type <> UserTypeEnum.Developer Then\'根据是否开发者,再检查升级
    Try
        Dim req = System.Net.WebRequest.Create(PublicUpdatePath & "/update.txt")
        Dim pos = req.GetResponse
        Dim stm As System.IO.Stream = pos.GetResponseStream()
        Dim reader As New System.IO.StreamReader(stm)
        Dim str As String = reader.ReadToEnd
        pos.Close
        stm.Close
        reader.close
        
        Dim ary() As String = str.split("|")
        Dim d As Date = ary(0)
        Dim dv As Date = ary(1)
        If PublishDate < d Then
            If MessageBox.show("发现新版本{" & d & "},是否升级?","在线升级提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
                \'备份一下Config文件夹--
                Dim now As String = Format(Date.now, "yyyyMMddHHmmss")
                If FileSys.DirectoryExists(ProjectPath & "Config") Then
                    FileSys.CopyDirectory (ProjectPath & "Config",ProjectPath & "Config备份_" & now, True)
                End If
                \'备份一下Config文件夹--
                
                If dv > ApplicationVertion Then
                    MessageBox.show("本次升级内容较多,请耐心等待" & vbcrlf & vbcrlf & "升级后需要【手动启动软件】!","升级重要提醒",MessageBoxButtons.OK,MessageBoxIcon.Warning)
                End If
                UpdatePath = PublicUpdatePath \'把自己定义的升级路径变量,覆盖给狐表的升级路径变量,才能开始做升级处理
                If Syscmd.Project.Update(False,False) =True Then
                    If dv <= ApplicationVertion Then \'小版本更新,可以用自动重启,大版本绝对不能用,会无限升级!
                        Application.ReStart  \'升级成功后重启项目
                    End If
                End If
                Return ""
            Else
                MessageBox.show("旧版程序运行过程中,可能会有报错,请尽快升级","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
            End If
        Else \'无需升级,正常启动
            \'继续执行Try组合后的代码
        End If
    Catch ex As exception
        \'MessageBox.Show("联网检测更新失败,将以当前版本运行")
    End Try
End If
\'联网检测更新---

--  作者:肥肥记
--  发布时间:2022/9/5 22:55:00
--  
\'小版本更新,可以用自动重启,大版本绝对不能用,会无限升级!。。。。。。。。。。。总算明白了,大升级会替换 入口程序 导致升级失败 而后无限升级