8179d11bf6e45093ceabf0449ddac3fd7a73e818..1c752c710464609d137012d6c9ca717a942cb6e9
2025-05-29 wbc
1
1c752c 对比 | 目录
2025-05-29 wbc
修改异常
a95ce4 对比 | 目录
已修改7个文件
已添加2个文件
104 ■■■■■ 文件已修改
MES.Service/bin/Debug/net8.0/MES.Service.dll 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/bin/Debug/net8.0/MES.Service.pdb 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/SysUpdateManager.cs 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/Base/UpdateController.cs 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MES.Service.dll 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MES.Service.pdb 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.dll 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.exe 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/bin/Debug/net8.0/MESApplication.pdb 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/bin/Debug/net8.0/MES.Service.dll
Binary files differ
MES.Service/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
MES.Service/service/SysUpdateManager.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,39 @@
using MES.Service.DB;
using MES.Service.Dto.@base;
using MES.Service.Dto.service;
using MES.Service.Dto.webApi;
using MES.Service.Modes;
using MES.Service.util;
using Microsoft.Data.SqlClient;
using SqlSugar;
using System.Data;
using System.Dynamic;
namespace MES.Service.service
{
    public class SysUpdateManager : Repository<SysUser>
    {
        // èŽ·å–æœ€æ–°ç‰ˆæœ¬ä¿¡æ¯
        public VersionInfo GetLatestVersion(string platform)
        {
            // è¿™é‡Œå¯ä»¥ä»Žæ•°æ®åº“或配置文件中读取
            // ç¤ºä¾‹ä¸­ç›´æŽ¥è¿”回硬编码的版本信息
            return new VersionInfo
            {
                Version = "1.0.1",
                UpdateInfo = "1. ä¿®å¤äº†ä¸€äº›å·²çŸ¥é—®é¢˜\n2. ä¼˜åŒ–了用户体验\n3. æ–°å¢žäº†ä¸€äº›åŠŸèƒ½",
                WgtUrl = "http://192.168.1.223:8085/updates/app_update_1.0.1.wgt",
                IsForceUpdate = false
            };
        }
        // æ¯”较版本号
        public int CompareVersion(string version1, string version2)
        {
            var v1 = new Version(version1);
            var v2 = new Version(version2);
            return v1.CompareTo(v2);
        }
    }
}
MESApplication/Controllers/Base/UpdateController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
using System.Dynamic;
using MES.Service.Dto.@base;
using MES.Service.service;
using MES.Service.util;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace MESApplication.Controllers.Base;
[ApiController]
[Route("api/[controller]")]
public class UpdateController : ControllerBase
{
    private readonly SysUpdateManager _sysUpdateManager = new SysUpdateManager();
    [HttpPost]
    [Route("checkUpdate")]
    public ResponseResult CheckUpdate([FromBody] UpdateCheckRequest request)
    {
        try
        {
            // ä»Žé…ç½®æ–‡ä»¶æˆ–数据库获取最新版本信息
            var latestVersion = _sysUpdateManager.GetLatestVersion(request.platform);
            // æ¯”较版本号
            if (_sysUpdateManager.CompareVersion(request.version, latestVersion.Version) < 0)
            {
                // éœ€è¦æ›´æ–°
                return new ResponseResult
                {
                    status = 0,
                    message = "发现新版本",
                    data = new
                    {
                        hasUpdate = true,
                        version = latestVersion.Version,
                        updateInfo = latestVersion.UpdateInfo,
                        wgtUrl = latestVersion.WgtUrl,
                        isForceUpdate = latestVersion.IsForceUpdate
                    }
                };
            }
            else
            {
                // ä¸éœ€è¦æ›´æ–°
                return new ResponseResult
                {
                    status = 0,
                    message = "当前已是最新版本",
                    data = new { hasUpdate = false }
                };
            }
        }
        catch (Exception ex)
        {
            return ResponseResult.ResponseError(ex);
        }
    }
}
MESApplication/bin/Debug/net8.0/MES.Service.dll
Binary files differ
MESApplication/bin/Debug/net8.0/MES.Service.pdb
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.dll
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.exe
Binary files differ
MESApplication/bin/Debug/net8.0/MESApplication.pdb
Binary files differ