From ff0fdb85d5dadc823ae05d3af5544f44c7866c8f Mon Sep 17 00:00:00 2001 From: mzhifa Date: Mon, 11 Mar 2024 12:57:01 +0800 Subject: [PATCH] =?UTF-8?q?1=E4=BF=AE=E6=94=B9=E9=9C=87=E7=BA=A7=E9=98=80?= =?UTF-8?q?=E5=80=BC=E5=88=A4=E6=96=AD=E9=97=AE=E9=A2=98=EF=BC=9B=202=20?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=B3=A2=E5=BD=A2=E6=97=A0=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/MainViewModel.cs | 9 ++++--- .../ViewModels/SetParamViewModel.cs | 5 ++-- .../WebsocketClient.cs | 27 ++++++++++--------- .../ViewModels/ChartPlotRealDataViewModel.cs | 5 ++-- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs index 7ec88c1..bf86c36 100644 --- a/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs @@ -91,7 +91,6 @@ namespace StartServerWPF.Modules.Main.ViewModels Application.Current.Dispatcher.Invoke(() => { - // HandyControl.Controls.MessageBox.Show(user.message, "提示"); if (user.code == 200) { _websocket.SendMes(JsonSerializer.Serialize(new CSUserSubscribeMessage { type = CSMessage.subscribe })); @@ -100,10 +99,14 @@ namespace StartServerWPF.Modules.Main.ViewModels { LogType = "系统", AppName = "系统", - State = user.account+ "登录", + State = user.account + "登录", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath, log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath, log.ToString()); + } + else + { + HandyControl.Controls.MessageBox.Show(user.message, "提示"); } }); break; diff --git a/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs index a25863d..0bbf501 100644 --- a/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs @@ -330,6 +330,7 @@ namespace StartServerWPF.Modules.Main.ViewModels wareaModelSingleton.apmsavepath = _wareaModel.apmsavepath; wareaModelSingleton.toolsavepath = _wareaModel.toolsavepath; wareaModelSingleton.delayTime = _wareaModel.delayTime; + wareaModelSingleton.apmpush2ddmag = _wareaModel.apmpush2ddmag; wareaModelSingleton.apmModel = _wareaModel.apmModel; wareaModelSingleton.StationConfig = _wareaModel.StationConfig; if (WorkareaNameSource.Count <= 0) @@ -381,7 +382,7 @@ namespace StartServerWPF.Modules.Main.ViewModels ApmsModel apms = curWorkarea.apmModel; apms.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/"); apms.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); - apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath).Replace("\\", "/"); ; + apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath).Replace("\\", "/"); apms.push2wx = curWorkarea.apmpush2wx ? "YES" : "NO"; JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proApms.ProPath, "apms.json"), apms); } @@ -391,7 +392,7 @@ namespace StartServerWPF.Modules.Main.ViewModels ApmsModel tools = curWorkarea.apmModel; tools.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/"); tools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); - tools.savepath = curWorkarea.savepath + "/" + curWorkarea.toolsavepath; + tools.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.toolsavepath).Replace("\\", "/"); tools.push2wx = curWorkarea.toolpush2wx ? "YES" : "NO"; ; JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proTools.ProPath, "apms.json"), tools); diff --git a/StartServerWPF.Modules.Main/WebsocketClient.cs b/StartServerWPF.Modules.Main/WebsocketClient.cs index cf301fd..c802c20 100644 --- a/StartServerWPF.Modules.Main/WebsocketClient.cs +++ b/StartServerWPF.Modules.Main/WebsocketClient.cs @@ -24,23 +24,23 @@ namespace StartServerWPF.Modules.Main webSocket4Net = new WebSocket(url); webSocket4Net.Opened += WebSocket4Net_Opened; webSocket4Net.Error += new EventHandler(WebSocket_Error); - webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived; + webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived; + webSocket4Net.Open(); + Task.Run(async () => { + await Task.Delay(2000); + isHeartbeat = true; + SendHeartbeat(); + }); Debug.WriteLine("客户端连接成功!"); } private string name = string.Empty; private string pwd = string.Empty; public void SiginServer(string account,string password) - { - - isHeartbeat = false; + { name = account; pwd = password; - webSocket4Net.Open(); - Task.Run(async () =>{ - await Task.Delay(2000); - isHeartbeat = true; - SendHeartbeat(); - }); + string jsonstr = JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account = name, password = pwd }); + SendMes(jsonstr); } public void Closed() @@ -86,8 +86,11 @@ namespace StartServerWPF.Modules.Main private void WebSocket4Net_Opened(object sender, EventArgs e) { Debug.WriteLine("连接websocket成功,自动登录****************"); - string jsonstr = JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account = name, password = pwd }); - SendMes(jsonstr); + if (!string.IsNullOrEmpty(name)) + { + string jsonstr = JsonSerializer.Serialize(new CSUserSigin { type = CSMessage.sigin, utype = "device", account = name, password = pwd }); + SendMes(jsonstr); + } } void WebSocket_Error(object sender, ErrorEventArgs e) { diff --git a/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs b/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs index 320922c..a0057ec 100644 --- a/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs +++ b/StartServerWPF.Modules.MseedChart/ViewModels/ChartPlotRealDataViewModel.cs @@ -1037,10 +1037,9 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels var d = _lChartAll.ViewXY.XAxes[0].DateTimeToAxisValue(item.Value.FirstSampleTime); _lChartAll.ViewXY.SampleDataSeries[index].FirstSampleTimeStamp = d;// _lChartAll.ViewXY.XAxes[0].Minimum;// item.Value.FirstSampleTimeStamp; } - Parallel.For(0, _channelCount, (seriesIndex) => + for(int seriesIndex = 0; seriesIndex < _channelCount; seriesIndex++) { double[] thisSeriesData = _data[seriesIndex]; - int yindex = _lChartAll.ViewXY.SampleDataSeries[seriesIndex].AssignYAxisIndex; if (yindex >= 0) { @@ -1049,7 +1048,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels _lChartAll.ViewXY.SampleDataSeries[seriesIndex].AddSamples(thisSeriesData, false); Debug.WriteLine($"{DateTime.Now}*********** index:{seriesIndex}," + $" pointCount:{_lChartAll.ViewXY.SampleDataSeries[seriesIndex].PointCount}"); - }); + } _pointsAppended += 1; double lastX = _pointsAppended * XInterval;