From 77ec57f97eda83fadb181889264c70a936af3246 Mon Sep 17 00:00:00 2001 From: SL <123@123.com> Date: Tue, 29 Aug 2023 11:16:43 +0800 Subject: [PATCH] Backup --- .../Aitex/Core/Account/LoginResult.cs | 15 ++++---- .../Common/Account/AccountExManager.cs | 24 ++++++++----- .../Common/Account/Extends/AccountEx.cs | 7 +--- .../Common/Account/Extends/UserContext.cs | 36 ++++--------------- .../CenterViews/LogOnOff/LogoffViewModel.cs | 2 +- 5 files changed, 32 insertions(+), 52 deletions(-) diff --git a/MECF.Framework.Common/Aitex/Core/Account/LoginResult.cs b/MECF.Framework.Common/Aitex/Core/Account/LoginResult.cs index 3946719..07c4f25 100644 --- a/MECF.Framework.Common/Aitex/Core/Account/LoginResult.cs +++ b/MECF.Framework.Common/Aitex/Core/Account/LoginResult.cs @@ -1,4 +1,5 @@ using System; +using MECF.Framework.Common.Account.Extends; namespace Aitex.Core.Account { @@ -6,30 +7,30 @@ namespace Aitex.Core.Account public class LoginResult { /// - /// 设置或返回是否登录成功。 + /// 璁剧疆鎴栬繑鍥炴槸鍚︾櫥褰曟垚鍔熴 /// public bool ActSucc { get; set; } /// - /// 设置或返回登录成功后RT分配的唯一识别码。 + /// 璁剧疆鎴栬繑鍥炵櫥褰曟垚鍔熷悗RT鍒嗛厤鐨勫敮涓璇嗗埆鐮併 /// - /// 该唯一识别码用于在RT区分每一个不同的客户端连接。 + /// 璇ュ敮涓璇嗗埆鐮佺敤浜庡湪RT鍖哄垎姣忎竴涓笉鍚岀殑瀹㈡埛绔繛鎺ャ /// /// public string SessionId { get; set; } /// - /// 设置或返回登录的账户信息。 + /// 璁剧疆鎴栬繑鍥炵櫥褰曠殑璐︽埛淇℃伅銆 /// - public Account AccountInfo { get; set; } + public AccountEx AccountInfo { get; set; } /// - /// 设置或返回登录结果描述。 + /// 璁剧疆鎴栬繑鍥炵櫥褰曠粨鏋滄弿杩般 /// public string Description { get; set; } /// - /// 设置或返回登录时间。 + /// 璁剧疆鎴栬繑鍥炵櫥褰曟椂闂淬 /// public DateTime LoginTime { get; set; } } diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/AccountExManager.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/AccountExManager.cs index 8300920..d75b38c 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/AccountExManager.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/AccountExManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security.Principal; using System.Threading; using Aitex.Common.Util; using Aitex.Core.Account; @@ -18,7 +19,9 @@ namespace MECF.Framework.Common.Account { #region Variables - private readonly Dictionary _loginUserList = new (); + private readonly Dictionary _dicLoginNameToLoginResult = new (); + private readonly Dictionary _dicSessionIdToLoginResult = new (); + private readonly string _scAccountFile = PathManager.GetCfgDir() + "Account//Account.xml"; private readonly string _scAccountLocalFile = PathManager.GetCfgDir() + "Account//_Account.xml"; @@ -88,19 +91,23 @@ namespace MECF.Framework.Common.Account if (roleId == role) { loginResult.ActSucc = true; + loginResult.AccountInfo = account; loginResult.Description = AuthorizeResult.None.ToString(); - foreach (var loginUser in _loginUserList) + foreach (var kvp in _dicLoginNameToLoginResult) { + var loggedIn = kvp.Value; + if (!SC.ContainsItem("System.AllowMultiClientLogin") || !SC.GetValue("System.AllowMultiClientLogin") || - loginUser.Value.LoginName == loginName) + loggedIn.AccountInfo.LoginName == loginName) { - EV.PostKickoutMessage(loginUser.Value.SessionId); + EV.PostKickoutMessage(loggedIn.SessionId); } } account.SessionId = loginResult.SessionId; - _loginUserList[loginName] = account; + _dicLoginNameToAccountInfo[loginName] = account; + _dicSessionIdToAccountInfo[account.SessionId] = account; return loginResult; } @@ -124,11 +131,12 @@ namespace MECF.Framework.Common.Account internal void Logout(string accountId, string loginId) { - foreach (string key in _loginUserList.Keys) + foreach (string key in _dicLoginNameToAccountInfo.Keys) { - if (accountId == key && _loginUserList[key].SessionId == loginId) + if (accountId == key && _dicLoginNameToAccountInfo[key].SessionId == loginId) { - _loginUserList.Remove(key); + _dicSessionIdToAccountInfo.Remove(accou) + _dicLoginNameToAccountInfo.Remove(key); break; } } diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AccountEx.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AccountEx.cs index be10417..84a7f66 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AccountEx.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AccountEx.cs @@ -102,12 +102,7 @@ namespace MECF.Framework.Common.Account.Extends get => _mStrPassword; set => _mStrPassword = value; } - - /// - /// 璁剧疆鎴栬繑鍥炲綋鍓嶇敤鎴风櫥褰曠殑Session ID銆 - /// - public string SessionId { get; set; } - + /// /// 璁剧疆鎴栬繑鍥炲綋鍓嶇敤鎴锋槸鍚︿负瓒呯骇鐢ㄦ埛銆 /// diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/UserContext.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/UserContext.cs index e4739f5..2f44de1 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/UserContext.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/UserContext.cs @@ -7,43 +7,17 @@ namespace MECF.Framework.Common.Account.Extends public class UserContext : NotifiableItem { private string _loginName; - - private string _rolename; - - public string Address { get; set; } - - public string HostName { get; set; } - + public string LoginName { - get - { - return _loginName; - } + get => _loginName; set { _loginName = value; - InvokePropertyChanged("LoginName"); + InvokePropertyChanged(); } } - - public string RoleName - { - get - { - return _rolename; - } - set - { - _rolename = value; - InvokePropertyChanged("RoleName"); - } - } - - public string RoleID { get; set; } - - public string LoginId { get; set; } - + public Role Role { get; set; } public DateTime LoginTime { get; set; } @@ -52,6 +26,8 @@ namespace MECF.Framework.Common.Account.Extends public int Token { get; set; } + public string SessionId { get; set; } + public string Language { get; private set; } public bool IsLogin { get; set; } diff --git a/MECF.Framework.UI.Client/CenterViews/LogOnOff/LogoffViewModel.cs b/MECF.Framework.UI.Client/CenterViews/LogOnOff/LogoffViewModel.cs index b26913c..d933277 100644 --- a/MECF.Framework.UI.Client/CenterViews/LogOnOff/LogoffViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/LogOnOff/LogoffViewModel.cs @@ -12,7 +12,7 @@ namespace MECF.Framework.UI.Client.CenterViews.LogOnOff this.DisplayName = (string)Application.Current.Resources["AppName"]; this.DialogResult = UserMode.None; this.LoginName = BaseApp.Instance.UserContext.LoginName; - this.RoleName = BaseApp.Instance.UserContext.RoleName; + this.RoleName = BaseApp.Instance.UserContext.Role.RoleName; this.LoginTime = BaseApp.Instance.UserContext.LoginTime; }