diff --git a/LoginWindow.xaml.cs b/LoginWindow.xaml.cs
index b7091c8..95c3fd4 100644
--- a/LoginWindow.xaml.cs
+++ b/LoginWindow.xaml.cs
@@ -37,15 +37,16 @@ public partial class LoginWindow : Window
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
{
#if DEBUG
+
new MainWindow().Show();
this.Close();
+
#else
string account = AccountTextBox.Text;
string password = PasswordBox.Password;
string passwordEnc = Common.GenerateMd5Hash(password);
string passworddb = getPassword(account);
- string passworddbEnc = Common.GenerateMd5Hash(passworddb);
- if (string.IsNullOrEmpty(passworddb) || !passwordEnc.Equals(passworddbEnc))
+ if (string.IsNullOrEmpty(password) || !passworddb.Equals(passwordEnc))
{
MessageBox.Show(MultilingualHelper.getString("NoPassword"));
return;
@@ -58,22 +59,24 @@ public partial class LoginWindow : Window
private void savePassword()
{
- if (IsRemberPassword.IsChecked ?? false || "Admin".Equals(AccountTextBox.Text))
+ if (IsRemberPassword.IsChecked ?? false)
{
- Settings saveAccount = new Settings()
- {
- Key = "SAVE_ACCOUNT",
- ItemName = "保存用户名",
- Value = AccountTextBox.Text,
- };
- saveAccount.insert();
- Settings savePassword = new Settings()
- {
- Key = "SAVE_PASSWORD",
- ItemName = "保存密码",
- Value = PasswordBox.Password,
- };
- savePassword.insert();
+ if (!"admin".Equals(AccountTextBox.Text)){
+ Settings saveAccount = new Settings()
+ {
+ Key = "SAVE_ACCOUNT",
+ ItemName = "保存用户名",
+ Value = AccountTextBox.Text,
+ };
+ saveAccount.insert();
+ Settings savePassword = new Settings()
+ {
+ Key = "SAVE_PASSWORD",
+ ItemName = "保存密码",
+ Value = PasswordBox.Password,
+ };
+ savePassword.insert();
+ }
}
else
{
@@ -96,7 +99,7 @@ public partial class LoginWindow : Window
{
Key = "PERMISSIONS",
ItemName = "权限",
- Value = PasswordBox.Password,
+ Value = AccountTextBox.Text,
};
PERMISSIONS.insert();
}
@@ -104,7 +107,7 @@ public partial class LoginWindow : Window
private string getPassword(string userName)
{
string password = string.Empty;
- string sql = $"SELECT USER_PASSWORD FROM USER WHERE USER_NAME='{userName}'";
+ string sql = $"SELECT USER_PASSWORD FROM USER WHERE USER_NAME='{userName}';";
DataTable dt = DataBaseHelper.ExecuteQuery(sql);
if (dt != null && dt.Rows.Count > 0)
{
diff --git a/SparkClient.csproj b/SparkClient.csproj
index a9cc9e6..1d8246f 100644
--- a/SparkClient.csproj
+++ b/SparkClient.csproj
@@ -74,7 +74,7 @@
Always
- Always
+ PreserveNewest
diff --git a/SparkDB.db b/SparkDB.db
index 1136fa7..70ebe87 100644
Binary files a/SparkDB.db and b/SparkDB.db differ
diff --git a/ViewModel/Configuration/AlgorithmConfigVM.cs b/ViewModel/Configuration/AlgorithmConfigVM.cs
index 3568c4e..3bb8c71 100644
--- a/ViewModel/Configuration/AlgorithmConfigVM.cs
+++ b/ViewModel/Configuration/AlgorithmConfigVM.cs
@@ -7,32 +7,35 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SparkClient.Model.Entity;
using SparkClient.Model.Helper;
+using SparkClient.ViewModel.Configuration.SettingsPages;
namespace SparkClient.ViewModel.Configuration;
public class AlgorithmConfigVM : BaseViewModel
{
- public ICommand SaveAlgorithmDataCommand { get; }
- public ICommand BeautifyJsonCommand { get; }
- public ICommand UglifyJsonCommand { get; }
-
-
- private string _AlgorithmConfigJson;
- public string AlgorithmConfigJson { get { return _AlgorithmConfigJson; } set { _AlgorithmConfigJson = value; OnPropertyChanged("AlgorithmConfigJson"); } }
- public AlgorithmConfigVM()
- {
- SaveAlgorithmDataCommand = new RelayCommand(SaveAlgorithmData);
- BeautifyJsonCommand = new RelayCommand(BeautifyJson);
- UglifyJsonCommand = new RelayCommand(UglifyJson);
- InitAlgorithmData(null);
- }
-
- ///
- /// 初始化算法数据
- ///
- ///
- public void InitAlgorithmData(object param)
- {
+ public ICommand SaveAlgorithmDataCommand { get; }
+ public ICommand BeautifyJsonCommand { get; }
+ public ICommand UglifyJsonCommand { get; }
+
+ private bool _isEnabled;
+ public bool IsEnabled { get { return _isEnabled; } set { _isEnabled = value; OnPropertyChanged(nameof(IsEnabled)); } }
+
+ private string _AlgorithmConfigJson;
+ public string AlgorithmConfigJson { get { return _AlgorithmConfigJson; } set { _AlgorithmConfigJson = value; OnPropertyChanged("AlgorithmConfigJson"); } }
+ public AlgorithmConfigVM()
+ {
+ SaveAlgorithmDataCommand = new RelayCommand(SaveAlgorithmData);
+ BeautifyJsonCommand = new RelayCommand(BeautifyJson);
+ UglifyJsonCommand = new RelayCommand(UglifyJson);
+ InitAlgorithmData(null);
+ }
+
+ ///
+ /// 初始化算法数据
+ ///
+ ///
+ public void InitAlgorithmData(object param)
+ {
AlgorithmConfigJson = "{}";
string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER";
DataTable dataTable = DataBaseHelper.ExecuteQuery(sql);
@@ -44,26 +47,26 @@ public class AlgorithmConfigVM : BaseViewModel
sb.Append(row["json"].ToString());
}
}
- if(sb.Length>0)
+ if (sb.Length > 0)
{
AlgorithmConfigJson = JToken.Parse(sb.ToString()).ToString();
}
}
-
- ///
- /// 保存数据
- ///
- ///
- public void SaveAlgorithmData(object param)
- {
+
+ ///
+ /// 保存数据
+ ///
+ ///
+ public void SaveAlgorithmData(object param)
+ {
DataBaseHelper.BeginTransaction();
string temp = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(AlgorithmConfigJson));
string deleteSql = @"DELETE FROM ALGORITHM_CONFIG";
DataBaseHelper.ExecuteNonQuery(deleteSql);
int order = 0;
int insertCount = 0;
- while (temp.Length>2000)
+ while (temp.Length > 2000)
{
AlgorithmConfigEntity entity = new AlgorithmConfigEntity()
{
@@ -80,7 +83,7 @@ public class AlgorithmConfigVM : BaseViewModel
};
insertCount += DataBaseHelper.ExecuteNonQuery(sql, sqliteParameters);
}
- if (temp.Length>0)
+ if (temp.Length > 0)
{
AlgorithmConfigEntity entity = new AlgorithmConfigEntity()
{
@@ -106,8 +109,18 @@ public class AlgorithmConfigVM : BaseViewModel
Growl.Error(MultilingualHelper.getString("SaveFail"));
DataBaseHelper.rollback();
}
- }
-
+ }
+ private void IsEnabledByRole (){
+ string PERMISSIONS = Settings.SelectValueByName("PERMISSIONS");
+ if ("admin".Equals(PERMISSIONS))
+ {
+ IsEnabled = true;
+ }
+ else
+ {
+ IsEnabled = false;
+ }
+ }
///
/// 美化JSON
///
@@ -122,8 +135,6 @@ public class AlgorithmConfigVM : BaseViewModel
{
Growl.ErrorGlobal(ex.Message);
}
-
-
}
///
diff --git a/ViewModel/Configuration/CutConfigVM.cs b/ViewModel/Configuration/CutConfigVM.cs
index 4f3dd7b..f774c8c 100644
--- a/ViewModel/Configuration/CutConfigVM.cs
+++ b/ViewModel/Configuration/CutConfigVM.cs
@@ -7,6 +7,7 @@ using SparkClient.Model.Helper;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
using System.Text.RegularExpressions;
using Microsoft.Data.Sqlite;
+using SparkClient.ViewModel.Configuration.SettingsPages;
namespace SparkClient.ViewModel.Configuration;
@@ -16,6 +17,8 @@ public class CutConfigVM: BaseViewModel
public ICommand SaveCutConfigDataCommand { get; }
public ICommand DelCutRowCommand { get; }
+ private bool _isEnabled;
+ public bool IsEnabled { get { return _isEnabled; } set { _isEnabled = value; OnPropertyChanged(nameof(IsEnabled)); } }
public DataTable _cutterInfos;
public DataTable CutterInfos { get { return _cutterInfos; } set { _cutterInfos = value; OnPropertyChanged("CutterInfos"); } }
@@ -144,7 +147,18 @@ public class CutConfigVM: BaseViewModel
Growl.Error("保存失败");
}
}
-
+ private void IsEnabledByRole()
+ {
+ string PERMISSIONS = Settings.SelectValueByName("PERMISSIONS");
+ if ("admin".Equals(PERMISSIONS))
+ {
+ IsEnabled = true;
+ }
+ else
+ {
+ IsEnabled = false;
+ }
+ }
///
/// 删除一行数据
///
diff --git a/ViewModel/Grading/DiamondSelectVM.cs b/ViewModel/Grading/DiamondSelectVM.cs
index 2d7d3a7..9af3dcc 100644
--- a/ViewModel/Grading/DiamondSelectVM.cs
+++ b/ViewModel/Grading/DiamondSelectVM.cs
@@ -116,7 +116,7 @@ public class DiamondSelectVM : BaseViewModel
{
#if DEBUG
DoStartGrading(param);
- #else
+#else
LoadingDialog loading = new LoadingDialog();
try
{
@@ -204,7 +204,7 @@ public class DiamondSelectVM : BaseViewModel
ShowErrorMessage(MultilingualHelper.getString("JsonParseFailure"), loading);
return;
}
- parameter.Standard = "IGI 2024";
+ parameter.Standard = getStandardName();
parameter.Shape = value.Split(" ")[0];
parameter.CrownType = value.Split(" ")[1];
parameter.PavType = value.Split(" ")[2];
@@ -238,9 +238,22 @@ public class DiamondSelectVM : BaseViewModel
finally {
}
- #endif
+#endif
}
+ private string getStandardName()
+ {
+ string sql = $"select\r\nRULE_NAME AS NAME,\r\nRULE_EN_NAME AS EN_NAME\r\nfrom\r\nsetting\r\nleft join rule\r\non setting.SETTING_P = rule.RULE_ID\r\nwhere\r\nsetting.SETTING_ID = 'RuleId'\r\n";
+ DataTable dataTable = DataBaseHelper.ExecuteQuery(sql);
+ if (dataTable == null || dataTable.Rows.Count == 0)
+ {
+ return "";
+ }
+ else
+ {
+ return dataTable.Rows[0][MultilingualHelper.getString("NameType")].ToString()??"";
+ }
+ }
// 将 UI 操作调度到主线程并显示错误信息
void ShowErrorMessage(string errorMessage, LoadingDialog loading)
{
diff --git a/Views/Configuration/AlgorithmConfigPage.xaml b/Views/Configuration/AlgorithmConfigPage.xaml
index 3b6268b..7c6ce8b 100644
--- a/Views/Configuration/AlgorithmConfigPage.xaml
+++ b/Views/Configuration/AlgorithmConfigPage.xaml
@@ -23,7 +23,7 @@