From a0605cba8cea274dabe1a534ad5d354e8551cc9d Mon Sep 17 00:00:00 2001 From: liuwf Date: Mon, 14 Oct 2024 11:12:59 +0800 Subject: [PATCH] =?UTF-8?q?add-=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/ProdCompletionBusiness.cs | 2 +- SlnMesnac.Config/DebugConfig.cs | 18 ++++++++ .../ViewModel/MainWindowViewModel.cs | 42 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs index aa5ff75..fa867c0 100644 --- a/SlnMesnac.Business/ProdCompletionBusiness.cs +++ b/SlnMesnac.Business/ProdCompletionBusiness.cs @@ -80,7 +80,7 @@ namespace SlnMesnac.Business _mesProductOrderService = serviceProvider.GetRequiredService(); _baseMaterialInfoService = serviceProvider.GetRequiredService(); Init(); - + } private void test() diff --git a/SlnMesnac.Config/DebugConfig.cs b/SlnMesnac.Config/DebugConfig.cs index df66cde..5d77735 100644 --- a/SlnMesnac.Config/DebugConfig.cs +++ b/SlnMesnac.Config/DebugConfig.cs @@ -140,5 +140,23 @@ namespace SlnMesnac.Config } + /// + ///软件自动更新,当前版本号 + /// + public string Version + { + get { return iniHelper.IniReadValue("system", "Version"); } + set { iniHelper.IniWriteValue("system", "Version", value); } + } + + /// + ///软件自动更新,当前程序名 + /// + public string ProcessName + { + get { return iniHelper.IniReadValue("system", "ProcessName"); } + set { iniHelper.IniWriteValue("system", "ProcessName", value); } + } + } } diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs index c54c33c..2a698bc 100644 --- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs @@ -7,12 +7,15 @@ using OracleInternal.Sharding; using ServiceStack; using SlnMesnac.Business; using SlnMesnac.Business.@base; +using SlnMesnac.Common; using SlnMesnac.Config; using SlnMesnac.Plc; using SlnMesnac.TouchSocket; using SlnMesnac.WPF.Page; using SlnMesnac.WPF.Page.Generate; using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -152,8 +155,47 @@ namespace SlnMesnac.WPF.ViewModel StartLiseningStatus(); checkStatus(); RefreshTime(); + } + + + /// + /// 检查版本--暂时不使用 + /// + private void CheckVersion() + { + try + { + string version = HttpHelper.SendGetMessage("172.16.12.100", 5001, "wcs/RecieveRcs/version"); + var vs = new Version(version); + // SystemData.VerSion + var lovs = new Version(debugConfig.Version); + if (vs > lovs) + { + var result = MessageBox.Show("有新版本是否更新?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information); + if (result == MessageBoxResult.Yes) + { + Process.Start("AutoUpdate.exe", new List + { + version, + debugConfig.ProcessName, + // SystemData.ProcessName, + $"http://172.16.12.100:5001/wcs/RecieveRcs?fileName={debugConfig.ProcessName}.zip" + }); + debugConfig.Version = version; + Application.Current.Shutdown(); + Process.GetCurrentProcess().Kill(); + } + } + } + catch + { + + } + } + + private void RefreshTime() { DispatcherTimer _timer = new DispatcherTimer();