From 7dda496345596b9482029bb7ec6b040a6d9bf27e Mon Sep 17 00:00:00 2001 From: mzhifa Date: Fri, 8 Mar 2024 21:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/DataProcessViewModel.cs | 6 ++---- StartServerWPF.Modules.Main/WebsocketClient.cs | 10 ++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs index 1324bb9..84fdce5 100644 --- a/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs @@ -88,9 +88,8 @@ namespace StartServerWPF.Modules.Main.ViewModels } catch (Exception ex) { - MessageBox.Show("加载配置失败,"+path); + MessageBox.Show($"加载配置失败,路径:{path},错误:{ex}"); } - } SetProperty(ref _wareaSelectedIndex, value); } @@ -276,8 +275,8 @@ namespace StartServerWPF.Modules.Main.ViewModels { ApmsEventSource.Clear(); } - var fileName = Directory.GetFiles(SavePath, "*.index", SearchOption.AllDirectories); + var fileName = Directory.GetFiles(SavePath, "*.index", SearchOption.AllDirectories); foreach (var file in fileName) { bool flag= DateTime.TryParseExact(Path.GetFileNameWithoutExtension(file), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture, @@ -289,7 +288,6 @@ namespace StartServerWPF.Modules.Main.ViewModels File.Delete(file); } } - } Task.Run(() => diff --git a/StartServerWPF.Modules.Main/WebsocketClient.cs b/StartServerWPF.Modules.Main/WebsocketClient.cs index 693be87..cf301fd 100644 --- a/StartServerWPF.Modules.Main/WebsocketClient.cs +++ b/StartServerWPF.Modules.Main/WebsocketClient.cs @@ -21,15 +21,11 @@ namespace StartServerWPF.Modules.Main public Action WebSocketMessageReceived; public void WebSocketInit(string url) { - Debug.WriteLine("客户端"); webSocket4Net = new WebSocket(url); webSocket4Net.Opened += WebSocket4Net_Opened; webSocket4Net.Error += new EventHandler(WebSocket_Error); - webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived; - + webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived; Debug.WriteLine("客户端连接成功!"); - - // thread.Start(); } private string name = string.Empty; private string pwd = string.Empty; @@ -40,8 +36,6 @@ namespace StartServerWPF.Modules.Main name = account; pwd = password; webSocket4Net.Open(); - // string jsonstr= JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account=account,password=password}); - // SendMes(jsonstr); Task.Run(async () =>{ await Task.Delay(2000); isHeartbeat = true; @@ -91,7 +85,7 @@ namespace StartServerWPF.Modules.Main private void WebSocket4Net_Opened(object sender, EventArgs e) { - Debug.WriteLine("连接websocket成功****************"); + Debug.WriteLine("连接websocket成功,自动登录****************"); string jsonstr = JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account = name, password = pwd }); SendMes(jsonstr); }