feat: migrate business settings to json

master
tayttt 3 days ago
parent 343fcd8b80
commit 15b7ac84e8

@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using Txgy.EWS.Client.Common;
using Txgy.EWS.Client.Entity; using Txgy.EWS.Client.Entity;
using Txgy.EWS.Client.IBLL; using Txgy.EWS.Client.IBLL;
using Txgy.EWS.Client.Models; using Txgy.EWS.Client.Models;
@ -73,7 +74,7 @@ namespace BaseModule.ViewModels
UserId = MainModel.UserId, UserId = MainModel.UserId,
UserName = MainModel.UserName, UserName = MainModel.UserName,
RealName = MainModel.RealName, 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, Password = MainModel.Password,
Age = MainModel.Age Age = MainModel.Age
}); });

@ -55,7 +55,7 @@ namespace BaseModule.ViewModels
Index = users.IndexOf(item) + 1, Index = users.IndexOf(item) + 1,
UserId = item.UserId, UserId = item.UserId,
UserName = item.UserName, UserName = item.UserName,
UserIcon = System.Configuration.ConfigurationManager.AppSettings["api_domain"].ToString() + item.UserIcon, UserIcon = BusinessConfigManager.Current.Endpoints.ApiDomain + item.UserIcon,
Age = item.Age, Age = item.Age,
Password = item.Password, Password = item.Password,
RealName = item.RealName RealName = item.RealName

@ -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<string, string> 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; }
}
}

@ -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<BusinessConfig>(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<string>() : 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<BusinessConfig>();
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<BusinessConfig>();
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<string, JToken> GetLegacyAppSettings()
{
return GetLegacyAppSettings(ReadRoot());
}
private static Dictionary<string, JToken> GetLegacyAppSettings(JObject root)
{
return new Dictionary<string, JToken>
{
{ "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}");
}
}
}
}

@ -1,16 +1,29 @@
using System; using System;
using System.Configuration; using System.IO;
using System.Diagnostics;
namespace Txgy.EWS.Client.Common namespace Txgy.EWS.Client.Common
{ {
public class FreeSqlLocalSqLite public class FreeSqlLocalSqLite
{ {
static Lazy<IFreeSql> sqLiteLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder() private static Lazy<IFreeSql> sqLiteLazy = CreateLazy();
//.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时才会生成表。
public static IFreeSql freeLocalSqLite => sqLiteLazy.Value; public static IFreeSql freeLocalSqLite => sqLiteLazy.Value;
public static void Reset()
{
if (sqLiteLazy.IsValueCreated)
{
sqLiteLazy.Value.Dispose();
}
sqLiteLazy = CreateLazy();
}
private static Lazy<IFreeSql> CreateLazy()
{
return new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.Sqlite, "Data Source=" + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BusinessConfigManager.Current.Paths.LocalSqLiteDb))
.Build());
}
} }
} }

@ -1,18 +1,30 @@
using System; using System;
using System.Configuration;
using System.Diagnostics; using System.Diagnostics;
namespace Txgy.EWS.Client.Common namespace Txgy.EWS.Client.Common
{ {
public class FreeSqlTencent public class FreeSqlTencent
{ {
static Lazy<IFreeSql> mySQLLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder() private static Lazy<IFreeSql> mySQLLazy = CreateLazy();
.UseMonitorCommand(cmd => Trace.WriteLine($"Sql{cmd.CommandText}"))//监听SQL语句,Trace在输出选项卡中查看
.UseConnectionString(FreeSql.DataType.MySql, ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString)
.Build()); //自动同步实体结构到数据库FreeSql不会扫描程序集只有CRUD时才会生成表。
public static IFreeSql tencentRemoteMySQL => mySQLLazy.Value; public static IFreeSql tencentRemoteMySQL => mySQLLazy.Value;
public static void Reset()
{
if (mySQLLazy.IsValueCreated)
{
mySQLLazy.Value.Dispose();
}
mySQLLazy = CreateLazy();
}
private static Lazy<IFreeSql> CreateLazy()
{
return new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
.UseMonitorCommand(cmd => Trace.WriteLine($"Sql:{cmd.CommandText}"))
.UseConnectionString(FreeSql.DataType.MySql, BusinessConfigManager.GetConnectionString("TencetnMySQL"))
.Build());
}
} }
} }

