124 lines
6.0 KiB
C#
124 lines
6.0 KiB
C#
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Sacs.Web.Components;
|
|
using Sarand.BusinessMgr.Net.Core.Web.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.CodeTypes;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Diary;
|
|
using Sarand.Net.Standard.Base.Email;
|
|
using Sarand.Net.Standard.Base.Interfaces;
|
|
using Sarand.Net.Standard.Base.ItemData;
|
|
using Sarand.Net.Standard.Base.ItemDocs;
|
|
using Sarand.Net.Standard.Base.ItemOptions;
|
|
using Sarand.Net.Standard.Base.ReferenceData;
|
|
using Sarand.Net.Standard.Base.Security;
|
|
using Sarand.Net.Standard.Base.UpdateLog;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
|
{
|
|
//=======================================================================
|
|
public abstract class SbmController_Base : SaController
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private SbmInternals internals;
|
|
private SbmInternals_Control internals_Control;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Protected construction.
|
|
protected SbmController_Base(SbmLocaliser localiser)
|
|
{
|
|
Localiser = localiser;
|
|
|
|
// Initialise console (debug) logging listener.
|
|
//if (Directory.Exists(App.LoggingRootFolder) && SbmSystem.DebugMode)
|
|
// SbmConsoleListener.ConfigureDebugListener(App.LoggingRootFolder);
|
|
if (DebugMode) SaLogger.Trace($"{GetType().Name}.CTR");
|
|
}
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
if (internals != null) internals.Dispose();
|
|
internals = null;
|
|
if (internals_Control != null) internals_Control.Dispose();
|
|
internals_Control = null;
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public SbmLocaliser Localiser { get; }
|
|
protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
|
|
public App.SbmAppConfig AppConfig { get { return App.AppConfig; } }
|
|
public abstract SbmSessionContext SessionContext { get; }
|
|
public abstract ISbmUserContext_Core UserContext_Core { get; }
|
|
// Business components.
|
|
public SbmInternals Internals { get { if (internals == null && UserContext_Core != null) { internals = new SbmInternals(UserContext_Core); } return internals; } }
|
|
public SbmInternals_Control Internals_Control { get { if (internals_Control == null) { internals_Control = new SbmInternals_Control(); } return internals_Control; } }
|
|
// Managers.
|
|
public SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
|
public SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } }
|
|
public SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } }
|
|
public SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } }
|
|
public SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } }
|
|
public SbmStockMgr StockMgr { get { return Internals.StockMgr; } }
|
|
public SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } }
|
|
public SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
|
// Control.
|
|
protected SbmcAccountMgr ControlAccountMgr { get { return Internals_Control.ControlAccountMgr; } }
|
|
protected SbmcInstanceMgr ControlInstanceMgr { get { return Internals_Control.ControlInstanceMgr; } }
|
|
protected SbmcItemMgr ControlItemMgr { get { return Internals_Control.ControlItemMgr; } }
|
|
// Consoles.
|
|
public SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } }
|
|
public SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
|
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
|
public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
|
public SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } }
|
|
public SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
|
public SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
|
public SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } }
|
|
public SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
|
public SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } }
|
|
// Configurations.
|
|
public SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
|
|
public SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
|
|
// System codes.
|
|
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); }
|
|
// Email.
|
|
public SaEmailConfig EmailConfig { get { return Internals.EmailConfig; } }
|
|
public SbmEmailConsole EmailConsole { get { return Internals.EmailConsole; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Action execution events.
|
|
//-------------------------------------------------------------------
|
|
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
{
|
|
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
|
base.OnActionExecuting(filterContext);
|
|
}
|
|
public override void OnActionExecuted(ActionExecutedContext filterContext)
|
|
{
|
|
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
|
base.OnActionExecuted(filterContext);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|