|
@@ -52,24 +52,41 @@ namespace ivf_tl_Operate.Helpers
|
|
|
return CryptoHelper.Decrypt(raw);
|
|
return CryptoHelper.Decrypt(raw);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>配置收敛:operate↔control 共享的连接键(唯一数据源 tl-shared.config)。</summary>
|
|
|
|
|
+ private static readonly System.Collections.Generic.HashSet<string> SharedKeys =
|
|
|
|
|
+ new System.Collections.Generic.HashSet<string>(System.StringComparer.OrdinalIgnoreCase)
|
|
|
|
|
+ { "urlIp", "urlPort", "mqttIp", "mqttPort", "kfkaIP", "kfkaPort", "outInter" };
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>共享文件路径 = operate 输出根目录\tl-shared.config(control 经 ..\ 指此)。</summary>
|
|
|
|
|
+ public static string SharedConfigPath =>
|
|
|
|
|
+ System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "tl-shared.config");
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 写回普通键(沿用 OpenExeConfiguration + RefreshSection,对齐 AppData.SetApp 写法)。
|
|
|
|
|
|
|
+ /// 写回普通键。配置收敛:共享键落唯一数据源 tl-shared.config(SharedConfigStore),
|
|
|
|
|
+ /// 非共享键沿用 OpenExeConfiguration 落 operate 自己的 config。写后刷新本进程缓存。
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
public static void Save(string key, string value)
|
|
public static void Save(string key, string value)
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
|
|
|
- if (config.AppSettings.Settings[key] == null)
|
|
|
|
|
- config.AppSettings.Settings.Add(key, value);
|
|
|
|
|
|
|
+ if (SharedKeys.Contains(key))
|
|
|
|
|
+ {
|
|
|
|
|
+ SharedConfigStore.Write(SharedConfigPath, key, value);
|
|
|
|
|
+ }
|
|
|
else
|
|
else
|
|
|
- config.AppSettings.Settings[key].Value = value;
|
|
|
|
|
- config.Save(ConfigurationSaveMode.Modified);
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
|
|
|
+ if (config.AppSettings.Settings[key] == null)
|
|
|
|
|
+ config.AppSettings.Settings.Add(key, value);
|
|
|
|
|
+ else
|
|
|
|
|
+ config.AppSettings.Settings[key].Value = value;
|
|
|
|
|
+ config.Save(ConfigurationSaveMode.Modified);
|
|
|
|
|
+ }
|
|
|
ConfigurationManager.RefreshSection("appSettings");
|
|
ConfigurationManager.RefreshSection("appSettings");
|
|
|
}
|
|
}
|
|
|
catch
|
|
catch
|
|
|
{
|
|
{
|
|
|
- // 写失败不抛出(避免阻断 UI/启动);[M7] 运行环境核查落盘。
|
|
|
|
|
|
|
+ // 写失败不抛出(避免阻断 UI/启动);[M7] 运行环境核查落盘。
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|