diff --git a/BaseModule/ViewModels/AddUserDialogViewModel.cs b/BaseModule/ViewModels/AddUserDialogViewModel.cs index c12a23c..c1e0c4c 100644 --- a/BaseModule/ViewModels/AddUserDialogViewModel.cs +++ b/BaseModule/ViewModels/AddUserDialogViewModel.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; +using Txgy.EWS.Client.Common; using Txgy.EWS.Client.Entity; using Txgy.EWS.Client.IBLL; using Txgy.EWS.Client.Models; @@ -73,7 +74,7 @@ namespace BaseModule.ViewModels UserId = MainModel.UserId, UserName = MainModel.UserName, RealName = MainModel.RealName, - UserIcon = MainModel.UserIcon?.Replace(System.Configuration.ConfigurationManager.AppSettings["CadSettingsFileName"].ToString(), ""), + UserIcon = MainModel.UserIcon?.Replace(BusinessConfigManager.GetRequiredPath(BusinessConfigManager.Current.Paths.CadSettingsFileName, "paths.cadSettingsFileName"), ""), Password = MainModel.Password, Age = MainModel.Age }); diff --git a/BaseModule/ViewModels/UserManagementViewModel.cs b/BaseModule/ViewModels/UserManagementViewModel.cs index 36171e9..ac67b33 100644 --- a/BaseModule/ViewModels/UserManagementViewModel.cs +++ b/BaseModule/ViewModels/UserManagementViewModel.cs @@ -55,7 +55,7 @@ namespace BaseModule.ViewModels Index = users.IndexOf(item) + 1, UserId = item.UserId, UserName = item.UserName, - UserIcon = System.Configuration.ConfigurationManager.AppSettings["api_domain"].ToString() + item.UserIcon, + UserIcon = BusinessConfigManager.Current.Endpoints.ApiDomain + item.UserIcon, Age = item.Age, Password = item.Password, RealName = item.RealName diff --git a/Txgy.EWS.Client.Common/BusinessConfig.cs b/Txgy.EWS.Client.Common/BusinessConfig.cs new file mode 100644 index 0000000..7899a78 --- /dev/null +++ b/Txgy.EWS.Client.Common/BusinessConfig.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; + +namespace Txgy.EWS.Client.Common +{ + public class BusinessConfig + { + public EndpointSettings Endpoints { get; set; } + public PathSettings Paths { get; set; } + public RuntimeSettings Runtime { get; set; } + public DatabaseSettings Database { get; set; } + public BrandingSettings Branding { get; set; } + public ReportSettings Report { get; set; } + public CoordinateSettings Coordinates { get; set; } + } + + public class EndpointSettings + { + public string ApiDomain { get; set; } + } + + public class PathSettings + { + public string AlarmSetting { get; set; } + public string AlarmLevelConfig { get; set; } + public string ReportEventLevelSetting { get; set; } + public string WorkAreaFilePath { get; set; } + public string StationsCsvFilePath { get; set; } + public string CadDwgFilePath { get; set; } + public string DwgJsonSetting { get; set; } + public string WavesMseedFilePath { get; set; } + public string WavesTxtFilePath { get; set; } + public string LocalSqLiteDb { get; set; } + public string DwgSettings { get; set; } + public string CadSettingsFileName { get; set; } + } + + public class RuntimeSettings + { + public bool IsDesign { get; set; } + public bool IsRealtime { get; set; } + public int RefreshInterval { get; set; } + public int EventShowTotalSeconds { get; set; } + public int LoadDataTimeLenMins { get; set; } + public int DataCacheTimeLenMins { get; set; } + } + + public class DatabaseSettings + { + public Dictionary Connections { get; set; } + public TableSettings Tables { get; set; } + } + + public class TableSettings + { + public string RealtimeResultTable { get; set; } + public string RealtimeWaveDataTable { get; set; } + public string RealtimeFocalmechanismTable { get; set; } + public string PostResultTable { get; set; } + public string PostWaveDataTable { get; set; } + public string PostFocalmechanismTable { get; set; } + } + + public class BrandingSettings + { + public string CommpanyName { get; set; } + public string SystemNameCn { get; set; } + public string SystemNameEn { get; set; } + public string WorkAreaName { get; set; } + public string SystemShortName { get; set; } + } + + public class ReportSettings + { + public string DailyReportStartTime { get; set; } + public double DailyReportPlanOffsetX { get; set; } + public double DailyReportPlanOffsetY { get; set; } + } + + public class CoordinateSettings + { + public double BaseX { get; set; } + public double BaseY { get; set; } + public double BaseZ { get; set; } + } +} diff --git a/Txgy.EWS.Client.Common/BusinessConfigManager.cs b/Txgy.EWS.Client.Common/BusinessConfigManager.cs new file mode 100644 index 0000000..12445a6 --- /dev/null +++ b/Txgy.EWS.Client.Common/BusinessConfigManager.cs @@ -0,0 +1,267 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Txgy.EWS.Client.Common +{ + public static class BusinessConfigManager + { + private static readonly object SyncRoot = new object(); + private static BusinessConfig _current; + + public static string ConfigPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "client-settings.json"); + + public static BusinessConfig Current + { + get + { + lock (SyncRoot) + { + return _current ?? (_current = Read()); + } + } + } + + public static BusinessConfig Read() + { + if (!File.Exists(ConfigPath)) + { + throw new FileNotFoundException("Business config file was not found.", ConfigPath); + } + + var json = File.ReadAllText(ConfigPath); + var config = JsonConvert.DeserializeObject(json); + Validate(config); + return config; + } + + public static BusinessConfig Reload() + { + lock (SyncRoot) + { + _current = Read(); + FreeSqlTencent.Reset(); + FreeSqlLocalSqLite.Reset(); + return _current; + } + } + + public static string GetConnectionString(string name) + { + var connections = Current.Database.Connections; + if (connections == null || !connections.TryGetValue(name, out var value) || string.IsNullOrWhiteSpace(value)) + { + throw new InvalidOperationException($"Business config is missing database connection: {name}"); + } + + return value; + } + + public static string GetRequiredPath(string value, string name) + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new InvalidOperationException($"Business config is missing path: {name}"); + } + + return value; + } + + public static string GetAppSetting(string key) + { + if (!GetLegacyAppSettings().TryGetValue(key, out var token)) + { + return null; + } + + if (token == null || token.Type == JTokenType.Null) + { + return null; + } + + return token.Type == JTokenType.String ? token.Value() : token.ToString(); + } + + public static void UpdateAppSetting(string key, string value) + { + lock (SyncRoot) + { + var root = ReadRoot(); + var appSettings = GetLegacyAppSettings(root); + if (!appSettings.TryGetValue(key, out var token) || token == null) + { + throw new InvalidOperationException($"Business config does not support writing setting: {key}"); + } + + token.Replace(ConvertValue(token, value)); + SaveRoot(root); + _current = root.ToObject(); + Validate(_current); + FreeSqlTencent.Reset(); + FreeSqlLocalSqLite.Reset(); + } + } + + public static void UpdateRuntimeSettings(int loadDataTimeLenMins, int dataCacheTimeLenMins) + { + lock (SyncRoot) + { + var root = ReadRoot(); + root["runtime"]["loadDataTimeLenMins"] = loadDataTimeLenMins; + root["runtime"]["dataCacheTimeLenMins"] = dataCacheTimeLenMins; + SaveRoot(root); + _current = root.ToObject(); + Validate(_current); + } + } + + private static JObject ReadRoot() + { + if (!File.Exists(ConfigPath)) + { + throw new FileNotFoundException("Business config file was not found.", ConfigPath); + } + + return JObject.Parse(File.ReadAllText(ConfigPath)); + } + + private static void SaveRoot(JObject root) + { + var serializer = JsonSerializer.Create(new JsonSerializerSettings + { + Formatting = Formatting.Indented, + StringEscapeHandling = StringEscapeHandling.EscapeNonAscii + }); + string json; + using (var writer = new StringWriter()) + { + serializer.Serialize(writer, root); + json = writer.ToString(); + } + var tempPath = ConfigPath + ".tmp"; + File.WriteAllText(tempPath, json); + if (File.Exists(ConfigPath)) + { + File.Delete(ConfigPath); + } + File.Move(tempPath, ConfigPath); + } + + private static Dictionary GetLegacyAppSettings() + { + return GetLegacyAppSettings(ReadRoot()); + } + + private static Dictionary GetLegacyAppSettings(JObject root) + { + return new Dictionary + { + { "api_domain", root["endpoints"]?["apiDomain"] }, + { "AlarmSetting", root["paths"]?["alarmSetting"] }, + { "AlarmLevelConfig", root["paths"]?["alarmLevelConfig"] }, + { "ReportEventLevelSetting", root["paths"]?["reportEventLevelSetting"] }, + { "WorkAreaFilePath", root["paths"]?["workAreaFilePath"] }, + { "StationsCsvFilePath", root["paths"]?["stationsCsvFilePath"] }, + { "CadDwgFilePath", root["paths"]?["cadDwgFilePath"] }, + { "DwgJsonSetting", root["paths"]?["dwgJsonSetting"] }, + { "WavesMseedFilePath", root["paths"]?["wavesMseedFilePath"] }, + { "WavesTxtFilePath", root["paths"]?["wavesTxtFilePath"] }, + { "LocalSqLiteDb", root["paths"]?["localSqLiteDb"] }, + { "DwgSettings", root["paths"]?["dwgSettings"] }, + { "CadSettingsFileName", root["paths"]?["cadSettingsFileName"] }, + { "IsDesign", root["runtime"]?["isDesign"] }, + { "IsRealtime", root["runtime"]?["isRealtime"] }, + { "RefreshInterval", root["runtime"]?["refreshInterval"] }, + { "EventShowTotalSeconds", root["runtime"]?["eventShowTotalSeconds"] }, + { "LoadDataTimeLenMins", root["runtime"]?["loadDataTimeLenMins"] }, + { "DataCacheTimeLenMins", root["runtime"]?["dataCacheTimeLenMins"] }, + { "RealtimeResultTable", root["database"]?["tables"]?["realtimeResultTable"] }, + { "RealtimeWaveDataTable", root["database"]?["tables"]?["realtimeWaveDataTable"] }, + { "RealtimeFocalmechanismTable", root["database"]?["tables"]?["realtimeFocalmechanismTable"] }, + { "PostResultTable", root["database"]?["tables"]?["postResultTable"] }, + { "PostWaveDataTable", root["database"]?["tables"]?["postWaveDataTable"] }, + { "PostFocalmechanismTable", root["database"]?["tables"]?["postFocalmechanismTable"] }, + { "CommpanyName", root["branding"]?["commpanyName"] }, + { "SystemNameCn", root["branding"]?["systemNameCn"] }, + { "SystemNameEn", root["branding"]?["systemNameEn"] }, + { "WorkAreaName", root["branding"]?["workAreaName"] }, + { "SystemShortName", root["branding"]?["systemShortName"] }, + { "日报起始时间", root["report"]?["dailyReportStartTime"] }, + { "日报平面图横向偏移", root["report"]?["dailyReportPlanOffsetX"] }, + { "日报平面图纵向偏移", root["report"]?["dailyReportPlanOffsetY"] }, + { "BaseX", root["coordinates"]?["baseX"] }, + { "BaseY", root["coordinates"]?["baseY"] }, + { "BaseZ", root["coordinates"]?["baseZ"] } + }; + } + + private static JToken ConvertValue(JToken currentValue, string value) + { + switch (currentValue.Type) + { + case JTokenType.Boolean: + return bool.Parse(value); + case JTokenType.Integer: + return int.Parse(value); + case JTokenType.Float: + return double.Parse(value); + default: + return value; + } + } + + private static void Validate(BusinessConfig config) + { + if (config == null) + { + throw new InvalidOperationException("Business config file format is invalid."); + } + + Require(config.Endpoints?.ApiDomain, "endpoints.apiDomain"); + Require(config.Paths?.AlarmSetting, "paths.alarmSetting"); + Require(config.Paths?.AlarmLevelConfig, "paths.alarmLevelConfig"); + Require(config.Paths?.ReportEventLevelSetting, "paths.reportEventLevelSetting"); + Require(config.Paths?.WorkAreaFilePath, "paths.workAreaFilePath"); + Require(config.Paths?.StationsCsvFilePath, "paths.stationsCsvFilePath"); + Require(config.Paths?.CadDwgFilePath, "paths.cadDwgFilePath"); + Require(config.Paths?.DwgJsonSetting, "paths.dwgJsonSetting"); + Require(config.Paths?.WavesMseedFilePath, "paths.wavesMseedFilePath"); + Require(config.Paths?.WavesTxtFilePath, "paths.wavesTxtFilePath"); + Require(config.Paths?.LocalSqLiteDb, "paths.localSqLiteDb"); + Require(config.Branding?.CommpanyName, "branding.commpanyName"); + Require(config.Branding?.SystemNameCn, "branding.systemNameCn"); + Require(config.Branding?.SystemNameEn, "branding.systemNameEn"); + Require(config.Branding?.WorkAreaName, "branding.workAreaName"); + Require(config.Branding?.SystemShortName, "branding.systemShortName"); + Require(config.Report?.DailyReportStartTime, "report.dailyReportStartTime"); + Require(config.Database?.Tables?.RealtimeResultTable, "database.tables.realtimeResultTable"); + Require(config.Database?.Tables?.RealtimeWaveDataTable, "database.tables.realtimeWaveDataTable"); + Require(config.Database?.Tables?.RealtimeFocalmechanismTable, "database.tables.realtimeFocalmechanismTable"); + Require(config.Database?.Tables?.PostResultTable, "database.tables.postResultTable"); + Require(config.Database?.Tables?.PostWaveDataTable, "database.tables.postWaveDataTable"); + Require(config.Database?.Tables?.PostFocalmechanismTable, "database.tables.postFocalmechanismTable"); + GetConnectionStringFromConfig(config, "TencetnMySQL"); + GetConnectionStringFromConfig(config, "NasMySQL"); + } + + private static void Require(string value, string name) + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new InvalidOperationException($"Business config is missing setting: {name}"); + } + } + + private static void GetConnectionStringFromConfig(BusinessConfig config, string name) + { + if (config.Database?.Connections == null || + !config.Database.Connections.TryGetValue(name, out var value) || + string.IsNullOrWhiteSpace(value)) + { + throw new InvalidOperationException($"Business config is missing database connection: {name}"); + } + } + } +} diff --git a/Txgy.EWS.Client.Common/FreeSqlLocalSqLite.cs b/Txgy.EWS.Client.Common/FreeSqlLocalSqLite.cs index 78de822..e2d761d 100644 --- a/Txgy.EWS.Client.Common/FreeSqlLocalSqLite.cs +++ b/Txgy.EWS.Client.Common/FreeSqlLocalSqLite.cs @@ -1,16 +1,29 @@ -using System; -using System.Configuration; -using System.Diagnostics; +using System; +using System.IO; namespace Txgy.EWS.Client.Common { public class FreeSqlLocalSqLite { - static Lazy sqLiteLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - //.UseMonitorCommand(cmd => Trace.WriteLine($"Sql:{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看 - .UseConnectionString(FreeSql.DataType.Sqlite, "Data Source="+ System.AppDomain.CurrentDomain.BaseDirectory + System.Configuration.ConfigurationManager.AppSettings["LocalSqLiteDb"].ToString()) - //.UseConnectionString(FreeSql.DataType.Sqlite, "Data Source=EwsLocalSqLite.db") - .Build()); //自动同步实体结构到数据库,FreeSql不会扫描程序集,只有CRUD时才会生成表。 + private static Lazy sqLiteLazy = CreateLazy(); + public static IFreeSql freeLocalSqLite => sqLiteLazy.Value; + + public static void Reset() + { + if (sqLiteLazy.IsValueCreated) + { + sqLiteLazy.Value.Dispose(); + } + + sqLiteLazy = CreateLazy(); + } + + private static Lazy CreateLazy() + { + return new Lazy(() => new FreeSql.FreeSqlBuilder() + .UseConnectionString(FreeSql.DataType.Sqlite, "Data Source=" + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BusinessConfigManager.Current.Paths.LocalSqLiteDb)) + .Build()); + } } } diff --git a/Txgy.EWS.Client.Common/FreeSqlTencent.cs b/Txgy.EWS.Client.Common/FreeSqlTencent.cs index 8243a2d..66de012 100644 --- a/Txgy.EWS.Client.Common/FreeSqlTencent.cs +++ b/Txgy.EWS.Client.Common/FreeSqlTencent.cs @@ -1,18 +1,30 @@ -using System; -using System.Configuration; +using System; using System.Diagnostics; namespace Txgy.EWS.Client.Common { public class FreeSqlTencent { - static Lazy mySQLLazy = new Lazy(() => new FreeSql.FreeSqlBuilder() - .UseMonitorCommand(cmd => Trace.WriteLine($"Sql:{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看 - .UseConnectionString(FreeSql.DataType.MySql, ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString) - .Build()); //自动同步实体结构到数据库,FreeSql不会扫描程序集,只有CRUD时才会生成表。 + private static Lazy mySQLLazy = CreateLazy(); public static IFreeSql tencentRemoteMySQL => mySQLLazy.Value; - + public static void Reset() + { + if (mySQLLazy.IsValueCreated) + { + mySQLLazy.Value.Dispose(); + } + + mySQLLazy = CreateLazy(); + } + + private static Lazy CreateLazy() + { + return new Lazy(() => new FreeSql.FreeSqlBuilder() + .UseMonitorCommand(cmd => Trace.WriteLine($"Sql:{cmd.CommandText}")) + .UseConnectionString(FreeSql.DataType.MySql, BusinessConfigManager.GetConnectionString("TencetnMySQL")) + .Build()); + } } } diff --git a/Txgy.EWS.Client.Common/GlobalConfig.cs b/Txgy.EWS.Client.Common/GlobalConfig.cs index 0a992cb..c01ed89 100644 --- a/Txgy.EWS.Client.Common/GlobalConfig.cs +++ b/Txgy.EWS.Client.Common/GlobalConfig.cs @@ -89,7 +89,7 @@ namespace Txgy.EWS.Client.Common set { _loadDataTimeLenMins = value; StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("LoadDataTimeLenMins")); - ConfigManager.UpdateAppSetting("LoadDataTimeLenMins", LoadDataTimeLenMins.ToString()); + BusinessConfigManager.UpdateRuntimeSettings(LoadDataTimeLenMins, DataCacheTimeLenMins); } } @@ -102,10 +102,19 @@ namespace Txgy.EWS.Client.Common set { _dataCacheTimeLenMins = value; StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("DataCacheTimeLenMins")); - ConfigManager.UpdateAppSetting("DataCacheTimeLenMins", DataCacheTimeLenMins.ToString()); + BusinessConfigManager.UpdateRuntimeSettings(LoadDataTimeLenMins, DataCacheTimeLenMins); } } + public static void InitializeRuntimeSettings(RuntimeSettings runtime) + { + IsDesign = runtime.IsDesign; + _loadDataTimeLenMins = runtime.LoadDataTimeLenMins; + _dataCacheTimeLenMins = runtime.DataCacheTimeLenMins; + StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("LoadDataTimeLenMins")); + StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("DataCacheTimeLenMins")); + } + private static bool _isInitializing=false; public static bool IsInitializing { @@ -183,17 +192,16 @@ namespace Txgy.EWS.Client.Common } public static void ReadConfig() { - - string cn = System.Configuration.ConfigurationManager.AppSettings["SystemNameCn"].ToString(); - GlobalConfig.SystemNameCN = System.Configuration.ConfigurationManager.AppSettings["SystemNameCn"].ToString(); - GlobalConfig.SystemNameEN = System.Configuration.ConfigurationManager.AppSettings["SystemNameEn"].ToString(); - GlobalConfig.CommpanyName = System.Configuration.ConfigurationManager.AppSettings["CommpanyName"].ToString(); - GlobalConfig.WorkAreaName = System.Configuration.ConfigurationManager.AppSettings["WorkAreaName"].ToString(); - GlobalConfig.SystemShortName = System.Configuration.ConfigurationManager.AppSettings["SystemShortName"].ToString(); + var config = BusinessConfigManager.Current; + GlobalConfig.SystemNameCN = config.Branding.SystemNameCn; + GlobalConfig.SystemNameEN = config.Branding.SystemNameEn; + GlobalConfig.CommpanyName = config.Branding.CommpanyName; + GlobalConfig.WorkAreaName = config.Branding.WorkAreaName; + GlobalConfig.SystemShortName = config.Branding.SystemShortName; string jsonText; //读取工区配置文件 using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["WorkAreaFilePath"].ToString())) + config.Paths.WorkAreaFilePath)) { jsonText = sr.ReadToEnd(); } @@ -202,26 +210,16 @@ namespace Txgy.EWS.Client.Common //初始化波形数据、Json文件路径 InitializationPath(); - //从app.config内读取X,Y基址 - //BaseX = double.Parse(System.Configuration.ConfigurationManager.AppSettings["BaseX"].ToString()); - //BaseY = double.Parse(System.Configuration.ConfigurationManager.AppSettings["BaseY"].ToString()); - //从ProjectConfig中读取EMin,NMin作为X,Y基址 BaseX = 0; BaseY = 0; //BaseX = ProjectConfig.WorkArea.EMin; //BaseY = ProjectConfig.WorkArea.NMin; - BaseZ= double.Parse(System.Configuration.ConfigurationManager.AppSettings["BaseZ"].ToString()); - //读取Cad层配置文件 - //using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + - // System.Configuration.ConfigurationManager.AppSettings["DwgJsonSetting"].ToString())) - //{ - // jsonText = sr.ReadToEnd(); - //} + BaseZ= config.Coordinates.BaseZ; //读取Dwg图层配置文件 string jsonFile = AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["DwgJsonSetting"].ToString(); + config.Paths.DwgJsonSetting; var jlist = CadLayerModel.CreateFromJson(jsonFile); GlobalConfig.CadLayerConfigs = new ObservableCollection(jlist); foreach (var item in GlobalConfig.CadLayerConfigs) @@ -231,48 +229,46 @@ namespace Txgy.EWS.Client.Common //读取报表事件分级配置文件 string eventLevelFile= AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["ReportEventLevelSetting"].ToString(); + config.Paths.ReportEventLevelSetting; var elList = ReportEventLevel.CreateFromJson(eventLevelFile); GlobalData.ReportEventLevelList= new ObservableCollection(elList); //日报起始时间 - string drTime = System.Configuration.ConfigurationManager.AppSettings["日报起始时间"].ToString(); + string drTime = config.Report.DailyReportStartTime; DailyReportStartTime = DateTime.Parse(drTime); //MessageBox.Show($"配置文件中的日报时间:{drTime}\t参数:{DailyReportStartTime.ToShortTimeString()}"); //Console.WriteLine(DailyReportStartTime.ToString()); //日报表平面图横向偏移 - DailyReportPlanOffX = double.Parse(System.Configuration.ConfigurationManager.AppSettings["日报平面图横向偏移"].ToString()); + DailyReportPlanOffX = config.Report.DailyReportPlanOffsetX; //日报表平面图纵向偏移 - DailyReportPlanOffY =double.Parse(System.Configuration.ConfigurationManager.AppSettings["日报平面图纵向偏移"].ToString()); + DailyReportPlanOffY = config.Report.DailyReportPlanOffsetY; //Console.WriteLine(DailyReportStartTime.ToString()); //设置实时监测数据配置文件 - IsRealtime =bool.Parse(System.Configuration.ConfigurationManager.AppSettings["IsRealtime"].ToString()); + IsRealtime = config.Runtime.IsRealtime; if (IsRealtime) { - UseResultTable = System.Configuration.ConfigurationManager.AppSettings["RealtimeResultTable"].ToString(); - UseFocalMechanismTable = System.Configuration.ConfigurationManager.AppSettings["RealtimeFocalmechanismTable"].ToString(); - UseWaveDataTable= System.Configuration.ConfigurationManager.AppSettings["RealtimeWaveDataTable"].ToString(); + UseResultTable = config.Database.Tables.RealtimeResultTable; + UseFocalMechanismTable = config.Database.Tables.RealtimeFocalmechanismTable; + UseWaveDataTable= config.Database.Tables.RealtimeWaveDataTable; DataTypeString = "A"; EventIDColName = "RTEventID"; } else { - UseResultTable = System.Configuration.ConfigurationManager.AppSettings["PostResultTable"].ToString(); - UseFocalMechanismTable = System.Configuration.ConfigurationManager.AppSettings["PostFocalmechanismTable"].ToString(); - UseWaveDataTable = System.Configuration.ConfigurationManager.AppSettings["PostWaveDataTable"].ToString(); + UseResultTable = config.Database.Tables.PostResultTable; + UseFocalMechanismTable = config.Database.Tables.PostFocalmechanismTable; + UseWaveDataTable = config.Database.Tables.PostWaveDataTable; DataTypeString = "B"; EventIDColName = "PostEventID"; } - //从app.config内读取Cad背景图文件 ProjectConfig.CadFileName = AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["CadDwgFilePath"].ToString(); + config.Paths.CadDwgFilePath; - //从app.config内读取台站列表文件 ProjectConfig.StationDic = CreateStationFromCSV(AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["StationsCsvFilePath"].ToString()); + config.Paths.StationsCsvFilePath); //台站数量 StationCount = ProjectConfig.StationDic.Count; @@ -289,8 +285,9 @@ namespace Txgy.EWS.Client.Common } public static void InitializationPath() { - ProjectConfig.MseedFilePath = System.Configuration.ConfigurationManager.AppSettings["WavesMseedFilePath"].ToString(); - ProjectConfig.TxtFilePath= System.Configuration.ConfigurationManager.AppSettings["WavesTxtFilePath"].ToString(); + var config = BusinessConfigManager.Current; + ProjectConfig.MseedFilePath = config.Paths.WavesMseedFilePath; + ProjectConfig.TxtFilePath= config.Paths.WavesTxtFilePath; if (!Directory.Exists(ProjectConfig.MseedFilePath)) { Directory.CreateDirectory(ProjectConfig.MseedFilePath); @@ -369,8 +366,9 @@ namespace Txgy.EWS.Client.Common public static List ReadDwgLayerDisplay() { List lds= new List(); + var dwgSettings = BusinessConfigManager.GetRequiredPath(BusinessConfigManager.Current.Paths.DwgSettings, "paths.dwgSettings"); string filePath = AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString(); + dwgSettings; string[] rows; using (StreamReader sr=new StreamReader(filePath)) { diff --git a/Txgy.EWS.Client.Common/GlobalData.cs b/Txgy.EWS.Client.Common/GlobalData.cs index a548179..b91b25a 100644 --- a/Txgy.EWS.Client.Common/GlobalData.cs +++ b/Txgy.EWS.Client.Common/GlobalData.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Configuration; using System.IO; using System.Linq; using System.Reflection; diff --git a/Txgy.EWS.Client.Common/Helpers/ConfigManager.cs b/Txgy.EWS.Client.Common/Helpers/ConfigManager.cs index e3713bb..041b2da 100644 --- a/Txgy.EWS.Client.Common/Helpers/ConfigManager.cs +++ b/Txgy.EWS.Client.Common/Helpers/ConfigManager.cs @@ -1,63 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - namespace Txgy.EWS.Client.Common.Helpers { public static class ConfigManager { - private static Configuration _config; - private static string _configPath; - // 初始化配置对象 - static ConfigManager() - { - _configPath = Assembly.GetExecutingAssembly().Location + ".config"; - _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - } - // 获取设置值 public static string GetAppSetting(string key) { - return ConfigurationManager.AppSettings[key]; + return BusinessConfigManager.GetAppSetting(key); } - // 更新设置值(重要) + public static void UpdateAppSetting(string key, string value) { - try - { - // 1. 更新内存中的配置文件对象 - if (_config.AppSettings.Settings[key] == null) - { - _config.AppSettings.Settings.Add(key, value); - } - else - { - _config.AppSettings.Settings[key].Value = value; - } - - // 2. 保存到物理文件 - _config.Save(ConfigurationSaveMode.Modified); - - // 3. 强制刷新内存中的配置(否则需重启才能生效) - ConfigurationManager.RefreshSection("appSettings"); - - // 4. 更新当前内存中的ConfigurationManager - typeof(ConfigurationManager) - .GetField("s_initState", BindingFlags.NonPublic | BindingFlags.Static) - ?.SetValue(null, 0); - - typeof(ConfigurationManager) - .GetField("s_configSystem", BindingFlags.NonPublic | BindingFlags.Static) - ?.SetValue(null, null); - } - catch (ConfigurationErrorsException ex) - { - // 处理配置文件错误 - throw new ApplicationException("配置文件写入失败", ex); - } + BusinessConfigManager.UpdateAppSetting(key, value); } } } diff --git a/Txgy.EWS.Client.Common/RemoteMySqlDownloadData.cs b/Txgy.EWS.Client.Common/RemoteMySqlDownloadData.cs index c03554b..7e196bc 100644 --- a/Txgy.EWS.Client.Common/RemoteMySqlDownloadData.cs +++ b/Txgy.EWS.Client.Common/RemoteMySqlDownloadData.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Data.SqlClient; using System.Data; using System.IO; @@ -132,24 +131,6 @@ namespace Txgy.EWS.Client.Common // fs.Close(); // return (int)new FileInfo(fn).Length; //} - //private bool DBConnection() - //{ - // string connStr = ConfigurationManager.ConnectionStrings["NasMySQL"].ConnectionString; - // if (RemoteConn == null) - // RemoteConn = new MySqlConnection(connStr); - // try - // { - // if (RemoteConn.State != ConnectionState.Open) - // { - // RemoteConn.Open(); - // } - // return true; - // } - // catch - // { - // return false; - // } - //} //private void Dispose() //{ // if (Adap != null) diff --git a/Txgy.EWS.Client.Common/Txgy.EWS.Client.Common.csproj b/Txgy.EWS.Client.Common/Txgy.EWS.Client.Common.csproj index 23f9bca..88eef3f 100644 --- a/Txgy.EWS.Client.Common/Txgy.EWS.Client.Common.csproj +++ b/Txgy.EWS.Client.Common/Txgy.EWS.Client.Common.csproj @@ -154,6 +154,8 @@ + + diff --git a/Txgy.EWS.Client.DAL/RemoteMySQLDataAccess.cs b/Txgy.EWS.Client.DAL/RemoteMySQLDataAccess.cs index 31e1b50..2880d0e 100644 --- a/Txgy.EWS.Client.DAL/RemoteMySQLDataAccess.cs +++ b/Txgy.EWS.Client.DAL/RemoteMySQLDataAccess.cs @@ -1,7 +1,6 @@ using MySql.Data.MySqlClient; using System; using System.Collections.Generic; -using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Diagnostics; @@ -33,7 +32,7 @@ namespace Txgy.EWS.Client.DAL public MySqlDataAdapter Adap { get; set; } private int preSelectCount = 0; private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); - private string _connectionString = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; + private string _connectionString => BusinessConfigManager.GetConnectionString("TencetnMySQL"); int IRemoteMySQLDataAccess.PreSelectCount { get { return preSelectCount; } @@ -61,7 +60,7 @@ namespace Txgy.EWS.Client.DAL } private bool DBConnection() { - string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; + string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL"); if (RemoteConn == null) RemoteConn = new MySqlConnection(connStr); try diff --git a/Txgy.EWS.Client.DAL/RemoteMySqlDownload.cs b/Txgy.EWS.Client.DAL/RemoteMySqlDownload.cs index b18a5d8..db01267 100644 --- a/Txgy.EWS.Client.DAL/RemoteMySqlDownload.cs +++ b/Txgy.EWS.Client.DAL/RemoteMySqlDownload.cs @@ -1,12 +1,12 @@ using MySql.Data.MySqlClient; using System; using System.Collections.Generic; -using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Txgy.EWS.Client.Common; using Txgy.EWS.Client.IDAL; namespace Txgy.EWS.Client.DAL @@ -142,7 +142,7 @@ namespace Txgy.EWS.Client.DAL } private bool DBConnection() { - string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; + string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL"); if (RemoteConn == null) RemoteConn = new MySqlConnection(connStr); try diff --git a/Txgy.EWS.Client.DAL/WebDataAccess.cs b/Txgy.EWS.Client.DAL/WebDataAccess.cs index ef32416..0d3833d 100644 --- a/Txgy.EWS.Client.DAL/WebDataAccess.cs +++ b/Txgy.EWS.Client.DAL/WebDataAccess.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using Txgy.EWS.Client.Common; using Txgy.EWS.Client.IDAL; namespace Txgy.EWS.Client.DAL @@ -12,11 +13,7 @@ namespace Txgy.EWS.Client.DAL public class WebDataAccess : IWebDataAccess { //protected string domain = "http://101.43.141.10:8090/api/v1/"; - protected string domain = "http://localhost:5000/api/v1/"; - public WebDataAccess() - { - domain = System.Configuration.ConfigurationManager.AppSettings["api_domain"].ToString(); - } + protected string domain => BusinessConfigManager.Current.Endpoints.ApiDomain; public async Task GetDatas(string url) { using (var client = new HttpClient()) diff --git a/Txgy.EWS.Client.Models/CadLayerModel.cs b/Txgy.EWS.Client.Models/CadLayerModel.cs index b85cb4f..f9a11f3 100644 --- a/Txgy.EWS.Client.Models/CadLayerModel.cs +++ b/Txgy.EWS.Client.Models/CadLayerModel.cs @@ -73,8 +73,6 @@ namespace Txgy.EWS.Client.Models public static List ReadDwgTxtConfig(string configPath) { List lds = new List(); - //string filePath = AppDomain.CurrentDomain.BaseDirectory + - // System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString(); string[] rows, cols; using (StreamReader sr = new StreamReader(configPath)) { diff --git a/Txgy.EWS.Client.Models/CadLinePropertyModel.cs b/Txgy.EWS.Client.Models/CadLinePropertyModel.cs index 1277239..b147c93 100644 --- a/Txgy.EWS.Client.Models/CadLinePropertyModel.cs +++ b/Txgy.EWS.Client.Models/CadLinePropertyModel.cs @@ -62,13 +62,11 @@ namespace Txgy.EWS.Client.Models return clps; } - public static List ReadDwgLineList() + public static List ReadDwgLineList(string configPath) { List lds = new List(); - string filePath = AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString(); string[] rows, cols; - using (StreamReader sr = new StreamReader(filePath)) + using (StreamReader sr = new StreamReader(configPath)) { rows = sr.ReadToEnd().Trim().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); } diff --git a/Txgy.EWS.Client.PageModule/PageModuleProfile.cs b/Txgy.EWS.Client.PageModule/PageModuleProfile.cs index 83323f3..4569b2b 100644 --- a/Txgy.EWS.Client.PageModule/PageModuleProfile.cs +++ b/Txgy.EWS.Client.PageModule/PageModuleProfile.cs @@ -17,8 +17,6 @@ namespace Txgy.EWS.Client.PageModule public void OnInitialized(IContainerProvider containerProvider) { - //string dwgJsonPath = AppDomain.CurrentDomain.BaseDirectory + - // System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString(); //CadLineList.LineProperties = CadLineList.ReadDwgFromJson(dwgJsonPath); var regionManager = containerProvider.Resolve(); //regionManager.RegisterViewWithRegion("PlaneViewEventListContentRegion", typeof(EventListView)); diff --git a/Txgy.EWS.Client.PageModule/Services/DownloadJsonFile.cs b/Txgy.EWS.Client.PageModule/Services/DownloadJsonFile.cs index 423cd13..c3a641e 100644 --- a/Txgy.EWS.Client.PageModule/Services/DownloadJsonFile.cs +++ b/Txgy.EWS.Client.PageModule/Services/DownloadJsonFile.cs @@ -1,12 +1,12 @@ using MySql.Data.MySqlClient; using System; using System.Collections.Generic; -using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Txgy.EWS.Client.Common; namespace Txgy.EWS.Client.PageModule.Services { @@ -14,7 +14,7 @@ namespace Txgy.EWS.Client.PageModule.Services { public int Download(string eventTime, string savePath, string saveName, string tableName) { - string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; + string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL"); MySqlConnection RemoteConn = new MySqlConnection(connStr); string courseSql = @"select JsonFile from " + tableName + " where EventTime=@eventTime"; MySqlCommand Comm = new MySqlCommand(courseSql, RemoteConn); @@ -86,7 +86,7 @@ namespace Txgy.EWS.Client.PageModule.Services public static async Task DownloadAsync(string eventTime, string savePath, string saveName, string tableName) { - string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; + string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL"); using (MySqlConnection RemoteConn = new MySqlConnection(connStr)) using (MySqlCommand Comm = new MySqlCommand($"SELECT JsonFile FROM {tableName} WHERE EventTime=@eventTime", RemoteConn)) { diff --git a/Txgy.EWS.Client.PageModule/Services/DownloadWavedata.cs b/Txgy.EWS.Client.PageModule/Services/DownloadWavedata.cs index 38be9cc..96c04e2 100644 --- a/Txgy.EWS.Client.PageModule/Services/DownloadWavedata.cs +++ b/Txgy.EWS.Client.PageModule/Services/DownloadWavedata.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Data.SqlClient; using System.Data; using System.IO; @@ -8,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using MySql.Data.MySqlClient; +using Txgy.EWS.Client.Common; namespace Txgy.EWS.Client.PageModule.Services { @@ -15,7 +15,7 @@ namespace Txgy.EWS.Client.PageModule.Services { public int Download(string eventTime, string savePath, string saveName, string tableName) { - string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; + string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL"); MySqlConnection RemoteConn = new MySqlConnection(connStr); string courseSql = @"select WaveData from " + tableName + " where EventTime=@eventTime"; MySqlCommand Comm = new MySqlCommand(courseSql, RemoteConn); diff --git a/Txgy.EWS.Client.PageModule/ViewModels/EventListViewModel.cs b/Txgy.EWS.Client.PageModule/ViewModels/EventListViewModel.cs index 221541b..1f6d841 100644 --- a/Txgy.EWS.Client.PageModule/ViewModels/EventListViewModel.cs +++ b/Txgy.EWS.Client.PageModule/ViewModels/EventListViewModel.cs @@ -14,7 +14,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Configuration; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; diff --git a/Txgy.EWS.Client.PageModule/ViewModels/TitleViewModel.cs b/Txgy.EWS.Client.PageModule/ViewModels/TitleViewModel.cs index 6d47507..d8e5fe8 100644 --- a/Txgy.EWS.Client.PageModule/ViewModels/TitleViewModel.cs +++ b/Txgy.EWS.Client.PageModule/ViewModels/TitleViewModel.cs @@ -176,20 +176,21 @@ namespace Txgy.EWS.Client.PageModule.ViewModels this._ea = ea; this._logHelper = logHelper; this.searchMsEventBLL = searchMsEventBLL; + var config = BusinessConfigManager.Current; //AlarmThreshold = 1000; using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["AlarmSetting"].ToString())) + config.Paths.AlarmSetting)) { AlarmSetting = JsonConvert.DeserializeObject(sr.ReadToEnd()); } //AlarmThreshold = AlarmSettingConfig.AlarmThreshold; //RefreshInterval = AlarmSetting.RefreshInterval; - RefreshInterval = int.Parse(System.Configuration.ConfigurationManager.AppSettings["RefreshInterval"].ToString()); + RefreshInterval = config.Runtime.RefreshInterval; CurAlarmMusic = AlarmSetting.AlarmSound; ListAlarmLevel = new List(); using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + - System.Configuration.ConfigurationManager.AppSettings["AlarmLevelConfig"].ToString())) + config.Paths.AlarmLevelConfig)) { ListAlarmLevel = JsonConvert.DeserializeObject>(sr.ReadToEnd()); } diff --git a/Txgy.EWS.Client.PageModule/Views/EarlyWarningView.xaml.cs b/Txgy.EWS.Client.PageModule/Views/EarlyWarningView.xaml.cs index bf432f6..37ab71c 100644 --- a/Txgy.EWS.Client.PageModule/Views/EarlyWarningView.xaml.cs +++ b/Txgy.EWS.Client.PageModule/Views/EarlyWarningView.xaml.cs @@ -136,7 +136,7 @@ namespace Txgy.EWS.Client.PageModule.Views transGroup.Children.Add(new TranslateTransform(-380, 0)); canvas.RenderTransform = transGroup; //事件时限秒数 - EventShowTotalSeconds = int.Parse(System.Configuration.ConfigurationManager.AppSettings["EventShowTotalSeconds"].ToString()); + EventShowTotalSeconds = BusinessConfigManager.Current.Runtime.EventShowTotalSeconds; _handleDataGenerated = new HandleDataGeneratedDelegate(rpi.DrawGierInTime); //更新接收到的事件到平面图 diff --git a/Txgy.EWS.Client.PageModule/Views/EarlyWarningViewBak.xaml.cs b/Txgy.EWS.Client.PageModule/Views/EarlyWarningViewBak.xaml.cs index 6402167..a41e346 100644 --- a/Txgy.EWS.Client.PageModule/Views/EarlyWarningViewBak.xaml.cs +++ b/Txgy.EWS.Client.PageModule/Views/EarlyWarningViewBak.xaml.cs @@ -132,7 +132,7 @@ namespace Txgy.EWS.Client.PageModule.Views transGroup.Children.Add(new TranslateTransform(-380, -150)); canvas.RenderTransform = transGroup; //事件时限秒数 - EventShowTotalSeconds = int.Parse(System.Configuration.ConfigurationManager.AppSettings["EventShowTotalSeconds"].ToString()); + EventShowTotalSeconds = BusinessConfigManager.Current.Runtime.EventShowTotalSeconds; _handleDataGenerated = new HandleDataGeneratedDelegate(rpi.DrawGierInTime); diff --git a/Txgy.EWS.Client.Start/App.config b/Txgy.EWS.Client.Start/App.config index cccb9e6..6bef7de 100644 --- a/Txgy.EWS.Client.Start/App.config +++ b/Txgy.EWS.Client.Start/App.config @@ -3,52 +3,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Txgy.EWS.Client.Start/App.xaml.cs b/Txgy.EWS.Client.Start/App.xaml.cs index 952a600..da6606d 100644 --- a/Txgy.EWS.Client.Start/App.xaml.cs +++ b/Txgy.EWS.Client.Start/App.xaml.cs @@ -5,7 +5,6 @@ using Prism.Services.Dialogs; using Prism.Unity; using System; using System.Collections.Generic; -using System.Configuration; using System.Data; using System.Diagnostics; using System.Linq; @@ -61,11 +60,8 @@ namespace Txgy.EWS.Client.Start protected override Window CreateShell() { - //bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString(), out GlobalConfig.IsDesign); - //Console.WriteLine(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString()); - GlobalConfig.IsDesign = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString()); - GlobalConfig.LoadDataTimeLenMins=int.Parse(System.Configuration.ConfigurationManager.AppSettings["LoadDataTimeLenMins"].ToString()); - GlobalConfig.DataCacheTimeLenMins = int.Parse(System.Configuration.ConfigurationManager.AppSettings["DataCacheTimeLenMins"].ToString()); + var config = BusinessConfigManager.Current; + GlobalConfig.InitializeRuntimeSettings(config.Runtime); Debug.WriteLine(GlobalConfig.LoadDataTimeLenMins); Debug.WriteLine(GlobalConfig.DataCacheTimeLenMins); return Container.Resolve(); @@ -89,7 +85,6 @@ namespace Txgy.EWS.Client.Start else { //CommonLogHelper.Debug("====Start=====>"); - //Console.WriteLine(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString()); base.InitializeShell(shell); } } diff --git a/Txgy.EWS.Client.Start/Txgy.EWS.Client.Start.csproj b/Txgy.EWS.Client.Start/Txgy.EWS.Client.Start.csproj index 70104bf..532d81c 100644 --- a/Txgy.EWS.Client.Start/Txgy.EWS.Client.Start.csproj +++ b/Txgy.EWS.Client.Start/Txgy.EWS.Client.Start.csproj @@ -151,6 +151,9 @@ + + Always + SettingsSingleFileGenerator diff --git a/Txgy.EWS.Client.Start/ViewModels/MainWindowViewModel.cs b/Txgy.EWS.Client.Start/ViewModels/MainWindowViewModel.cs index 8563f82..72f6335 100644 --- a/Txgy.EWS.Client.Start/ViewModels/MainWindowViewModel.cs +++ b/Txgy.EWS.Client.Start/ViewModels/MainWindowViewModel.cs @@ -17,7 +17,6 @@ namespace Txgy.EWS.Client.Start.ViewModels { public MainWindowViewModel() { - //WorkArea= System.Configuration.ConfigurationManager.AppSettings["WorkArea"].ToString(); //GlobalData.SearchEventResults = new ObservableCollection(); //GlobalData.DisplayEvents = new List(); //GlobalConfig.ReadConfig(); diff --git a/Txgy.EWS.Client.Start/config/client-settings.json b/Txgy.EWS.Client.Start/config/client-settings.json new file mode 100644 index 0000000..50b5ccd --- /dev/null +++ b/Txgy.EWS.Client.Start/config/client-settings.json @@ -0,0 +1,58 @@ +{ + "endpoints": { + "apiDomain": "http://8.141.12.31:80/api/v1/" + }, + "paths": { + "alarmSetting": "\\resources\\alarmsetting.json", + "alarmLevelConfig": "\\resources\\alarmlevel.json", + "reportEventLevelSetting": "resources\\ReportEventLevelSettings.json", + "workAreaFilePath": "\\resources\\WorkAreaSettings-N2107.json", + "stationsCsvFilePath": "\\resources\\N2107_1116.csv", + "cadDwgFilePath": "\\resources\\N2107_V2013_1117.dwg", + "dwgJsonSetting": "resources\\DwgSetting.json", + "wavesMseedFilePath": "D:\\EwsCache\\Mseed", + "wavesTxtFilePath": "D:\\EwsCache\\Txt", + "localSqLiteDb": "EwsLocalSqLite.db", + "dwgSettings": null, + "cadSettingsFileName": null + }, + "runtime": { + "isDesign": false, + "isRealtime": true, + "refreshInterval": 10, + "eventShowTotalSeconds": 86400, + "loadDataTimeLenMins": 720, + "dataCacheTimeLenMins": 720 + }, + "database": { + "connections": { + "TencetnMySQL": "Data Source=bj-cdb-q64mbxr6.sql.tencentcdb.com;Port=60027;Database=yuwu2026;User=yuwudba;Password=Yw123456;SslMode = none;", + "NasMySQL": "Data Source=tayfx.work;Port=60027;Database=YuwuN1100;User=yuwudba;Password=Yw123456;SslMode = none;" + }, + "tables": { + "realtimeResultTable": "realtimeeventresult", + "realtimeWaveDataTable": "realtimewavedatas", + "realtimeFocalmechanismTable": "realtimefocalmechanism", + "postResultTable": "postproeventresult", + "postWaveDataTable": "postproeventwavedatas", + "postFocalmechanismTable": "postprofocalmechanism" + } + }, + "branding": { + "commpanyName": "\u6cb3\u5357\u7406\u5de5\u5927\u5b66", + "systemNameCn": "\u7164\u77ff\u52a8\u529b\u707e\u5bb3\u5fae\u5730\u9707\u5b9e\u65f6\u9884\u8b66\u7cfb\u7edf", + "systemNameEn": "Microseismic Real-time Monitoring System", + "workAreaName": "N2107", + "systemShortName": "\u9884\u8b66\u7cfb\u7edf" + }, + "report": { + "dailyReportStartTime": "00:00:00", + "dailyReportPlanOffsetX": -200, + "dailyReportPlanOffsetY": -350 + }, + "coordinates": { + "baseX": 38396517, + "baseY": 4029418, + "baseZ": 1208 + } +}