116 lines
4.6 KiB
C#
116 lines
4.6 KiB
C#
using Sarand.Core.App;
|
|
using Sarand.Core.Base;
|
|
using Sarand.Core.Dbas.Base;
|
|
using Sarand.OperationsMgr.Web.App;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Sarand.OperationsMgr.Web.Models
|
|
{
|
|
//=======================================================================
|
|
public class Model_Base
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly List<String> infoMessages = new List<string>();
|
|
private readonly List<String> warningMessages = new List<string>();
|
|
private readonly List<String> errorMessages = new List<string>();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Protected construction - use derived class.
|
|
protected Model_Base ()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Application properties.
|
|
protected SaOperationsMgrWebApp App { get { return SaOperationsMgrWebApp.GetInstance(); } }
|
|
public bool OK { get { return !HasMessages; } }
|
|
public bool AwaitingLogin { get; set; } = true;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Session profile.
|
|
public SessionData SessionData { get; set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Business Object Managers.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Version parameter for includes.
|
|
public String HrefVersion
|
|
{
|
|
get
|
|
{
|
|
DateTime versionDate = SacsSystem.AssemblyBuildAt;
|
|
if (!DateUtil.IsValid(versionDate) || SacsSystem.DebugMode)
|
|
versionDate = DateTime.Now;
|
|
return DateUtil.Format(versionDate, "yyyyMMdd" /*+ (SacsSystem.Debug ? "HHmm" : "")*/);
|
|
}
|
|
}
|
|
// Additional includes.
|
|
public List<String> AdditionalFiles_CSS { get; set; } = new List<string>();
|
|
public List<String> AdditionalFiles_JS { get; set; } = new List<string>();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Redirection locations.
|
|
public class RedirectLocationData
|
|
{
|
|
// Properties populated in Controller_Base.OnActionExecuted.
|
|
public String Home { get; internal set; }
|
|
public String Home_SessionExpired { get; internal set; }
|
|
}
|
|
public RedirectLocationData RedirectLocation { get; } = new RedirectLocationData();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Paging properties.
|
|
private readonly DbQuery.Paging dataPaging = new DbQuery.Paging();
|
|
public bool DataPaged { get { return dataPaging.Paged; } }
|
|
public uint DataPageNo { get { return dataPaging.PageNo; } set { dataPaging.PageNo = value; } }
|
|
public ushort DataPageLength { get { return dataPaging.PageLength; } set { dataPaging.PageLength = value; } }
|
|
public uint DataPageCount { get { return (DataPageLength > 0 ? (uint)Math.Ceiling((decimal)DataItemTotal / DataPageLength) : 0); } }
|
|
public uint DataItemCount { get; set; }
|
|
public uint DataItemTotal { get; set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Form properties.
|
|
/// <summary>
|
|
/// User session index to identify the site resources, eg. database.
|
|
/// <para>Equivalent to the Site index on the login form.</para>
|
|
/// <para>Populates value on logout form to identify default site for next login.</para>
|
|
/// </summary>
|
|
public ushort SessionIdx { get; set; }
|
|
public String FormAction { get; set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Message properties.
|
|
public virtual bool ShowMessagesAtTopOfBody { get; } = true;
|
|
public bool HasMessages { get { return (infoMessages.Count > 0 || warningMessages.Count > 0 || errorMessages.Count > 0); } }
|
|
public List<String> InfoMessages { get { return new List<string>(infoMessages); } }
|
|
public List<String> WarningMessages { get { return new List<string>(warningMessages); } }
|
|
public List<String> ErrorMessages { get { return new List<string>(errorMessages); } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Form messages.
|
|
public void AddInfoMessage (String message)
|
|
{
|
|
if (StringUtil.IsEmpty(StringUtil.TrimAll(message))) return;
|
|
infoMessages.Add(message);
|
|
}
|
|
public void AddWarningMessage (String message)
|
|
{
|
|
if (StringUtil.IsEmpty(StringUtil.TrimAll(message))) return;
|
|
warningMessages.Add(message);
|
|
}
|
|
public void AddErrorMessage (String message)
|
|
{
|
|
if (StringUtil.IsEmpty(StringUtil.TrimAll(message))) return;
|
|
errorMessages.Add(message);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|