117 lines
4.1 KiB
C#
117 lines
4.1 KiB
C#
using Sarand.BusinessMgr.Net.Core.Web.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Security;
|
|
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config.Database;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using Newtonsoft.Json;
|
|
using Sarand.Net.Standard.Base.Helpers;
|
|
using Sarand.BusinessMgr.Web.Control.Controllers;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Dbas;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
namespace Sarand.BusinessMgr.Web.Control.App
|
|
{
|
|
//=======================================================================
|
|
public class SbmSessionData_Control : SbmSessionData_Web
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
[JsonConstructor]
|
|
private SbmSessionData_Control(long sessionIdx, int itemIdx, SbmSessionContext sessionContext) :
|
|
base(sessionIdx, itemIdx, sessionContext)
|
|
{ }
|
|
/// <summary>
|
|
/// SessionData construction.
|
|
/// <para>SessionContext and UserAccount must be supplied.</para>
|
|
/// </summary>
|
|
public SbmSessionData_Control(SbmSessionContext sessionContext, SbmcUserAccount userAccount) :
|
|
base(sessionContext)
|
|
{
|
|
User = new UserData_Control(sessionContext, userAccount);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
|
|
[JsonIgnore]
|
|
public override String UserDisplayName { get { return User?.DisplayName; } }
|
|
[JsonIgnore]
|
|
public override String UserEmailAddress { get { return User?.EmailAddress; } }
|
|
[JsonIgnore]
|
|
public override bool ValidUser { get { return SysId.IsValid(User?.UserAccountId); } }
|
|
[JsonIgnore]
|
|
public override bool KeepLoggedIn { get { return User.KeepLoggedIn; } }
|
|
[JsonIgnore]
|
|
public override DbUpdateInfo DbUpdateInfo
|
|
{
|
|
get
|
|
{
|
|
return new DbUpdateInfo(User?.UserAccountId, StringUtil.OnEmpty(User.DisplayName, User.EmailAddress), SbmSystem.ComputerName);
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// User details.
|
|
public class UserData_Control : UserData
|
|
{
|
|
[JsonConstructor]
|
|
private UserData_Control()
|
|
{ }
|
|
internal UserData_Control(SbmSessionContext sessionContext, SbmcUserAccount userAccount) :
|
|
base(sessionContext)
|
|
{
|
|
UserAccountId = userAccount.Id;
|
|
if (SysId.IsValid(UserAccountId))
|
|
{
|
|
UserAccountSupplied = true;
|
|
DisplayName = userAccount.GetDisplayName();
|
|
Title = userAccount.Title;
|
|
FirstName = userAccount.FirstName;
|
|
LastName = userAccount.LastName;
|
|
EmailAddress = userAccount.EmailAddress;
|
|
}
|
|
}
|
|
internal UserData_Control(UserData userData) :
|
|
base(userData)
|
|
{
|
|
UserData_Control userData_Control = userData as UserData_Control;
|
|
if (userData_Control != null)
|
|
{
|
|
UserAccountId = userData_Control.UserAccountId;
|
|
UserAccountSupplied = userData_Control.UserAccountSupplied;
|
|
KeepLoggedIn= userData_Control.KeepLoggedIn;
|
|
}
|
|
DisplayName = userData.DisplayName;
|
|
Title = userData.Title;
|
|
FirstName = userData.FirstName;
|
|
LastName = userData.LastName;
|
|
EmailAddress = userData.EmailAddress;
|
|
}
|
|
// Properties.
|
|
public SysId UserAccountId { get; private set; }
|
|
public bool UserAccountSupplied { get; private set; }
|
|
public bool KeepLoggedIn { get; private set; }
|
|
}
|
|
protected UserData CreateUserData(SbmSessionContext sessionContext, SbmcUserAccount userAccount)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/// <summary>User - JSON deserialisation route.</summary>
|
|
public UserData_Control User { get; private set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Control application encryption IV value - for consistent encryption during session.
|
|
public String Base64IV_ControlApp { get; private set; } = SacsEncryptionHelper.InitSymmetricEncryptionIV(SbmController_Control.Base64Key_ControlApp);
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|