parent
b2e805a0dd
commit
4898aa6911
|
@ -14,7 +14,25 @@ public class CredentialManager : Singleton<CredentialManager>
|
||||||
{
|
{
|
||||||
#region Variables
|
#region Variables
|
||||||
|
|
||||||
private const int KEEP_ALIVE_TIMEOUT_SEC = 60;
|
/// <summary>
|
||||||
|
/// 已登录的凭据激活超时时间。
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 如果凭据超过此时间没有被激活,则自动移除此凭据。
|
||||||
|
/// </remarks>
|
||||||
|
public const int LOGIN_CRED_KEEP_ALIVE_TIMEOUT_SEC = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 正在请求登录的凭据的生命时长。
|
||||||
|
/// </summary>
|
||||||
|
public const int REQ_LOGIN_CRED_LIFT_TIME_SEC = REQ_LOGIN_DIALOG_LIFT_TIME__SEC + 5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UI中的请求登录/授权登录对话框存活时间
|
||||||
|
/// </summary>
|
||||||
|
public const int REQ_LOGIN_DIALOG_LIFT_TIME__SEC = 30;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private readonly object _syncRoot = new();
|
private readonly object _syncRoot = new();
|
||||||
|
|
||||||
|
@ -88,11 +106,13 @@ public class CredentialManager : Singleton<CredentialManager>
|
||||||
{
|
{
|
||||||
lock (_syncRoot)
|
lock (_syncRoot)
|
||||||
{
|
{
|
||||||
|
#region 已登录凭据存活检测
|
||||||
|
|
||||||
var loginRemovableList = new List<Guid>();
|
var loginRemovableList = new List<Guid>();
|
||||||
foreach (var kvp in _dictCredentialsLoggedIn)
|
foreach (var kvp in _dictCredentialsLoggedIn)
|
||||||
{
|
{
|
||||||
var cred = kvp.Value;
|
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);
|
loginRemovableList.Add(cred.Token);
|
||||||
EV.PostLoginBySameUser(cred.Token, new Credential());
|
EV.PostLoginBySameUser(cred.Token, new Credential());
|
||||||
|
@ -108,11 +128,15 @@ public class CredentialManager : Singleton<CredentialManager>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 请求登录凭据存活检测
|
||||||
|
|
||||||
var requestRemovableList = new List<string>();
|
var requestRemovableList = new List<string>();
|
||||||
foreach (var kvp in _dictCredentialsRequesting)
|
foreach (var kvp in _dictCredentialsRequesting)
|
||||||
{
|
{
|
||||||
var cred = kvp.Value;
|
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);
|
requestRemovableList.Add(kvp.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +150,8 @@ public class CredentialManager : Singleton<CredentialManager>
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using Aitex.Core.Account;
|
||||||
|
|
||||||
namespace MECF.Framework.UI.Client.ClientBase.Dialog
|
namespace MECF.Framework.UI.Client.ClientBase.Dialog
|
||||||
{
|
{
|
||||||
|
@ -36,7 +37,7 @@ namespace MECF.Framework.UI.Client.ClientBase.Dialog
|
||||||
{
|
{
|
||||||
base.OnSourceInitialized(e);
|
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(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Aitex.Core.Account;
|
||||||
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -37,7 +38,7 @@ namespace MECF.Framework.UI.Client.ClientBase.Dialog
|
||||||
{
|
{
|
||||||
base.OnSourceInitialized(e);
|
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(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
|
Loading…
Reference in New Issue