|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
using HandyControl.Controls; |
|
|
|
|
using log4net; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
using SparkClient.Model.Entity.Base; |
|
|
|
|
using SparkClient.Model.Helper; |
|
|
|
@ -17,6 +18,7 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
{ |
|
|
|
|
public class SettingsVM : BaseViewModel |
|
|
|
|
{ |
|
|
|
|
private static readonly ILog Logger = LogManager.GetLogger(typeof(ModelColorSetPageVM)); |
|
|
|
|
public ICommand SelectFileCommand { get; } |
|
|
|
|
|
|
|
|
|
public string _languageId; |
|
|
|
@ -47,36 +49,51 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
public DataTable Rules { get { return _rules; } set { _rules = value; OnPropertyChanged(nameof(Rules)); } } |
|
|
|
|
public SettingsVM() |
|
|
|
|
{ |
|
|
|
|
try { |
|
|
|
|
SelectFileCommand = new RelayCommand(SelectFile); |
|
|
|
|
InitSetting(); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error($"全局异常捕获:{ex.Message}", ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void InitSetting() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
Languages = new DataTable(); |
|
|
|
|
Languages.Columns.Add("Key"); |
|
|
|
|
Languages.Columns.Add("Value"); |
|
|
|
|
Languages.Rows.Add("中文", "zh-cn"); |
|
|
|
|
Languages.Rows.Add("English", "en"); |
|
|
|
|
LanguageId = Settings.SelectValueByName("LanguageId"); |
|
|
|
|
LanguageId = Settings.SelectValueById("LanguageId"); |
|
|
|
|
if (LanguageId.Length == 0) |
|
|
|
|
{ |
|
|
|
|
LanguageId = "zh-cn"; |
|
|
|
|
} |
|
|
|
|
bool.TryParse( Settings.SelectValueByName("TxtFileChecked"), out bool TxtFileChecked); |
|
|
|
|
bool.TryParse( Settings.SelectValueById("TxtFileChecked"), out bool TxtFileChecked); |
|
|
|
|
this.TxtFileChecked = TxtFileChecked; |
|
|
|
|
bool.TryParse(Settings.SelectValueByName("StlFileChecked"), out bool StlFileChecked); |
|
|
|
|
bool.TryParse(Settings.SelectValueById("StlFileChecked"), out bool StlFileChecked); |
|
|
|
|
this.StlFileChecked = StlFileChecked; |
|
|
|
|
bool.TryParse(Settings.SelectValueByName("ExcelFileChecked"), out bool ExcelFileChecked); |
|
|
|
|
bool.TryParse(Settings.SelectValueById("ExcelFileChecked"), out bool ExcelFileChecked); |
|
|
|
|
this.ExcelFileChecked = ExcelFileChecked; |
|
|
|
|
bool.TryParse(Settings.SelectValueByName("DatFileChecked"), out bool DatFileChecked); |
|
|
|
|
bool.TryParse(Settings.SelectValueById("DatFileChecked"), out bool DatFileChecked); |
|
|
|
|
this.DatFileChecked = DatFileChecked; |
|
|
|
|
FilePath = Settings.SelectValueByName("FilePath"); |
|
|
|
|
RuleId = Settings.SelectValueByName("RuleId"); |
|
|
|
|
FilePath = Settings.SelectValueById("FilePath"); |
|
|
|
|
RuleId = Settings.SelectValueById("RuleId"); |
|
|
|
|
selectRules(); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error($"全局异常捕获:{ex.Message}", ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void selectRules() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
Rules = new DataTable(); |
|
|
|
|
Rules.Columns.Add("Key"); |
|
|
|
@ -87,9 +104,16 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
{ |
|
|
|
|
Rules.Rows.Add(row[MultilingualHelper.getString("RULE_NAME")].ToString(), row["RULE_ID"].ToString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error($"全局异常捕获:{ex.Message}", ex); |
|
|
|
|
} |
|
|
|
|
//Rules.Rows.Add("IGI 2023", "IGI2023"); |
|
|
|
|
} |
|
|
|
|
public bool SaveUpdate(object param) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (!Directory.Exists(FilePath)) |
|
|
|
|
{ |
|
|
|
@ -102,7 +126,15 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
Growl.InfoGlobal(MultilingualHelper.getString("Save_successful_message")); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error($"全局异常捕获:{ex.Message}", ex); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
private void updateDataBase() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
// 语言设置登录 |
|
|
|
|
Settings LanguageData = new Settings() |
|
|
|
@ -161,6 +193,11 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
}; |
|
|
|
|
RuleData.insert(); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Error($"全局异常捕获:{ex.Message}", ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public void SelectFile(object param) |
|
|
|
|
{ |
|
|
|
|
using (var folderBrowserDlg = new FolderBrowserDialog()) |
|
|
|
@ -182,6 +219,9 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 设定表实体 |
|
|
|
|
/// </summary> |
|
|
|
|
public class Settings |
|
|
|
|
{ |
|
|
|
|
private static string TABLE_NAME = "SETTING"; |
|
|
|
@ -203,7 +243,10 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
/// </summary> |
|
|
|
|
[DbField("SETTING_P")] |
|
|
|
|
public required string Value { get; set; } |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 设定表DB登录 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <returns>更新数量</returns> |
|
|
|
|
public int insert() |
|
|
|
|
{ |
|
|
|
|
string sql = $"SELECT * FROM {TABLE_NAME} WHERE SETTING_ID = '{Key}';"; |
|
|
|
@ -219,8 +262,12 @@ namespace SparkClient.ViewModel.Configuration.SettingsPages |
|
|
|
|
return DataBaseHelper.ExecuteNonQuery(insertSql); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static string SelectValueByName(string Id) |
|
|
|
|
/// <summary> |
|
|
|
|
/// 设定表值检索 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="Id"></param> |
|
|
|
|
/// <returns>value</returns> |
|
|
|
|
public static string SelectValueById(string Id) |
|
|
|
|
{ |
|
|
|
|
string sql = $"SELECT * FROM {TABLE_NAME} WHERE SETTING_ID = '{Id}';"; |
|
|
|
|
DataTable db = DataBaseHelper.ExecuteQuery(sql); |
|
|
|
|