From a7075d8608ab4e5461b9d264a605b7d8820fda77 Mon Sep 17 00:00:00 2001 From: mzhifa Date: Tue, 2 Jan 2024 00:31:18 +0800 Subject: [PATCH] =?UTF-8?q?1=20=E6=9B=B4=E6=96=B0=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E6=B3=A2=E5=BD=A2=E7=95=8C=E9=9D=A2=EF=BC=9B=202=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- StartServerWPF.Assets/GlobalData.cs | 14 - .../StartServerWPF.Assets.csproj | 1 - StartServerWPF.Models/ApmsModel.cs | 164 +++++ .../JsonParser.cs | 61 +- .../ProcessInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 36 + .../RemoteDataBase.cs | 2 +- .../StartServerWPF.Models.csproj | 70 ++ StartServerWPF.Models/StationModel.cs | 22 + .../SystemConfigModel.cs | 7 +- .../VpnInfo.cs | 7 +- StartServerWPF.Models/WorkareaModel.cs | 101 +++ StartServerWPF.Models/packages.config | 7 + .../Models/ApmsConfig.cs | 27 - StartServerWPF.Modules.Main/MySqlHelper.cs | 1 + .../StartServerWPF.Modules.Main.csproj | 1 + .../ViewModels/LogManagementViewModel.cs | 2 +- .../ViewModels/LoginViewDialogViewModel.cs | 1 + .../ViewModels/MainViewModel.cs | 79 ++- .../ViewModels/SetParamDialogViewModel.cs | 5 +- .../ViewModels/SetParamViewModel.cs | 126 +++- .../Views/SetParamView.xaml | 287 ++++++-- .../Models/WavesModel.cs | 12 +- .../Mseed2asciiApi.cs | 51 +- .../Service/RedisListService.cs | 6 +- .../StartServerWPF.Modules.MseedChart.csproj | 4 + .../ViewModels/ChartPlotRealDataViewModel.cs | 652 +++++++++--------- .../Views/ChartPlotRealDataView.xaml | 101 ++- StartServerWPF.sln | 14 + StartServerWPF/App.xaml.cs | 17 +- StartServerWPF/StartServerWPF.csproj | 7 + StartServerWPF/SystemConfig.json | 13 +- .../ViewModels/MainWindowViewModel.cs | 2 +- StartServerWPF/Workarea.json | 8 + StartServerWPF/apms.json | 39 ++ .../apms/N3102_staion_20230403.csv | 10 + .../tools/N3102_staion_20230403.csv | 10 + .../serverprogram/tools/ttime_gw20210427.tab | 207 ++++++ 39 files changed, 1604 insertions(+), 575 deletions(-) delete mode 100644 StartServerWPF.Assets/GlobalData.cs create mode 100644 StartServerWPF.Models/ApmsModel.cs rename {StartServerWPF.Modules.Main => StartServerWPF.Models}/JsonParser.cs (78%) rename {StartServerWPF.Modules.Main => StartServerWPF.Models}/ProcessInfo.cs (98%) create mode 100644 StartServerWPF.Models/Properties/AssemblyInfo.cs rename {StartServerWPF.Modules.Main => StartServerWPF.Models}/RemoteDataBase.cs (93%) create mode 100644 StartServerWPF.Models/StartServerWPF.Models.csproj create mode 100644 StartServerWPF.Models/StationModel.cs rename StartServerWPF.Modules.Main/Models/SystemConfig.cs => StartServerWPF.Models/SystemConfigModel.cs (91%) rename {StartServerWPF.Modules.Main/Models => StartServerWPF.Models}/VpnInfo.cs (88%) create mode 100644 StartServerWPF.Models/WorkareaModel.cs create mode 100644 StartServerWPF.Models/packages.config delete mode 100644 StartServerWPF.Modules.Main/Models/ApmsConfig.cs create mode 100644 StartServerWPF/Workarea.json create mode 100644 StartServerWPF/apms.json create mode 100644 StartServerWPF/serverprogram/apms/N3102_staion_20230403.csv create mode 100644 StartServerWPF/serverprogram/tools/N3102_staion_20230403.csv create mode 100644 StartServerWPF/serverprogram/tools/ttime_gw20210427.tab diff --git a/.gitignore b/.gitignore index 9491a2f..e5b89b4 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,5 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +/mseedC/.vscode diff --git a/StartServerWPF.Assets/GlobalData.cs b/StartServerWPF.Assets/GlobalData.cs deleted file mode 100644 index f98d261..0000000 --- a/StartServerWPF.Assets/GlobalData.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; - -namespace StartServerWPF.Assets -{ - public class GlobalData - { - public static string[] StationNames { get; set; } - } -} diff --git a/StartServerWPF.Assets/StartServerWPF.Assets.csproj b/StartServerWPF.Assets/StartServerWPF.Assets.csproj index 4a17d71..8d0b5b3 100644 --- a/StartServerWPF.Assets/StartServerWPF.Assets.csproj +++ b/StartServerWPF.Assets/StartServerWPF.Assets.csproj @@ -84,7 +84,6 @@ - Code diff --git a/StartServerWPF.Models/ApmsModel.cs b/StartServerWPF.Models/ApmsModel.cs new file mode 100644 index 0000000..912eb7e --- /dev/null +++ b/StartServerWPF.Models/ApmsModel.cs @@ -0,0 +1,164 @@ +using Aspose.Cells; +using Newtonsoft.Json; +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StartServerWPF.Models +{ + public class ApmsModel : BindableBase + { + private string station1; + private List ttime1; + private string push2wx1; + private string savepath1; + private string xmin1; + private string xmax1; + private string ymin1; + private string ymax1; + private string zref1; + private string zmin1; + private string zmax1; + private string minstep1; + private List channels1; + + [JsonProperty("station")] + public string station { get => station1; set => SetProperty(ref station1, value); } + [JsonProperty("ttime")] + public List ttime { get => ttime1; set => SetProperty(ref ttime1, value); } + [JsonProperty("Main.log_level")] + public string log_level { get; set; } + [JsonProperty("Main.slice_seconds")] + public string slice_seconds { get; set; } + [JsonProperty("Main.overlap_seconds")] + public string overlap_seconds { get; set; } + [JsonProperty("Main.is_mag")] + public string is_mag { get; set; } + [JsonProperty("Main.is_write_slice")] + public string is_write_slice { get; set; } + [JsonProperty("Main.lon")] + public string lon { get; set; } + [JsonProperty("Main.lat")] + public string lat { get; set; } + [JsonProperty("Main.height")] + public string height { get; set; } + [JsonProperty("Main.savepath")] + public string savepath { get => savepath1; set => SetProperty(ref savepath1, value); } + [JsonProperty("Main.push2wx")] + public string push2wx { get => push2wx1; set => SetProperty(ref push2wx1, value); } + [JsonProperty("Main.push_url")] + public string push_url { get; set; } + [JsonProperty("Main.push_mag")] + public string push_mag { get; set; } + [JsonProperty("Main.message_id")] + public string message_id { get; set; } + [JsonProperty("Main.company_id")] + public string company_id { get; set; } + [JsonProperty("Main.area_id")] + public string area_id { get; set; } + [JsonProperty("Main.content")] + public string content { get; set; } + [JsonProperty("Main.push_key")] + public string push_key { get; set; } + [JsonProperty("RServer.host")] + public string host { get; set; } + public List channels { get => channels1; set => SetProperty(ref channels1, value); } + + [JsonProperty("Locate.log_level")] + public string llog_level { get; set; } + [JsonProperty("Locate.work_path")] + public string work_path { get; set; } + [JsonProperty("Locate.xmin")] + public string xmin { get => xmin1; set => SetProperty(ref xmin1, value); } + [JsonProperty("Locate.xmax")] + public string xmax { get => xmax1; set => SetProperty(ref xmax1, value); } + [JsonProperty("Locate.ymin")] + public string ymin { get => ymin1; set => SetProperty(ref ymin1, value); } + [JsonProperty("Locate.ymax")] + public string ymax { get => ymax1; set => SetProperty(ref ymax1, value); } + [JsonProperty("Locate.zref")] + public string zref { get => zref1; set => SetProperty(ref zref1, value); } + [JsonProperty("Locate.zmin")] + public string zmin { get => zmin1; set => SetProperty(ref zmin1, value); } + [JsonProperty("Locate.zmax")] + public string zmax { get => zmax1; set => SetProperty(ref zmax1, value); } + [JsonProperty("Locate.minstep")] + public string minstep { get => minstep1; set => SetProperty(ref minstep1, value); } + [JsonProperty("Locate.method")] + public string method { get; set; } + [JsonProperty("Locate.clusted_otime")] + public string clusted_otime { get; set; } + + // public string delaytime { get; set; } + public List CreateStationFromCSV(string fn) + { + if (!File.Exists(fn)) return null; + List stations = new List(); + Aspose.Cells.TxtLoadOptions lo = new TxtLoadOptions(); + lo.Encoding = Encoding.Default;//设置编码方式 + Workbook workbook = new Workbook(fn, lo); + + //配置读取文件的类型(CSV) + workbook.FileFormat = FileFormatType.Csv;//可在此配置Excel文件类型 + Worksheet worksheet = workbook.Worksheets[0];//默认第一个Sheet页 + + Cells cells = worksheet.Cells; + + //读取到DataTable中 + DataTable dt = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, true); + for (int i = 0; i < dt.Rows.Count; i++) + { + DataRow row = dt.Rows[i]; + StationControlModel model = new StationControlModel(); + model.NetWork = row[0].ToString(); + model.Num = row[1].ToString(); + model.Coordinate = new Coordinate3D(double.Parse(row[2].ToString()), double.Parse(row[3].ToString()), double.Parse(row[4].ToString())); + model.Sens = double.Parse(row[5].ToString()); + model.BeginUseTime = DateTime.Parse(row[6].ToString()); + model.StopUseTime = DateTime.Parse(row[7].ToString()); + // model.Location = this.StationConfig.Location; + stations.Add(model); + } + //释放资源 + workbook = null; + worksheet = null; + return stations; + } + + } + + public class TTime : BindableBase + { + private string ttime2d1; + + [JsonProperty("station")] + public string station { get; set; } + + [JsonProperty("ttime")] + public string ttime { get; set; } + + [JsonProperty("ttime2d")] + public string ttime2d { get => ttime2d1; + set => SetProperty(ref ttime2d1, value); + } + } + public class StationChannelsModel : BindableBase + { + private string station1; + + public string network { get; set; } + + public string location { get; set; } + + public string channels { get; set; } + + public string station { get => station1; + set => SetProperty(ref station1, value); + } + } +} diff --git a/StartServerWPF.Modules.Main/JsonParser.cs b/StartServerWPF.Models/JsonParser.cs similarity index 78% rename from StartServerWPF.Modules.Main/JsonParser.cs rename to StartServerWPF.Models/JsonParser.cs index fb734c1..ea292f5 100644 --- a/StartServerWPF.Modules.Main/JsonParser.cs +++ b/StartServerWPF.Models/JsonParser.cs @@ -4,27 +4,25 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System.IO; -using StartServerWPF.Modules.Main.Models; -namespace StartServerWPF.Modules.Main +namespace StartServerWPF.Models { public class JsonParser { - // public static string zyProPath = @"\serverprogram"; public static string systemConfigPath = "SystemConfig.json"; public static string serverVision = "20230517"; - public static SystemConfig ReadSystemJsonFile(string jsonFile) + public SystemConfigModel ReadSystemJsonFile(string jsonFile) { //try { //StreamReader sr = File.OpenText(jsonFile); //JsonTextReader reader = new JsonTextReader(sr); //JObject jobj = (JObject)JToken.ReadFrom(reader); - SystemConfig sc = new SystemConfig(); + SystemConfigModel sc = new SystemConfigModel(); string str = File.ReadAllText(jsonFile); - sc = JsonConvert.DeserializeObject(str); + sc = JsonConvert.DeserializeObject(str); //sc.SystemLogPath = jobj["SystemLogPath"].ToString(); //sc.DataSavePath = jobj["DataSavePath"].ToString(); @@ -92,7 +90,7 @@ namespace StartServerWPF.Modules.Main // return null; //} } - public static void WriteSystemConfigFile(string jsonFile, SystemConfig sc) + public static void WriteSystemConfigFile(string jsonFile, object sc) { string str = JsonConvert.SerializeObject(sc, Formatting.Indented); File.WriteAllText(jsonFile, str); @@ -100,20 +98,23 @@ namespace StartServerWPF.Modules.Main public static void UpdateApmsJson(string apmsJsonPath, string savePath) { - StreamReader reader = new StreamReader(apmsJsonPath, Encoding.UTF8); - string saveStr = reader.ReadToEnd(); - int strInd = saveStr.IndexOf("Main.savepath") - 1; - string str1 = saveStr.Substring(strInd); - strInd = str1.IndexOf(","); - string str2 = str1.Substring(0, strInd); - strInd = str2.IndexOf(":"); - string strs1 = str2.Substring(0, strInd); - string strs2 = str2.Substring(strInd + 1); - savePath = savePath.Replace("\\", "\\\\"); - saveStr = saveStr.Replace(strs2, $"\"{savePath}\""); - reader.Close(); - File.WriteAllText(apmsJsonPath, saveStr); - + using (StreamReader reader = new StreamReader(apmsJsonPath, Encoding.UTF8)) + { + string saveStr = reader.ReadToEnd(); + // strInd = saveStr.IndexOf("station"); + + int strInd = saveStr.IndexOf("Main.savepath") - 1; + string str1 = saveStr.Substring(strInd); + strInd = str1.IndexOf(","); + string str2 = str1.Substring(0, strInd); + strInd = str2.IndexOf(":"); + string strs1 = str2.Substring(0, strInd); + string strs2 = str2.Substring(strInd + 1); + savePath = savePath.Replace("\\", "\\\\"); + saveStr = saveStr.Replace(strs2, $"\"{savePath}\""); + reader.Close(); + File.WriteAllText(apmsJsonPath, saveStr); + } } public static void UpdateRecvJson(string recvJsonPath, string savePath) { @@ -141,25 +142,23 @@ namespace StartServerWPF.Modules.Main } - public static string[] ReadApmsJson(string apmsJsonPath) + public static ApmsModel ReadApmsJson(string apmsJsonPath) { + ApmsModel model = new ApmsModel(); using (StreamReader sr = File.OpenText(apmsJsonPath)) { - JsonTextReader reader = new JsonTextReader(sr); JObject jobj = (JObject)JToken.ReadFrom(reader); + model.station = jobj["station"].ToString(); + // model.ttime2d = jobj["ttime2d"].ToString(); + model.savepath = jobj["Main.savepath"].ToString(); + model.push2wx = jobj["push2wx"].ToString(); var jor = jobj["channels"].First; JObject jordb = JObject.Parse(jor.ToString()); - string sta = jordb["station"].ToString(); - - var staList= sta.Split(","); - return staList; + // model.channels = JsonConvert.DeserializeObject(jor.ToString()); } - + return model; } - - - } } diff --git a/StartServerWPF.Modules.Main/ProcessInfo.cs b/StartServerWPF.Models/ProcessInfo.cs similarity index 98% rename from StartServerWPF.Modules.Main/ProcessInfo.cs rename to StartServerWPF.Models/ProcessInfo.cs index def4c30..6869d9c 100644 --- a/StartServerWPF.Modules.Main/ProcessInfo.cs +++ b/StartServerWPF.Models/ProcessInfo.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; -namespace StartServerWPF.Modules.Main +namespace StartServerWPF.Models { public class ProcessInfo { diff --git a/StartServerWPF.Models/Properties/AssemblyInfo.cs b/StartServerWPF.Models/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c73c9b3 --- /dev/null +++ b/StartServerWPF.Models/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("StartServerWPF.Models")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("StartServerWPF.Models")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("34cc2459-f4f2-4a93-827f-85da7422c736")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/StartServerWPF.Modules.Main/RemoteDataBase.cs b/StartServerWPF.Models/RemoteDataBase.cs similarity index 93% rename from StartServerWPF.Modules.Main/RemoteDataBase.cs rename to StartServerWPF.Models/RemoteDataBase.cs index a4d5e2f..614071e 100644 --- a/StartServerWPF.Modules.Main/RemoteDataBase.cs +++ b/StartServerWPF.Models/RemoteDataBase.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StartServerWPF.Modules.Main +namespace StartServerWPF.Models { public class RemoteDataBase { diff --git a/StartServerWPF.Models/StartServerWPF.Models.csproj b/StartServerWPF.Models/StartServerWPF.Models.csproj new file mode 100644 index 0000000..ad6681e --- /dev/null +++ b/StartServerWPF.Models/StartServerWPF.Models.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {34CC2459-F4F2-4A93-827F-85DA7422C736} + Library + Properties + StartServerWPF.Models + StartServerWPF.Models + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Aspose.Cells.23.12.0\lib\net40\Aspose.Cells.dll + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Prism.Core.8.1.97\lib\net461\Prism.dll + + + + + ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StartServerWPF.Models/StationModel.cs b/StartServerWPF.Models/StationModel.cs new file mode 100644 index 0000000..09158c3 --- /dev/null +++ b/StartServerWPF.Models/StationModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StartServerWPF.Models +{ + public class StationControlModel + { + public string Num { get; set; } + public string VpnName { get; set; } + public string NetWork { get; set;} + public string Location { get; set; } + public bool Enable { get; set; } = true; + public bool Visible { get; set; } = true; + public Coordinate3D Coordinate { get; set; } + public double Sens { get; set; } + public DateTime BeginUseTime { get; set; } + public DateTime StopUseTime { get; set;} + } +} diff --git a/StartServerWPF.Modules.Main/Models/SystemConfig.cs b/StartServerWPF.Models/SystemConfigModel.cs similarity index 91% rename from StartServerWPF.Modules.Main/Models/SystemConfig.cs rename to StartServerWPF.Models/SystemConfigModel.cs index 64b5d36..691606d 100644 --- a/StartServerWPF.Modules.Main/Models/SystemConfig.cs +++ b/StartServerWPF.Models/SystemConfigModel.cs @@ -1,12 +1,13 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StartServerWPF.Modules.Main.Models +namespace StartServerWPF.Models { - public class SystemConfig + public class SystemConfigModel { /// diff --git a/StartServerWPF.Modules.Main/Models/VpnInfo.cs b/StartServerWPF.Models/VpnInfo.cs similarity index 88% rename from StartServerWPF.Modules.Main/Models/VpnInfo.cs rename to StartServerWPF.Models/VpnInfo.cs index 5166a94..fe5d1eb 100644 --- a/StartServerWPF.Modules.Main/Models/VpnInfo.cs +++ b/StartServerWPF.Models/VpnInfo.cs @@ -2,10 +2,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; -namespace StartServerWPF.Modules.Main.Models +namespace StartServerWPF.Models { /// /// VPN信息类 @@ -22,7 +23,9 @@ namespace StartServerWPF.Modules.Main.Models /// /// VPN名称 /// - public string VpnName { get => vpnName; set => SetProperty(ref vpnName, value); } + public string VpnName { get => vpnName; + set => SetProperty(ref vpnName, value); + } /// /// VPNIP /// diff --git a/StartServerWPF.Models/WorkareaModel.cs b/StartServerWPF.Models/WorkareaModel.cs new file mode 100644 index 0000000..4683591 --- /dev/null +++ b/StartServerWPF.Models/WorkareaModel.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells; +using Newtonsoft.Json; + +namespace StartServerWPF.Models +{ + public class WorkareaModel + { + + [JsonProperty("StationConfig")] + public StationConfigModel StationConfig { get; set; } + [JsonIgnore] + public List Stations { get; set; } + + public List CreateStationFromCSV(string fn) + { + if (!File.Exists(fn)) return null; + List stations = new List(); + Aspose.Cells.TxtLoadOptions lo = new TxtLoadOptions(); + //Debug.WriteLine(Encoding.Default.ToString()); + lo.Encoding = Encoding.Default;//设置编码方式 + Workbook workbook = new Workbook(fn, lo); + + //配置读取文件的类型(CSV) + workbook.FileFormat = FileFormatType.Csv;//可在此配置Excel文件类型 + Worksheet worksheet = workbook.Worksheets[0];//默认第一个Sheet页 + + Cells cells = worksheet.Cells; + + //读取到DataTable中 + DataTable dt = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, true); + for (int i = 0; i < dt.Rows.Count; i++) + { + DataRow row = dt.Rows[i]; + StationControlModel model = new StationControlModel(); + model.NetWork = row[0].ToString(); + model.Num = row[1].ToString(); + model.Coordinate=new Coordinate3D(double.Parse(row[2].ToString()), double.Parse(row[3].ToString()), double.Parse(row[4].ToString())); + model.Sens = double.Parse(row[5].ToString()); + model.BeginUseTime = DateTime.Parse(row[6].ToString()); + model.StopUseTime = DateTime.Parse(row[7].ToString()); + model.Location=this.StationConfig.Location; + stations.Add(model); + } + //释放资源 + workbook = null; + worksheet = null; + return stations; + } + } + + + + public class StationConfigModel + { + [JsonProperty("Network")] + public string Network { get; set; } + + [JsonProperty("Location")] + public string Location { get; set; } + + [JsonProperty("Channels")] + public string[] Channels { get; set; } + + [JsonProperty("StationCoordCsvPath")] + public string StationCoordCsvPath { get; set; } + } + + public class Coordinate3D + { + [JsonProperty("X")] + public double X { get; set; } + + [JsonProperty("Y")] + public double Y { get; set; } + + [JsonProperty("Z")] + public double Z { get; set; } + public Coordinate3D() + { + + } + public Coordinate3D(double x,double y,double z) + { + X= x; + Y= y; + Z= z; + } + } + public enum WellType + { + Wellhead=0, + TargetLayer=1 + } +} diff --git a/StartServerWPF.Models/packages.config b/StartServerWPF.Models/packages.config new file mode 100644 index 0000000..7974ccd --- /dev/null +++ b/StartServerWPF.Models/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/StartServerWPF.Modules.Main/Models/ApmsConfig.cs b/StartServerWPF.Modules.Main/Models/ApmsConfig.cs deleted file mode 100644 index 51169d1..0000000 --- a/StartServerWPF.Modules.Main/Models/ApmsConfig.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StartServerWPF.Modules.Main.Models -{ - public class ApmsConfig - { - private string station; - - public string Station - { - get { return station; } - set { station = value; } - } - private string mainlog_level; - - public string Mainlog_level - { - get { return mainlog_level; } - set { mainlog_level = value; } - } - - } -} diff --git a/StartServerWPF.Modules.Main/MySqlHelper.cs b/StartServerWPF.Modules.Main/MySqlHelper.cs index 3658e54..6c8929e 100644 --- a/StartServerWPF.Modules.Main/MySqlHelper.cs +++ b/StartServerWPF.Modules.Main/MySqlHelper.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using MySql.Data.MySqlClient; +using StartServerWPF.Models; using StartServerWPF.Modules.Main.Models; namespace StartServerWPF.Modules.Main diff --git a/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj b/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj index 6b587a0..2713507 100644 --- a/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj +++ b/StartServerWPF.Modules.Main/StartServerWPF.Modules.Main.csproj @@ -29,6 +29,7 @@ + diff --git a/StartServerWPF.Modules.Main/ViewModels/LogManagementViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/LogManagementViewModel.cs index a6173fa..f2e3228 100644 --- a/StartServerWPF.Modules.Main/ViewModels/LogManagementViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/LogManagementViewModel.cs @@ -59,7 +59,7 @@ namespace StartServerWPF.Modules.Main.ViewModels { SelectIndexLogType = "全部"; DataList = new List(); - string fileName = _mainViewModel.sc.vpnInfo.SystemLogPath+ "SerLog_" + EndTime.ToString("yyyyMMdd") + ".txt"; + string fileName = _mainViewModel._systemConfig.vpnInfo.SystemLogPath+ "SerLog_" + EndTime.ToString("yyyyMMdd") + ".txt"; if (!File.Exists(fileName)) return; Task.Run(() => diff --git a/StartServerWPF.Modules.Main/ViewModels/LoginViewDialogViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/LoginViewDialogViewModel.cs index 64ad0f8..d426a11 100644 --- a/StartServerWPF.Modules.Main/ViewModels/LoginViewDialogViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/LoginViewDialogViewModel.cs @@ -1,6 +1,7 @@ using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; +using StartServerWPF.Models; using StartServerWPF.Modules.Main.models; using StartServerWPF.Modules.Main.Models; using System; diff --git a/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs index 9aa2c4c..d4f29e8 100644 --- a/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs @@ -4,6 +4,7 @@ using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; using StartServerWPF.Assets; +using StartServerWPF.Models; using StartServerWPF.Modules.Main.models; using StartServerWPF.Modules.Main.Models; using System; @@ -28,33 +29,31 @@ namespace StartServerWPF.Modules.Main.ViewModels { public class MainViewModel : BindableBase { - public MainViewModel(IDialogService dialogService, WebsocketClient websocket, LoginViewDialogViewModel loginViewDialogViewModel) + public MainViewModel(SystemConfigModel systemConfig, IDialogService dialogService, WebsocketClient websocket, LoginViewDialogViewModel loginViewDialogViewModel) { Message = "View A" ; Console.WriteLine(System.Environment.CurrentDirectory + "\\" + JsonParser.systemConfigPath); - sc = JsonParser.ReadSystemJsonFile(JsonParser.systemConfigPath); + _systemConfig = systemConfig; // int moniTimeInd = sc.proMonitor.ProParams.IndexOf("-btime"); // string moniTimeStr = sc.proMonitor.ProParams.Substring(moniTimeInd + 7); // int moniTimeIndEnd = moniTimeStr.IndexOf(">"); //moniTimeStr = moniTimeStr.Substring(0, moniTimeIndEnd - 1); // MoniStartTime = DateTime.Parse(moniTimeStr); InitializeParams(); - JsonParser.UpdateApmsJson(sc.proApms.ProPath + "apms.json", sc.vpnInfo.DataSavePath); - JsonParser.UpdateRecvJson(sc.proRecv.ProPath + "gw.recvftp.json", sc.vpnInfo.DataSavePath); + JsonParser.UpdateApmsJson(_systemConfig.proApms.ProPath + "apms.json", _systemConfig.vpnInfo.DataSavePath); + JsonParser.UpdateRecvJson(_systemConfig.proRecv.ProPath + "gw.recvftp.json", _systemConfig.vpnInfo.DataSavePath); // sc.proMonitor.ProParams = JsonParser.CreateMonitorStartParam(sc.vpnInfo.DataSavePath, MoniStartTime); StartTime = DateTime.Now; Console.WriteLine(System.Environment.CurrentDirectory); - Console.WriteLine(sc.remoteDb.ServerAddress + "\t" + sc.remoteDb.ServerPort - + "\t" + sc.remoteDb.UserName + "\t" + sc.remoteDb.Password); + Console.WriteLine(_systemConfig.remoteDb.ServerAddress + "\t" + _systemConfig.remoteDb.ServerPort + + "\t" + _systemConfig.remoteDb.UserName + "\t" + _systemConfig.remoteDb.Password); this._dialogService = dialogService; this._websocket = websocket; this._loginViewDialogViewModel = loginViewDialogViewModel; - _websocket.WebSocketInit(sc.remoteDb.WebsocketUrl); + _websocket.WebSocketInit(_systemConfig.remoteDb.WebsocketUrl); _websocket.WebsocketError = WebSocket_Error; _websocket.WebSocketMessageReceived = WebSocket4Net_MessageReceived; - GlobalData.StationNames = JsonParser.ReadApmsJson(sc.proApms.ProPath + sc.proApms.JsonPath); - DialogParameters param = new DialogParameters(); param.Add("type", 1);// 编辑 _dialogService.ShowDialog( @@ -108,7 +107,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State = user.account+ "登录", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath, log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath, log.ToString()); } }); break; @@ -307,8 +306,8 @@ namespace StartServerWPF.Modules.Main.ViewModels } private void ConnectVPN() { - vpn.CreateOrUpdateVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnIP); - vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw); + vpn.CreateOrUpdateVPN(_systemConfig.vpnInfo.VpnName, _systemConfig.vpnInfo.VpnIP); + vpn.ConnectVPN(_systemConfig.vpnInfo.VpnName, _systemConfig.vpnInfo.VpnUserName, _systemConfig.vpnInfo.VpnPsw); Thread.Sleep(1000); var log = new LogMessageModel { @@ -317,7 +316,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State="连接", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); SetControlstatus(); } @@ -325,7 +324,7 @@ namespace StartServerWPF.Modules.Main.ViewModels { if (MessageBox.Show("是否断开VPN连接?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { - vpn.DisConnectVPN(sc.vpnInfo.VpnName); + vpn.DisConnectVPN(_systemConfig.vpnInfo.VpnName); Thread.Sleep(500); SetControlstatus(); Thread.Sleep(100); @@ -336,13 +335,13 @@ namespace StartServerWPF.Modules.Main.ViewModels State = "断开", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); } } private void GetVPNStatus() { - if (vpn.CheckVpnStatus(sc.vpnInfo.VpnName)) + if (vpn.CheckVpnStatus(_systemConfig.vpnInfo.VpnName)) { MessageBox.Show("VPN已经连接!"); } @@ -356,7 +355,7 @@ namespace StartServerWPF.Modules.Main.ViewModels { DialogParameters param = new DialogParameters(); param.Add("type", 1);// 编辑 - param.Add("model", sc); + param.Add("model", _systemConfig); param.Add("moniTime", MoniStartTime); _dialogService.ShowDialog( "SetParamDialog", @@ -372,7 +371,7 @@ namespace StartServerWPF.Modules.Main.ViewModels private void DisplayLog() { - Process.Start("explorer.exe", sc.vpnInfo.SystemLogPath); + Process.Start("explorer.exe", _systemConfig.vpnInfo.SystemLogPath); } private void Start( object obj) { @@ -390,9 +389,9 @@ namespace StartServerWPF.Modules.Main.ViewModels private void OneKeyStart() { ProcessDataSource.Clear(); - foreach (var item in sc.GetType().GetProperties()) + foreach (var item in _systemConfig.GetType().GetProperties()) { - var pro = item.GetValue(sc) as ProcessInfo; + var pro = item.GetValue(_systemConfig) as ProcessInfo; if (pro != null) { StartTime = DateTime.Now; @@ -402,7 +401,7 @@ namespace StartServerWPF.Modules.Main.ViewModels ProName = pro.ProName, ProcessTile = pro.ProTitle, MonitorTime = DateTime.Now.ToString(), - ProcessStatus = sc.proServer.Pid == 0 ? "正常运行" : "未运行" + ProcessStatus = _systemConfig.proServer.Pid == 0 ? "正常运行" : "未运行" }) ; Thread.Sleep(10); } @@ -415,7 +414,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State = "启动服务程序", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); IsIndeterminate =true; timer1.Interval = TimeSpan.FromSeconds(ProMonInterval); timer1.Start(); @@ -423,9 +422,9 @@ namespace StartServerWPF.Modules.Main.ViewModels public void OneKeyStop() { - foreach (var item in sc.GetType().GetProperties()) + foreach (var item in _systemConfig.GetType().GetProperties()) { - var pro = item.GetValue(sc) as ProcessInfo; + var pro = item.GetValue(_systemConfig) as ProcessInfo; if (pro != null) { int indexPro = KillProcess(pro); @@ -444,7 +443,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State = "启动服务关闭", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); StartTime = new DateTime(); } @@ -484,7 +483,7 @@ namespace StartServerWPF.Modules.Main.ViewModels } private void IntilVPN() { - vpn = new VPNHelper(sc.vpnInfo.VpnName, sc.vpnInfo.VpnIP, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw); + vpn = new VPNHelper(_systemConfig.vpnInfo.VpnName, _systemConfig.vpnInfo.VpnIP, _systemConfig.vpnInfo.VpnUserName, _systemConfig.vpnInfo.VpnPsw); } @@ -494,7 +493,7 @@ namespace StartServerWPF.Modules.Main.ViewModels public VPNHelper vpn; public bool vpnStatus = false; - public SystemConfig sc; + public SystemConfigModel _systemConfig; private DispatcherTimer timer1= new DispatcherTimer(); private readonly IDialogService _dialogService; @@ -520,7 +519,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State = "程序启动", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); } #region 方法 private bool CMDStartProcess(ProcessInfo proInfo) @@ -564,11 +563,11 @@ namespace StartServerWPF.Modules.Main.ViewModels { Application.Current.Dispatcher.BeginInvoke(() => { - if (pro.MainModule.ModuleName.Contains(sc.proApms.ProName)) + if (pro.MainModule.ModuleName.Contains(_systemConfig.proApms.ProName)) { AddItems(ApmsProcessSliceSource, new ProcessingInformationModel { ProcessMes = outLine.Data, MonitorTime = DateTime.Now.ToString() }); } - else if (pro.MainModule.ModuleName.Contains(sc.proTools.ProName)) + else if (pro.MainModule.ModuleName.Contains(_systemConfig.proTools.ProName)) { AddItems(ToolsProcessSliceSource, new ProcessingInformationModel { ProcessMes = outLine.Data, MonitorTime = DateTime.Now.ToString() }); } @@ -582,7 +581,7 @@ namespace StartServerWPF.Modules.Main.ViewModels { Application.Current.Dispatcher.BeginInvoke(() => { - if (pro.MainModule.ModuleName.Contains(sc.proApms.ProName)) + if (pro.MainModule.ModuleName.Contains(_systemConfig.proApms.ProName)) { var ms = new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now }; AddItems(ApmsEventSource, ms); @@ -598,7 +597,7 @@ namespace StartServerWPF.Modules.Main.ViewModels _websocket.SendMes(jsonStr); } } - else if (pro.MainModule.ModuleName.Contains(sc.proTools.ProName)) + else if (pro.MainModule.ModuleName.Contains(_systemConfig.proTools.ProName)) { AddItems(ToolsEventSource, new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now }); } @@ -710,9 +709,9 @@ namespace StartServerWPF.Modules.Main.ViewModels private void timer1_Tick(object? sender, EventArgs e) { - foreach (var item in sc.GetType().GetProperties()) + foreach (var item in _systemConfig.GetType().GetProperties()) { - var pro = item.GetValue(sc) as ProcessInfo; + var pro = item.GetValue(_systemConfig) as ProcessInfo; if (pro != null) { int sfp = FindProcess(pro); @@ -734,7 +733,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State = "重启", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); string jsonStr= JsonSerializer.Serialize(new CSDeviceWebhook { @@ -752,10 +751,10 @@ namespace StartServerWPF.Modules.Main.ViewModels } } RunTime = DateDiff(DateTime.Now, StartTime); - vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName); + vpnStatus = vpn.CheckVpnStatus(_systemConfig.vpnInfo.VpnName); if (!vpnStatus) { - vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw); + vpn.ConnectVPN(_systemConfig.vpnInfo.VpnName, _systemConfig.vpnInfo.VpnUserName, _systemConfig.vpnInfo.VpnPsw); Thread.Sleep(1000); var log = new LogMessageModel { @@ -764,7 +763,7 @@ namespace StartServerWPF.Modules.Main.ViewModels State = "重连", OriginTime = DateTime.Now, }; - LogHelper.WriteSerLog(sc.vpnInfo.SystemLogPath , log.ToString()); + LogHelper.WriteSerLog(_systemConfig.vpnInfo.SystemLogPath , log.ToString()); string jsonStr = JsonSerializer.Serialize(new CSDeviceWebhook { @@ -793,7 +792,7 @@ namespace StartServerWPF.Modules.Main.ViewModels AddressIP = _IPAddress.ToString(); if (AddressIP.Contains("172.16")) { - sc.vpnInfo.VpnIP = AddressIP; + _systemConfig.vpnInfo.VpnIP = AddressIP; } } } @@ -801,7 +800,7 @@ namespace StartServerWPF.Modules.Main.ViewModels public void SetControlstatus() { - vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName); + vpnStatus = vpn.CheckVpnStatus(_systemConfig.vpnInfo.VpnName); if (vpnStatus) { VPNIsConnect = true; diff --git a/StartServerWPF.Modules.Main/ViewModels/SetParamDialogViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/SetParamDialogViewModel.cs index cb51d02..e394b41 100644 --- a/StartServerWPF.Modules.Main/ViewModels/SetParamDialogViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/SetParamDialogViewModel.cs @@ -1,6 +1,7 @@ using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; +using StartServerWPF.Models; using StartServerWPF.Modules.Main.Models; using System; using System.Collections.Generic; @@ -34,12 +35,12 @@ namespace StartServerWPF.Modules.Main.ViewModels // _title = "编辑" + _title; var _type = parameters.GetValue("type"); // _title = (_type == 0 ? "新增" : "修改") + _title; - _systemConfig = parameters.GetValue("model"); + _systemConfig = parameters.GetValue("model"); MainModel= _systemConfig.vpnInfo; MoniTime= parameters.GetValue("moniTime"); } - private SystemConfig _systemConfig; + private SystemConfigModel _systemConfig; private VpnInfo _mainModel = new VpnInfo(); public VpnInfo MainModel { diff --git a/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs index 519ddab..ce35ba0 100644 --- a/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs @@ -1,9 +1,14 @@ -using Prism.Commands; +using Newtonsoft.Json; +using Prism.Commands; +using Prism.Ioc; using Prism.Mvvm; using Prism.Services.Dialogs; +using StartServerWPF.Models; using StartServerWPF.Modules.Main.Models; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,24 +19,110 @@ namespace StartServerWPF.Modules.Main.ViewModels { public class SetParamViewModel : BindableBase { - public SetParamViewModel(MainViewModel mainViewModel) + public SetParamViewModel(MainViewModel mainViewModel,SystemConfigModel configModel) { - _systemConfig = mainViewModel.sc; + _systemConfig = mainViewModel._systemConfig; MainModel = _systemConfig.vpnInfo; MoniTime = mainViewModel.MoniStartTime; + + string sapm = File.ReadAllText(configModel.proApms.ProPath+ "apms.json"); + AModel = JsonConvert.DeserializeObject(sapm); + ApmsJsonName = _systemConfig.proApms.JsonPath; + var apmsStation = ToolsModel.CreateStationFromCSV(configModel.proApms.ProPath + AModel.station); + ApmsStationSource = new ObservableCollection(); + foreach (var item in apmsStation) + { + if (item.Enable) + { + ApmsStationSource.Add(item); + } + } + IsApmswxNotity = AModel.push2wx == "NO" ? false : true; + + string tool = File.ReadAllText(configModel.proTools.ProPath + "apms.json"); + ToolsModel = JsonConvert.DeserializeObject(tool); + ToolsJsonName = _systemConfig.proTools.JsonPath; + + var st= ToolsModel.CreateStationFromCSV(configModel.proTools.ProPath + AModel.station); + ToolsStationSource = new ObservableCollection(); + foreach (var item in st) + { + if (item.Enable) + { + ToolsStationSource.Add(item); + } + } + IsToolswxNotity = ToolsModel.push2wx == "NO" ? false : true; + int index= _systemConfig.proTools.ProParams.IndexOf("-delay"); + int.TryParse (_systemConfig.proTools.ProParams.Substring(index+ "-delay".Length), out int Time); + DelayTime = Time/60; + } private string _title = "应用列表"; public string Title => _title; - + + private SystemConfigModel _systemConfig; + private string _apmsJsonName; + public string ApmsJsonName + { + get => _apmsJsonName; + set { SetProperty(ref _apmsJsonName, value); } + } + private bool _isApmswxNotity; + public bool IsApmswxNotity + { + get => _isApmswxNotity; + set { SetProperty(ref _isApmswxNotity, value); } + } + private ApmsModel _apmsModel = new ApmsModel(); + public ApmsModel AModel + { + get => _apmsModel; + set { SetProperty(ref _apmsModel, value); } + } + + private string _toolsJsonName; + public string ToolsJsonName + { + get => _toolsJsonName; + set { SetProperty(ref _toolsJsonName, value); } + } + private ApmsModel _toolsModel = new ApmsModel(); + public ApmsModel ToolsModel + { + get => _toolsModel; + set { SetProperty(ref _toolsModel, value); } + } + + private bool _isToolswxNotity; + public bool IsToolswxNotity + { + get => _isToolswxNotity; + set { SetProperty(ref _isToolswxNotity, value); } + } + private int _delayTime; + public int DelayTime + { + get => _delayTime; + set { SetProperty(ref _delayTime, value); } + } + + private ObservableCollection _toolsStationSource; + public ObservableCollection ToolsStationSource + { get => _toolsStationSource; set => SetProperty(ref _toolsStationSource, value); } + + private ObservableCollection _ApmsStationSource; + public ObservableCollection ApmsStationSource + { get => _ApmsStationSource; set => SetProperty(ref _ApmsStationSource, value); } - private SystemConfig _systemConfig; private VpnInfo _mainModel = new VpnInfo(); public VpnInfo MainModel { get => _mainModel; set { SetProperty(ref _mainModel, value); } } + private DateTime _moniTime ; public DateTime MoniTime { @@ -71,7 +162,6 @@ namespace StartServerWPF.Modules.Main.ViewModels { get => new DelegateCommand(() => { - // 确认操作 // 数据校验(关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查(自定义特性检查) if (string.IsNullOrEmpty(MainModel.VpnName) || string.IsNullOrEmpty(MainModel.VpnIP)) { @@ -82,12 +172,34 @@ namespace StartServerWPF.Modules.Main.ViewModels MessageBoxImage.Exclamation) == MessageBoxResult.OK) { + AModel.channels[0].station = string.Join(",", ApmsStationSource.Where(p => p.Enable).Select(a => a.Num)); + if(_systemConfig.proApms.JsonPath != ApmsJsonName) + { + _systemConfig.proApms.ProParams = _systemConfig.proApms.ProParams.Replace(_systemConfig.proApms.JsonPath, ApmsJsonName); + _systemConfig.proApms.JsonPath = ApmsJsonName; + } + JsonParser.WriteSystemConfigFile(_systemConfig.proApms.ProPath + ApmsJsonName, AModel); + ToolsModel.channels[0].station = string.Join(",", ToolsStationSource.Where(p => p.Enable).Select(a => a.Num)); + if (_systemConfig.proTools.JsonPath != ToolsJsonName) + { + _systemConfig.proTools.ProParams = _systemConfig.proTools.ProParams.Replace(_systemConfig.proTools.JsonPath, ToolsJsonName); + _systemConfig.proTools.JsonPath = ToolsJsonName; + } + if (_systemConfig.vpnInfo.DataSavePath != ToolsModel.savepath) + { + _systemConfig.proTools.ProParams= _systemConfig.proTools.ProParams.Replace(_systemConfig.vpnInfo.DataSavePath, ToolsModel.savepath); + _systemConfig.vpnInfo.DataSavePath = ToolsModel.savepath; + } + JsonParser.WriteSystemConfigFile(_systemConfig.proTools.ProPath + ToolsJsonName, ToolsModel); + int index = _systemConfig.proTools.ProParams.IndexOf("-delay"); + _systemConfig.proTools.ProParams= $"{_systemConfig.proTools.ProParams.Substring(0, index)} -delay {DelayTime*60}"; JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig); + if (updateJson) { JsonParser.UpdateRecvJson(_systemConfig.proRecv.ProPath + _systemConfig.proRecv.JsonPath, _systemConfig.vpnInfo.DataSavePath); - JsonParser.UpdateApmsJson(_systemConfig.proApms.ProPath + _systemConfig.proApms.JsonPath, _systemConfig.vpnInfo.DataSavePath); + //JsonParser.UpdateApmsJson(_systemConfig.proApms.ProPath + _systemConfig.proApms.JsonPath, _systemConfig.vpnInfo.DataSavePath); } // RequestClose?.Invoke(new DialogResult(ButtonResult.OK)); } diff --git a/StartServerWPF.Modules.Main/Views/SetParamView.xaml b/StartServerWPF.Modules.Main/Views/SetParamView.xaml index 98c942b..c022a6e 100644 --- a/StartServerWPF.Modules.Main/Views/SetParamView.xaml +++ b/StartServerWPF.Modules.Main/Views/SetParamView.xaml @@ -4,9 +4,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:prism="http://prismlibrary.com/" + xmlns:hc="https://handyorg.github.io/handycontrol" prism:ViewModelLocator.AutoWireViewModel="True" mc:Ignorable="d" Background="#FFEEF1F3" - d:DesignHeight="300" d:DesignWidth="500"> + d:DesignHeight="600" d:DesignWidth="900"> @@ -22,53 +23,243 @@ - - + + - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +