diff --git a/CommonLibrary/BasicSupport/SoftSettings.cs b/CommonLibrary/BasicSupport/SoftSettings.cs
index 7bd8fc8..001d6d1 100644
--- a/CommonLibrary/BasicSupport/SoftSettings.cs
+++ b/CommonLibrary/BasicSupport/SoftSettings.cs
@@ -38,6 +38,8 @@ namespace CommonLibrary
///
public class ServerSettings : SoftFileSaveBase
{
+ #region Public Property
+
///
/// 系统的版本号,可以用来验证版本更新的依据
/// 初始化1.0.0
@@ -56,17 +58,88 @@ namespace CommonLibrary
///
public string Account_Forbidden_Reason { get; set; } = "系统处于维护中,请稍后登录。";
///
- /// 系统的所属分厂
+ /// 系统的所有分厂信息
///
public List SystemFactories { get; set; } = new List()
{
"分厂示例1","分厂示例2"
};
+ #endregion
+
+ #region TrustedClientAuthentication
+
+ ///
+ /// 是否开启仅信任客户端验证
+ ///
+ public bool WhetherToEnableTrustedClientAuthentication { get; set; } = false;
+
+ ///
+ /// 信任的客户端列表
+ ///
+ public List TrustedClientList { get; set; } = new List();
+
+ ///
+ /// 列表锁
+ ///
+ private HslCommunication.SimpleHybirdLock hybirdLock = new HslCommunication.SimpleHybirdLock();
+
+ ///
+ /// 判断一个客户端的ID能否登录到系统
+ ///
+ ///
+ ///
+ public bool CanClientLogin(string machineId)
+ {
+ bool result = false;
+ hybirdLock.Enter();
+ result = TrustedClientList.Contains(machineId);
+ hybirdLock.Leave();
+ return result;
+ }
+
+ ///
+ /// 新增一个客户端ID到信任列表中,新增成功True,原来已经存在False
+ ///
+ ///
+ ///
+ public bool AddTrustedClient(string machineId)
+ {
+ bool result = false;
+ hybirdLock.Enter();
+ if(!TrustedClientList.Contains(machineId))
+ {
+ TrustedClientList.Add(machineId);
+ result = true;
+ }
+ hybirdLock.Leave();
+ return result;
+ }
+ ///
+ /// 从信任的列表中删除一个存在的客户端ID
+ ///
+ ///
+ public bool DeleteTrustedClient(string machineId)
+ {
+ bool result = false;
+ hybirdLock.Enter();
+ if (TrustedClientList.Contains(machineId))
+ {
+ TrustedClientList.Remove(machineId);
+ result = true;
+ }
+ hybirdLock.Leave();
+ return result;
+ }
+
+
+ #endregion
+ #region Override Method
+
///
/// 获取需要存储的数据
@@ -80,7 +153,9 @@ namespace CommonLibrary
{ nameof(Announcement), new JValue(Announcement) },
{ nameof(Can_Account_Login), new JValue(Can_Account_Login) },
{ nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) },
- { nameof(SystemFactories), new JArray(SystemFactories) }
+ { nameof(SystemFactories), new JArray(SystemFactories) },
+ { nameof(WhetherToEnableTrustedClientAuthentication),new JValue(WhetherToEnableTrustedClientAuthentication) },
+ { nameof(TrustedClientList),new JArray(TrustedClientList) }
};
return json.ToString();
}
@@ -91,13 +166,17 @@ namespace CommonLibrary
public override void LoadByString(string content)
{
JObject json = JObject.Parse(content);
- SystemVersion = new SystemVersion(json.Property(nameof(SystemVersion)).Value.Value());
- Announcement = json.Property(nameof(Announcement)).Value.Value();
+ SystemVersion = new SystemVersion(SoftBasic.GetValueFromJsonObject(json, nameof(SystemVersion), "1.0.0"));
+ Announcement = SoftBasic.GetValueFromJsonObject(json, nameof(Announcement), Announcement);
Can_Account_Login = SoftBasic.GetValueFromJsonObject(json, nameof(Can_Account_Login), Can_Account_Login);
Account_Forbidden_Reason = SoftBasic.GetValueFromJsonObject(json, nameof(Account_Forbidden_Reason), Account_Forbidden_Reason);
SystemFactories = JArray.Parse(SoftBasic.GetValueFromJsonObject(json, nameof(SystemFactories), "[]")).ToObject>();
+ WhetherToEnableTrustedClientAuthentication = SoftBasic.GetValueFromJsonObject(json, nameof(WhetherToEnableTrustedClientAuthentication), false);
+ TrustedClientList = JArray.Parse(SoftBasic.GetValueFromJsonObject(json, nameof(TrustedClientList), "[]")).ToObject>();
}
+ #endregion
+
}
@@ -113,6 +192,9 @@ namespace CommonLibrary
{
SystemInfo = SoftAuthorize.GetInfo();
}
+
+
+
///
/// 指示系统是否是更新后第一次运行
///
@@ -141,7 +223,10 @@ namespace CommonLibrary
public string SystemInfo { get; private set; }
-
+ #region Override Method
+
+
+
public override string ToSaveString()
{
JObject json = new JObject();
@@ -176,10 +261,16 @@ namespace CommonLibrary
{
LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonLibrary.Security));
}
+ ///
+ /// 使用指定的加密实现数据加密
+ ///
public override void SaveToFile()
{
SaveToFile(m => SoftSecurity.MD5Encrypt(m, CommonLibrary.Security));
}
+
+
+ #endregion
}
}
diff --git a/Public/HslCommunication.dll b/Public/HslCommunication.dll
index 9307617..dff7060 100644
Binary files a/Public/HslCommunication.dll and b/Public/HslCommunication.dll differ