@ -89,7 +89,7 @@ namespace Txgy.EWS.Client.Common
set { set {
_loadDataTimeLenMins = value; _loadDataTimeLenMins = value;
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("LoadDataTimeLenMins")); 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 { set {
_dataCacheTimeLenMins = value; _dataCacheTimeLenMins = value;
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("DataCacheTimeLenMins")); 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; private static bool _isInitializing=false;
public static bool IsInitializing public static bool IsInitializing
{ {
@ -183,17 +192,16 @@ namespace Txgy.EWS.Client.Common
} }
public static void ReadConfig() public static void ReadConfig()
{ {
var config = BusinessConfigManager.Current;
string cn = System.Configuration.ConfigurationManager.AppSettings["SystemNameCn"].ToString(); GlobalConfig.SystemNameCN = config.Branding.SystemNameCn;
GlobalConfig.SystemNameCN = System.Configuration.ConfigurationManager.AppSettings["SystemNameCn"].ToString(); GlobalConfig.SystemNameEN = config.Branding.SystemNameEn;
GlobalConfig.SystemNameEN = System.Configuration.ConfigurationManager.AppSettings["SystemNameEn"].ToString(); GlobalConfig.CommpanyName = config.Branding.CommpanyName;
GlobalConfig.CommpanyName = System.Configuration.ConfigurationManager.AppSettings["CommpanyName"].ToString(); GlobalConfig.WorkAreaName = config.Branding.WorkAreaName;
GlobalConfig.WorkAreaName = System.Configuration.ConfigurationManager.AppSettings["WorkAreaName"].ToString(); GlobalConfig.SystemShortName = config.Branding.SystemShortName;
GlobalConfig.SystemShortName = System.Configuration.ConfigurationManager.AppSettings["SystemShortName"].ToString();
string jsonText; string jsonText;
//读取工区配置文件 //读取工区配置文件
using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["WorkAreaFilePath"].ToString())) config.Paths.WorkAreaFilePath))
{ {
jsonText = sr.ReadToEnd(); jsonText = sr.ReadToEnd();
} }
@ -202,26 +210,16 @@ namespace Txgy.EWS.Client.Common
//初始化波形数据、Json文件路径 //初始化波形数据、Json文件路径
InitializationPath(); 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基址 //从ProjectConfig中读取EMin,NMin作为X,Y基址
BaseX = 0; BaseX = 0;
BaseY = 0; BaseY = 0;
//BaseX = ProjectConfig.WorkArea.EMin; //BaseX = ProjectConfig.WorkArea.EMin;
//BaseY = ProjectConfig.WorkArea.NMin; //BaseY = ProjectConfig.WorkArea.NMin;
BaseZ= double.Parse(System.Configuration.ConfigurationManager.AppSettings["BaseZ"].ToString()); BaseZ= config.Coordinates.BaseZ;
//读取Cad层配置文件
//using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory +
// System.Configuration.ConfigurationManager.AppSettings["DwgJsonSetting"].ToString()))
//{
// jsonText = sr.ReadToEnd();
//}
//读取Dwg图层配置文件 //读取Dwg图层配置文件
string jsonFile = AppDomain.CurrentDomain.BaseDirectory + string jsonFile = AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["DwgJsonSetting"].ToString(); config.Paths.DwgJsonSetting;
var jlist = CadLayerModel.CreateFromJson(jsonFile); var jlist = CadLayerModel.CreateFromJson(jsonFile);
GlobalConfig.CadLayerConfigs = new ObservableCollection<CadLayerModel>(jlist); GlobalConfig.CadLayerConfigs = new ObservableCollection<CadLayerModel>(jlist);
foreach (var item in GlobalConfig.CadLayerConfigs) foreach (var item in GlobalConfig.CadLayerConfigs)
@ -231,48 +229,46 @@ namespace Txgy.EWS.Client.Common
//读取报表事件分级配置文件 //读取报表事件分级配置文件
string eventLevelFile= AppDomain.CurrentDomain.BaseDirectory + string eventLevelFile= AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["ReportEventLevelSetting"].ToString(); config.Paths.ReportEventLevelSetting;
var elList = ReportEventLevel.CreateFromJson(eventLevelFile); var elList = ReportEventLevel.CreateFromJson(eventLevelFile);
GlobalData.ReportEventLevelList= new ObservableCollection<ReportEventLevel>(elList); GlobalData.ReportEventLevelList= new ObservableCollection<ReportEventLevel>(elList);
//日报起始时间 //日报起始时间
string drTime = System.Configuration.ConfigurationManager.AppSettings["日报起始时间"].ToString(); string drTime = config.Report.DailyReportStartTime;
DailyReportStartTime = DateTime.Parse(drTime); DailyReportStartTime = DateTime.Parse(drTime);
//MessageBox.Show($"配置文件中的日报时间:{drTime}\t参数{DailyReportStartTime.ToShortTimeString()}"); //MessageBox.Show($"配置文件中的日报时间:{drTime}\t参数{DailyReportStartTime.ToShortTimeString()}");
//Console.WriteLine(DailyReportStartTime.ToString()); //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()); //Console.WriteLine(DailyReportStartTime.ToString());
//设置实时监测数据配置文件 //设置实时监测数据配置文件
IsRealtime =bool.Parse(System.Configuration.ConfigurationManager.AppSettings["IsRealtime"].ToString()); IsRealtime = config.Runtime.IsRealtime;
if (IsRealtime) if (IsRealtime)
{ {
UseResultTable = System.Configuration.ConfigurationManager.AppSettings["RealtimeResultTable"].ToString(); UseResultTable = config.Database.Tables.RealtimeResultTable;
UseFocalMechanismTable = System.Configuration.ConfigurationManager.AppSettings["RealtimeFocalmechanismTable"].ToString(); UseFocalMechanismTable = config.Database.Tables.RealtimeFocalmechanismTable;
UseWaveDataTable= System.Configuration.ConfigurationManager.AppSettings["RealtimeWaveDataTable"].ToString(); UseWaveDataTable= config.Database.Tables.RealtimeWaveDataTable;
DataTypeString = "A"; DataTypeString = "A";
EventIDColName = "RTEventID"; EventIDColName = "RTEventID";
} }
else else
{ {
UseResultTable = System.Configuration.ConfigurationManager.AppSettings["PostResultTable"].ToString(); UseResultTable = config.Database.Tables.PostResultTable;
UseFocalMechanismTable = System.Configuration.ConfigurationManager.AppSettings["PostFocalmechanismTable"].ToString(); UseFocalMechanismTable = config.Database.Tables.PostFocalmechanismTable;
UseWaveDataTable = System.Configuration.ConfigurationManager.AppSettings["PostWaveDataTable"].ToString(); UseWaveDataTable = config.Database.Tables.PostWaveDataTable;
DataTypeString = "B"; DataTypeString = "B";
EventIDColName = "PostEventID"; EventIDColName = "PostEventID";
} }
//从app.config内读取Cad背景图文件
ProjectConfig.CadFileName = AppDomain.CurrentDomain.BaseDirectory + ProjectConfig.CadFileName = AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["CadDwgFilePath"].ToString(); config.Paths.CadDwgFilePath;
//从app.config内读取台站列表文件
ProjectConfig.StationDic = CreateStationFromCSV(AppDomain.CurrentDomain.BaseDirectory + ProjectConfig.StationDic = CreateStationFromCSV(AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["StationsCsvFilePath"].ToString()); config.Paths.StationsCsvFilePath);
//台站数量 //台站数量
StationCount = ProjectConfig.StationDic.Count; StationCount = ProjectConfig.StationDic.Count;
@ -289,8 +285,9 @@ namespace Txgy.EWS.Client.Common
} }
public static void InitializationPath() public static void InitializationPath()
{ {
ProjectConfig.MseedFilePath = System.Configuration.ConfigurationManager.AppSettings["WavesMseedFilePath"].ToString(); var config = BusinessConfigManager.Current;
ProjectConfig.TxtFilePath= System.Configuration.ConfigurationManager.AppSettings["WavesTxtFilePath"].ToString(); ProjectConfig.MseedFilePath = config.Paths.WavesMseedFilePath;
ProjectConfig.TxtFilePath= config.Paths.WavesTxtFilePath;
if (!Directory.Exists(ProjectConfig.MseedFilePath)) if (!Directory.Exists(ProjectConfig.MseedFilePath))
{ {
Directory.CreateDirectory(ProjectConfig.MseedFilePath); Directory.CreateDirectory(ProjectConfig.MseedFilePath);
@ -369,8 +366,9 @@ namespace Txgy.EWS.Client.Common
public static List<string> ReadDwgLayerDisplay() public static List<string> ReadDwgLayerDisplay()
{ {
List<string> lds= new List<string>(); List<string> lds= new List<string>();
var dwgSettings = BusinessConfigManager.GetRequiredPath(BusinessConfigManager.Current.Paths.DwgSettings, "paths.dwgSettings");
string filePath = AppDomain.CurrentDomain.BaseDirectory + string filePath = AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString(); dwgSettings;
string[] rows; string[] rows;
using (StreamReader sr=new StreamReader(filePath)) using (StreamReader sr=new StreamReader(filePath))
{ {

@ -7,7 +7,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Configuration;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

@ -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 namespace Txgy.EWS.Client.Common.Helpers
{ {
public static class ConfigManager 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) public static string GetAppSetting(string key)
{ {
return ConfigurationManager.AppSettings[key]; return BusinessConfigManager.GetAppSetting(key);
} }
// 更新设置值(重要)
public static void UpdateAppSetting(string key, string value) public static void UpdateAppSetting(string key, string value)
{ {
try BusinessConfigManager.UpdateAppSetting(key, value);
{
// 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);
}
} }
} }
} }

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Data; using System.Data;
using System.IO; using System.IO;
@ -132,24 +131,6 @@ namespace Txgy.EWS.Client.Common
// fs.Close(); // fs.Close();
// return (int)new FileInfo(fn).Length; // 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() //private void Dispose()
//{ //{
// if (Adap != null) // if (Adap != null)

@ -154,6 +154,8 @@
<ItemGroup> <ItemGroup>
<Compile Include="ApiResponse.cs" /> <Compile Include="ApiResponse.cs" />
<Compile Include="BindingProxy.cs" /> <Compile Include="BindingProxy.cs" />
<Compile Include="BusinessConfig.cs" />
<Compile Include="BusinessConfigManager.cs" />
<Compile Include="Converters\Absolute2RelativeConverter.cs" /> <Compile Include="Converters\Absolute2RelativeConverter.cs" />
<Compile Include="Converters\SourceCharaInt2StringConverter.cs" /> <Compile Include="Converters\SourceCharaInt2StringConverter.cs" />
<Compile Include="Converters\Bool2BlurConverter.cs" /> <Compile Include="Converters\Bool2BlurConverter.cs" />

@ -1,7 +1,6 @@
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Diagnostics; using System.Diagnostics;
@ -33,7 +32,7 @@ namespace Txgy.EWS.Client.DAL
public MySqlDataAdapter Adap { get; set; } public MySqlDataAdapter Adap { get; set; }
private int preSelectCount = 0; private int preSelectCount = 0;
private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
private string _connectionString = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; private string _connectionString => BusinessConfigManager.GetConnectionString("TencetnMySQL");
int IRemoteMySQLDataAccess.PreSelectCount int IRemoteMySQLDataAccess.PreSelectCount
{ {
get { return preSelectCount; } get { return preSelectCount; }
@ -61,7 +60,7 @@ namespace Txgy.EWS.Client.DAL
} }
private bool DBConnection() private bool DBConnection()
{ {
string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL");
if (RemoteConn == null) if (RemoteConn == null)
RemoteConn = new MySqlConnection(connStr); RemoteConn = new MySqlConnection(connStr);
try try

@ -1,12 +1,12 @@
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Txgy.EWS.Client.Common;
using Txgy.EWS.Client.IDAL; using Txgy.EWS.Client.IDAL;
namespace Txgy.EWS.Client.DAL namespace Txgy.EWS.Client.DAL
@ -142,7 +142,7 @@ namespace Txgy.EWS.Client.DAL
} }
private bool DBConnection() private bool DBConnection()
{ {
string connStr = ConfigurationManager.ConnectionStrings["TencetnMySQL"].ConnectionString; string connStr = BusinessConfigManager.GetConnectionString("TencetnMySQL");
if (RemoteConn == null) if (RemoteConn == null)
RemoteConn = new MySqlConnection(connStr); RemoteConn = new MySqlConnection(connStr);
try try

@ -5,6 +5,7 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Txgy.EWS.Client.Common;
using Txgy.EWS.Client.IDAL; using Txgy.EWS.Client.IDAL;
namespace Txgy.EWS.Client.DAL namespace Txgy.EWS.Client.DAL
@ -12,11 +13,7 @@ namespace Txgy.EWS.Client.DAL
public class WebDataAccess : IWebDataAccess public class WebDataAccess : IWebDataAccess
{ {
//protected string domain = "http://101.43.141.10:8090/api/v1/"; //protected string domain = "http://101.43.141.10:8090/api/v1/";
protected string domain = "http://localhost:5000/api/v1/"; protected string domain => BusinessConfigManager.Current.Endpoints.ApiDomain;
public WebDataAccess()
{
domain = System.Configuration.ConfigurationManager.AppSettings["api_domain"].ToString();
}
public async Task<string> GetDatas(string url) public async Task<string> GetDatas(string url)
{ {
using (var client = new HttpClient()) using (var client = new HttpClient())

@ -73,8 +73,6 @@ namespace Txgy.EWS.Client.Models
public static List<CadLayerModel> ReadDwgTxtConfig(string configPath) public static List<CadLayerModel> ReadDwgTxtConfig(string configPath)
{ {
List<CadLayerModel> lds = new List<CadLayerModel>(); List<CadLayerModel> lds = new List<CadLayerModel>();
//string filePath = AppDomain.CurrentDomain.BaseDirectory +
// System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString();
string[] rows, cols; string[] rows, cols;
using (StreamReader sr = new StreamReader(configPath)) using (StreamReader sr = new StreamReader(configPath))
{ {

@ -62,13 +62,11 @@ namespace Txgy.EWS.Client.Models
return clps; return clps;
} }
public static List<CadLinePropertyModel> ReadDwgLineList() public static List<CadLinePropertyModel> ReadDwgLineList(string configPath)
{ {
List<CadLinePropertyModel> lds = new List<CadLinePropertyModel>(); List<CadLinePropertyModel> lds = new List<CadLinePropertyModel>();
string filePath = AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString();
string[] rows, cols; 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); rows = sr.ReadToEnd().Trim().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
} }

@ -17,8 +17,6 @@ namespace Txgy.EWS.Client.PageModule
public void OnInitialized(IContainerProvider containerProvider) public void OnInitialized(IContainerProvider containerProvider)
{ {
//string dwgJsonPath = AppDomain.CurrentDomain.BaseDirectory +
// System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString();
//CadLineList.LineProperties = CadLineList.ReadDwgFromJson(dwgJsonPath); //CadLineList.LineProperties = CadLineList.ReadDwgFromJson(dwgJsonPath);
var regionManager = containerProvider.Resolve<IRegionManager>(); var regionManager = containerProvider.Resolve<IRegionManager>();
//regionManager.RegisterViewWithRegion("PlaneViewEventListContentRegion", typeof(EventListView)); //regionManager.RegisterViewWithRegion("PlaneViewEventListContentRegion", typeof(EventListView));

@ -1,12 +1,12 @@
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Txgy.EWS.Client.Common;
namespace Txgy.EWS.Client.PageModule.Services 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) 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); MySqlConnection RemoteConn = new MySqlConnection(connStr);
string courseSql = @"select JsonFile from " + tableName + " where EventTime=@eventTime"; string courseSql = @"select JsonFile from " + tableName + " where EventTime=@eventTime";
MySqlCommand Comm = new MySqlCommand(courseSql, RemoteConn); MySqlCommand Comm = new MySqlCommand(courseSql, RemoteConn);
@ -86,7 +86,7 @@ namespace Txgy.EWS.Client.PageModule.Services
public static async Task<int> DownloadAsync(string eventTime, string savePath, string saveName, string tableName) public static async Task<int> 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 (MySqlConnection RemoteConn = new MySqlConnection(connStr))
using (MySqlCommand Comm = new MySqlCommand($"SELECT JsonFile FROM {tableName} WHERE EventTime=@eventTime", RemoteConn)) using (MySqlCommand Comm = new MySqlCommand($"SELECT JsonFile FROM {tableName} WHERE EventTime=@eventTime", RemoteConn))
{ {

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Data; using System.Data;
using System.IO; using System.IO;
@ -8,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Txgy.EWS.Client.Common;
namespace Txgy.EWS.Client.PageModule.Services 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) 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); MySqlConnection RemoteConn = new MySqlConnection(connStr);
string courseSql = @"select WaveData from " + tableName + " where EventTime=@eventTime"; string courseSql = @"select WaveData from " + tableName + " where EventTime=@eventTime";
MySqlCommand Comm = new MySqlCommand(courseSql, RemoteConn); MySqlCommand Comm = new MySqlCommand(courseSql, RemoteConn);

@ -14,7 +14,6 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.SqlTypes; using System.Data.SqlTypes;
using System.Diagnostics; using System.Diagnostics;

@ -176,20 +176,21 @@ namespace Txgy.EWS.Client.PageModule.ViewModels
this._ea = ea; this._ea = ea;
this._logHelper = logHelper; this._logHelper = logHelper;
this.searchMsEventBLL = searchMsEventBLL; this.searchMsEventBLL = searchMsEventBLL;
var config = BusinessConfigManager.Current;
//AlarmThreshold = 1000; //AlarmThreshold = 1000;
using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["AlarmSetting"].ToString())) config.Paths.AlarmSetting))
{ {
AlarmSetting = JsonConvert.DeserializeObject<AlarmSetting>(sr.ReadToEnd()); AlarmSetting = JsonConvert.DeserializeObject<AlarmSetting>(sr.ReadToEnd());
} }
//AlarmThreshold = AlarmSettingConfig.AlarmThreshold; //AlarmThreshold = AlarmSettingConfig.AlarmThreshold;
//RefreshInterval = AlarmSetting.RefreshInterval; //RefreshInterval = AlarmSetting.RefreshInterval;
RefreshInterval = int.Parse(System.Configuration.ConfigurationManager.AppSettings["RefreshInterval"].ToString()); RefreshInterval = config.Runtime.RefreshInterval;
CurAlarmMusic = AlarmSetting.AlarmSound; CurAlarmMusic = AlarmSetting.AlarmSound;
ListAlarmLevel = new List<AlarmLevelModel>(); ListAlarmLevel = new List<AlarmLevelModel>();
using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory +
System.Configuration.ConfigurationManager.AppSettings["AlarmLevelConfig"].ToString())) config.Paths.AlarmLevelConfig))
{ {
ListAlarmLevel = JsonConvert.DeserializeObject<List<AlarmLevelModel>>(sr.ReadToEnd()); ListAlarmLevel = JsonConvert.DeserializeObject<List<AlarmLevelModel>>(sr.ReadToEnd());
} }

@ -136,7 +136,7 @@ namespace Txgy.EWS.Client.PageModule.Views
transGroup.Children.Add(new TranslateTransform(-380, 0)); transGroup.Children.Add(new TranslateTransform(-380, 0));
canvas.RenderTransform = transGroup; canvas.RenderTransform = transGroup;
//事件时限秒数 //事件时限秒数
EventShowTotalSeconds = int.Parse(System.Configuration.ConfigurationManager.AppSettings["EventShowTotalSeconds"].ToString()); EventShowTotalSeconds = BusinessConfigManager.Current.Runtime.EventShowTotalSeconds;
_handleDataGenerated = new HandleDataGeneratedDelegate(rpi.DrawGierInTime); _handleDataGenerated = new HandleDataGeneratedDelegate(rpi.DrawGierInTime);
//更新接收到的事件到平面图 //更新接收到的事件到平面图

@ -132,7 +132,7 @@ namespace Txgy.EWS.Client.PageModule.Views
transGroup.Children.Add(new TranslateTransform(-380, -150)); transGroup.Children.Add(new TranslateTransform(-380, -150));
canvas.RenderTransform = transGroup; canvas.RenderTransform = transGroup;
//事件时限秒数 //事件时限秒数
EventShowTotalSeconds = int.Parse(System.Configuration.ConfigurationManager.AppSettings["EventShowTotalSeconds"].ToString()); EventShowTotalSeconds = BusinessConfigManager.Current.Runtime.EventShowTotalSeconds;
_handleDataGenerated = new HandleDataGeneratedDelegate(rpi.DrawGierInTime); _handleDataGenerated = new HandleDataGeneratedDelegate(rpi.DrawGierInTime);

@ -3,52 +3,6 @@
<startup useLegacyV2RuntimeActivationPolicy="true"> <startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
<appSettings>
<add key="api_domain" value="http://8.141.12.31:80/api/v1/" />
<!--<add key="api_domain" value="http://localhost:5000/api/v1/" />-->
<!--<add key="CadSettingsFilePath" value="\\resources\\CadFileSettings.txt" />-->
<add key="AlarmSetting" value="\\resources\\alarmsetting.json" />
<add key="AlarmLevelConfig" value="\\resources\\alarmlevel.json" />
<add key="ReportEventLevelSetting" value="resources\ReportEventLevelSettings.json" />
<add key="WorkAreaFilePath" value="\\resources\\WorkAreaSettings-N2107.json" />
<add key="StationsCsvFilePath" value="\\resources\\N2107_1116.csv" />
<add key="CadDwgFilePath" value="\\resources\\N2107_V2013_1117.dwg" />
<!--<add key="CadDwgFilePath" value="\\resources\\余吾煤业N1100布设图_2013_20230204.dwg" />-->
<add key="DwgJsonSetting" value="resources\DwgSetting.json" />
<!--<add key="DwgSettings" value="\\resources\\DwgSettings.txt" />-->
<add key="WavesMseedFilePath" value="D:\EwsCache\Mseed" />
<add key="WavesTxtFilePath" value="D:\EwsCache\Txt" />
<add key="IsDesign" value="false" />
<add key="IsRealtime" value="true" />
<add key="RealtimeResultTable" value="realtimeeventresult" />
<add key="RealtimeWaveDataTable" value="realtimewavedatas" />
<add key="RealtimeFocalmechanismTable" value="realtimefocalmechanism" />
<add key="PostResultTable" value="postproeventresult" />
<add key="PostWaveDataTable" value="postproeventwavedatas" />
<add key="PostFocalmechanismTable" value="postprofocalmechanism" />
<add key="CommpanyName" value="河南理工大学" />
<add key="SystemNameCn" value="煤矿动力灾害微地震实时预警系统" />
<add key="日报起始时间" value="00:00:00" />
<add key="日报平面图横向偏移" value="-200" />
<add key="日报平面图纵向偏移" value="-350" />
<!--<add key="CommpanyName" value="工程技术研究院" />
<add key="SystemNameCn" value="微地震实时监测系统" />-->
<add key="SystemNameEn" value="Microseismic Real-time Monitoring System" />
<add key="WorkAreaName" value="N2107" />
<add key="SystemShortName" value="预警系统" />
<add key="RefreshInterval" value="10" />
<add key="LocalSqLiteDb" value="EwsLocalSqLite.db" />
<add key="EventShowTotalSeconds" value="86400" />
<add key="BaseX" value="38396517" />
<add key="BaseY" value="4029418" />
<add key="BaseZ" value="1208" />
<add key="LoadDataTimeLenMins" value="720" />
<add key="DataCacheTimeLenMins" value="720" />
</appSettings>
<connectionStrings>
<add name="TencetnMySQL" connectionString="Data Source=bj-cdb-q64mbxr6.sql.tencentcdb.com;Port=60027;Database=yuwu2026;User=yuwudba;Password=Yw123456;SslMode = none;" />
<add name="NasMySQL" connectionString="Data Source=tayfx.work;Port=60027;Database=YuwuN1100;User=yuwudba;Password=Yw123456;SslMode = none;" />
</connectionStrings>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>

@ -5,7 +5,6 @@ using Prism.Services.Dialogs;
using Prism.Unity; using Prism.Unity;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -61,11 +60,8 @@ namespace Txgy.EWS.Client.Start
protected override Window CreateShell() protected override Window CreateShell()
{ {
//bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString(), out GlobalConfig.IsDesign); var config = BusinessConfigManager.Current;
//Console.WriteLine(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString()); GlobalConfig.InitializeRuntimeSettings(config.Runtime);
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());
Debug.WriteLine(GlobalConfig.LoadDataTimeLenMins); Debug.WriteLine(GlobalConfig.LoadDataTimeLenMins);
Debug.WriteLine(GlobalConfig.DataCacheTimeLenMins); Debug.WriteLine(GlobalConfig.DataCacheTimeLenMins);
return Container.Resolve<MainWindow>(); return Container.Resolve<MainWindow>();
@ -89,7 +85,6 @@ namespace Txgy.EWS.Client.Start
else else
{ {
//CommonLogHelper.Debug("====Start=====>"); //CommonLogHelper.Debug("====Start=====>");
//Console.WriteLine(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString());
base.InitializeShell(shell); base.InitializeShell(shell);
} }
} }

@ -151,6 +151,9 @@
</EmbeddedResource> </EmbeddedResource>
<None Include=".editorconfig" /> <None Include=".editorconfig" />
<None Include="ClassDiagram1.cd" /> <None Include="ClassDiagram1.cd" />
<None Include="config\client-settings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>

@ -17,7 +17,6 @@ namespace Txgy.EWS.Client.Start.ViewModels
{ {
public MainWindowViewModel() public MainWindowViewModel()
{ {
//WorkArea= System.Configuration.ConfigurationManager.AppSettings["WorkArea"].ToString();
//GlobalData.SearchEventResults = new ObservableCollection<RemoteRealtimeResultEntity>(); //GlobalData.SearchEventResults = new ObservableCollection<RemoteRealtimeResultEntity>();
//GlobalData.DisplayEvents = new List<GridItemEventResult>(); //GlobalData.DisplayEvents = new List<GridItemEventResult>();
//GlobalConfig.ReadConfig(); //GlobalConfig.ReadConfig();

@ -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
}
}
Loading…
Cancel
Save