diff --git a/MECF.Framework.Common/Aitex/Core/Account/CredentialManager.cs b/MECF.Framework.Common/Aitex/Core/Account/CredentialManager.cs index f9b3803..ac24840 100644 --- a/MECF.Framework.Common/Aitex/Core/Account/CredentialManager.cs +++ b/MECF.Framework.Common/Aitex/Core/Account/CredentialManager.cs @@ -14,7 +14,25 @@ public class CredentialManager : Singleton { #region Variables - private const int KEEP_ALIVE_TIMEOUT_SEC = 60; + /// + /// 已登录的凭据激活超时时间。 + /// + /// + /// 如果凭据超过此时间没有被激活,则自动移除此凭据。 + /// + public const int LOGIN_CRED_KEEP_ALIVE_TIMEOUT_SEC = 60; + + /// + /// 正在请求登录的凭据的生命时长。 + /// + public const int REQ_LOGIN_CRED_LIFT_TIME_SEC = REQ_LOGIN_DIALOG_LIFT_TIME__SEC + 5; + + /// + /// UI中的请求登录/授权登录对话框存活时间 + /// + public const int REQ_LOGIN_DIALOG_LIFT_TIME__SEC = 30; + + private readonly object _syncRoot = new(); @@ -88,11 +106,13 @@ public class CredentialManager : Singleton { lock (_syncRoot) { + #region 已登录凭据存活检测 + var loginRemovableList = new List(); foreach (var kvp in _dictCredentialsLoggedIn) { var cred = kvp.Value; - if ((DateTime.Now - cred.LastAliveTime).TotalSeconds > KEEP_ALIVE_TIMEOUT_SEC) + if ((DateTime.Now - cred.LastAliveTime).TotalSeconds > LOGIN_CRED_KEEP_ALIVE_TIMEOUT_SEC) { loginRemovableList.Add(cred.Token); EV.PostLoginBySameUser(cred.Token, new Credential()); @@ -108,11 +128,15 @@ public class CredentialManager : Singleton } } + #endregion + + #region 请求登录凭据存活检测 + var requestRemovableList = new List(); foreach (var kvp in _dictCredentialsRequesting) { var cred = kvp.Value; - if ((DateTime.Now - cred.LastAliveTime).TotalSeconds > KEEP_ALIVE_TIMEOUT_SEC) + if ((DateTime.Now - cred.LastAliveTime).TotalSeconds > REQ_LOGIN_CRED_LIFT_TIME_SEC) requestRemovableList.Add(kvp.Key); } @@ -126,6 +150,8 @@ public class CredentialManager : Singleton } return true; + + #endregion } } diff --git a/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestConfirmationDialog.xaml.cs b/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestConfirmationDialog.xaml.cs index 6fc4446..80268ec 100644 --- a/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestConfirmationDialog.xaml.cs +++ b/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestConfirmationDialog.xaml.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; +using Aitex.Core.Account; namespace MECF.Framework.UI.Client.ClientBase.Dialog { @@ -36,7 +37,7 @@ namespace MECF.Framework.UI.Client.ClientBase.Dialog { base.OnSourceInitialized(e); - var closeTime = DateTime.Now.Add(TimeSpan.FromSeconds(30)); + var closeTime = DateTime.Now.Add(TimeSpan.FromSeconds(CredentialManager.REQ_LOGIN_DIALOG_LIFT_TIME__SEC)); Task.Run(() => { while (true) diff --git a/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestWaitDialog.xaml.cs b/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestWaitDialog.xaml.cs index 6c236ec..2d01fcc 100644 --- a/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestWaitDialog.xaml.cs +++ b/MECF.Framework.UI.Client/ClientBase/Dialog/LoginRequestWaitDialog.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Aitex.Core.Account; +using System; using System.ComponentModel; using System.Threading; using System.Threading.Tasks; @@ -37,7 +38,7 @@ namespace MECF.Framework.UI.Client.ClientBase.Dialog { base.OnSourceInitialized(e); - var closeTime = DateTime.Now.Add(TimeSpan.FromSeconds(30)); + var closeTime = DateTime.Now.Add(TimeSpan.FromSeconds(CredentialManager.REQ_LOGIN_DIALOG_LIFT_TIME__SEC)); Task.Run(() => { while (true)