This commit is contained in:
2021-07-23 14:01:49 +01:00
parent 10907d3aff
commit 0d7be69e1e
109 changed files with 3161 additions and 943 deletions
@@ -61,7 +61,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
// Properties.
public bool DebugMode { get; } = SacsSystem.DebugMode;
protected SaxApplication_Web App { get { return SaxApplication_Web.WebApp; } }
public SaxSessionConfig SessionConfig { get { return App.SessionConfig; } }
public SaxAppConfig AppConfig { get { return App.AppConfig; } }
public SaxSessionContext SessionContext { get { return App.SessionContext; } }
protected SaxLocaliser Localiser { get; }
/// <summary>
@@ -164,10 +164,10 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
if (StoreSessionData)
{
String sessionDataJson = JsonConvert.SerializeObject(SessionData);
HttpContext.Session.Set(SessionStorage.SessionKey_SessionConfig, SessionStorage.sessionDataEncoding.GetBytes(sessionDataJson));
HttpContext.Session.Set(SessionStorage.SessionKey_SessionData, SessionStorage.sessionDataEncoding.GetBytes(sessionDataJson));
}
}
else HttpContext.Session.Remove(SessionStorage.SessionKey_SessionConfig);
else HttpContext.Session.Remove(SessionStorage.SessionKey_SessionData);
// Response headers.
if (baseModel != null && baseModel.ProhibitCache)
@@ -293,7 +293,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
public class SessionStorage
{
public SaxSessionData SessionData { get; set; }
public static String SessionKey_SessionConfig { get; } = "SaxSessionData";
public static String SessionKey_SessionData { get; } = "SaxSessionData";
public static Encoding sessionDataEncoding { get; } = Encoding.UTF8;
//JSON Serialisation.
public class SaxSessionDataContractResolver : DefaultContractResolver
@@ -334,7 +334,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
if (sessionStorage.SessionData == null)
{
byte[] sessionDataBytes = null;
HttpContext.Session.TryGetValue(SessionStorage.SessionKey_SessionConfig, out sessionDataBytes);
HttpContext.Session.TryGetValue(SessionStorage.SessionKey_SessionData, out sessionDataBytes);
if (sessionDataBytes != null)
{
String sessionDataJson = SessionStorage.sessionDataEncoding.GetString(sessionDataBytes);
@@ -408,10 +408,37 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
//-------------------------------------------------------------------
public class AjaxResponse_Data : AjaxResponse_Base
{
//---------------------------------------------------------------
// Construction.
protected AjaxResponse_Data(SaxModel_Base model)
{
}
//---------------------------------------------------------------
// Item data.
public class ItemData_Base
{
// Common item properties.
public String Id { get; set; }
public String StatusCode { get; set; }
public String StatusDesc { get; set; }
// Flags for common status values.
// Return true or null so that property is not serialised when false.
public bool? Awaiting { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Awaiting)) ? true : (bool?)null; } }
public bool? Active { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Active)) ? true : (bool?)null; } }
public bool? Inactive { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Inactive)) ? true : (bool?)null; } }
public bool? Deleted { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Deleted)) ? true : (bool?)null; } }
/// <summary>Created on date - YYYYMMDD</summary>
public String CreatedOn { get; set; }
/// <summary>Created on date - formatted per locale</summary>
public String CreatedOnFmt { get; set; }
/// <summary>Updated on date - YYYYMMDD</summary>
public String UpdatedOn { get; set; }
/// <summary>Updated on date - formatted per locale</summary>
public String UpdatedOnFmt { get; set; }
}
//---------------------------------------------------------------
// Form data.
public class FormControlValue
{
@@ -464,6 +491,8 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
}
return false;
}
//---------------------------------------------------------------
// Notification - briefly displays after response received.
public class NotificationData
{
@@ -477,6 +506,8 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
Notification = new NotificationData() { Title = title, Message = message };
return this;
}
//---------------------------------------------------------------
// Paged data.
public class PagingData
{
@@ -502,6 +533,8 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
{
Paging = new PagingData(model);
}
//---------------------------------------------------------------
}
//-------------------------------------------------------------------