Sic.Framework-Nanjing-Baishi/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/UserContext.cs

61 lines
1.1 KiB
C#
Raw Normal View History

2023-04-13 11:51:03 +08:00
using System;
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
{
#region Variables
private Credential _cred;
2023-04-13 11:51:03 +08:00
private string _loginName;
#endregion
#region Properties
public Credential Credential
2023-04-13 11:51:03 +08:00
{
get => _cred;
2023-04-13 11:51:03 +08:00
set
{
_cred = value;
InvokePropertyChanged(nameof(Token));
InvokePropertyChanged(nameof(LoginName));
InvokePropertyChanged(nameof(LoginTime));
2023-04-13 11:51:03 +08:00
}
}
public Guid Token => _cred.Token;
2023-04-13 11:51:03 +08:00
public string LoginName => _cred?.AccountInfo?.LoginName ?? "";
public DateTime LoginTime => _cred?.LoginTime ?? DateTime.MinValue;
2023-04-13 11:51:03 +08:00
public Role Role { get; set; }
2023-04-13 11:51:03 +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; }
#endregion
#region Methods
public void Clear()
{
_cred = Credential.Empty;
Role = null;
LastAccessTime = DateTime.MinValue;
Language = string.Empty;
IsLogin = false;
}
#endregion
}
2023-04-13 11:51:03 +08:00
}