GZUpdate自动升级程序客户端演示


新建一个winform项目

GZUpdate自动升级程序客户端演示

添加Nuget包 GZUpdate.Client

nuget包名:GZUpdate.Client

GZUpdate自动升级程序客户端演示

GZUpdate自动升级程序 支持.net framework.net core平台

GZUpdate自动升级程序客户端演示

客户端升级配置

GZUpdate自动升级程序客户端演示

获得当前版本

C# 全选
private void Form1_Load(object sender, EventArgs e)
{
	// 当前版本
	txt_CurrentVersion.Text = UpdateClient.getCurrentVersion();

	// 删除上个版本的备份文件
	UpdateClient.deleteBak();
}

初始化更新服务

C# 全选
/// <summary>
/// 初始化更新服务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_init_Click(object sender, EventArgs e)
{
	// 版本更新服务器
	string updateServer = txt_update_server.Text;
	// 产品ID
	string productID = txt_ProductID.Text;
	// 版本类型
	EnumVersionType updateVersionType = (EnumVersionType)Enum.Parse(typeof(EnumVersionType), cmb_VersionType.Text, true);


	if (String.IsNullOrEmpty(updateServer))
	{
		MessageBox.Show("请填写更新服务器!");
	}
	if (String.IsNullOrEmpty(productID))
	{
		MessageBox.Show("请填写产品编号!");
	}

	UpdateClient.Regsiter(updateServer, productID, updateVersionType);

	btn_CheckUpdate.Enabled = true;

}

检查更新

C# 全选
private void btn_CheckUpdate_Click(object sender, EventArgs e)
{
	var data = UpdateClient.doCheckVersion();
	if (data != null && data.Count > 0)
	{
		string newVersion = data.OrderByDescending(o => o.version).Select(s => s.versionTxt).FirstOrDefault();
		if (MessageBox.Show($"发现新版本[{newVersion}],是否立即更新?", "提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Cancel)
			return;


		lbl_updateMessage.Visible = true;
		progressBar1.Visible = true;
		UpdateClient.doUpdate(p =>
		{
			switch (p.Type)
			{
				case "message":
					lbl_updateMessage.Text = p.Message;
					break;
				case "process":
					progressBar1.Maximum = p.Total;
					progressBar1.Value = p.Index;
					break;
				case "success":
					MessageBox.Show("更新成功!");
					// 删除上个版本的备份文件,需要在系统退出后,或者系统下次启动时,调用删除备份文件
					// UpdateClient.deleteBak();

					break;
				case "fail":
					MessageBox.Show("更新失败");
					break;

			}
		});
	}
	else
	{
		MessageBox.Show("当前已经是最新版本");
	}
}

 

测试

制作升级包

先编译一个初始的版本备份起来,然后修改窗体的背景色

GZUpdate自动升级程序客户端演示

再次编译,把生成新的exe打包为一个zip文件

GZUpdate自动升级程序客户端演示

GZUpdate自动升级程序客户端演示

目前只支持打包为zip格式的压缩包

压缩包的内容截图

GZUpdate自动升级程序客户端演示

上传升级包

GZUpdate自动升级程序客户端演示

GZUpdate自动升级程序客户端演示

压缩包文件为上一步制作的压缩包 zip文件

版本采用《(yy)(MM)(dd)序号(两位数字) 》的方式

保存后如图

GZUpdate自动升级程序客户端演示

升级测试

GZUpdate自动升级程序客户端演示

升级服务器:升级服务的服务器信息 https://www.***.com

产品标识:由于升级服务器支持多个产品,用产品标识来区分不同的应用升级

版本类型:支持多种版本类型,发布版本/测试版本,互不干扰

点击检查更新按钮后,系统从服务器检索是否有新版本,如果存在新版本,会提示更新,点击是(Y),系统进行更新

GZUpdate自动升级程序客户端演示

为了安全考虑,动态图片中对版本服务器做了*处理,实际使用中,这里需要是实际的服务器地址

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
管理员
上一篇:C# MEF插件化开发
下一篇:SEO刷排名工具参数配置指南
评论列表

发表评论

评论内容
昵称:
关联文章

GZUpdate自动升级程序客户演示
GZUpdate自动升级服务 .NET C/S Winform客户程序自动升级演示
GZUpdate自动升级之自定义更新补丁程序
2.客户与服务连接
客户接收文件
客户的实现
客户发送数据
服务获取客户连接
客户发送,服务接收并输出
服务回发,客户接收并输出
FTP客户工具 FileZilla
FTP客户工具 WinSCP ( 推荐,免费 )
FTP客户工具 FlashFXP (推荐)
ABP VNext框架中Winform终端的开发和客户授权信息的处理
YES-WinFramework演示Demo下载
CMD运行命令程序自动暂停问题解决
程序测试
VS制作C#程序windows安装程序
网易闪电邮客户中配置企业邮箱的方法
服务实现

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码