2023-04-13 11:51:03 +08:00
|
|
|
using System;
|
2023-09-13 17:31:22 +08:00
|
|
|
using Aitex.Core.Account;
|
2023-04-13 11:51:03 +08:00
|
|
|
using MECF.Framework.Common.CommonData;
|
|
|
|
|
|
|
|
namespace MECF.Framework.Common.Account.Extends
|
|
|
|
{
|
|
|
|
[Serializable]
|
|
|
|
public class UserContext : NotifiableItem
|
|
|
|
{
|
2023-09-13 17:31:22 +08:00
|
|
|
#region Variables
|
|
|
|
|
|
|
|
private Credential _cred;
|
2023-04-13 11:51:03 +08:00
|
|
|
private string _loginName;
|
2023-09-13 17:31:22 +08:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
public Credential Credential
|
2023-04-13 11:51:03 +08:00
|
|
|
{
|
2023-09-13 17:31:22 +08:00
|
|
|
get => _cred;
|
2023-04-13 11:51:03 +08:00
|
|
|
set
|
|
|
|
{
|
2023-09-13 17:31:22 +08:00
|
|
|
_cred = value;
|
|
|
|
InvokePropertyChanged(nameof(Token));
|
|
|
|
InvokePropertyChanged(nameof(LoginName));
|
|
|
|
InvokePropertyChanged(nameof(LoginTime));
|
2023-04-13 11:51:03 +08:00
|
|
|
}
|
|
|
|
}
|
2023-09-13 17:31:22 +08:00
|
|
|
|
|
|
|
public Guid Token => _cred.Token;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
2023-09-13 17:31:22 +08:00
|
|
|
public string LoginName => _cred?.AccountInfo?.LoginName ?? "";
|
|
|
|
|
|
|
|
public DateTime LoginTime => _cred?.LoginTime ?? DateTime.MinValue;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
2023-09-13 17:31:22 +08:00
|
|
|
public Role Role { get; set; }
|
2023-04-13 11:51:03 +08:00
|
|
|
|
2023-09-13 17:31:22 +08:00
|
|
|
public DateTime LastAccessTime { get; set; }
|
2023-08-29 11:16:43 +08:00
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
public string Language { get; private set; }
|
|
|
|
|
|
|
|
public bool IsLogin { get; set; }
|
2023-09-06 14:45:06 +08:00
|
|
|
|
2023-09-13 17:31:22 +08:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
{
|
|
|
|
_cred = Credential.Empty;
|
|
|
|
Role = null;
|
|
|
|
LastAccessTime = DateTime.MinValue;
|
|
|
|
Language = string.Empty;
|
|
|
|
IsLogin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2023-09-06 14:45:06 +08:00
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
}
|