diff --git a/Model/Entity/AlgorithmConfigEntity.cs b/Model/Entity/AlgorithmConfigEntity.cs
new file mode 100644
index 0000000..1b77cdd
--- /dev/null
+++ b/Model/Entity/AlgorithmConfigEntity.cs
@@ -0,0 +1,83 @@
+using SparkClient.Model.Entity.Base;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+namespace SparkClient.Model.Entity;
+
+///
+/// 系统设置实体
+///
+
+public class AlgorithmConfigEntity
+{
+ public static readonly string TableName = "ALGORITHM_CONFIG";
+ [DbField("GUID")]
+ public Guid GUID { get; set; }
+ ///
+ /// json内容
+ ///
+ [DbField("JSON")]
+ public required string Json { get; set; }
+ ///
+ /// Json排序
+ ///
+ [DbField("JSON_ORDER")]
+ public required int JsonOrder { get; set; }
+
+ private static Dictionary GetFieldMappings()
+ {
+ var properties = typeof(AlgorithmConfigEntity).GetProperties(BindingFlags.Public | BindingFlags.Instance);
+ return properties
+ .Where(p => Attribute.IsDefined(p, typeof(DbFieldAttribute)))
+ .ToDictionary(
+ p => p.Name,
+ p => ((DbFieldAttribute)p.GetCustomAttribute(typeof(DbFieldAttribute))).FieldName
+ );
+ }
+
+ // 生成 Insert 语句
+ public string GenerateInsertSQL()
+ {
+ var mappings = GetFieldMappings();
+ var columns = string.Join(", ", mappings.Values);
+ var values = string.Join(", ", mappings.Keys.Select(k => $"@{k}"));
+ return $"INSERT INTO {TableName} ({columns}) VALUES ({values});";
+ }
+
+ // 生成 Update 语句
+ public string GenerateUpdateSQL(Dictionary fieldsToUpdate = null)
+ {
+ if (fieldsToUpdate == null || fieldsToUpdate.Count == 0)
+ {
+ // 默认根据 ID 更新所有字段
+ var mappings = GetFieldMappings();
+ var setClause = string.Join(", ", mappings.Values.Select(f => $"{f} = @{f}"));
+ return $"UPDATE {TableName} SET {setClause} WHERE GUID = " + GUID.ToString() + ";";
+ }
+ else
+ {
+ // 根据传入的字段更新
+ var setClause = string.Join(", ", fieldsToUpdate.Keys.Select(f => $"{f} = @{f}"));
+ return $"UPDATE {TableName} SET {setClause} WHERE GUID = " + GUID.ToString() + ";";
+ }
+ }
+
+ // 生成 Delete 语句
+ public string GenerateDeleteSQL(Dictionary conditions = null)
+ {
+ if (conditions == null || conditions.Count == 0)
+ {
+ // 默认根据 ID 删除
+ return $"DELETE FROM {TableName} WHERE GUID =" + GUID.ToString() + ";";
+ }
+ else
+ {
+ // 根据传入条件删除
+ var whereClause = string.Join(" AND ", conditions.Keys.Select(f => $"{f} = @{f}"));
+ return $"DELETE FROM {TableName} WHERE {whereClause};";
+ }
+ }
+
+}
+
+
diff --git a/Resource/Images/Setting_Def@3x.png b/Resource/Images/Setting_Def@3x.png
new file mode 100644
index 0000000..1b2550e
Binary files /dev/null and b/Resource/Images/Setting_Def@3x.png differ
diff --git a/Resource/Images/Setting_Sel@3x.png b/Resource/Images/Setting_Sel@3x.png
new file mode 100644
index 0000000..67e98cb
Binary files /dev/null and b/Resource/Images/Setting_Sel@3x.png differ
diff --git a/ViewModel/Configuration/SettingsVM.cs b/ViewModel/Configuration/SettingsVM.cs
new file mode 100644
index 0000000..de8e69a
--- /dev/null
+++ b/ViewModel/Configuration/SettingsVM.cs
@@ -0,0 +1,234 @@
+using HandyControl.Controls;
+using Newtonsoft.Json.Linq;
+using SparkClient.Model.Entity.Base;
+using SparkClient.Model.Helper;
+using SparkClient.ViewModel.BaseWindow;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Input;
+
+namespace SparkClient.ViewModel.Configuration
+{
+ class SettingsVM : BaseViewModel
+ {
+ public ICommand SaveUpdateCommand { get; }
+ public ICommand SelectFileCommand { get; }
+
+ public string _languageId;
+ public string LanguageId { get { return _languageId; } set { _languageId = value; OnPropertyChanged(nameof(LanguageId)); } }
+
+ public bool _txtFileChecked;
+ public bool TxtFileChecked { get { return _txtFileChecked; } set { _txtFileChecked = value; OnPropertyChanged(nameof(TxtFileChecked)); } }
+
+ public bool _stlFileChecked;
+ public bool StlFileChecked { get { return _stlFileChecked; } set { _stlFileChecked = value; OnPropertyChanged(nameof(StlFileChecked)); } }
+
+ public bool _excelFileChecked;
+ public bool ExcelFileChecked { get { return _excelFileChecked; } set { _excelFileChecked = value; OnPropertyChanged(nameof(ExcelFileChecked)); } }
+
+ public bool _datFileChecked;
+ public bool DatFileChecked { get { return _datFileChecked; } set { _datFileChecked = value; OnPropertyChanged(nameof(DatFileChecked)); } }
+
+ public string _filePath;
+ public string FilePath { get { return _filePath; } set { _filePath = value; OnPropertyChanged(nameof(FilePath)); } }
+
+ public string _ruleId;
+ public string RuleId { get { return _ruleId; } set { _ruleId = value; OnPropertyChanged(nameof(RuleId)); } }
+
+ public DataTable _languages;
+ public DataTable Languages { get { return _languages; } set { _languages = value; OnPropertyChanged(nameof(Languages)); } }
+
+ public DataTable _rules;
+ public DataTable Rules { get { return _rules; } set { _rules = value; OnPropertyChanged(nameof(Rules)); } }
+ public SettingsVM()
+ {
+ SaveUpdateCommand = new RelayCommand(SaveUpdate);
+ SelectFileCommand = new RelayCommand(SelectFile);
+ InitSetting();
+ }
+
+ private void InitSetting()
+ {
+ 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");
+ bool.TryParse( Settings.SelectValueByName("TxtFileChecked"), out bool TxtFileChecked);
+ this.TxtFileChecked = TxtFileChecked;
+ bool.TryParse(Settings.SelectValueByName("StlFileChecked"), out bool StlFileChecked);
+ this.StlFileChecked = StlFileChecked;
+ bool.TryParse(Settings.SelectValueByName("ExcelFileChecked"), out bool ExcelFileChecked);
+ this.ExcelFileChecked = ExcelFileChecked;
+ bool.TryParse(Settings.SelectValueByName("DatFileChecked"), out bool DatFileChecked);
+ this.DatFileChecked = DatFileChecked;
+ FilePath = Settings.SelectValueByName("FilePath");
+ RuleId = Settings.SelectValueByName("RuleId");
+ selectRules();
+ }
+
+ private void selectRules()
+ {
+ Rules = new DataTable();
+ Rules.Columns.Add("Key");
+ Rules.Columns.Add("Value");
+ //string sql = $"SELECT * FROM RULE;";
+ //DataTable db = DataBaseHelper.ExecuteQuery(sql);
+ //foreach (DataRow row in db.Rows)
+ //{
+ // Rules.Rows.Add(row[MultilingualHelper.getString("RULE_NAME")].ToString(), row["RULE_ID"].ToString());
+ //}
+ Rules.Rows.Add("IGI 2023", "IGI2023");
+ }
+ public void SaveUpdate(object param)
+ {
+ if (!Directory.Exists(FilePath))
+ {
+ Growl.Error(MultilingualHelper.getString("SavePathIsnotExists"));
+ return;
+ }
+ MultilingualHelper.setLanguage(_languageId);
+
+ updateDataBase();
+
+ WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
+ }
+ private void updateDataBase()
+ {
+ // 语言设置登录
+ Settings LanguageData = new Settings()
+ {
+ Key = "LanguageId",
+ ItemName = "语言设置",
+ Value = LanguageId,
+ };
+ LanguageData.insert();
+ // 上传文件登录
+ Settings TxtFileCheckedData = new Settings()
+ {
+ Key = "TxtFileChecked",
+ ItemName = "上传文件 TXT文件",
+ Value = TxtFileChecked.ToString(),
+ };
+ TxtFileCheckedData.insert();
+
+ Settings StlFileCheckedData = new Settings()
+ {
+ Key = "StlFileChecked",
+ ItemName = "上传文件 STL文件",
+ Value = StlFileChecked.ToString(),
+ };
+ StlFileCheckedData.insert();
+
+ Settings ExcelFileCheckedData = new Settings()
+ {
+ Key = "ExcelFileChecked",
+ ItemName = "上传文件 Excel文件",
+ Value = ExcelFileChecked.ToString(),
+ };
+ ExcelFileCheckedData.insert();
+
+ Settings DatFileCheckedData = new Settings()
+ {
+ Key = "DatFileChecked",
+ ItemName = "上传文件 Dat文件",
+ Value = DatFileChecked.ToString(),
+ };
+ DatFileCheckedData.insert();
+ // 保存路径登录
+ Settings FilePathData = new Settings()
+ {
+ Key = "FilePath",
+ ItemName = "保存路径",
+ Value = FilePath,
+ };
+ FilePathData.insert();
+ // 定级标准登录
+ Settings RuleData = new Settings()
+ {
+ Key = "RuleId",
+ ItemName = "定级标准",
+ Value = RuleId,
+ };
+ RuleData.insert();
+ }
+ public void SelectFile(object param)
+ {
+ using (var folderBrowserDlg = new FolderBrowserDialog())
+ {
+ if (string.IsNullOrEmpty(FilePath))
+ {
+ folderBrowserDlg.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
+ }
+ else
+ {
+ folderBrowserDlg.SelectedPath = FilePath;
+ }
+ DialogResult result = folderBrowserDlg.ShowDialog();
+
+ if (result == DialogResult.OK)
+ {
+ FilePath = folderBrowserDlg.SelectedPath;
+ }
+ }
+ }
+ }
+ class Settings
+ {
+ private static string TABLE_NAME = "SETTING";
+
+ [DbField("GUID")]
+ public Guid GUID { get; set; }
+ ///
+ /// 项目名称
+ ///
+ [DbField("SETTING_ID")]
+ public required string Key { get; set; }
+ ///
+ /// key
+ ///
+ [DbField("SETTING_NAME")]
+ public required string ItemName{ get; set; }
+ ///
+ /// value
+ ///
+ [DbField("SETTING_P")]
+ public required string Value { get; set; }
+
+ public int insert()
+ {
+ string sql = $"SELECT * FROM {TABLE_NAME} WHERE SETTING_ID = '{Key}';";
+ DataTable db = DataBaseHelper.ExecuteQuery(sql);
+ if (db.Rows.Count > 0)
+ {
+ string updateSql = $"UPDATE {TABLE_NAME} SET SETTING_P = '{this.Value}' WHERE SETTING_ID = '{Key}';";
+ return DataBaseHelper.ExecuteNonQuery(updateSql);
+ }
+ else
+ {
+ string insertSql = $"INSERT INTO {TABLE_NAME} ('GUID','SETTING_ID','SETTING_NAME','SETTING_P') VALUES('{Guid.NewGuid().ToString()}','{Key}','{ItemName}','{Value}');";
+ return DataBaseHelper.ExecuteNonQuery(insertSql);
+ }
+ }
+
+ public static string SelectValueByName(string Id)
+ {
+ string sql = $"SELECT * FROM {TABLE_NAME} WHERE SETTING_ID = '{Id}';";
+ DataTable db = DataBaseHelper.ExecuteQuery(sql);
+ if (db!=null && db.Rows.Count > 0) {
+ return db.Rows[0]["SETTING_P"].ToString()??"";
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+}
diff --git a/Views/Configuration/SettingsPage.xaml b/Views/Configuration/SettingsPage.xaml
new file mode 100644
index 0000000..17e31ca
--- /dev/null
+++ b/Views/Configuration/SettingsPage.xaml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Views/Configuration/SettingsPage.xaml.cs b/Views/Configuration/SettingsPage.xaml.cs
new file mode 100644
index 0000000..acd7709
--- /dev/null
+++ b/Views/Configuration/SettingsPage.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SparkClient.Views.Configuration
+{
+ ///
+ /// SettingsPage.xaml 的交互逻辑
+ ///
+ public partial class SettingsPage
+ {
+ public SettingsPage()
+ {
+ InitializeComponent();
+ }
+ }
+}