Add project files.
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
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);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sarand.Core.App;
|
||||
using Sarand.Core.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static Sarand.OperationsMgr.Web.App.SaOperationsMgrWebApp;
|
||||
|
||||
namespace Sarand.OperationsMgr.Web.Models
|
||||
{
|
||||
//=======================================================================
|
||||
public class Model_Home_Index : Model_Base
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private List<SelectListItem> instances = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Form properties.
|
||||
public ushort InstanceIdx { get; set; } = 0;
|
||||
public String UserCode { get; set; }
|
||||
public String UserPwrd { get; set; }
|
||||
public String SessionExpired { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// I n s t a n c e s
|
||||
//-------------------------------------------------------------------
|
||||
public IEnumerable<SelectListItem> Instances
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SacsSystem.DebugMode) Logger.Trace(GetType().Name + ".GetInstances()");
|
||||
if (instances == null)
|
||||
{
|
||||
// Populate list of instances.
|
||||
instances = new List<SelectListItem>();
|
||||
foreach (ushort sessionContextConfigIndex in App.GetSessionContextIndices())
|
||||
{
|
||||
SessionContextConfig sessionContextConfig = App.GetSessionContextConfig(sessionContextConfigIndex);
|
||||
if (sessionContextConfig != null)
|
||||
{
|
||||
instances.Add(new SelectListItem() { Value = sessionContextConfig.SessionContext.Index.ToString(), Text = sessionContextConfig.Caption });
|
||||
}
|
||||
}
|
||||
Logger.Debug(GetType().Name + ".Instances Populated instances: " + instances.Count);
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user