From a3ac029d55c62751efa90b325413e8deb6915176 Mon Sep 17 00:00:00 2001 From: Andy Howard Date: Mon, 27 Jan 2025 10:01:32 +0000 Subject: [PATCH] Asset Categories --- .../Procs/Consoles/SbmProcessConsole.cs | 2 +- .../SbmInterfaceProcess_Commodity_Export.cs | 2 +- SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj | 4 - .../Web/App/SbmInstanceConfig_Control.cs | 55 +++- .../Web/App/SbmInstanceConfig_Core.cs | 17 + .../SbmController_Base.cs | 5 +- .../SbmController_Web.cs | 29 +- .../Web/Components/SbmModel_Base.cs | 231 +++++++++++++ SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs | 287 ---------------- SaBusMgrStandardBase/Base/App/Sbm.cs | 2 + .../Base/App/SbmInstanceConfig.cs | 20 +- SaBusMgrStandardBase/Base/App/SbmInternals.cs | 96 ++++-- .../Base/App/SbmSecurityProfile.cs | 77 +++-- .../Base/App/SbmSystem-Statics.cs | 5 +- .../Base/Bus/Control/SbmcItemParam.cs | 4 - .../Base/Bus/SbmAccountsDfn.cs | 5 +- SaBusMgrStandardBase/Base/Bus/SbmAddress.cs | 41 +-- SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs | 10 +- SaBusMgrStandardBase/Base/Bus/SbmAsset.cs | 35 +- .../Base/Bus/SbmAssetCategory.cs | 4 +- .../Base/Bus/SbmAssetProcess.cs | 10 +- .../Base/Bus/SbmAssociation.cs | 30 +- SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs | 10 +- .../Base/Bus/SbmCommodityCustomer.cs | 21 +- .../Base/Bus/SbmCommoditySupplier.cs | 19 +- .../Base/Bus/SbmConstituent.cs | 6 +- SaBusMgrStandardBase/Base/Bus/SbmContainer.cs | 17 +- .../Base/Bus/SbmContainerItem.cs | 23 +- .../Base/Bus/SbmCostEstimate.cs | 144 ++++---- SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs | 5 +- SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs | 17 +- SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs | 25 +- .../Base/Bus/SbmItemProcess.cs | 21 +- SaBusMgrStandardBase/Base/Bus/SbmLocation.cs | 17 +- SaBusMgrStandardBase/Base/Bus/SbmMovement.cs | 16 +- .../Base/Bus/SbmPortfolioItem.cs | 14 +- SaBusMgrStandardBase/Base/Bus/SbmPrice.cs | 12 +- SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs | 10 +- SaBusMgrStandardBase/Base/Bus/SbmProcess.cs | 11 +- .../Base/Bus/SbmRequirement.cs | 16 +- .../Base/Bus/SbmStockLevel.cs | 13 +- SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs | 6 +- .../Base/Bus/SbmSystemAccount.cs | 4 +- .../Base/Bus/SbmSystemAccountUser.cs | 4 +- .../Base/Bus/SbmSystemUser.cs | 10 +- .../Base/Bus/SbmTransaction.cs | 7 +- .../Base/Bus/SbmTransactionPayment.cs | 6 +- SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs | 17 +- .../Base/Bus/SbmVehicleClass.cs | 17 +- .../Base/Bus/SbmVehicleEvent.cs | 17 +- .../Base/Bus/SbmVehicleFeature.cs | 19 +- .../Base/Consoles/SbmSessionConsole.cs | 7 +- .../Base/Core/ISbmInstanceConfig.cs | 14 + .../Base/Core/ISbmOrganisationConfig.cs | 23 +- .../Base/Mgr/Control/SbmcInstanceMgr.cs | 8 +- .../Base/Mgr/SbmAccountMgr_Affiliate.cs | 3 +- .../Base/Mgr/SbmAccountMgr_Organisation.cs | 2 + .../Base/Mgr/SbmCommodityMgr_PortfolioItem.cs | 6 +- SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs | 60 +--- .../Base/UpdateLog/SbmUpdateLogItemMonitor.cs | 2 +- .../Dbas/Bus/SbmProcess_Dbas.cs | 26 +- .../Consoles/SbmReferenceDataConsole_Dbas.cs | 5 + .../Mgr/SbmAccountMgr_Dbas-Association.cs | 3 +- .../Mgr/SbmAssetMgr_Dbas-AssetCategory.cs | 90 ++--- .../Mgr/SbmCommodityMgr_Dbas-Commodity.cs | 6 +- .../Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs | 4 +- .../Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs | 6 +- .../Mgr/SbmTransactionMgr_Dbas-Requirement.cs | 2 +- .../Mgr/SbmTransactionMgr_Dbas-Transaction.cs | 3 +- .../Dbas/Mgr/SbmTransactionMgr_Dbas.cs | 8 +- .../App/SbmApplication_SessionData_Tester.cs | 2 +- .../Control/App/SbmApplication_Tester_Base.cs | 7 +- .../App/SbmApplication_SessionData_Tester.cs | 2 +- .../Control/App/SbmApplication_Control.cs | 15 +- .../Control/App/SbmSessionData_Control.cs | 22 +- .../Control/App/SbmSystem_Control.cs | 8 +- .../SbmReferenceDataConsole_Control.cs | 33 ++ .../Instance/RepositoryController-Ajax.cs | 2 - .../Controllers/Param/ParamController-Ajax.cs | 5 +- .../Controllers/SbmController_Control.cs | 3 +- .../Security/SecurityController-Ajax.cs | 17 +- .../Models/Account/Model_UserAccount.cs | 9 +- .../Control/Models/Instance/Model_Owner.cs | 2 +- .../Models/Instance/Model_Repository.cs | 2 +- .../Models/Instance/Model_RepositoryInit.cs | 2 +- .../Control/Models/Model_Home.cs | 34 +- .../Control/Models/Model_Security.cs | 6 +- .../Control/Models/Param/Model_Param.cs | 7 +- .../Control/Models/SbmModel_Control.cs | 5 +- .../Localisation/SbmControlProperties.resx | 12 + .../Views/Home/Index.cshtml | 51 ++- .../wwwroot/css/sbc-main.css | 4 +- .../Portal/App/SbmSessionData_Portal.cs | 15 +- .../Portal/App/SbmSystem_Portal.cs | 1 - .../Assets/AssetCategoryController-Ajax.cs | 5 +- .../Assets/AssetController-Ajax.cs | 2 +- .../Commodities/CommodityController-Ajax.cs | 5 +- .../Controllers/SbmController_Portal.cs | 88 +++-- .../Security/SecurityController-Ajax.cs | 18 +- .../TransactionController-Ajax.cs | 1 - .../Helpers/SbmSessionContextHelper_Portal.cs | 1 - .../Models/Assets/Model_Asset-Config.cs | 311 ++++++++++++++++++ .../Portal/Models/Assets/Model_Asset.cs | 31 +- .../Assets/Model_AssetCategory-Config.cs | 3 +- .../Models/Assets/Model_AssetCategory.cs | 2 +- .../Portal/Models/Codes/Model_Code.cs | 2 +- .../Portal/Models/Codes/Model_CodeType.cs | 2 +- .../Models/Commodities/Model_Commodity.cs | 10 +- .../Models/Contacts/Model_Association.cs | 11 +- .../Portal/Models/Contacts/Model_Contact.cs | 9 +- .../Portal/Models/Model_Home.cs | 9 - .../Portal/Models/Model_Security.cs | 2 +- .../Portal/Models/SbmModel_Portal.cs | 96 +++++- .../Models/Transactions/Model_Transaction.cs | 11 +- .../Portal/Models/Vehicles/Model_Vehicle.cs | 2 +- .../Models/Vehicles/Model_VehicleClass.cs | 7 +- .../SaBusinessMgrCoreWebPortal.csproj | 5 +- .../Views/Assets/Asset/Index.cshtml | 209 +----------- .../Assets/Asset/Panel-AssetDialog.cshtml | 121 +++++++ .../Views/Assets/Asset/Panel-AssetList.cshtml | 55 ++++ .../Assets/Asset/Panel-AssetMaintain.cshtml | 71 ++++ .../Assets/Asset/Panel-AssetSelect.cshtml | 43 +++ .../Panel-AssetCategoryDialog.cshtml | 5 +- .../Panel-AssetCategoryList.cshtml | 6 +- .../Panel-AssetCategoryMaintain.cshtml | 6 +- .../Panel-AssetCategorySelect.cshtml | 6 +- .../wwwroot/css/sbm-data.css | 7 + .../wwwroot/css/sbm-main.css | 4 +- .../wwwroot/js/sbm-asset-cat.js | 12 +- .../wwwroot/js/sbm-asset.js | 15 +- 130 files changed, 1809 insertions(+), 1423 deletions(-) rename SaBusMgrCoreWeb/Web/{Controllers => Components}/SbmController_Base.cs (93%) rename SaBusMgrCoreWeb/Web/{Controllers => Components}/SbmController_Web.cs (89%) create mode 100644 SaBusMgrCoreWeb/Web/Components/SbmModel_Base.cs delete mode 100644 SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs create mode 100644 SaBusinessMgrCoreWebControl/Control/Consoles/SbmReferenceDataConsole_Control.cs create mode 100644 SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset-Config.cs create mode 100644 SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetDialog.cshtml create mode 100644 SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetList.cshtml create mode 100644 SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetMaintain.cshtml create mode 100644 SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetSelect.cshtml diff --git a/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs b/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs index 6c1d871..ad792f7 100644 --- a/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs +++ b/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs @@ -195,7 +195,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles SaInterface saInterface = null; SaInterface.Params prmInterface = new SaInterface.Params(); prmInterface.InterfaceCategory = interfaceCategory; - prmInterface.IncludedInterfaceTypes.Add(interfaceType); + prmInterface.InterfaceTypesIncluded.Add(interfaceType); prmInterface.StatusCat = SaInterface.StatusCat.Any; using (SaInterfaceConsole interfaceConsole = SbmGlobals.System.CreateInterfaceConsole(userContext)) { diff --git a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs index b185689..251c305 100644 --- a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs +++ b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs @@ -320,7 +320,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces public SbmCommodity.Params GetParams() { SbmCommodity.Params prmCommodity = config.CommodityParams ?? new SbmCommodity.Params(); - prmCommodity.IdsIncluded.AddRange(config.ItemIds); + prmCommodity.IdsIncluded.UnionWith(config.ItemIds); return prmCommodity; } private DbResultSet ExecuteQuery() diff --git a/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj b/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj index 7f045aa..bbc7706 100644 --- a/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj +++ b/SaBusMgrCoreWeb/SaBusMgrCoreWeb.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs index 320a3ff..a1e00e0 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs @@ -1,5 +1,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; +using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; @@ -9,7 +10,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Core.Web.App { @@ -111,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { // Affiliate types. Sbm.AffiliateType affiliateType = EnumUtil.ParseEnum(itemParam.Name, Sbm.AffiliateType.Unknown); - if (affiliateType != AffiliateType.Unknown) + if (affiliateType != Sbm.AffiliateType.Unknown) { if (StringUtil.ToBool(itemParam.Value)) AffiliateTypes_Allowed.Add(affiliateType); @@ -124,7 +124,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { // Association types. Sbm.AssociationType associationType = EnumUtil.ParseEnum(itemParam.Name, Sbm.AssociationType.Unknown); - if (associationType != AssociationType.Unknown) + if (associationType != Sbm.AssociationType.Unknown) { if (StringUtil.ToBool(itemParam.Value)) AssociationTypes_Allowed.Add(associationType); @@ -137,7 +137,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { // Transaction types. Sbm.TransactionType transactionType = EnumUtil.ParseEnum(itemParam.Name, Sbm.TransactionType.Unknown); - if (transactionType != TransactionType.Unknown) + if (transactionType != Sbm.TransactionType.Unknown) { if (StringUtil.ToBool(itemParam.Value)) TransactionTypes_Allowed.Add(transactionType); @@ -169,10 +169,26 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App else if (itemParam.Context.EqualsCI(ParamContext_DefaultValue)) { // Default Value. + if (itemParam.Name.EqualsCI("CommodityType")) + { + Sbm.CommodityType commodityType = EnumUtil.ParseEnum(itemParam.Value, Sbm.CommodityType.Unknown); + if (commodityType > 0) + Defaults.CommodityType = commodityType; + else SaLogger.Debug($"{SysUtil.Fn} Unrecognised Default Commodity Type: '{itemParam.Value}'. Context: {itemParam.Context}. Name: {itemParam.Name}."); + } + else SaLogger.Debug($"{SysUtil.Fn} Unrecognised Default Value. Context: {itemParam.Context}. Name: {itemParam.Name}."); } else if (itemParam.Context.EqualsCI(ParamContext_ColumnChangeLogged)) { // Update Log. + SbmDbDfn.ColumnIdx column = EnumUtil.ParseEnum(itemParam.Name, SbmDbDfn.ColumnIdx.Unknown); + if (column != SbmDbDfn.ColumnIdx.Unknown) + { + if (StringUtil.ToBool(itemParam.Value)) + ColumnChangeLogged_Allowed.Add(column); + else ColumnChangeLogged_Disallowed.Add(column); + } + else SaLogger.Debug($"{SysUtil.Fn} Unrecognised Change Log column. Context: {itemParam.Context}. Name: {itemParam.Name}."); } else SaLogger.Debug($"{SysUtil.Fn} Unrecognised option. Context: {itemParam.Context}. Name: {itemParam.Name}."); } @@ -192,6 +208,16 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App return defaultResponse; } + //------------------------------------------------------------------- + // Defaults. + + private ISbmInstanceConfig.DefaultsData Defaults { get; } = new ISbmInstanceConfig.DefaultsData(); + + public override ISbmInstanceConfig.DefaultsData GetDefaults() + { + return Defaults; + } + //------------------------------------------------------------------- // Contacts. @@ -230,16 +256,33 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App private readonly HashSet InterfaceCategories_Allowed = new HashSet(); private readonly HashSet InterfaceCategories_Disallowed = new HashSet(); + /// /// Whether the Interface Category is allowed. /// public override bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse) { - if (InterfaceCategories_Allowed.Contains(interfaceCategory)) return false; - if (InterfaceCategories_Disallowed.Contains(interfaceCategory)) return true; + if (InterfaceCategories_Disallowed.Contains(interfaceCategory)) return false; + if (InterfaceCategories_Allowed.Contains(interfaceCategory)) return true; return defaultResponse; } + //------------------------------------------------------------------- + // Update Log. + + private readonly HashSet ColumnChangeLogged_Allowed = new HashSet(); + private readonly HashSet ColumnChangeLogged_Disallowed = new HashSet(); + + /// + /// Are changes to values in the specified database column recorded in the Change Log. + /// + public override bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column, bool defaultResponse) + { + if (ColumnChangeLogged_Disallowed.Any(item => item == column)) return false; + if (ColumnChangeLogged_Allowed.Any(item => item == column)) return true; + return false; + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs index 9e1fb79..fe7d17f 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs @@ -1,6 +1,7 @@ using DocumentFormat.OpenXml.Drawing.Diagrams; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; +using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; @@ -49,6 +50,14 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App return defaultResponse; } + //------------------------------------------------------------------- + // Defaults. + + public override ISbmInstanceConfig.DefaultsData GetDefaults() + { + return new ISbmInstanceConfig.DefaultsData(); + } + //------------------------------------------------------------------- // Contacts. @@ -81,6 +90,14 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App return defaultResponse; } + //------------------------------------------------------------------- + // Update Log. + + public override bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column, bool defaultResponse) + { + return defaultResponse; + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs b/SaBusMgrCoreWeb/Web/Components/SbmController_Base.cs similarity index 93% rename from SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs rename to SaBusMgrCoreWeb/Web/Components/SbmController_Base.cs index c3b37de..cec170c 100644 --- a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs +++ b/SaBusMgrCoreWeb/Web/Components/SbmController_Base.cs @@ -21,7 +21,7 @@ using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.UpdateLog; using System.Collections.Generic; -namespace Sarand.BusinessMgr.Net.Core.Web.Controllers +namespace Sarand.BusinessMgr.Net.Core.Web.Components { //======================================================================= public abstract class SbmController_Base : SaController @@ -53,8 +53,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers 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 ISbmUserOrganisationContext UserContext_Core { get; } + protected abstract SbmSessionContext SessionContext { get; } //------------------------------------------------------------------- // Action execution events. diff --git a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Web.cs b/SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs similarity index 89% rename from SaBusMgrCoreWeb/Web/Controllers/SbmController_Web.cs rename to SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs index 16f9a7d..e9eac76 100644 --- a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Web.cs +++ b/SaBusMgrCoreWeb/Web/Components/SbmController_Web.cs @@ -8,7 +8,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Sacs.Web.Components; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Models; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Consoles; @@ -38,7 +37,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Web; -namespace Sarand.BusinessMgr.Net.Core.Web.Controllers +namespace Sarand.BusinessMgr.Net.Core.Web.Components { //======================================================================= public abstract class SbmController_Web : SbmController_Base @@ -65,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers //------------------------------------------------------------------- // Properties. - public override SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } } + protected override SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } } //------------------------------------------------------------------- // Action execution events. @@ -95,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers // Some actions (eg. score password) don't need to. if (StoreSessionData) { - String sessionDataJson = JsonConvert.SerializeObject(SessionData, SbmController_Web.SessionDataJsonSerializerSettings); + string sessionDataJson = JsonConvert.SerializeObject(SessionData, SessionDataJsonSerializerSettings); HttpContext.Session.Set(SessionStorage.SessionKey_SessionData, SessionStorage.sessionDataEncoding.GetBytes(sessionDataJson)); } } @@ -122,8 +121,8 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers if (model == null) return; // Session data. - model.Controller = this; - model.SessionData_Web = SessionData; + model.SetController(this); + model.SetSessionData(SessionData); // Redirect locations. model.RedirectLocation.Base = GetRedirectLocation(RedirectLocation.WebAppBase); @@ -138,18 +137,18 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers // the base Controller so that they can be shared with the Admin application. // NB IV value is generated from the key and fixed so that it doesn't change when the application restarts. // IV Must be regenerated if key is changed. - protected static String Base64Key_RequestPassword_Portal { get; } = SacsEncryptionHelper.EncodePlainKey("[5Abus1neSSmGR~Request#Password}", SacsEncryptionHelper.KeyLength); + protected static string Base64Key_RequestPassword_Portal { get; } = SacsEncryptionHelper.EncodePlainKey("[5Abus1neSSmGR~Request#Password}", SacsEncryptionHelper.KeyLength); //private static String Base64IV_RequestPassword_Generated_Portal = SacsEncryptionHelper.InitSymmetricEncryptionIV(Base64Key_RequestPassword_Portal); - protected static String Base64IV_RequestPassword_Portal { get; } = "8TRhBayBJZmACQ6pld1F9A=="; + protected static string Base64IV_RequestPassword_Portal { get; } = "8TRhBayBJZmACQ6pld1F9A=="; //------------------------------------------------------------------- // Session. //------------------------------------------------------------------- - public bool ValidUserSession { get { return SessionData?.ValidUser ?? false; } } - public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } } + protected bool ValidUserSession { get { return SessionData?.ValidUser ?? false; } } + protected DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SacsSystem.ComputerName); } } // Referrer. - public String Referer { get { return Request.Headers["Referer"].ToString(); } } - public bool ValidReferer { get { return !StringUtil.IsEmpty(Referer); } } + protected string Referer { get { return Request.Headers["Referer"].ToString(); } } + protected bool ValidReferer { get { return !Referer.IsEmpty(); } } /// Store session data, eg. to start a new user session on sign-in. protected bool SetSessionData(SbmSessionData_Web sessionData) { @@ -169,7 +168,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers public class SessionStorage { public SbmSessionData_Web SessionData { get; set; } - public static String SessionKey_SessionData { get; } = "SbmSessionData"; + public static string SessionKey_SessionData { get; } = "SbmSessionData"; public static Encoding sessionDataEncoding { get; } = Encoding.UTF8; //JSON Serialisation. public class SbmSessionDataContractResolver : DefaultContractResolver @@ -219,7 +218,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers HttpContext.Session.TryGetValue(SessionStorage.SessionKey_SessionData, out sessionDataBytes); if (sessionDataBytes != null) { - String sessionDataJson = SessionStorage.sessionDataEncoding.GetString(sessionDataBytes); + string sessionDataJson = SessionStorage.sessionDataEncoding.GetString(sessionDataBytes); sessionStorage.SessionData = DeserializeSessionData(sessionDataJson); } } @@ -232,7 +231,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers return null; } } - protected abstract SbmSessionData_Web DeserializeSessionData(String sessionDataJson); + protected abstract SbmSessionData_Web DeserializeSessionData(string sessionDataJson); //------------------------------------------------------------------- } diff --git a/SaBusMgrCoreWeb/Web/Components/SbmModel_Base.cs b/SaBusMgrCoreWeb/Web/Components/SbmModel_Base.cs new file mode 100644 index 0000000..3c68423 --- /dev/null +++ b/SaBusMgrCoreWeb/Web/Components/SbmModel_Base.cs @@ -0,0 +1,231 @@ +using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Mvc.Rendering; +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.CodeTypes; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Diary; +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.Globalization; +using System.Text; + +namespace Sarand.BusinessMgr.Net.Core.Web.Components +{ + //======================================================================= + public abstract class SbmModel_Base : SaModel + { + //------------------------------------------------------------------- + // Data members. + private SbmInternals_Control internals_Control; + + //------------------------------------------------------------------- + // Protected construction. + protected SbmModel_Base(SbmLocaliser localiser) + { + Localiser = localiser; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (internals_Control != null) internals_Control.Dispose(); internals_Control = null; + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Application properties. + private SbmApplication_Web App { get { return SbmGlobals_Web.Application; } } + protected App.SbmAppConfig AppConfig { get { return App.AppConfig; } } + protected SbmSystem_Web System { get { return App.System_Web; } } + public string SessionCookieName { get { return App.SessionCookieName; } } + protected SbmSessionData_Web SessionData_Web { get; private set; } + internal void SetSessionData(SbmSessionData_Web sessionData) { SessionData_Web = sessionData; } + protected SbmSessionContext SessionContext { get { return SessionData_Web?.SessionContext ?? null; } } + protected DbUpdateInfo DbUpdateInfo { get { return SessionData_Web?.DbUpdateInfo ?? new DbUpdateInfo(null, "", Sarand.Net.Standard.Base.App.SacsSystem.ComputerName); } } + protected SbmLocaliser Localiser { get; } + // Request properties. + protected SbmController_Web Controller { get; private set; } + internal void SetController(SbmController_Web controller) { Controller = controller; } + protected CultureInfo SessionCulture { get { return Controller?.SessionCulture ?? CultureInfo.InvariantCulture; } } + + //------------------------------------------------------------------- + // Page configuration. + public string InstanceVersion { get { return !App.AppConfig.Instance.IsEmpty() ? App.AppConfig.Instance + " v" + Sbm.Version.GetFullVersion() : "v" + Sbm.Version.GetAppVersion(); } } + + //------------------------------------------------------------------- + // Business components. + // NB Keep these accessors protected to avoid them being called by the model binding logic before the session data is ready. + protected SbmInternals_Control Internals_Control { get { if (internals_Control == null) internals_Control = new SbmInternals_Control(); return internals_Control; } } + // 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; } } + + //------------------------------------------------------------------- + // Security. + protected bool ValidUserSession { get { return SessionData_Web?.ValidUser ?? false; } } + public bool AwaitingLogin { get { return !ValidUserSession; } } + public bool KeepLoggedIn { get { return !AwaitingLogin && (SessionData_Web?.KeepLoggedIn ?? false); } } + /// Maximum length allowed for password entry: sign-up, change password etc. + public int PasswordMaxLength { get; } = 32; + + //------------------------------------------------------------------- + /// + /// Form control value max length - Security tables. + /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. + /// Hence, several cases where the value entered in the control isn't allowed the full database length. + /// + public int GetControlMaxLength(SaSecurityDbDfn.ColumnIdx column) + { + int maxLength = (int)SaSecurityDbDfn.GetColTextLen(column); + switch (column) + { + case SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress: + return Math.Min(maxLength, 100); + } + return maxLength; + } + + /// + /// Form control value max length - code type tables. + /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. + /// Hence, several cases where the value entered in the control isn't allowed the full database length. + /// + public int GetControlMaxLength(SaCodeTypeDbDfn.ColumnIdx column) + { + int maxLength = (int)SaCodeTypeDbDfn.GetColTextLen(column); + switch (column) + { + case SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name: + case SaCodeTypeDbDfn.ColumnIdx.SaCode_Description: + return Math.Min(maxLength, 100); + } + return maxLength; + } + + /// + /// Form control value max length - BusinessMgr tables. + /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. + /// Hence, several cases where the value entered in the control isn't allowed the full database length. + /// + public int GetControlMaxLength(SbmDbDfn.ColumnIdx column) + { + int maxLength = (int)SbmDbDfn.GetColTextLen(column); + switch (column) + { + case SbmDbDfn.ColumnIdx.Affiliate_Email: + return Math.Min(maxLength, 100); + case SbmDbDfn.ColumnIdx.Affiliate_FirstName: + case SbmDbDfn.ColumnIdx.Affiliate_LastName: + return Math.Min(maxLength, 40); + case SbmDbDfn.ColumnIdx.Affiliate_Name: + return Math.Min(maxLength, 80); + case SbmDbDfn.ColumnIdx.Affiliate_PhoneMain: + case SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile: + case SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt: + return Math.Min(maxLength, 20); + case SbmDbDfn.ColumnIdx.Address_Postcode: + return Math.Min(maxLength, 16); + } + return maxLength; + } + + //------------------------------------------------------------------- + // Copyright notice. + public HtmlString CopyrightNotice + { + get + { + int initialYear = 2020; + int currentYear = DateTime.Today.Year; + return Localiser.GetHtmlText("copyright.symbol.year.html", (initialYear != currentYear ? initialYear + "-" : "") + currentYear.ToString()); + } + } + + //------------------------------------------------------------------- + // Display data - Dates. + public string FormatDateForDisplay(DateTime? value) + { + return value.Format("d-MMM-yy", SessionCulture); + } + public string FormatDateTimeForDisplay(DateTime? value) + { + return value.Format("d-MMM-yy HH:mm", SessionCulture).TrimAll(); + } + + //------------------------------------------------------------------- + // Form data - Dates. + // Format may depend on locale, but as long as these methods are used consistently, + // there should be consistent formatting, display and parsing of date values. + public string CalendarDateFormat + { + get + { + // JQuery-UI DatePicker date format. + // Format: + // d Single digit day of month + // dd Double digit day of month + // D 3 letter day of week abbreviation. + // DD Day of week. + // m Single digit month. + // mm Double digit month. + // M 3 letter month abbreviation. + // MM Month name. + // yy 4 digit year. + // Examples: + // dd/mm/yy 07/04/2012 + // dd-M-yy 07-Apr-2012 + // d-M-yy 7-Apr-2012 + return "dd-M-yy"; + } + } + public string FormatDateForForm(DateTime value) + { + return value.Format("dd-MMM-yyyy"); + } + public DateTime ParseDateFromForm(string value) + { + return DateUtil.ParseExact(value, "dd-MMM-yyyy"); + } + + //------------------------------------------------------------------- + // Link URLs. + public class LinksData + { + public string Facebook { get; } = "https://www.facebook.com/BusinessMgr/"; + public string LinkedIn { get; } = "https://www.linkedin.com/company/BusinessMgr/about/"; + } + public LinksData Links { get; } = new LinksData(); + + //------------------------------------------------------------------- + // Form properties. + /// + /// User session index to identify the site resources, eg. database. + /// Equivalent to the Site index on the login form. + /// Populates value on logout form to identify default site for next login. + /// + public ushort SessionIdx { get { return SessionContext?.Index ?? 0; } } + public string FormAction { get; set; } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs b/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs deleted file mode 100644 index e3f64a0..0000000 --- a/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs +++ /dev/null @@ -1,287 +0,0 @@ -using Microsoft.AspNetCore.Html; -using Microsoft.AspNetCore.Mvc.Rendering; -using Sacs.Web.Components; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; -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.CodeTypes; -using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Dbas; -using Sarand.Net.Standard.Base.Diary; -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.Globalization; -using System.Text; - -namespace Sarand.BusinessMgr.Net.Core.Web.Models -{ - //======================================================================= - public abstract class SbmModel_Base : SaModel - { - //------------------------------------------------------------------- - // Data members. - private SbmInternals internals; - private SbmInternals_Control internals_Control; - - //------------------------------------------------------------------- - // Protected construction. - protected SbmModel_Base(SbmLocaliser localiser) - { - Localiser = localiser; - } - - 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); - } - - //------------------------------------------------------------------- - // Application properties. - private SbmApplication_Web App { get { return SbmGlobals_Web.Application; } } - protected App.SbmAppConfig AppConfig { get { return App.AppConfig; } } - protected SbmSystem_Web System { get { return App.System_Web; } } - public String SessionCookieName { get { return App.SessionCookieName; } } - public SbmSessionData SessionData { get { return SessionData_Web; } } - public SbmSessionData_Web SessionData_Web { get; set; } - public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } } - public abstract ISbmUserOrganisationContext UserContext_Core { get; } - public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } } - public SbmLocaliser Localiser { get; } - // Request properties. - public SbmController_Web Controller { get; set; } - public CultureInfo SessionCulture { get { return Controller?.SessionCulture ?? CultureInfo.InvariantCulture; } } - - //------------------------------------------------------------------- - // Page configuration. - public String InstanceVersion { get { return !StringUtil.IsEmpty(App.AppConfig.Instance) ? App.AppConfig.Instance + " v" + Sbm.Version.GetFullVersion() : "v" + Sbm.Version.GetAppVersion(); } } - - //------------------------------------------------------------------- - // Business components. - // NB Keep these accessors protected to avoid them being called by the model binding logic before the session data is ready. - protected SbmInternals Internals { get { if (internals == 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. - protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } } - protected SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } } - protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } } - protected SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } } - protected SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } } - protected SbmStockMgr StockMgr { get { return Internals.StockMgr; } } - protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } } - protected 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. - protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } - protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } } - protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } - protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } - protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } } - protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } } - protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } } - protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } } - protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } } - protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } } - // Configurations. - protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } - protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } - // System codes. - protected List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); } - - //------------------------------------------------------------------- - // Security. - public bool ValidUserSession { get { return SessionData?.ValidUser ?? false; } } - public bool AwaitingLogin { get { return !ValidUserSession; } } - public bool KeepLoggedIn { get { return !AwaitingLogin && SessionData_Web.KeepLoggedIn; } } - /// Maximum length allowed for password entry: sign-up, change password etc. - public int PasswordMaxLength { get; } = 32; - - //------------------------------------------------------------------- - /// - /// Form control value max length - Security tables. - /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. - /// Hence, several cases where the value entered in the control isn't allowed the full database length. - /// - public int GetControlMaxLength(SaSecurityDbDfn.ColumnIdx column) - { - int maxLength = (int)SaSecurityDbDfn.GetColTextLen(column); - switch (column) - { - case SaSecurityDbDfn.ColumnIdx.SaSecItem_EmailAddress: - return Math.Min(maxLength, 100); - } - return maxLength; - } - - /// - /// Form control value max length - code type tables. - /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. - /// Hence, several cases where the value entered in the control isn't allowed the full database length. - /// - public int GetControlMaxLength(SaCodeTypeDbDfn.ColumnIdx column) - { - int maxLength = (int)SaCodeTypeDbDfn.GetColTextLen(column); - switch (column) - { - case SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name: - case SaCodeTypeDbDfn.ColumnIdx.SaCode_Description: - return Math.Min(maxLength, 100); - } - return maxLength; - } - - /// - /// Form control value max length - BusinessMgr tables. - /// In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted. - /// Hence, several cases where the value entered in the control isn't allowed the full database length. - /// - public int GetControlMaxLength(SbmDbDfn.ColumnIdx column) - { - int maxLength = (int)SbmDbDfn.GetColTextLen(column); - switch (column) - { - case SbmDbDfn.ColumnIdx.Affiliate_Email: - return Math.Min(maxLength, 100); - case SbmDbDfn.ColumnIdx.Affiliate_FirstName: - case SbmDbDfn.ColumnIdx.Affiliate_LastName: - return Math.Min(maxLength, 40); - case SbmDbDfn.ColumnIdx.Affiliate_Name: - return Math.Min(maxLength, 80); - case SbmDbDfn.ColumnIdx.Affiliate_PhoneMain: - case SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile: - case SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt: - return Math.Min(maxLength, 20); - case SbmDbDfn.ColumnIdx.Address_Postcode: - return Math.Min(maxLength, 16); - } - return maxLength; - } - - //------------------------------------------------------------------- - // Copyright notice. - public HtmlString CopyrightNotice - { - get - { - int initialYear = 2020; - int currentYear = DateTime.Today.Year; - return Localiser.GetHtmlText("copyright.symbol.year.html", (initialYear != currentYear ? initialYear + "-" : "") + currentYear.ToString()); - } - } - - //------------------------------------------------------------------- - // Display data - Dates. - public String FormatDateForDisplay(DateTime? value) - { - return DateUtil.Format(value, "d-MMM-yy", SessionCulture); - } - public String FormatDateTimeForDisplay(DateTime? value) - { - return StringUtil.TrimAll(DateUtil.Format(value, "d-MMM-yy HH:mm", SessionCulture)); - } - - //------------------------------------------------------------------- - // Form data - Dates. - // Format may depend on locale, but as long as these methods are used consistently, - // there should be consistent formatting, display and parsing of date values. - public String CalendarDateFormat - { - get - { - // JQuery-UI DatePicker date format. - // Format: - // d Single digit day of month - // dd Double digit day of month - // D 3 letter day of week abbreviation. - // DD Day of week. - // m Single digit month. - // mm Double digit month. - // M 3 letter month abbreviation. - // MM Month name. - // yy 4 digit year. - // Examples: - // dd/mm/yy 07/04/2012 - // dd-M-yy 07-Apr-2012 - // d-M-yy 7-Apr-2012 - return "dd-M-yy"; - } - } - public String FormatDateForForm(DateTime value) - { - return DateUtil.Format(value, "dd-MMM-yyyy"); - } - public DateTime ParseDateFromForm(String value) - { - return DateUtil.ParseExact(value, "dd-MMM-yyyy"); - } - - //------------------------------------------------------------------- - // Link URLs. - public class LinksData - { - public String Facebook { get; } = "https://www.facebook.com/BusinessMgr/"; - public String LinkedIn { get; } = "https://www.linkedin.com/company/BusinessMgr/about/"; - } - public LinksData Links { get; } = new LinksData(); - - //------------------------------------------------------------------- - // Form data. - // NB Use methods rathe rthan accessors for properties that depend on session data - // to avoid the model binding logic invoking a getter before it's ready for use. - - /// List of Code Types for dropdown. - public IEnumerable GetCodeTypesForSelect() - { - List codeTypes = new List(); - SaCodeType.Params prmCodeType = new SaCodeType.Params(); - prmCodeType.SortColumns.Add(CodeTypeConsole.GetCodeTypeColumnDfn(SaCodeType.Column.Name)); - foreach (SaCodeType codeType in CodeTypeConsole.GetCodeTypeList(prmCodeType)) - codeTypes.Add(codeType.Code, codeType.Name); - return new SelectList(codeTypes, "Code", "Desc"); - } - - /// List of Code Type Codes for dropdown. - public IEnumerable GetCodeTypeCodesForSelect(Sbm.ApplCodeType codeType, bool activeOnly = true) - { - List codes = new List(); - foreach (SaCode code in CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(codeType), activeOnly)) - codes.Add(code.Code, code.Description); - return new SelectList(codes, "Code", "Desc"); - } - - //------------------------------------------------------------------- - // Form properties. - /// - /// User session index to identify the site resources, eg. database. - /// Equivalent to the Site index on the login form. - /// Populates value on logout form to identify default site for next login. - /// - public ushort SessionIdx { get { return SessionContext?.Index ?? 0; } } - public String FormAction { get; set; } - - //------------------------------------------------------------------- - } - //======================================================================= -} diff --git a/SaBusMgrStandardBase/Base/App/Sbm.cs b/SaBusMgrStandardBase/Base/App/Sbm.cs index 81fdaec..b63434c 100644 --- a/SaBusMgrStandardBase/Base/App/Sbm.cs +++ b/SaBusMgrStandardBase/Base/App/Sbm.cs @@ -1134,8 +1134,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App OrderItem_ShowCommodityDetails, OrderItem_ShowStockDetails, PurchaseItem_AssociatedSalesItems, + Asset_Purchase, Asset_Sale, Asset_Rental, + Asset_Disposal, } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs b/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs index eaf6f82..87ced71 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs @@ -1,14 +1,5 @@ -using Org.BouncyCastle.Math.EC; -using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; -using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.SbmInstanceConfig; namespace Sarand.BusinessMgr.Net.Standard.Base.App { @@ -27,6 +18,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public abstract bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse); + //------------------------------------------------------------------- + // Defaults. + + public abstract ISbmInstanceConfig.DefaultsData GetDefaults(); + //------------------------------------------------------------------- // Contacts. @@ -50,6 +46,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App /// public abstract bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse); + //------------------------------------------------------------------- + // Update Log. + public abstract bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column, bool defaultResponse); + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/App/SbmInternals.cs b/SaBusMgrStandardBase/Base/App/SbmInternals.cs index e322b39..5acdfec 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInternals.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInternals.cs @@ -21,7 +21,6 @@ using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.Linq; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.App { @@ -95,21 +94,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App private SbmStockControlConfig stockControlConfig; private SbmRequirementCostingConfig requirementCostingConfig; // Reference data. - private List currencies = null; - private List taxCodes = null; - private List unitsOfMeasure = null; + private Dictionary regions = null; + private Dictionary currencies = null; + private Dictionary taxCodes = null; + private Dictionary unitsOfMeasure = null; //------------------------------------------------------------------- // Construction. /// /// Sessionless construction - minimal context information. + /// - Used by Instance Data Cache and Control application. /// public SbmInternals(SbmSessionContext sessionContext) { UserContext = new SbmSessionData_Internals(sessionContext); ReadOnly = true; } - // Session dependent construction. + /// + /// Session dependent construction. + /// public SbmInternals(ISbmUserOrganisationContext userContext) { UserContext = userContext; @@ -129,9 +132,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App if (mgr.processMgr != null) mgr.processMgr.Dispose(); if (mgr.dataItemMgr != null) mgr.dataItemMgr.Dispose(); // Reference data. - if (currencies != null) currencies.ClearAndDispose(); - if (taxCodes != null) taxCodes.ClearAndDispose(); - if (unitsOfMeasure != null) unitsOfMeasure.ClearAndDispose(); + if (regions != null) regions.Values.ToList().ClearAndDispose(); + if (currencies != null) currencies.Values.ToList().ClearAndDispose(); + if (taxCodes != null) taxCodes.Values.ToList().ClearAndDispose(); + if (unitsOfMeasure != null) unitsOfMeasure.Values.ToList().ClearAndDispose(); // Consoles. if (con.sessionConsole != null) con.sessionConsole.Dispose(); if (con.diaryConsole != null) con.diaryConsole.Dispose(); @@ -207,13 +211,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App if (code.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue; break; case Sbm.SystemCode.OrgOption_PeriodDays: - if (code.Type == (int)Sbm.OrgOption_PeriodDays.UpdateClosedTransaction_DispatchDetails && !SessionConsole.AllowOption(ConfigOption.DeliveryPlanning)) continue; + if (code.Type == (int)Sbm.OrgOption_PeriodDays.UpdateClosedTransaction_DispatchDetails && !SessionConsole.AllowOption(Sbm.ConfigOption.DeliveryPlanning)) continue; if (code.Type == (int)Sbm.OrgOption_PeriodDays.UpdateStockLevelsInPast && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue; break; case Sbm.SystemCode.OrgOption_PeriodWeeks: - if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.Timesheets && !SessionConsole.AllowOption(ConfigOption.TimeRecording)) continue; - if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control && !SessionConsole.AllowOption(ConfigOption.TimeRecording)) continue; - if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.ImminentStockDue && !SessionConsole.GetOwnerOption_AllowOption(OrgOption_AllowOption.ImminentStock)) continue; + if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.Timesheets && !SessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording)) continue; + if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control && !SessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording)) continue; + if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.ImminentStockDue && !SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.ImminentStock)) continue; break; case Sbm.SystemCode.OrgOption_Caption: if (!SessionConsole.AllowTransactionType(Sbm.OrgOptionToTransType((Sbm.OrgOption_Caption)code.Type))) continue; @@ -449,6 +453,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App } } + //------------------------------------------------------------------- + // T a x C o d e s + //------------------------------------------------------------------- + private void populateRegions() + { + if (regions != null) return; + SaRegion.Params prmRegion = new SaRegion.Params(); + prmRegion.StatusCat = SaRegion.StatusCat.Any; + regions = ReferenceDataConsole.GetRegionList(prmRegion).ToDictionary(region => region.Id, region => region); + } + public List GetRegions() + { + populateRegions(); + return new List(regions.Values); + } + public SaRegion GetRegionById(SysId regionId) + { + if (!SysId.IsValid(regionId)) return null; + populateRegions(); + return regions.GetValueOrDefault(regionId); + } + //------------------------------------------------------------------- // C u r r e n c i e s //------------------------------------------------------------------- @@ -457,28 +483,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App if (currencies != null) return; SaCurrency.Params prmCurrency = new SaCurrency.Params(); prmCurrency.StatusCat = SaCurrency.StatusCat.Any; - currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency); + currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency).ToDictionary(currency => currency.Id, currency => currency); } public List GetCurrencies() { populateCurrencies(); - return new List(currencies); + return new List(currencies.Values); } public SaCurrency GetCurrencyById(SysId currencyId) { if (!SysId.IsValid(currencyId)) return null; populateCurrencies(); - return currencies.Find(item => item.Id.Equals(currencyId)); + return currencies.GetValueOrDefault(currencyId); } public SaCurrency GetCurrencyByCode(String currencyCode) { - if (StringUtil.IsEmpty(currencyCode)) - { + if (StringUtil.IsBlank(currencyCode)) return null; - } - populateCurrencies(); - return currencies.Find(item => item.Code.EqualsCI(currencyCode)); + return currencies.Values.Where(item => item.Code.EqualsCI(currencyCode)).FirstOrDefault(); } // Currency Decimals. public static byte CurrencyDecimalsDefault { get; } = 2; @@ -499,18 +522,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App if (taxCodes != null) return; SaTaxCode.Params prmTaxCode = new SaTaxCode.Params(); prmTaxCode.StatusCat = SaTaxCode.StatusCat.Any; - taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode); + taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode).ToDictionary(taxCode => taxCode.Id, taxCode => taxCode); } public List GetTaxCodes() { populateTaxCodes(); - return new List(taxCodes); + return new List(taxCodes.Values); } - public SaTaxCode GetTaxCodeById(SysId currencyId) + public SaTaxCode GetTaxCodeById(SysId taxCodeId) { - if (!SysId.IsValid(currencyId)) return null; + if (!SysId.IsValid(taxCodeId)) return null; populateTaxCodes(); - return taxCodes.Find(item => item.Id.Equals(currencyId)); + return taxCodes.GetValueOrDefault(taxCodeId); } //------------------------------------------------------------------- @@ -521,31 +544,34 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App if (unitsOfMeasure != null) return; SaUnitMeasure.Params prmUnitMeasure = new SaUnitMeasure.Params(); prmUnitMeasure.StatusCat = SaUnitMeasure.StatusCat.Any; - unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitMeasure); + unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitMeasure).ToDictionary(unitMeasure => unitMeasure.Id, unitMeasure => unitMeasure); } public List GetUnitsOfMeasure() { populateUnitsOfMeasure(); - return new List(unitsOfMeasure); + return new List(unitsOfMeasure.Values); } - public String GetUnitOfMeasureCaption(SysId currencyId) + public SaUnitMeasure GetUnitOfMeasureById(SysId unitMeasureId) { - if (!SysId.IsValid(currencyId)) return null; + if (!SysId.IsValid(unitMeasureId)) return null; populateUnitsOfMeasure(); - SaUnitMeasure uom = unitsOfMeasure.Find(item => item.Id.Equals(currencyId)); - return uom?.Single ?? ""; + return unitsOfMeasure.GetValueOrDefault(unitMeasureId); } - public SaUnitMeasure GetUnitOfMeasureById(SysId currencyId) + public String GetUnitOfMeasureCaption(SysId unitMeasureId) { - if (!SysId.IsValid(currencyId)) return null; + return GetUnitOfMeasureById(unitMeasureId)?.Single ?? ""; + } + public List GetUnitsOfMeasureByCategory(SaUomCategory uomCategory) + { + if (uomCategory == 0) return null; populateUnitsOfMeasure(); - return unitsOfMeasure.Find(item => item.Id.Equals(currencyId)); + return new List(unitsOfMeasure.Values.Where(item => item.Category == uomCategory)); } public SaUnitMeasure GetUnitOfMeasureByType(SaUomCategory uomCategory, SaUomType uomType) { if (uomCategory == 0 || uomType == 0) return null; populateUnitsOfMeasure(); - return unitsOfMeasure.Find(item => item.Category == uomCategory && item.UnitType == uomType); + return unitsOfMeasure.Values.Where(item => item.Category == uomCategory && item.UnitType == uomType).FirstOrDefault(); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs b/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs index f868aa2..c26ae3a 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs @@ -10,7 +10,6 @@ using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.Linq; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.App { @@ -102,17 +101,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App } //------------------------------------------------------------------- - // Security Rights. - public class SecurityRightData - { - public int Type { get; set; } - public String Code { get; set; } - } + /// + /// Registered Security Rights to identify code for enumerated right. + /// Optinised for speed of conversin and serialised storage. + /// [JsonProperty("SecurityRights")] - public List SecurityRights { get; private set; } = new List(); + public Dictionary SecurityRights { get; private set; } = new Dictionary(); private void PopulateSecurityRights(List rights) { - SecurityRights = rights.Select(item => new SecurityRightData() { Type = item.Type, Code = item.Code }).ToList(); + SecurityRights = rights.ToDictionary(item => item.Type, item => item.Code); } //------------------------------------------------------------------- @@ -170,7 +167,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public List Groups { get; private set; } = new List(); public class RightData { - public String Code { get; set; } public SysId DataItemId { get; set; } } public class RightsData @@ -184,11 +180,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Security. public bool IsSecurityRightGranted(String rightCode, SysId dataItemId) { - return Granted != null && Granted.Any(item => item.Code.EqualsCI(rightCode) && SysId.ToInt(dataItemId) == SysId.ToInt(item.DataItemId)); + return Granted != null && (Granted.GetValueOrDefault(rightCode)?.Any(item => SysId.ToInt(dataItemId) == SysId.ToInt(item.DataItemId)) ?? false); } public bool IsSecurityRightDenied(String rightCode, SysId dataItemId) { - return Denied != null && Denied.Any(item => item.Code.EqualsCI(rightCode) && SysId.ToInt(dataItemId) == SysId.ToInt(item.DataItemId)); + return Denied != null && (Denied.GetValueOrDefault(rightCode)?.Any(item => SysId.ToInt(dataItemId) == SysId.ToInt(item.DataItemId)) ?? false); } // Population. public void Populate(IEnumerable rights) @@ -196,16 +192,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Clear(); foreach (var right in rights) { - RightData rightData = new RightData() { Code = right.Code, DataItemId = SysId.IsValid(right.DataItemId) ? right.DataItemId : null }; + RightData rightData = new RightData() { DataItemId = SysId.IsValid(right.DataItemId) ? right.DataItemId : null }; if (right.Granted) { - if (Granted == null) Granted = new HashSet(); - Granted.Add(rightData); + if (Granted == null) Granted = new Dictionary>(); + if (!Granted.ContainsKey(right.Code)) Granted[right.Code] = new List(); + Granted[right.Code].Add(rightData); } else { - if (Denied == null) Denied = new HashSet(); - Denied.Add(rightData); + if (Denied == null) Denied = new Dictionary>(); + if (!Denied.ContainsKey(right.Code)) Denied[right.Code] = new List(); + Denied[right.Code].Add(rightData); } } } @@ -214,8 +212,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Granted = null; Denied = null; } - public HashSet Granted { get; private set; } - public HashSet Denied { get; private set; } + public Dictionary> Granted { get; private set; } + public Dictionary> Denied { get; private set; } } public RightsData Rights { get; private set; } = new RightsData(); } @@ -227,7 +225,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Utilities. public String GetSecurityRightCode(Sbm.SecurityRight securityRight) { - return SecurityRights.FirstOrDefault(item => item.Type == (int)securityRight)?.Code ?? ""; + return SecurityRights.GetValueOrDefault((int)securityRight) ?? ""; } public bool IsSecurityRightGranted(Sbm.SecurityRight securityRight, SysId id = null) { @@ -470,19 +468,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public ItemTypesProfile ItemType { get; } = new ItemTypesProfile(); private void RefreshItemTypeProfile(SbmSessionConsole sessionConsole) { - ItemType.Processes = sessionConsole.AllowOption(Sbm.ConfigOption.Processes); - ItemType.Contacts = sessionConsole.AllowOption(Sbm.ConfigOption.Contacts); - ItemType.Commodities = sessionConsole.AllowOption(Sbm.ConfigOption.Commodities); - ItemType.Portfolios = sessionConsole.AllowOption(Sbm.ConfigOption.Portfolios); - ItemType.PriceSets = sessionConsole.AllowOption(Sbm.ConfigOption.PriceSets); - ItemType.CommodityCustomers = sessionConsole.AllowOption(Sbm.ConfigOption.CommodityCustomers); - ItemType.CommoditySuppliers = sessionConsole.AllowOption(Sbm.ConfigOption.CommoditySuppliers); - ItemType.Transactions = sessionConsole.AllowOption(Sbm.ConfigOption.Transactions); - ItemType.Assets = sessionConsole.AllowOption(Sbm.ConfigOption.Assets); - ItemType.Vehicles = sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles); - ItemType.StockLocations = sessionConsole.GetStockControlConfig().AllowStockLocations(); - ItemType.StockContainers = sessionConsole.GetStockControlConfig().AllowStockContainers(); - ItemType.StockControl = sessionConsole.GetStockControlConfig().AllowStockControl(); + if (sessionConsole.AllowOption(Sbm.ConfigOption.Processes)) + ItemType.Processes = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) + ItemType.Contacts = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) + ItemType.Commodities = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.Portfolios)) + ItemType.Portfolios = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.PriceSets)) + ItemType.PriceSets = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.CommodityCustomers)) + ItemType.CommodityCustomers = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.CommoditySuppliers)) + ItemType.CommoditySuppliers = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) + ItemType.Transactions = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.Assets)) + ItemType.Assets = true; + if (sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles)) + ItemType.Vehicles = true; + if (sessionConsole.GetStockControlConfig().AllowStockLocations()) + ItemType.StockLocations = true; + if (sessionConsole.GetStockControlConfig().AllowStockContainers()) + ItemType.StockContainers = true; + if (sessionConsole.GetStockControlConfig().AllowStockControl()) + ItemType.StockControl = true; } // Item types. public bool UserCanViewItemType(Sbm.ItemType itemType) diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs index f4d508f..1f99a01 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs @@ -4,7 +4,6 @@ using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.ReferenceData; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.App { @@ -778,8 +777,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription, "OrderItemModCmdDesc", "Order item - modify commodity description", ""), new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails, "OrderItemShowCmdDet", "Order item - show commodity details", ""), new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails, "OrderItemShowStkDet", "Order item - show Stock details", ""), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Purchase, "AssetPurchase", "Asset Purchase"), new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Sale, "AssetSale", "Asset Sale"), - new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Rental, "AssetRental", "Asset rental") + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Rental, "AssetRental", "Asset rental"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Disposal, "AssetDisposal", "Asset Disposal") }; // Organisation Option - Caption diff --git a/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs b/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs index b350c99..5f1fc5e 100644 --- a/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs +++ b/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs @@ -3,10 +3,6 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.SbmSysParamCache; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus.Control { diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs index 13ca9e2..eed3056 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs @@ -12,7 +12,6 @@ using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.IO; -using static Sarand.Net.Standard.Base.Bus.ItemId; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -127,9 +126,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } return false; } - public List GetInterfaceIds(bool activeOnly) + public HashSet GetInterfaceIds(bool activeOnly) { - List interfaceIds = new List(); + HashSet interfaceIds = new HashSet(); if (SysId.IsValid(sageParams.InterfaceId) && (!activeOnly || sageParams.dfnInt_Sage.Active)) interfaceIds.Add(qbkParams.InterfaceId); if (SysId.IsValid(qbkParams.InterfaceId) && (!activeOnly || qbkParams.dfnInt_QBooks.Active)) diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs b/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs index e899b9a..0592d35 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs @@ -5,7 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.Net.Standard.Base.Core.StringPair; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -699,8 +699,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Address. public Sbm.AddressType AddressType { get; set; } public ItemId ItemId { get; set; } @@ -732,65 +732,50 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmAddressList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool FindPrimary(this List values, bool IsPrimary) { if (!IsPrimary) return false; - return values.Exists(item => item.IsPrimary.Equals(IsPrimary)); + return values.Any(item => item.IsPrimary.Equals(IsPrimary)); } public static bool FindById(this List values, SysId addressId) { if (!SysId.IsValid(addressId)) return false; - return values.Exists(item => item.Id.Equals(addressId)); + return values.Any(item => item.Id.Equals(addressId)); } public static bool FindByType(this List values, String addressType) { if (StringUtil.IsEmpty(addressType)) return false; - return values.Exists(item => item.AddressType.ToString().EqualsCI(addressType)); + return values.Any(item => item.AddressType.ToString().EqualsCI(addressType)); } public static bool FindByTypeRef(this List values, String refExt) { if (String.IsNullOrEmpty(refExt)) return false; - return values.Exists(item => item.RefExt.Equals(refExt)); + return values.Any(item => item.RefExt.Equals(refExt)); } public static bool FindByPostcode(this List values, String postcode) { if (String.IsNullOrEmpty(postcode)) return false; - return values.Exists(item => item.Postcode.Equals(postcode)); + return values.Any(item => item.Postcode.Equals(postcode)); } public static bool FindByTypeVisitOn(this List values, String type, DateTime visitOn) { if (StringUtil.IsEmpty(type)) return false; if (!DateUtil.IsValid(visitOn)) return false; - return values.Exists(item => item.AddressType.Equals(type) && item.IsVisitOn(visitOn)); + return values.Any(item => item.AddressType.Equals(type) && item.IsVisitOn(visitOn)); } public static bool HasType(this List values, Sbm.AddressType addressType, SbmAddress addressIgnore) { - foreach (SbmAddress address in values) - { - if (address == addressIgnore) continue; - if (address.AddressType == addressType) return true; - } - return false; + return values.Any(address => address.AddressType == addressType && address != addressIgnore); } public static bool HasType(this List values, Sbm.AddressType addressType, SysId addressIdIgnore) { - foreach (SbmAddress address in values) - { - if (!SysId.IsValid(addressIdIgnore) || address.Id != addressIdIgnore) continue; - if (address.AddressType == addressType) return true; - } - return false; + return values.Any(address => address.AddressType == addressType && !SysId.IsValid(addressIdIgnore) || address.Id != addressIdIgnore); } public static int OccurrencesOf(this List values, Sbm.AddressType addressType) { // How many addresses of the specified type are in the list? - int iOccur = 0; - foreach (SbmAddress address in values) - { - if (address.AddressType == addressType) iOccur++; - } - return iOccur; + return values.Count(address => address.AddressType == addressType); } public static int OccurrencesOfType(this List values) { diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs index e793fec..9425f89 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs @@ -767,8 +767,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Affiliate. public Sbm.AffiliateType AffiliateType { get; set; } = Sbm.AffiliateType.Any; public SysId AffiliateIdParent { get; set; } @@ -801,12 +801,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SysId InterfaceIdExcludeSystemUsers { get; set; } /// Contact status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs b/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs index 43b6307..05eccf1 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -80,6 +81,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String RefExt { get; set; } = ""; public String DescBrief { get; set; } = ""; public ItemId ItemId { get; set; } = new ItemId(); + // Purchase. public DateTime PurchaseOn { get; set; } = DateTime.MinValue; public SysId AssocIdSupplier { get; set; } = new SysId(); public String PurchaseInvoiceRef { get; set; } = ""; @@ -89,6 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public decimal AmountPurchaseGross { get; set; } = 0.0m; public decimal AmountSettlementGross { get; set; } = 0.0m; public decimal AmountEnhancementGross { get; set; } = 0.0m; + // Sale. public SysId AssocIdCustomer { get; set; } = new SysId(); public String SellCategoryCode { get; set; } = ""; public decimal AmountSell { get; set; } = 0.0m; @@ -98,15 +101,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public DateTime SoldOn { get; set; } = DateTime.MinValue; public decimal AmountSold { get; set; } = 0.0m; public decimal AmountSoldGross { get; set; } = 0.0m; + // Disposal. public String DisposeCode { get; set; } = ""; public DateTime DisposeOn { get; set; } = DateTime.MinValue; public DateTime DueBackOn { get; set; } = DateTime.MinValue; + // Rental. public decimal AmountRentalCost { get; set; } = 0.0m; public SysId UomIdRentalCost { get; set; } = new SysId(); public SysId TaxCodeIdRentalCost { get; set; } = new SysId(); public decimal AmountRentalPrice { get; set; } = 0.0m; public SysId UomIdRentalPrice { get; set; } = new SysId(); public SysId TaxCodeIdRentalPrice { get; set; } = new SysId(); + // Processes. public SysId ProcessIdNext { get; set; } = new SysId(); } @@ -633,8 +639,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Asset. public SysId AssetCatId { get; set; } public String Search { get; set; } @@ -648,25 +654,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool RestrictToActive { get; set; } /// Asset status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List value = new List(); - - if (IdsIncluded.Count > 0) value.Add("Assets included", IdsIncluded.ToString()); - if (IdsExcluded.Count > 0) value.Add("Assets excluded", IdsExcluded.ToString()); - if (SysId.IsValid(AssetCatId)) value.Add("Asset category Id", AssetCatId.ToString()); - if (ItemType > 0) value.Add("Item type", ItemType.ToString()); - if (ItemId.IsValid(ItemId)) value.Add("Item Id", ItemId.ToString()); - if (!StringUtil.IsEmpty(SerialNumber)) value.Add("SerialNumber", SerialNumber); - if (!StringUtil.IsEmpty(SerialNumberPartial)) value.Add("SerialNumber starts", SerialNumberPartial); - if (!StringUtil.IsEmpty(DescBriefPartial)) value.Add("Description starts", DescBriefPartial); - if (SysId.IsValid(ProcessIdNext)) value.Add("Next process #", ProcessIdNext.ToString()); - if (SysId.IsValid(ProcessIdActive)) value.Add("Active process #", ProcessIdActive.ToString()); - if (!RestrictToActive) value.Add("Status", "Active"); - - return value; - } } //------------------------------------------------------------------- } @@ -675,16 +662,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmAssetList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmAddress address) { if (address == null) return false; - return (values.Find(item => item == address) != null); + return values.Any(item => item == address); } public static bool FindById(this List values, SysId addressId) { if (!SysId.IsValid(addressId)) return false; - return values.Exists(item => item.Id.Equals(addressId)); + return values.Any(item => item.Id.Equals(addressId)); } } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs index b120b55..e97fe6f 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs @@ -382,8 +382,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // AssetCategory. public Sbm.AssetType AssetType { get; set; } public String Search { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs index f21181b..db0bfcb 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs @@ -232,8 +232,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // AssetProcess. public SysId AssetId { get; set; } public SysId ProcessId { get; set; } @@ -241,12 +241,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool RestrictToActive { get; set; } /// Asset Process status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs index 51c6d8e..8474724 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs @@ -873,8 +873,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Association. public Sbm.AssociationType AssociationType { get; set; } = Sbm.AssociationType.NotInternal; public SysId AffiliateIdOwner { get; set; } @@ -894,19 +894,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus // Association codes. public String DefaultNominalCodeFull { get; set; } public String DefaultNominalCodePartial { get; set; } - public List AccountManagerCodes { get; } = new List(); - public List AccountHandlerCodes { get; } = new List(); - public List AccountTypeCodes { get; } = new List(); - public List AccountRatingCodes { get; } = new List(); - public List ContactAreaCodes { get; } = new List(); - public List ContactHandlerCodes { get; } = new List(); - public List ContactMethodCodes { get; } = new List(); - public List ContactCallCycleCodes { get; } = new List(); - public List OrderLeadTimeCodes { get; } = new List(); - public List DeliveryTypeCodes { get; } = new List(); - public List DeliveryMethodCodes { get; } = new List(); - public List DeliveryCourierCodes { get; } = new List(); - public List DeliveryBookInCodes { get; } = new List(); + public HashSet AccountManagerCodes { get; } = new HashSet(); + public HashSet AccountHandlerCodes { get; } = new HashSet(); + public HashSet AccountTypeCodes { get; } = new HashSet(); + public HashSet AccountRatingCodes { get; } = new HashSet(); + public HashSet ContactAreaCodes { get; } = new HashSet(); + public HashSet ContactHandlerCodes { get; } = new HashSet(); + public HashSet ContactMethodCodes { get; } = new HashSet(); + public HashSet ContactCallCycleCodes { get; } = new HashSet(); + public HashSet OrderLeadTimeCodes { get; } = new HashSet(); + public HashSet DeliveryTypeCodes { get; } = new HashSet(); + public HashSet DeliveryMethodCodes { get; } = new HashSet(); + public HashSet DeliveryCourierCodes { get; } = new HashSet(); + public HashSet DeliveryBookInCodes { get; } = new HashSet(); // Association must have a transaction of the specified type (optional) active at some time between the specified dates (one date can be specified for open ended period). /// Transaction status - Value other than 'Any' triggers transaction filter. public SbmTransaction.StatusCat TransactionStatusCat { get; set; } = SbmTransaction.StatusCat.Any; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs index 0412bfd..d3cb2fc 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs @@ -1787,8 +1787,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // Commodity Ids. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Commodity. public Sbm.CommodityType CommodityType { get; set; } public bool StockItemsOnly { get; set; } = false; @@ -1804,7 +1804,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String Search { get; set; } // Category. public String CatalogRefPartial { get; set; } - public List Categories { get; } = new List(); + public HashSet Categories { get; } = new HashSet(); // Customer. public SysId AssociationIdCustomer { get; set; } public String CustomerName { get; set; } @@ -1828,8 +1828,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String FinishCode { get; set; } public String PromotionCode { get; set; } // Price Set. - public List PriceSetIdsIncluded { get; } = new List(); - public List PriceSetIdsExcluded { get; } = new List(); + public HashSet PriceSetIdsIncluded { get; } = new HashSet(); + public HashSet PriceSetIdsExcluded { get; } = new HashSet(); // Stock Control. public Sbm.LocationFilter StockLocationFilter { get; set; } public SysId LocationIdStock { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs index 3d26408..1157edd 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -230,8 +231,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // CommodityCustomer. public SysId CommodityId { get; set; } public SysId AssocIdCustomer { get; set; } @@ -242,12 +243,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool RestrictToActive { get; set; } = true; /// Commodity Customer status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -257,26 +252,26 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmCommodityCustomerList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmCommodityCustomer commodityCustomer) { if (commodityCustomer == null) return false; - return (values.Find(item => item == commodityCustomer) != null); + return values.Any(item => item == commodityCustomer); } public static bool FindByCommodity(this List values, SysId commodityId) { if (!SysId.IsValid(commodityId)) return false; - return (values.Find(item => item.CommodityId.Equals(commodityId)) != null); + return values.Any(item => item.CommodityId.Equals(commodityId)); } public static bool FindByCustomer(this List values, SysId customerId) { if (!SysId.IsValid(customerId)) return false; - return (values.Find(item => item.AssocIdCustomer.Equals(customerId)) != null); + return values.Any(item => item.AssocIdCustomer.Equals(customerId)); } public static bool FindByProductCode(this List values, String productCode) { if (StringUtil.IsEmpty(productCode)) return false; - return (values.Find(item => item.ProductCode.Equals(productCode)) != null); + return values.Any(item => item.ProductCode.Equals(productCode)); } } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs index bc3fa39..0127968 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -220,8 +221,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // CommoditySupplier. public SysId CommodityId { get; set; } public SysId AssocIdSupplier { get; set; } @@ -231,12 +232,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool RestrictToActive { get; set; } = true; /// Commodity Supplier status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -246,21 +241,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmCommoditySupplierList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmCommoditySupplier commoditySupplier) { if (commoditySupplier == null) return false; - return (values.Find(item => item == commoditySupplier) != null); + return values.Any(item => item == commoditySupplier); } public static bool FindByCommodity(this List values, SysId commodityId) { if (!SysId.IsValid(commodityId)) return false; - return (values.Find(item => item.CommodityId.Equals(commodityId)) != null); + return values.Any(item => item.CommodityId.Equals(commodityId)); } public static bool FindBySupplier(this List values, SysId supplierId) { if (!SysId.IsValid(supplierId)) return false; - return (values.Find(item => item.AssocIdSupplier.Equals(supplierId)) != null); + return values.Any(item => item.AssocIdSupplier.Equals(supplierId)); } } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs b/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs index 3882a0d..6adf628 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs @@ -660,8 +660,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Constituent. public Sbm.ConstituentType ConstituentType { get; set; } = Sbm.ConstituentType.Any; public SysId AffIdTarget { get; set; } @@ -688,7 +688,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmConstituentList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static int CompareEffectiveAscend(SbmConstituent constituent1, SbmConstituent constituent2) { if (constituent1 != null || constituent2 != null) return 0; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs b/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs index 878d8ac..d671d0a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -302,8 +303,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus HasItems = prmContainerItem.ContainerHasItems; } // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Container. //public SysId AffiliateIdOwner { get; set; } public Sbm.ContainerCategory ContainerCategory { get; set; } = Sbm.ContainerCategory.Any; @@ -325,12 +326,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SaStatus ContainerStatus { get; set; } /// Container status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -340,16 +335,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmContainerList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmContainer container) { if (container == null) return false; - return (values.Find(item => item == container) != null); + return values.Any(item => item == container); } public static bool FindById(this List values, SysId containerId) { if (!SysId.IsValid(containerId)) return false; - return values.Exists(item => item.Id.Equals(containerId)); + return values.Any(item => item.Id.Equals(containerId)); } } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs index ade9287..8b0fd8c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -273,15 +274,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // Item Ids. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Item properties. public SysId ContainerId { get; set; } public short ItemSeq { get; set; } public Sbm.ItemType ItemType { get; set; } - public List ItemIds { get; } = new List(); + public HashSet ItemIds { get; } = new HashSet(); public Sbm.ItemType ItemTypeSource { get; set; } - public List ItemIdsSource { get; } = new List(); + public HashSet ItemIdsSource { get; } = new HashSet(); public decimal Quantity { get; set; } // Container. public String TableAlias_Container { get; set; } @@ -299,12 +300,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool ContainerHasItems { get; set; } = false; /// Container Item status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -315,21 +310,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmContainerItemList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmContainerItem containerItem) { if (containerItem == null) return false; - return (values.Find(item => item == containerItem) != null); + return values.Any(item => item == containerItem); } public static bool FindByContainerId(this List values, SysId containerId) { if (!SysId.IsValid(containerId)) return false; - return values.Exists(item => item.ContainerId.Equals(containerId)); + return values.Any(item => item.ContainerId.Equals(containerId)); } public static bool FindByItemId(this List values, SysId itemId) { if (!SysId.IsValid(itemId)) return false; - return values.Exists(item => item.ItemType.Equals(itemId)); + return values.Any(item => item.ItemType.Equals(itemId)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs b/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs index 35da021..d883ca0 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs @@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -119,48 +120,41 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Data members. private readonly Data data = new Data(); - private readonly Sbm.CostEstimateCategory costEstimateCategory; - private readonly String type; - private readonly decimal time = 0.0m; - private readonly decimal rate = 0.0m; - private readonly decimal cost = 0.0m; - private readonly ushort markup = 0; - private readonly ushort minQuantity = 0; - private readonly ushort codeSeq = 0; // Static Definition. - private static String costEstimate = "CostEstimate"; - private static String delimArchiveOld = "#~#"; - private static String delimArchive = "#~#"; +#pragma warning disable IDE0051 // Remove unused private members + private static readonly String delimArchiveOld = "#~#"; +#pragma warning restore IDE0051 // Remove unused private members + private static readonly String delimArchive = "#~#"; //------------------------------------------------------------------- // Construction. - public SbmCostEstimate(ISbmUserOrganisationContext userContext, Sbm.CostEstimateCategory costEstimateCategory) : base(userContext) + public SbmCostEstimate(ISbmUserOrganisationContext userContext, Sbm.CostEstimateCategory category) : base(userContext) { - CostEstimateCategory = costEstimateCategory; + CostEstimateCategory = category; Status = DefaultStatus; } // Conversion from ItemLink. public SbmCostEstimate(ISbmUserOrganisationContext userContext, String archive) : base(userContext) { String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None); - costEstimateCategory = (Sbm.CostEstimateCategory)(data.Length > 0 ? StringUtil.ToShort(data[0]) : 0); - type = (data.Length > 1 ? data[1] : ""); - time = (data.Length > 2 ? StringUtil.ToDecimal(data[2]) : 0.0m); - rate = (data.Length > 3 ? StringUtil.ToDecimal(data[3]) : 0.0m); - cost = (data.Length > 4 ? StringUtil.ToDecimal(data[4]) : 0.0m); - markup = (ushort)(data.Length > 5 ? StringUtil.ToInt(data[5]) : 0); - minQuantity = (ushort)(data.Length > 6 ? StringUtil.ToInt(data[6]) : 0); + CostEstimateCategory = (Sbm.CostEstimateCategory)(data.Length > 0 ? StringUtil.ToShort(data[0]) : 0); + Type = (data.Length > 1 ? data[1] : ""); + Time = (data.Length > 2 ? StringUtil.ToDecimal(data[2]) : 0.0m); + Rate = (data.Length > 3 ? StringUtil.ToDecimal(data[3]) : 0.0m); + Cost = (data.Length > 4 ? StringUtil.ToDecimal(data[4]) : 0.0m); + Markup = (ushort)(data.Length > 5 ? StringUtil.ToInt(data[5]) : 0); + MinQuantity = (ushort)(data.Length > 6 ? StringUtil.ToInt(data[6]) : 0); } //------------------------------------------------------------------- // CostEstimate status. - private static readonly List containerItemStatuses = new List() + private static readonly List costEstimateStatuses = new List() { SaStatus.Active, SaStatus.Disabled, }; public static SaStatus DefaultStatus { get { return SaStatus.Current; } } - public static List CostEstimateStatuses { get { return new List(containerItemStatuses); } } + public static List CostEstimateStatuses { get { return new List(costEstimateStatuses); } } public static DataValue.TriStateType GetStatusTriState(SaStatus status) { switch (status) @@ -179,7 +173,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Utilities. - public List GetCategories(Sbm.CostEstimateCategoryType costEstimateCategoryType, bool includeCommodityCode) + public List GetCategories(Sbm.CostEstimateCategoryType categoryType, bool includeCommodityCode) { List categories = new List(); if (includeCommodityCode) @@ -189,31 +183,31 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus categories.Add(Sbm.CostEstimateCategory.LabourPerUnit, "LPU", "Labour per unit"); categories.Add(Sbm.CostEstimateCategory.LabourPerJob, "LPJ", "Labour per job"); // Remove unneccessary categories from the list: - if (costEstimateCategoryType != Sbm.CostEstimateCategoryType.Any) + if (categoryType != Sbm.CostEstimateCategoryType.Any) { foreach (TypeCodeDesc category in categories) { - if (costEstimateCategoryType == Sbm.CostEstimateCategoryType.Cost && IsLabour((Sbm.CostEstimateCategory)category.Type)) categories.Clear(); - else if (costEstimateCategoryType == Sbm.CostEstimateCategoryType.Labour && !IsLabour((Sbm.CostEstimateCategory)category.Type)) categories.Clear(); + if (categoryType == Sbm.CostEstimateCategoryType.Cost && IsLabour((Sbm.CostEstimateCategory)category.Type)) categories.Clear(); + else if (categoryType == Sbm.CostEstimateCategoryType.Labour && !IsLabour((Sbm.CostEstimateCategory)category.Type)) categories.Clear(); } } return categories; } // Cost estimate types. - public Sbm.ApplCodeType GetCodeTypeForCategory(Sbm.CostEstimateCategory costEstimateCategory) + public Sbm.ApplCodeType GetCodeTypeForCategory(Sbm.CostEstimateCategory category) { - if (costEstimateCategory == Sbm.CostEstimateCategory.CostPerUnit) return Sbm.ApplCodeType.CostPerUnit; - if (costEstimateCategory == Sbm.CostEstimateCategory.CostPerJob) return Sbm.ApplCodeType.CostPerJob; - if (costEstimateCategory == Sbm.CostEstimateCategory.LabourPerUnit) return Sbm.ApplCodeType.LabourPerUnit; - if (costEstimateCategory == Sbm.CostEstimateCategory.LabourPerJob) return Sbm.ApplCodeType.LabourPerJob; + if (category == Sbm.CostEstimateCategory.CostPerUnit) return Sbm.ApplCodeType.CostPerUnit; + if (category == Sbm.CostEstimateCategory.CostPerJob) return Sbm.ApplCodeType.CostPerJob; + if (category == Sbm.CostEstimateCategory.LabourPerUnit) return Sbm.ApplCodeType.LabourPerUnit; + if (category == Sbm.CostEstimateCategory.LabourPerJob) return Sbm.ApplCodeType.LabourPerJob; return Sbm.ApplCodeType.Unknown; } // Matching. - public bool MatchesByCategoryType(Sbm.CostEstimateCategory costEstimateCategory, String type) + public bool MatchesByCategoryType(Sbm.CostEstimateCategory category, String type) { - if (CostEstimateCategory != costEstimateCategory) return false; + if (CostEstimateCategory != category) return false; if (Type != type) return false; return true; } @@ -221,15 +215,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus // Cloning - make a copy of the item. public SbmCostEstimate Clone() { - SbmCostEstimate costEstimateCost = new SbmCostEstimate(UserContext, costEstimateCategory.ToString()); - //costEstimateCost.CopyAttributesFrom(this); - costEstimateCost.Type = Type; - costEstimateCost.Time = Time; - costEstimateCost.Rate = Rate; - costEstimateCost.Cost = Cost; - costEstimateCost.Markup = Markup; - costEstimateCost.MinQuantity = MinQuantity; - costEstimateCost.Changed = false; + SbmCostEstimate costEstimateCost = new SbmCostEstimate(UserContext, CostEstimateCategory); + costEstimateCost.SetData(GetData().Clone()); return costEstimateCost; } @@ -251,7 +238,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus // Validation. public bool IsValid() { - if (!IsValidCategory(costEstimateCategory)) return false; + if (!IsValidCategory(CostEstimateCategory)) return false; if (!IsValidType()) return false; if (!IsValidTime()) return false; if (!IsValidRate()) return false; @@ -259,10 +246,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus return true; } - public bool IsValidCategory(Sbm.CostEstimateCategory costEstimateCategory) + public bool IsValidCategory(Sbm.CostEstimateCategory category) { - if (costEstimateCategory < Sbm.CostEstimateCategory.CommodityCost) return false; - if (costEstimateCategory > Sbm.CostEstimateCategory.LabourPerJob) return false; + if (category < Sbm.CostEstimateCategory.CommodityCost) return false; + if (category > Sbm.CostEstimateCategory.LabourPerJob) return false; return true; } @@ -307,11 +294,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } public bool IsLabour() { - return IsLabour(costEstimateCategory); + return IsLabour(CostEstimateCategory); } - public bool IsLabour(Sbm.CostEstimateCategory costEstimateCategory) + public bool IsLabour(Sbm.CostEstimateCategory category) { - switch (costEstimateCategory) + switch (category) { case Sbm.CostEstimateCategory.LabourPerJob: case Sbm.CostEstimateCategory.LabourPerUnit: @@ -321,11 +308,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } public bool IsUnitCost() { - return IsUnitCost(costEstimateCategory); + return IsUnitCost(CostEstimateCategory); } - public bool IsUnitCost(Sbm.CostEstimateCategory costEstimateCategory) + public bool IsUnitCost(Sbm.CostEstimateCategory category) { - switch (costEstimateCategory) + switch (category) { case Sbm.CostEstimateCategory.CommodityCost: case Sbm.CostEstimateCategory.CostPerUnit: @@ -336,11 +323,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } public bool IsJobCost() { - return IsJobCost(costEstimateCategory); + return IsJobCost(CostEstimateCategory); } - public bool IsJobCost(Sbm.CostEstimateCategory costEstimateCategory) + public bool IsJobCost(Sbm.CostEstimateCategory category) { - switch (costEstimateCategory) + switch (category) { case Sbm.CostEstimateCategory.CostPerJob: case Sbm.CostEstimateCategory.LabourPerJob: @@ -387,9 +374,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus // Calculated costs. public decimal GetCostPerUnit(decimal quantity) { - decimal costPerUnit = cost; + decimal costPerUnit = Cost; if (IsLabour()) - costPerUnit = time * rate; + costPerUnit = Time * Rate; if (IsJobCost()) { if (quantity != 0.0m) @@ -398,8 +385,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus costPerUnit = 0m; } // Apply the markup % - if (markup > 0) - costPerUnit *= 1 + (markup / 100.0m); + if (Markup > 0) + costPerUnit *= 1 + (Markup / 100.0m); // Round to 2 decimals. long costPerUnit100 = (long)((costPerUnit * 100.0m) + 0.5m); costPerUnit = costPerUnit100 / 100.0m; @@ -409,11 +396,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public decimal GetCostPerJob(decimal quantity) { // Check for 'Cost per job' categories. - if (IsJobCost(costEstimateCategory)) + if (IsJobCost(CostEstimateCategory)) { if (IsLabour()) - return time * rate; - return cost; + return Time * Rate; + return Cost; } // Cost is 'per unit'. decimal costPerJob = GetCostPerUnit(quantity) * quantity; @@ -421,24 +408,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } //------------------------------------------------------------------- } + //======================================================================= // C o s t E s t i m a t e D a t a L i s t //======================================================================= public static class SbmCostEstimateList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. //------------------------------------------------------------------- // Find in List. - public static bool Find(this List values, SbmCostEstimate containerItem) + public static bool Find(this List values, SbmCostEstimate costEstimate) { - if (containerItem == null) return false; - return (values.Find(item => item == containerItem) != null); + if (costEstimate == null) return false; + return values.Any(item => item == costEstimate); } - public static bool FindByCategoryType(this List values, Sbm.CostEstimateCategory costEstimateCategory, String type) + public static bool FindByCategoryType(this List values, Sbm.CostEstimateCategory category, String type) { - if (costEstimateCategory < 0 && StringUtil.IsEmpty(type)) return false; - return values.Exists(item => item.MatchesByCategoryType(costEstimateCategory, type)); + if (category < 0 && StringUtil.IsEmpty(type)) return false; + return values.Any(item => item.MatchesByCategoryType(category, type)); } //------------------------------------------------------------------- @@ -517,7 +505,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { // Check if this cost estimate's min qty is higher than the specified quantity. SbmCostEstimate costEstimateCost = values[est]; - Sbm.CostEstimateCategory costEstimateCategoryCost = costEstimateCost.CostEstimateCategory; + Sbm.CostEstimateCategory category = costEstimateCost.CostEstimateCategory; ushort iMinQty = costEstimateCost.MinQuantity; if (iMinQty > iQuantity) { @@ -536,7 +524,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus if (costEstimateCommodity == costEstimateCost) continue; // Only interested if the category and type are the same: - if (costEstimateCategoryCost == costEstimateCommodity.CostEstimateCategory && costEstimateCost.Type == costEstimateCommodity.Type) + if (category == costEstimateCommodity.CostEstimateCategory && costEstimateCost.Type == costEstimateCommodity.Type) { ushort iMinQtyCmp = costEstimateCommodity.MinQuantity; // Commodity costs are banded by minimum quantity. @@ -634,30 +622,30 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } // Costs by category. - public static bool HasCostsByCategory(this List values, Sbm.CostEstimateCategory costEstimateCategory) + public static bool HasCostsByCategory(this List values, Sbm.CostEstimateCategory category) { - if (costEstimateCategory < 0) return false; - return values.Exists(item => item.CostEstimateCategory.Equals(costEstimateCategory)); + if (category < 0) return false; + return values.Exists(item => item.CostEstimateCategory.Equals(category)); } - public static List GetCostCodesByCategory(this List values, Sbm.CostEstimateCategory costEstimateCategory) + public static List GetCostCodesByCategory(this List values, Sbm.CostEstimateCategory category) { List codes = new List(); for (int i = 1; i <= values.Count; i++) { SbmCostEstimate costEstimateCost = values[i]; - if (costEstimateCost.CostEstimateCategory == costEstimateCategory) + if (costEstimateCost.CostEstimateCategory == category) codes.Add(costEstimateCost.Clone().ToString()); } return codes; } - public static List GetCostsByCategory(this List values, Sbm.CostEstimateCategory costEstimateCategory) + public static List GetCostsByCategory(this List values, Sbm.CostEstimateCategory category) { List costEstimateCosts = new List(); for (int i = 1; i <= values.Count; i++) { SbmCostEstimate costEstimateCost = values[i]; - if (costEstimateCost.CostEstimateCategory == costEstimateCategory) + if (costEstimateCost.CostEstimateCategory == category) costEstimateCosts.Add(costEstimateCost.Clone()); } return costEstimateCosts; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs index b080e6a..913d15c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs @@ -222,8 +222,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // ItemBatch. public Sbm.ItemBatchType ItemBatchType { get; set; } public String Ref { get; set; } @@ -240,7 +240,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmItemBatchList { - /// Check whether currency exists/locate in list with specified Id. } //======================================================================= } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs index db702d3..1cd2526 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -366,8 +367,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // ItemLink. public Sbm.ItemLinkType ItemLinkType { get; set; } public Sbm.ItemType ItemTypeFrom { get; set; } @@ -388,19 +389,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static class SbmItemLinkList { //------------------------------------------------------------------- - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmItemLink itemlink) { if (itemlink == null) return false; - return (values.Find(item => item == itemlink) != null); + return values.Any(item => item == itemlink); } public static bool FindByLink(this List values, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) { - return values.Exists(item => item.MatchesLink(itemLinkType, itemTypeFrom, itemIdFrom, itemTypeTo, itemIdTo)); + return values.Any(item => item.MatchesLink(itemLinkType, itemTypeFrom, itemIdFrom, itemTypeTo, itemIdTo)); } public static SbmItemLink GetByLink(this List values, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) { - return values.Find(item => item.MatchesLink(itemLinkType, itemTypeFrom, itemIdFrom, itemTypeTo, itemIdTo)); + return values.Where(item => item.MatchesLink(itemLinkType, itemTypeFrom, itemIdFrom, itemTypeTo, itemIdTo)).FirstOrDefault(); } public static bool RemoveByLink(this List values, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) { @@ -411,12 +412,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static bool FindByFromItem(this List values, Sbm.ItemType itypeFrom, SysId idFrom, Sbm.ItemLinkType itemlinkType) { if (!SysId.IsValid(idFrom)) return false; - return values.Exists(item => item.MatchesFromItem(itypeFrom, idFrom, itemlinkType)); + return values.Any(item => item.MatchesFromItem(itypeFrom, idFrom, itemlinkType)); } public static bool FindByToItem(this List values, Sbm.ItemType itypeTo, SysId idTo, Sbm.ItemLinkType itemlinkType) { if (!SysId.IsValid(idTo)) return false; - return values.Exists(item => item.MatchesToItem(itypeTo, idTo, itemlinkType)); + return values.Any(item => item.MatchesToItem(itypeTo, idTo, itemlinkType)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs index 9937063..a4cd81c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs @@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -82,13 +83,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Data members. private readonly Data data = new Data(); - private readonly String type; - private readonly decimal amount = 0.0m; - private readonly ushort codeSeq = 0; - // Static Definition. - private static String itemPrice = "ItemPrice"; - private static String delimArchiveOld = "#~#"; - private static String delimArchive = "#~#"; +#pragma warning disable IDE0051 // Remove unused private members + private static readonly String delimArchiveOld = "#~#"; +#pragma warning restore IDE0051 // Remove unused private members + private static readonly String delimArchive = "#~#"; //------------------------------------------------------------------- // Construction. @@ -100,8 +98,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SbmItemPrice(ISbmUserOrganisationContext userContext, String archive) : base(userContext) { String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None); - type = (data.Length > 1 ? data[1] : ""); - amount = (data.Length > 2 ? StringUtil.ToDecimal(data[2]) : 0.0m); + Type = (data.Length > 1 ? data[1] : ""); + Amount = (data.Length > 2 ? StringUtil.ToDecimal(data[2]) : 0.0m); } //------------------------------------------------------------------- @@ -143,10 +141,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SbmItemPrice Clone() { SbmItemPrice itemPrice = new SbmItemPrice(UserContext); - //itemPriceCost.CopyAttributesFrom(this); - itemPrice.Type = Type; - itemPrice.Amount = Amount; - //itemPricePayment.Changed = false; + itemPrice.SetData(GetData().Clone()); return itemPrice; } @@ -197,13 +192,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmItemPriceList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. //------------------------------------------------------------------- //Find. public static bool Find(this List values, SbmItemPrice containerItem) { if (containerItem == null) return false; - return (values.Find(item => item == containerItem) != null); + return values.Any(item => item == containerItem); } public static bool FindByType(this List values, String type) { diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs index ad0f639..6b1b604 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs @@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -349,8 +350,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // ItemProcess. public Sbm.ItemType ItemType { get; set; } public SysId ItemId { get; set; } @@ -366,23 +367,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmItemProcessList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. /// //------------------------------------------------------------------- // Get list of process Ids (valid values only). public static List GetProcessIds(this List values) { - List processIds = new List(); - foreach (SbmItemProcess processItem in values) - { - if (processItem.ItemType == Sbm.ItemType.Process) - { - SysId processId = processItem.ItemId; - if (SysId.IsValid(processId) && !processIds.Contains(processId)) - processIds.Add(processId); - } - } - return processIds; + return new List(values.Where(item => item.ItemType == Sbm.ItemType.Process).Select(item => item.ItemId).ToHashSet()); } //------------------------------------------------------------------- @@ -449,7 +440,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static bool FindByProcessId(this List values, SysId processId) { if (!SysId.IsValid(processId)) return false; - return (values.Find(item => item.ProcessId.Equals(processId)) != null); + return values.Any(item => item.ProcessId.Equals(processId)); } // Identify the next process that is due to be completed: public static SbmItemProcess GetNextProcessInSequence(this List values, SaStatus status) diff --git a/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs b/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs index 9f0542c..0fa452d 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -221,8 +222,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Location. public SysId AffiliateIdOwner { get; set; } public Sbm.LocationCategory LocationCategory { get; set; } @@ -234,12 +235,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool RestrictToCalculateStock { get; set; } = false; /// Location status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -249,16 +244,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmLocationList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmLocation location) { if (location == null) return false; - return (values.Find(item => item == location) != null); + return values.Any(item => item == location); } public static bool FindById(this List values, SysId locationId) { if (!SysId.IsValid(locationId)) return false; - return values.Exists(item => item.Id.Equals(locationId)); + return values.Any(item => item.Id.Equals(locationId)); } } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs b/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs index 2b1117a..af08728 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs @@ -305,16 +305,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Movement. public Sbm.ItemType ItemType { get; set; } public Sbm.ItemType ItemTypeSource { get; set; } - public List ItemIds { get; set; } - public List ItemIdsSource { get; set; } + public HashSet ItemIds { get; set; } + public HashSet ItemIdsSource { get; set; } public Sbm.ItemType ContainerItemType { get; set; } public SysId ContainerItemId { get; set; } - public List ItemIdSource { get; set; } + public HashSet ItemIdSource { get; set; } public bool ExcludeProvisionalContainers { get; set; } = true; public Sbm.MovementType MovementType { get; set; } public DateTime MovementFrom { get; set; } @@ -329,12 +329,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SaStatus Status { get; set; } /// Movement status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs index 4913da4..e62c290 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs @@ -329,14 +329,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Hierarchy. public SysId ParentItemId { get; set; } public SysId AncestorItemId { get; set; } // Commodity. - public List IncludedCommodityIds { get; } = new List(); - public List ExcludedCommodityIds { get; } = new List(); + public HashSet CommodityIdsIncluded { get; } = new HashSet(); + public HashSet CommodityIdsExcluded { get; } = new HashSet(); public String CommodityCodeFull { get; set; } public String CommodityCodePartial { get; set; } // Portfolio Item. @@ -347,12 +347,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String ShortCut { get; set; } /// Portfolio Item status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs b/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs index 06999e2..f375424 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs @@ -292,16 +292,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public Sbm.PriceRounderDirection RounderDirection { get; set; } = Sbm.PriceRounderDirection.Unknown; /// Price status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - if (SysId.IsValid(PriceSetId)) values.Add("Price set Id", PriceSetId.ToString()); - if (SysId.IsValid(CommodityId)) values.Add("Commodity Id", CommodityId.ToString()); - if (PriceType > 0) values.Add("Type", PriceType.ToString()); - if (StatusCat != StatusCat.Any) values.Add("Status", StatusCat.ToString()); - return values; - } } //------------------------------------------------------------------- @@ -312,7 +302,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmSaPriceList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs b/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs index 0ecf2d8..c83073f 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs @@ -231,8 +231,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // Item Ids. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Item properties. public Sbm.PriceType PriceType { get; set; } public String Reference { get; set; } @@ -241,12 +241,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String NamePartial { get; set; } /// Price Set status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs index c6a338e..d03b633 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -284,8 +285,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Process. public Sbm.ProcessCategory ProcessCategory { get; set; } @@ -305,7 +306,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmProcessList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. //------------------------------------------------------------------- // Resequence - sets sequence numbers from '1' at start of list. @@ -323,13 +324,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static bool Find(this List values, SbmProcess process) { if (process == null) return false; - return (values.Find(item => item == process) != null); + return values.Any(item => item == process); } public static bool FindById(this List values, SysId processId) { if (!SysId.IsValid(processId)) return false; - return values.Exists(item => item.Id.Equals(processId)); + return values.Any(item => item.Id.Equals(processId)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs b/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs index 2491934..39c6a54 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs @@ -1232,9 +1232,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public SysId CommodityId { get; set; } public SysId AssetId { get; set; } // Requirement. - public List RequirementIdsIncluded { get; } = new List(); - public List RequirementIdsExcluded { get; } = new List(); - public List RequirementIdsSource { get; } = new List(); + public HashSet RequirementIdsIncluded { get; } = new HashSet(); + public HashSet RequirementIdsExcluded { get; } = new HashSet(); + public HashSet RequirementIdsSource { get; } = new HashSet(); public String RequirementProductCodeFull { get; set; } public String RequirementProductCodePartial { get; set; } // Stored as product code for 'Project' transactions (populating this value will force the transaction type). @@ -1248,8 +1248,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String RequirementPromotionCode { get; set; } // Transaction. public String AliasTransaction { get; set; } - public List TransactionIdsIncluded { get; } = new List(); - public List TransactionIdsExcluded { get; } = new List(); + public HashSet TransactionIdsIncluded { get; } = new HashSet(); + public HashSet TransactionIdsExcluded { get; } = new HashSet(); public SysId TransactionRequirementSourceId { get; set; } // Identifies the transaction to which the source requirement belongs. public Sbm.TransactionType TransactionType { get; set; } = Sbm.TransactionType.Any; public SysId TransactionLocationIdStock { get; set; } @@ -1290,12 +1290,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String NotesPartial { get; set; } /// Requirement status. public StatusCat StatusCat { get; set; } = StatusCat.Default; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs b/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs index 7bd918c..7c96bb0 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -279,8 +280,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // StockLevel. public SysId CommodityId { get; set; } public SysId LocationId { get; set; } @@ -302,22 +303,22 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static bool Find(this List values, SbmStockLevel stockLevel) { if (stockLevel == null) return false; - return (values.Find(item => item == stockLevel) != null); + return values.Any(item => item == stockLevel); } public static bool FindById(this List values, SysId id) { if (!SysId.IsValid(id)) return false; - return values.Exists(item => item.Id.Equals(id)); + return values.Any(item => item.Id.Equals(id)); } public static bool FindByCommodityId(this List values, SysId commodityId) { if (!SysId.IsValid(commodityId)) return false; - return (values.Find(item => item.CommodityId.Equals(commodityId)) != null); + return values.Any(item => item.CommodityId.Equals(commodityId)); } public static bool FindByLocationId(this List values, SysId locationId) { if (!SysId.IsValid(locationId)) return false; - return (values.Find(item => item.LocationIdStock.Equals(locationId)) != null); + return values.Any(item => item.LocationIdStock.Equals(locationId)); } } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs b/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs index e6e9c29..b6d4bba 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs @@ -229,8 +229,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // SysParam. public Sbm.SysParamCategory Category { get; set; } = Sbm.SysParamCategory.Any; public String Name { get; set; } @@ -249,7 +249,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmSysParamList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, Sbm.SysParamCategory category, String name, SysId idAffOwner, SysId idAffTarget, SysId idAssoc) { return true; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs index 12b8c67..89840f2 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs @@ -245,8 +245,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // SystemAccount. public Sbm.SystemAccountType Type { get; set; } = Sbm.SystemAccountType.Customer; public SysId InterfaceId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs index 5925a23..3bff069 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs @@ -173,8 +173,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // SystemAccountUser. public SysId InterfaceId { get; set; } public SysId AccountId { get; set; } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs index 7c4637d..b8d6922 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs @@ -219,8 +219,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // User. public SysId AffIdOwner { get; set; } public SysId InterfaceId { get; set; } @@ -232,12 +232,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String EmailPartial { get; set; } /// System User status. public StatusCat StatusCat { get; set; } = StatusCat.Any; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs b/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs index ec33308..78b73dc 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs @@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -1792,16 +1793,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmTransactionList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmTransaction transaction) { if (transaction == null) return false; - return (values.Find(item => item == transaction) != null); + return values.Any(item => item == transaction); } public static bool FindById(this List values, SysId id) { if (!SysId.IsValid(id)) return false; - return values.Exists(item => item.Id.Equals(id)); + return values.Any(item => item.Id.Equals(id)); } } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs b/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs index 7c37778..b75fb1e 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs @@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -193,18 +194,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmTransactionPaymentList { - /// Check whether currency exists/locate in list with specified Id. //------------------------------------------------------------------- // Find. public static bool Find(this List values, SbmTransactionPayment containerItem) { if (containerItem == null) return false; - return (values.Find(item => item == containerItem) != null); + return values.Any(item => item == containerItem); } public static bool FindByType(this List values, String type) { if (StringUtil.IsEmpty(type)) return false; - return values.Exists(item => item.MatchesByType(type)); + return values.Any(item => item.MatchesByType(type)); } //------------------------------------------------------------------- public static void SetTypeCodeSequence(this List values, List typeCodeDfns) diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs index 07f54f0..bfbe85d 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -574,8 +575,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // Vehicle. public SysId VehicleClassId { get; set; } public SysId AssetCatIdInclude { get; set; } @@ -588,12 +589,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String ClassDescPartial { get; set; } /// Vehicle status. public StatusCat StatusCat { get; set; } = StatusCat.Any; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -604,16 +599,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmVehicleList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmVehicle vehicle) { if (vehicle == null) return false; - return (values.Find(item => item == vehicle) != null); + return values.Any(item => item == vehicle); } public static bool FindById(this List values, SysId id) { if (!SysId.IsValid(id)) return false; - return values.Exists(item => item.Id.Equals(id)); + return values.Any(item => item.Id.Equals(id)); } } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs index fb3a8eb..550ca6c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -432,8 +433,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); /// Generic property search - make, model, derivative etc. public String Search { get; set; } // Item properties. @@ -446,12 +447,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public String VehicleCategoryCode { get; set; } /// Vehicle Class status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -462,16 +457,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmVehicleClassList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmVehicleClass vehicleClass) { if (vehicleClass == null) return false; - return (values.Find(item => item == vehicleClass) != null); + return values.Any(item => item == vehicleClass); } public static bool FindById(this List values, SysId id) { if (!SysId.IsValid(id)) return false; - return values.Exists(item => item.Id.Equals(id)); + return values.Any(item => item.Id.Equals(id)); } } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs index e061ae1..be5ce00 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -321,8 +322,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // VehicleEvent. public SysId VehicleId { get; set; } public Sbm.VehicleEventType VehicleEventType { get; set; } = Sbm.VehicleEventType.Any; @@ -330,12 +331,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool RestrictToActive { get; set; } /// Vehicle Event status. public StatusCat StatusCat { get; set; } = StatusCat.Any; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -346,16 +341,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmVehicleEventList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmVehicleEvent vehicleEvent) { if (vehicleEvent == null) return false; - return (values.Find(item => item == vehicleEvent) != null); + return values.Any(item => item == vehicleEvent); } public static bool FindById(this List values, SysId id) { if (!SysId.IsValid(id)) return false; - return values.Exists(item => item.Id.Equals(id)); + return values.Any(item => item.Id.Equals(id)); } } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs index 2fb89ec..6892d2a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs @@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { @@ -305,8 +306,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public new class Params : SacsHierarchyItem.Params { // List filtering. - public List IdsIncluded { get; } = new List(); - public List IdsExcluded { get; } = new List(); + public HashSet IdsIncluded { get; } = new HashSet(); + public HashSet IdsExcluded { get; } = new HashSet(); // VehicleFeature. public SysId VehicleId { get; set; } public Sbm.VehicleFeatureSource VehicleFeatureSource { get; set; } = Sbm.VehicleFeatureSource.Any; @@ -316,12 +317,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public bool FullFeatureId { get; set; } /// Vehicle Feature status. public StatusCat StatusCat { get; set; } = StatusCat.Any; - // Utilities. - public List GetDisplayValues() - { - List values = new List(); - return values; - } } //------------------------------------------------------------------- @@ -332,21 +327,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //======================================================================= public static class SbmVehicleFeatureList { - /// Check whether currency exists/locate in list with specified Id. + /// Check whether item exists/locate in list with specified Id. public static bool Find(this List values, SbmVehicleFeature vehicleClass) { if (vehicleClass == null) return false; - return (values.Find(item => item == vehicleClass) != null); + return values.Any(item => item == vehicleClass); } public static bool FindByType(this List values, Sbm.VehicleFeatureType vehicleFeatureType) { if (vehicleFeatureType < 0) return false; - return values.Exists(item => item.VehicleFeatureType.Equals(vehicleFeatureType)); + return values.Any(item => item.VehicleFeatureType.Equals(vehicleFeatureType)); } public static bool FindBySourceType(this List values, Sbm.VehicleFeatureSource vehicleFeatureSource, Sbm.VehicleFeatureType vehicleFeatureType) { if (vehicleFeatureSource < 0 && vehicleFeatureType < 0) return false; - return values.Exists(item => item.VehicleFeatureSource.Equals(vehicleFeatureSource) && item.VehicleFeatureType.Equals(vehicleFeatureType)); + return values.Any(item => item.VehicleFeatureSource.Equals(vehicleFeatureSource) && item.VehicleFeatureType.Equals(vehicleFeatureType)); } public static List GetFeaturesOfSource(this List values, Sbm.VehicleFeatureSource vehicleFeatureSource) { diff --git a/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs index 138fa02..b3450d3 100644 --- a/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs +++ b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs @@ -13,9 +13,6 @@ using Sarand.Net.Standard.Base.ItemOptions; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; -using static Sarand.Net.Standard.Base.Core.StringPair; -using static Sarand.Net.Standard.Base.ItemOptions.SaItemOptionDfn; namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { @@ -423,9 +420,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Update Log. - public virtual bool IsColumnChangeLogged(ISbmUserOrganisationContext userContext, SbmDbDfn.ColumnIdx column) + public virtual bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column) { - return false; + return instanceConfig.IsColumnChangeLogged(column, false); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs b/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs index b253c3a..c024d0e 100644 --- a/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs +++ b/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs @@ -21,6 +21,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse); + //------------------------------------------------------------------- + // Defaults. + + public class DefaultsData + { + public Sbm.CommodityType CommodityType{ get; set; } = Sbm.CommodityType.Stock; + } + + DefaultsData GetDefaults(); + //------------------------------------------------------------------- // Contacts. @@ -50,6 +60,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core /// bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse); + //------------------------------------------------------------------- + // Update Log. + bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column, bool defaultResponse); + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs b/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs index e869ded..c5d2829 100644 --- a/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs +++ b/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.Core { @@ -17,19 +16,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Core public interface ISbmOrganisationConfig { //------------------------------------------------------------------- - string GetOwnerOption_Value(OrgOption_Value value); - string GetOwnerOption_Folder(OrgOption_Folder folder); - bool GetOwnerOption_AllowOption(OrgOption_AllowOption option); - string GetOwnerOption_Caption(OrgOption_Caption caption, string defaultValue); + string GetOwnerOption_Value(Sbm.OrgOption_Value value); + string GetOwnerOption_Folder(Sbm.OrgOption_Folder folder); + bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption option); + string GetOwnerOption_Caption(Sbm.OrgOption_Caption caption, string defaultValue); bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx column); - bool GetOwnerOption_ShowColumn(OrgOption_ShowColumn column); + bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn column); string GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx eCol, string defautValue); - int GetOwnerOption_Minutes(OrgOption_Minutes eLimit, int defautValue); - int GetOwnerOption_UpdateLimit(OrgOption_PeriodDays eLimit, int defautValue); - int GetOwnerOption_UpdateLimit(OrgOption_PeriodWeeks eLimit, int defautValue); - int GetOwnerOption_NumericDecimals(OrgOption_NumericDecimals eNumDecimals, int defautValue = 2); - CommodityType GetOwnerOption_CommodityType(OrgOption_CommodityType commodityTypeContext); - SysId GetOwnerOption_StockLocation(OrgOption_StockLocation stockLocation); + int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes eLimit, int defautValue); + int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays eLimit, int defautValue); + int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks eLimit, int defautValue); + int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals eNumDecimals, int defautValue = 2); + Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityTypeContext); + SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation stockLocation); //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr.cs b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr.cs index 8431a9f..33207ca 100644 --- a/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/Control/SbmcInstanceMgr.cs @@ -1,10 +1,4 @@ -using Sarand.BusinessMgr.Net.Standard.Base.App; -using Sarand.BusinessMgr.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Core; -using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config; - -namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control +namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control { //======================================================================= public abstract partial class SbmcInstanceMgr : SbmcControlMgr diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs index 9d37378..a8281f6 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Affiliate.cs @@ -7,7 +7,6 @@ using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { @@ -112,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr ClearErrorState(); if (StringUtil.IsBlank(firstName) || StringUtil.IsBlank(lastName)) return null; SbmAffiliate.Params prmAffiliate = new SbmAffiliate.Params(); - prmAffiliate.AffiliateType = AffiliateType.Individual; + prmAffiliate.AffiliateType = Sbm.AffiliateType.Individual; prmAffiliate.FirstName = firstName; prmAffiliate.LastName = lastName; prmAffiliate.StatusCat = SbmAffiliate.StatusCat.NotDeleted; diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs index 6f2c4b8..2e739de 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs @@ -334,8 +334,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr } if (bAllowAssets) { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Purchase)); orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Sale)); orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Rental)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Disposal)); } // Caption contexts: diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs index 0481bba..65ad88a 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_PortfolioItem.cs @@ -4,11 +4,11 @@ using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Interfaces; using Sarand.Net.Standard.Base.ItemOptions; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.Net.Standard.Base.Interfaces.SaInterfaceConsole; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { @@ -36,8 +36,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr // Build list of portfolios that are published to website(s): List portfolioIdsPublished = new List(); - List interfaceDfns = InterfaceConsole.GetInterfaceDfns(UserContext.OrganisationInterfaceContext, SaInterfaceCategory.Website, (short)Sbm.InterfaceType_Website.WebStore, false); - foreach (SaInterfaceDfn interfaceDfn in interfaceDfns) + List interfaceDfns = InterfaceConsole.GetInterfaceDfns(UserContext.OrganisationInterfaceContext, SaInterfaceCategory.Website, (short)Sbm.InterfaceType_Website.WebStore, false); + foreach (SaInterfaceConsole.SaInterfaceDfn interfaceDfn in interfaceDfns) { // Retrieve Portfolio Item Id option. foreach (SaItemOption itemOption in ItemOptionConsole.GetItemOptionsForItem(new ItemId((short)Sbm.ItemType.PortfolioItem, portfolioItem.Id))) diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs index 940fd6d..b7a7415 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs @@ -17,6 +17,7 @@ using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { @@ -87,11 +88,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr public int orderQuantityDecimals; // Reference data. public List currencyCodes; - public List currencies; - public List languages; - public List regions; - public List taxCodes; - public List unitsOfMeasure; } private readonly Members mbr = new Members(); @@ -346,74 +342,42 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // R e f e r e n c e D a t a //------------------------------------------------------------------- + // Currencies. - private void PopulateCurrencies() - { - if (mbr.currencies != null) return; - SaCurrency.Params prmCurrency = new SaCurrency.Params(); - prmCurrency.StatusCat = SaCurrency.StatusCat.Any; - mbr.currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency); - } public SaCurrency GetDefaultCurrency() { - PopulateCurrencies(); String currencyCode = CurrencyCodes.GetCodeForType(SaCurrencyCode.Sterling); - return mbr.currencies.Find(item => item.Code.EqualsCI(currencyCode)); + return Internals.GetCurrencyByCode(currencyCode); } public SaCurrency GetCurrency(SysId currencyId) { - PopulateCurrencies(); - return mbr.currencies.Find(item => item.Id.Equals(currencyId)); + return Internals.GetCurrencyById(currencyId); } - //------------------------------------------------------------------- + // Regions. - private void PopulateRegions() - { - if (mbr.regions != null) return; - SaRegion.Params prmRegion = new SaRegion.Params(); - mbr.regions = ReferenceDataConsole.GetRegionList(prmRegion); - } public SaRegion FindRegionById(SysId regionId) { - PopulateRegions(); - return mbr.regions.FindById(regionId); + return Internals.GetRegionById(regionId); } - //------------------------------------------------------------------- + // Tax codes. - private void PopulateTaxCodes() - { - if (mbr.taxCodes != null) return; - SaTaxCode.Params prmTaxCode = new SaTaxCode.Params(); - mbr.taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode); - } public SaTaxCode FindTaxCodeById(SysId taxCodeId) { - PopulateTaxCodes(); - return mbr.taxCodes.Find(item => item.Id.Equals(taxCodeId)); + return Internals.GetTaxCodeById(taxCodeId); } public SaTaxCode FindTaxCodeEffectiveOn(String taxCode, DateTime effectiveOn) { - PopulateTaxCodes(); - return mbr.taxCodes.FindByCodeEffectiveOn(taxCode, effectiveOn); + return Internals.GetTaxCodes().FindByCodeEffectiveOn(taxCode, effectiveOn); } - //------------------------------------------------------------------- + // Units of measure. - private void PopulateUnitsOfMeasure() - { - if (mbr.unitsOfMeasure != null) return; - SaUnitMeasure.Params prmUnitOfMeasure = new SaUnitMeasure.Params(); - prmUnitOfMeasure.StatusCat = SaUnitMeasure.StatusCat.Any; - mbr.unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitOfMeasure); - } public SaUnitMeasure FindUnitOfMeasureById(SysId uomId) { - PopulateUnitsOfMeasure(); - return mbr.unitsOfMeasure.FindById(uomId); + return Internals.GetUnitOfMeasureById(uomId); } public List FindUnitsOfMeasureByCategory(SaUomCategory uomCategory) { - PopulateUnitsOfMeasure(); - return mbr.unitsOfMeasure.FindAll(item => item.Category == uomCategory); + return Internals.GetUnitsOfMeasureByCategory(uomCategory); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs b/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs index 35be3ca..b875805 100644 --- a/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs +++ b/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs @@ -44,7 +44,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog protected virtual bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx columnIdx) { if (!config.UpdateLogConsole.CanUpdateDatabase) return false; - if (!sessionConsole.IsColumnChangeLogged(UserContext, columnIdx)) return false; + if (!sessionConsole.IsColumnChangeLogged(columnIdx)) return false; return true; } protected bool RecordAttrValue(SbmDbDfn.ColumnIdx columnIdx, String value, bool newValue) diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs index f42bdd3..18ec8bd 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs @@ -60,11 +60,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!SysId.IsValid(Id)) return false; SaItemData.Params prmItemData = new SaItemData.Params(); - prmItemData.IncludedItemIds.Add(new ItemId((short)Sbm.ItemType.Process, Id)); - prmItemData.IncludedDataTypes.Add(GetCodeForCostCode(SbmProcessCostCode.Fixed_Unit)); - prmItemData.IncludedDataTypes.Add(GetCodeForCostCode(SbmProcessCostCode.Fixed_Job)); - prmItemData.IncludedDataTypes.Add(GetCodeForCostCode(SbmProcessCostCode.Labour_Unit)); - prmItemData.IncludedDataTypes.Add(GetCodeForCostCode(SbmProcessCostCode.Labour_Job)); + prmItemData.ItemIdsIncluded.Add(new ItemId((short)Sbm.ItemType.Process, Id)); + prmItemData.DataTypesIncluded.Add(GetCodeForCostCode(SbmProcessCostCode.Fixed_Unit)); + prmItemData.DataTypesIncluded.Add(GetCodeForCostCode(SbmProcessCostCode.Fixed_Job)); + prmItemData.DataTypesIncluded.Add(GetCodeForCostCode(SbmProcessCostCode.Labour_Unit)); + prmItemData.DataTypesIncluded.Add(GetCodeForCostCode(SbmProcessCostCode.Labour_Job)); return internals.ItemDataConsole.ItemDataExists(prmItemData); } public override bool HasCostCodes(SbmProcessCostCode processCostCode) @@ -77,8 +77,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!StringUtil.IsEmpty(itemDataTypeCode)) { SaItemData.Params prmItemData = new SaItemData.Params(); - prmItemData.IncludedItemIds.Add(new ItemId((short)Sbm.ItemType.Process, Id)); - prmItemData.IncludedDataTypes.Add(itemDataTypeCode); + prmItemData.ItemIdsIncluded.Add(new ItemId((short)Sbm.ItemType.Process, Id)); + prmItemData.DataTypesIncluded.Add(itemDataTypeCode); bHas = internals.ItemDataConsole.ItemDataExists(prmItemData); } return bHas; @@ -92,8 +92,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!SysId.IsValid(Id) && !StringUtil.IsEmpty(itemDataTypeCode)) { SaItemData.Params prmItemData = new SaItemData.Params(); - prmItemData.IncludedItemIds.Add(new ItemId((short)Sbm.ItemType.Process, Id)); - prmItemData.IncludedDataTypes.Add(itemDataTypeCode); + prmItemData.ItemIdsIncluded.Add(new ItemId((short)Sbm.ItemType.Process, Id)); + prmItemData.DataTypesIncluded.Add(itemDataTypeCode); List itemDatas = internals.ItemDataConsole.GetItemDataList(prmItemData); foreach (SaItemData itemData in itemDatas) { @@ -114,8 +114,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!SysId.IsValid(Id) && !StringUtil.IsEmpty(itemDataTypeCode)) { SaItemData.Params prmItemData = new SaItemData.Params(); - prmItemData.IncludedItemIds.Add(new ItemId((short)Sbm.ItemType.Process, Id)); - prmItemData.IncludedDataTypes.Add(itemDataTypeCode); + prmItemData.ItemIdsIncluded.Add(new ItemId((short)Sbm.ItemType.Process, Id)); + prmItemData.DataTypesIncluded.Add(itemDataTypeCode); List itemDatas = internals.ItemDataConsole.GetItemDataList(prmItemData); // ToDo itemData condition. //itemDatas.GotoStart(); @@ -177,7 +177,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus ClearErrorState(); if (!SysId.IsValid(Id)) return false; SaItemData.Params prmItemData = new SaItemData.Params(); - prmItemData.IncludedItemIds.Add(new ItemId((short)Sbm.ItemType.Process, Id)); + prmItemData.ItemIdsIncluded.Add(new ItemId((short)Sbm.ItemType.Process, Id)); return internals.ItemDataConsole.ItemDataExists(prmItemData); } public override bool ClearAssociatedData() @@ -186,7 +186,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (!SysId.IsValid(Id)) return SetErrorState("item not specified"); // Clear Item data records. SaItemData.Params prmItemData = new SaItemData.Params(); - prmItemData.IncludedItemIds.Add(new ItemId((short)Sbm.ItemType.Process, Id)); + prmItemData.ItemIdsIncluded.Add(new ItemId((short)Sbm.ItemType.Process, Id)); List itemDatas = internals.ItemDataConsole.GetItemDataList(prmItemData); foreach (SaItemData itemData in itemDatas) { diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs index 5a82690..f25359b 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs @@ -43,6 +43,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles // Consoles. public override SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } } + //------------------------------------------------------------------- + // Default population. + + // Regions. + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs index cac7eac..3c1060c 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs @@ -14,7 +14,6 @@ using System; using System.Collections.Generic; using System.Data.Common; using System.Linq; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { @@ -1330,7 +1329,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAssociation_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type, aliasAssociation); if (prm.AssociationType > 0) filter.Add($"{colAssociation_Type}={(int)prm.AssociationType}"); - else if (prm.AssociationType == AssociationType.NotInternal) + else if (prm.AssociationType == Sbm.AssociationType.NotInternal) filter.Add($"{colAssociation_Type}!={(int)Sbm.AssociationType.Internal}"); //--------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs index 6729e96..b0ca05a 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs @@ -85,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { dbConnection.Open(); SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo); - dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, filter); + dbAssetCategory.PopulateFrom(dbCommand, AliasAssetCategory, filter); assetCategory = CreateAssetCategory(dbAssetCategory); } catch (Exception exc) @@ -216,7 +216,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Retrieve AssetCategory. dbConnection.Open(); SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo); - dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, $"Id={SysId.ToString(assetCategory.Id)}"); + dbAssetCategory.PopulateFrom(dbCommand, AliasAssetCategory, $"Id={SysId.ToString(assetCategory.Id)}"); SbmUpdateLogItemMonitor_AssetCategory updateLogMonitor = new SbmUpdateLogItemMonitor_AssetCategory(Internals, CreateAssetCategory(dbAssetCategory)); // Update properties. @@ -254,7 +254,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Retrieve AssetCategory. dbConnection.Open(); SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo); - dbAssetCategory.PopulateFrom(dbCommand, aliasAssetCategory, $"Id={assetCategory.Id.ToString()}"); + dbAssetCategory.PopulateFrom(dbCommand, AliasAssetCategory, $"Id={assetCategory.Id.ToString()}"); // Delete AssetCategory. dbCommand.CommandType = System.Data.CommandType.Text; dbCommand.CommandText = $"DELETE FROM {SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} WHERE Id={SysId.ToString(assetCategory.Id)};"; @@ -331,7 +331,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // AssetCategory column definitions. - private static readonly String aliasAssetCategory = "aAstCat"; + private static readonly String AliasAssetCategory = "aAstCat"; + private static readonly String colNameAssetCategory_AssetCount = "AssetCount"; private void SetAssetCategoryColDfn (ColumnDfn col, String caption, int width, SbmDbDfn.ColumnIdx dbCol, @@ -339,7 +340,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String alias = "", String prefix = "") { if (String.IsNullOrEmpty(alias) && SbmDbDfn.GetTableForColumn(dbCol) == SbmDbDfn.TableIdx.SaAssetCategory) - alias = aliasAssetCategory; + alias = AliasAssetCategory; col.Set(caption, width, (int)dbCol, prefix + SbmDbDfn.GetColumnName(dbCol, false), SbmDbDfn.GetColumnNameQual(dbCol, alias), dataType, align); if (dataType == DataValue.DataType.String && dbCol != SbmDbDfn.ColumnIdx.Unknown) col.MaxLength = (int)SbmDbDfn.GetColTextLen(dbCol); @@ -422,7 +423,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr break; case SbmAssetCategory.Column.AssetCount: SetAssetCategoryColDfn(columnDfn, "Asset Count", 70, SbmDbDfn.ColumnIdx.Unknown, ColumnAlignment.Center, DataValue.DataType.Long); - columnDfn.DataName = "AssetCount"; + columnDfn.DataName = colNameAssetCategory_AssetCount; break; } if (!String.IsNullOrEmpty(caption)) @@ -440,7 +441,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Asset Category Id. String includedIds = prm.IdsIncluded.Concat(","); - String colAssetCategory_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAssetCategory); + String colAssetCategory_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, AliasAssetCategory); if (!includedIds.IsEmpty()) filter.Add($"{colAssetCategory_Id} IN ({includedIds})"); String excludedIds = prm.IdsExcluded.Concat(","); @@ -448,24 +449,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.Add($"{colAssetCategory_Id} NOT IN ({excludedIds})"); // Asset Category Type. - String colSaAssetCategory_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, aliasAssetCategory); + String colSaAssetCategory_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, AliasAssetCategory); if (prm.AssetType > 0) filter.Add($"{colSaAssetCategory_Type}='{(int)prm.AssetType}"); // Partial Code. String code = DbQuery.FormatForCondition(prm.CodePartial); - String colAssetCategory_Code = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Code, aliasAssetCategory); + String colAssetCategory_Code = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Code, AliasAssetCategory); if (!StringUtil.IsEmpty(code)) filter.Add($"{DbQuery.FormatFn_Left(colAssetCategory_Code, prm.CodePartial.Length)}='{code}'"); // Partial Description. String description = DbQuery.FormatForCondition(prm.DescBriefPartial); - String colAssetCategory_DescBrief = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DescBrief, aliasAssetCategory); + String colAssetCategory_DescBrief = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DescBrief, AliasAssetCategory); if (!StringUtil.IsEmpty(description)) filter.Add($"{DbQuery.FormatFn_Left(colAssetCategory_DescBrief, prm.DescBriefPartial.Length)}='{description}'"); // Status. - String colAssetCategory_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Status, aliasAssetCategory); + String colAssetCategory_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Status, AliasAssetCategory); if (prm.RestrictToActive) filter.Add($"{colAssetCategory_Status}='{StatusActive}'"); @@ -484,7 +485,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String sortCol = String.Empty; if (SbmDbDfn.GetTableForColumn((SbmDbDfn.ColumnIdx)columnDfn.DbColumn) == SbmDbDfn.TableIdx.SaAssetCategory) { - sortCol = SbmDbDfn.GetColumnNameQual((SbmDbDfn.ColumnIdx)columnDfn.DbColumn, aliasAssetCategory); + sortCol = SbmDbDfn.GetColumnNameQual((SbmDbDfn.ColumnIdx)columnDfn.DbColumn, AliasAssetCategory); } else { @@ -502,7 +503,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (sortColumnCodes.IsEmpty()) { // Default sort columns: - sortColumnCodes.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, aliasAssetCategory) + " ASC"); + sortColumnCodes.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, AliasAssetCategory) + " ASC"); } return sortColumnCodes; } @@ -512,7 +513,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAssetCategoryCount(String filter) { ClearErrorState(); - return Database.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} As {aliasAssetCategory}", filter); + return Database.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} As {AliasAssetCategory}", filter); } public override long GetAssetCategoryCount(SbmAssetCategory.Params prm) { @@ -527,7 +528,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); List assetCategories = new List(); DbQuery qry = new DbQuery(Database.DbmsType); - qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), aliasAssetCategory); + qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), AliasAssetCategory); SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo); qry.Columns.AddRange(dbAssetCategory.ExistingColumnNames); qry.Filters.AddRange(GetAssetCategoryQueryFilter(prm)); @@ -564,47 +565,48 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override DbResultSet ExecuteAssetCategoryQuery(List columns, SbmAssetCategory.Params prm) { ClearErrorState(); - //--------------------------------------------------------------------- + // Construct build database query. DbQuery query = new DbQuery(Database.DbmsType); - query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), aliasAssetCategory); + query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), AliasAssetCategory); // AssetCategory Properties - add columns as defined in query list. if (columns.HasId(SbmAssetCategory.Column.Id)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.AffIdOwner)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AffIdOwner, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AffIdOwner, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.AssetType) || columns.HasId(SbmAssetCategory.Column.AssetType_Desc)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.Code)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Code, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Code, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.DescBrief)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DescBrief, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DescBrief, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.IncomeType)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_IncomeType, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_IncomeType, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.AssocIdSupplier)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssocIdSupplier, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssocIdSupplier, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.PaymentTerms)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_PaymentTerms, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_PaymentTerms, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.TaxCodeIdPurchase)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdPurchase, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdPurchase, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.AssocIdCustomer)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssocIdCustomer, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_AssocIdCustomer, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.TaxCodeIdSell)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdSell, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdSell, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.TaxCodeIdProfit)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdProfit, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdProfit, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.DisposeCode)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DisposeCode, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_DisposeCode, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.UomIdRentalCost)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_UomIdRentalCost, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_UomIdRentalCost, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.TaxCodeIdRentalCost)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdRentalCost, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdRentalCost, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.UomIdRentalPrice)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_UomIdRentalPrice, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_UomIdRentalPrice, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.TaxCodeIdRentalPrice)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdRentalPrice, aliasAssetCategory)); - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_TaxCodeIdRentalPrice, AliasAssetCategory)); + + //--------------------------------------------------------------- // Asset Count if (columns.HasId(SbmAssetCategory.Column.AssetCount)) { @@ -612,23 +614,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr DbQuery qryAssetCount = new DbQuery(Database.DbmsType); qryAssetCount.Tables.Add(tableAsset, aliasAsset); qryAssetCount.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasAsset)})"); - qryAssetCount.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasAsset)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAsset)}"); - query.Columns.Add($"({qryAssetCount.BuildQuery()})", "AssetCount"); + qryAssetCount.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasAsset)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, AliasAssetCategory)}"); + query.Columns.Add($"({qryAssetCount.BuildQuery()})", colNameAssetCategory_AssetCount); } + //--------------------------------------------------------------- // Common Properties if (columns.HasId(SbmAssetCategory.Column.Notes)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Notes, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Notes, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.Flag)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Flags, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Flags, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.Status) || columns.HasId(SbmAssetCategory.Column.Status_Desc) || columns.HasId(SbmAssetCategory.Column.Status_Ind)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Status, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Status, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.CreateOn_Date)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_CreateOn, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_CreateOn, AliasAssetCategory)); if (columns.HasId(SbmAssetCategory.Column.UpdateOn_Date)) - query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_UpdateOn, aliasAssetCategory)); + query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_UpdateOn, AliasAssetCategory)); - //--------------------------------------------------------------------- + //--------------------------------------------------------------- // Populate filter. query.Filters.AddRange(GetAssetCategoryQueryFilter(prm)); @@ -639,7 +642,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.OrderBy.Add(sortColumn); } - //--------------------------------------------------------------------- //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs index fdb8a43..6ae2b37 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs @@ -26,7 +26,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //------------------------------------------------------------------- // Data members. - private bool locationIdListPopulated = false; + private bool locationIdListsPopulated = false; private readonly List locationIds_All = new List(); private readonly List locationIds_Calc = new List(); private readonly List locationIds_Sales = new List(); @@ -514,11 +514,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Populate LocationId Lists. public void PopulateLocationIdLists() { + if (locationIdListsPopulated) return; + locationIdListsPopulated = true; + // Verify that the location table exists. String tableLocation = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location); if (!Database.TableExists(tableLocation)) return; - locationIdListPopulated = true; String colLocation_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_Id); String colLocation_AffIdOwner = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_AffIdOwner); String colLocation_Flags = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_Flags); diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs index a9af9f6..19aab54 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs @@ -779,10 +779,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Commodity Id. String colPortfolioItem_CommodityId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.PortfolioItem_CommodityId, aliasPortfolioItem); - String includedCommodityIds = prm.IncludedCommodityIds.Concat(","); + String includedCommodityIds = prm.CommodityIdsIncluded.Concat(","); if (!StringUtil.IsEmpty(includedCommodityIds)) filter.Add(colPortfolioItem_CommodityId + " IN (" + includedCommodityIds + ")"); - String excludedCommodityIds = prm.ExcludedCommodityIds.Concat(","); + String excludedCommodityIds = prm.CommodityIdsExcluded.Concat(","); if (!StringUtil.IsEmpty(excludedCommodityIds)) filter.Add(colPortfolioItem_CommodityId + " NOT IN (" + excludedCommodityIds + ")"); diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs index 87b604d..2884b16 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs @@ -25,9 +25,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //******************************************************************* // Data members. private bool locationIdsPopulated = false; - private List locationIds_All = new List(); - private List locationIds_Sales = new List(); - private List locationIds_Calc = new List(); + private HashSet locationIds_All = new HashSet(); + private HashSet locationIds_Sales = new HashSet(); + private HashSet locationIds_Calc = new HashSet(); private int orderQuantityDecimals; diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs index 75b15fb..900f380 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs @@ -322,7 +322,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (locationIds_Sales.Count > 1) { // Assume that all locations are for sales. - locationIds_Sales = new List(locationIds_NonSales); + locationIds_Sales = new HashSet(locationIds_NonSales); locationIds_NonSales.Clear(); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs index dae7756..a869e21 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs @@ -2142,8 +2142,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (bAccountInvoiceRef) { // Identify the accounts interface. - List accountsIdsInterface = new List(); - accountsIdsInterface = AccountsDfn.GetInterfaceIds(true); + HashSet accountsIdsInterface = AccountsDfn.GetInterfaceIds(true); if (accountsIdsInterface.Count > 0) { if (prm.TransactionType == Sbm.TransactionType.ProformaSalesInvoice) diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs index 6aa8162..e26b282 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs @@ -31,10 +31,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private int weightDecimals; bool locationIdListsPopulated = false; - private List locationIds_All; - private List locationIds_Calc; - private List locationIds_Sales; - private List locationIds_NonSales; + private HashSet locationIds_All; + private HashSet locationIds_Calc; + private HashSet locationIds_Sales; + private HashSet locationIds_NonSales; //------------------------------------------------------------------- // Construction. diff --git a/SaBusMgrTest_Control/Web/Control/App/SbmApplication_SessionData_Tester.cs b/SaBusMgrTest_Control/Web/Control/App/SbmApplication_SessionData_Tester.cs index 467e8c4..8b3c71f 100644 --- a/SaBusMgrTest_Control/Web/Control/App/SbmApplication_SessionData_Tester.cs +++ b/SaBusMgrTest_Control/Web/Control/App/SbmApplication_SessionData_Tester.cs @@ -1,7 +1,7 @@ using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; diff --git a/SaBusMgrTest_Control/Web/Control/App/SbmApplication_Tester_Base.cs b/SaBusMgrTest_Control/Web/Control/App/SbmApplication_Tester_Base.cs index 1475707..379f321 100644 --- a/SaBusMgrTest_Control/Web/Control/App/SbmApplication_Tester_Base.cs +++ b/SaBusMgrTest_Control/Web/Control/App/SbmApplication_Tester_Base.cs @@ -45,6 +45,9 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App mockEnvironment.Setup(m => m.ContentRootPath).Returns(@"D:\Sarand\Projects\Users\AHoward\VS2022\BusinessMgr\Workspace\SaBusinessMgrCoreWebControl"); App_Control = new SbmApplication_Control_Test(mockConfiguration.Object, mockEnvironment.Object); Internals_Control = new SbmInternals_Control(); + + // Control session data. + //SessionData_Control = null; } protected override void Dispose(bool disposing) @@ -60,8 +63,8 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App protected SbmApplication App { get { return App_Control; } } protected SbmApplication_Web App_Web { get { return App_Control; } } protected SbmApplication_Control App_Control { get; } - protected SbmSessionData_Control SessionData_Control { get; } - protected SbmInternals_Control Internals_Control { get; } + protected SbmSessionData_Control SessionData_Control { get; private set; } + protected SbmInternals_Control Internals_Control { get; private set; } // Utilities. protected SbmInternals_Control CreateInternalsControl() { return new SbmInternals_Control(); } diff --git a/SaBusMgrTest_Portal/Web/Portal/App/SbmApplication_SessionData_Tester.cs b/SaBusMgrTest_Portal/Web/Portal/App/SbmApplication_SessionData_Tester.cs index ed9cf31..9609470 100644 --- a/SaBusMgrTest_Portal/Web/Portal/App/SbmApplication_SessionData_Tester.cs +++ b/SaBusMgrTest_Portal/Web/Portal/App/SbmApplication_SessionData_Tester.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Consoles; diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs index 898a8ec..709edd5 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs @@ -2,14 +2,17 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Consoles; -using Sarand.BusinessMgr.Web.Control.Consoles; using Sarand.BusinessMgr.Net.Core.Web.Helpers; using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Consoles; using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; +using Sarand.BusinessMgr.Net.Standard.Dbas.App; using Sarand.BusinessMgr.Net.Standard.Dbas.Utils; +using Sarand.BusinessMgr.Web.Control.Consoles; using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.IO; @@ -18,14 +21,6 @@ using Sarand.Net.Standard.Dbas.Base; using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; -using Sarand.Net.Standard.Base.ReferenceData; -using Sarand.Net.Standard.Base.Bus; -using static Sarand.Net.Standard.Dbas.Base.SacsDatabaseConsole; -using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; -using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; -using Sarand.Net.Standard.Base.Security; -using Sarand.BusinessMgr.Net.Standard.Dbas.App; namespace Sarand.BusinessMgr.Web.Control.App { diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmSessionData_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmSessionData_Control.cs index 82f4850..5893079 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmSessionData_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmSessionData_Control.cs @@ -1,20 +1,14 @@ -using Sarand.BusinessMgr.Net.Core.Web.App; +using Newtonsoft.Json; +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; using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.BusinessMgr.Web.Control.Controllers; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Dbas; +using Sarand.Net.Standard.Base.Helpers; +using Sarand.Net.Standard.Base.Utils; +using System; namespace Sarand.BusinessMgr.Web.Control.App { diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmSystem_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmSystem_Control.cs index 34081a3..b0e5ee8 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmSystem_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmSystem_Control.cs @@ -1,8 +1,5 @@ -using Newtonsoft.Json.Serialization; -using NPOI.SS.Formula.Functions; -using Sarand.BusinessMgr.Net.Core.Web.App; +using Sarand.BusinessMgr.Net.Core.Web.App; using Sarand.BusinessMgr.Net.Core.Web.Consoles; -using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Consoles; using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Web.Control.Consoles; @@ -17,7 +14,6 @@ using Sarand.Net.Standard.Base.ReferenceData; using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.UpdateLog; using System; -using static Sarand.BusinessMgr.Net.Core.Web.App.SbmAppConfig; namespace Sarand.BusinessMgr.Web.Control.App { @@ -86,7 +82,7 @@ namespace Sarand.BusinessMgr.Web.Control.App public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserOrganisationContext userContext) { - throw new NotImplementedException(); + return new SbmReferenceDataConsole_Control(userContext); } public override SbmEmailConsole CreateEmailConsole(ISbmUserOrganisationContext userContext, SbmEmailConfig emailConfig) diff --git a/SaBusinessMgrCoreWebControl/Control/Consoles/SbmReferenceDataConsole_Control.cs b/SaBusinessMgrCoreWebControl/Control/Consoles/SbmReferenceDataConsole_Control.cs new file mode 100644 index 0000000..8c18cec --- /dev/null +++ b/SaBusinessMgrCoreWebControl/Control/Consoles/SbmReferenceDataConsole_Control.cs @@ -0,0 +1,33 @@ +using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles; + +namespace Sarand.BusinessMgr.Web.Control.Consoles +{ + //======================================================================= + public class SbmReferenceDataConsole_Control : SbmReferenceDataConsole_Dbas + { + //------------------------------------------------------------------- + // Data members. + //private SaUpdateLogConsole updateLogConsole; + + //------------------------------------------------------------------- + // Construction. + public SbmReferenceDataConsole_Control(ISbmUserOrganisationContext userContext) : + base(userContext) + { + } + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Properties. + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs index 3bdd831..aa81050 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Instance/RepositoryController-Ajax.cs @@ -8,10 +8,8 @@ using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Utils; -using Sarand.Net.Standard.Dbas.Base; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config.Security; namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance { diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs index 269f0c7..4638881 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs @@ -1,6 +1,4 @@ -using DocumentFormat.OpenXml.InkML; -using DocumentFormat.OpenXml.Wordprocessing; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Web.Control.Models; using Sarand.BusinessMgr.Web.Control.Models.Param; @@ -11,7 +9,6 @@ using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.SbmSysParamCache; namespace Sarand.BusinessMgr.Web.Control.Controllers.Param { diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs index 80a9771..18fbe5e 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Consoles; @@ -56,7 +56,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers /// Control session data protected SbmApplication_Control App_Control { get { return SbmApplication_Control.Instance; } } protected SbmSessionData_Control SessionData_Control { get { return SessionData as SbmSessionData_Control; } } - public override ISbmUserOrganisationContext UserContext_Core => throw new NotImplementedException(); protected override SbmSessionData_Web DeserializeSessionData(String sessionDataJson) { return JsonConvert.DeserializeObject(sessionDataJson, SessionDataJsonDeserializerSettings); diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController-Ajax.cs index 530202e4..7d066b1 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Security/SecurityController-Ajax.cs @@ -1,21 +1,18 @@ using Microsoft.AspNetCore.Mvc; -using NPOI.SS.Formula.Functions; -using Sarand.BusinessMgr.Net.Standard.Base.Helpers; +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; +using Sarand.BusinessMgr.Web.Control.Helpers; +using Sarand.BusinessMgr.Web.Control.Models; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Email; using Sarand.Net.Standard.Base.Helpers; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config.Security.SignIn; +using Sarand.Net.Standard.Base.Utils; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Web; -using System; -using Sarand.Net.Standard.Base.Utils; -using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; -using Sarand.BusinessMgr.Web.Control.Models; -using Sarand.BusinessMgr.Net.Standard.Base.App; -using Sarand.BusinessMgr.Web.Control.Helpers; namespace Sarand.BusinessMgr.Web.Control.Controllers { @@ -133,7 +130,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers } } if (userAccount == null && !responseData.HasControlErrors()) - responseData.SetControlError(nameof(model.EmailAddress), model.Localiser["security.msg.signin.invalid"]); + responseData.SetControlError(nameof(model.EmailAddress), Localiser["security.msg.signin.invalid"]); } return userAccount; } diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Account/Model_UserAccount.cs b/SaBusinessMgrCoreWebControl/Control/Models/Account/Model_UserAccount.cs index 191b41f..379a2f0 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Account/Model_UserAccount.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Account/Model_UserAccount.cs @@ -1,6 +1,4 @@ -using DocumentFormat.OpenXml.Spreadsheet; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.App; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.Net.Standard.Base.App; @@ -9,12 +7,11 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; using System; -using System.Diagnostics.Contracts; namespace Sarand.BusinessMgr.Web.Control.Models.Account { - //======================================================================= - public class Model_UserAccount : SbmModel_Control + //======================================================================= + public class Model_UserAccount : SbmModel_Control { //------------------------------------------------------------------- // Construction. diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Owner.cs b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Owner.cs index 57a66e8..cb00fcc 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Owner.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Owner.cs @@ -1,6 +1,6 @@ using DocumentFormat.OpenXml.Spreadsheet; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.Net.Standard.Base.App; diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs index 68b8033..8d4c150 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_Repository.cs @@ -1,6 +1,6 @@ using DocumentFormat.OpenXml.Spreadsheet; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.Net.Standard.Base.App; diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryInit.cs b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryInit.cs index daea964..a341449 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryInit.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Instance/Model_RepositoryInit.cs @@ -1,7 +1,7 @@ using DocumentFormat.OpenXml.Spreadsheet; using NPOI.OpenXml4Net.Exceptions; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Model_Home.cs b/SaBusinessMgrCoreWebControl/Control/Models/Model_Home.cs index 8f88564..67a15b7 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Model_Home.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Model_Home.cs @@ -1,4 +1,5 @@ using Sarand.BusinessMgr.Net.Core.Web.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; namespace Sarand.BusinessMgr.Web.Control.Models { @@ -12,7 +13,34 @@ namespace Sarand.BusinessMgr.Web.Control.Models { } - //------------------------------------------------------------------- - } - //======================================================================= + //------------------------------------------------------------------- + // Home page statictics. + + public long GetUserAccountCount() + { + SbmcUserAccount.Params prmUserAccount = new SbmcUserAccount.Params(); + prmUserAccount.StatusCat = SbmcUserAccount.StatusCat.NotDeleted; + return ControlAccountMgr.GetUserAccountCount(prmUserAccount); + + } + + public long GetOwnerCount() + { + SbmcOwner.Params prmOwner = new SbmcOwner.Params(); + prmOwner.StatusCat = SbmcOwner.StatusCat.NotDeleted; + return ControlInstanceMgr.GetOwnerCount(prmOwner); + + } + + public long GetRepositoryCount() + { + SbmcRepository.Params prmRepository = new SbmcRepository.Params(); + prmRepository.StatusCat = SbmcRepository.StatusCat.NotDeleted; + return ControlInstanceMgr.GetRepositoryCount(prmRepository); + + } + + //------------------------------------------------------------------- + } + //======================================================================= } diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Model_Security.cs b/SaBusinessMgrCoreWebControl/Control/Models/Model_Security.cs index 995ddd1..9c008c5 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Model_Security.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Model_Security.cs @@ -1,5 +1,5 @@ using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Helpers; @@ -8,8 +8,8 @@ using System; namespace Sarand.BusinessMgr.Web.Control.Models { - //======================================================================= - public class Model_Security : SbmModel_Control + //======================================================================= + public class Model_Security : SbmModel_Control { //------------------------------------------------------------------- // Construction. diff --git a/SaBusinessMgrCoreWebControl/Control/Models/Param/Model_Param.cs b/SaBusinessMgrCoreWebControl/Control/Models/Param/Model_Param.cs index 2ed032f..23df5c4 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/Param/Model_Param.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/Param/Model_Param.cs @@ -1,19 +1,14 @@ -using DocumentFormat.OpenXml.EMMA; -using DocumentFormat.OpenXml.Spreadsheet; -using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.Rendering; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.CodeTypes; using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; namespace Sarand.BusinessMgr.Web.Control.Models.Param { diff --git a/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs b/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs index fc5878a..100cbad 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Models; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Core; @@ -24,8 +24,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models //------------------------------------------------------------------- // Properties. protected SbmApplication_Control App_Control { get { return SbmApplication_Control.Instance; } } - public SbmSessionData_Control SessionData_Control { get { return SessionData as SbmSessionData_Control; } } - public override ISbmUserOrganisationContext UserContext_Core => throw new NotImplementedException(); + protected SbmSessionData_Control SessionData_Control { get { return SessionData_Web as SbmSessionData_Control; } } //------------------------------------------------------------------- public IEnumerable GetInstanceContextsForSelect() diff --git a/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx b/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx index 3639f4b..a552a00 100644 --- a/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx +++ b/SaBusinessMgrCoreWebControl/Localisation/SbmControlProperties.resx @@ -459,4 +459,16 @@ Create Vehicle + + Active + + + Total + + + Deleted + + + Count + \ No newline at end of file diff --git a/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml b/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml index 59663b4..6dd8a59 100644 --- a/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml +++ b/SaBusinessMgrCoreWebControl/Views/Home/Index.cshtml @@ -1,9 +1,56 @@ @model Model_Home @inject SbmLocaliser Localiser @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Home Page"; }
-

Welcome

+

Welcome

+
+ + + +
+ + + + + + + + + + + + + + + + + +
@Localiser["label.context"]@Localiser["label.count"]
Owners@Model.GetOwnerCount()
Repositories@Model.GetRepositoryCount()
Users@Model.GetUserAccountCount()
diff --git a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css index ce3c81f..2dbe08f 100644 --- a/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css +++ b/SaBusinessMgrCoreWebControl/wwwroot/css/sbc-main.css @@ -71,9 +71,9 @@ body /* Responsive */ -body > .container, header > .container, footer > .container +#sbc-page-body > .container, header > .container, footer > .container { - padding: 0 0.5%; + padding: 0 4px; } @media (min-width: 992px) diff --git a/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs index bd37ab5..718b852 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs @@ -1,24 +1,17 @@ using Newtonsoft.Json; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Web.Portal.Controllers; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.BusinessMgr.Net.Standard.Base.Mgr; +using Sarand.BusinessMgr.Web.Portal.Controllers; +using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; -using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.Utils; using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config.Database; -using Sarand.BusinessMgr.Net.Standard.Base.Core; -using Sarand.BusinessMgr.Net.Standard.Base.Mgr; -using Sarand.Net.Standard.Base.App; namespace Sarand.BusinessMgr.Web.Portal.App { diff --git a/SaBusinessMgrCoreWebPortal/Portal/App/SbmSystem_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/App/SbmSystem_Portal.cs index cb01264..1a425c0 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/App/SbmSystem_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/App/SbmSystem_Portal.cs @@ -14,7 +14,6 @@ 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 static Sarand.BusinessMgr.Net.Core.Web.App.SbmAppConfig; namespace Sarand.BusinessMgr.Web.Portal.App { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs index ec28258..ead2585 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetCategoryController-Ajax.cs @@ -26,7 +26,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets public String TypeDesc { get; set; } public String Code { get; set; } public String Caption { get; set; } - public long? AssetCount { get; set; } // Fields. public class FieldData { @@ -47,7 +46,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets data.Caption = assetCategory.DescBrief; // Asset count. long assetCount = Internals.AssetMgr.GetAssetCountForAssetCategory(assetCategory.Id); - if (assetCount > 0) data.AssetCount = assetCount; + if (assetCount > 0) data.Field.Value.Add($"{Model_AssetCategory.ItemField.AssetCount}", $"{assetCount}"); } private void PopulateAssetCategoryResponseItemData(SbmModel_Portal model, AssetCategoryItemData data, SbmAssetCategory assetCategory) { @@ -216,7 +215,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets assetCategoryData.Field.Value.Add($"{Model_AssetCategory.ItemField.Status}", SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))); long assetCount = values.GetLong(colAssetCount.DataName); if (assetCount > 0) - assetCategoryData.AssetCount = assetCount; + assetCategoryData.Field.Value.Add($"{Model_AssetCategory.ItemField.AssetCount}", $"{assetCount}"); // Cleanse item values. assetCategoryData.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value)); responseData.AssetCategories.Add(assetCategoryData); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs index c6bfb09..8f80e19 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Assets/AssetController-Ajax.cs @@ -100,7 +100,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets // Item filter. SbmAsset.Params prmAsset = new SbmAsset.Params(); prmAsset.Search = model.Filter.Search; - prmAsset.StatusCat = model.Filter.GetStatusCat(); + prmAsset.StatusCat = model.GetFilterStatusCat(); model.Paging.ItemTotal = (ulong)AssetMgr.GetAssetCount(prmAsset); model.PopulatePagingTo(prmAsset.ResultsPaging); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs index ec6c943..9b24554 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Commodities/CommodityController-Ajax.cs @@ -12,7 +12,6 @@ using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities { @@ -473,8 +472,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities // Oct24 Not yet implemented - may be in separate page/controller. private class AssociatedProductsData { - public Sbm.AssociatedItemMode ItemMode = AssociatedItemMode.Unknown; - public Sbm.ItemLinkType ItemLinkType = ItemLinkType.Unknown; + public Sbm.AssociatedItemMode ItemMode = Sbm.AssociatedItemMode.Unknown; + public Sbm.ItemLinkType ItemLinkType = Sbm.ItemLinkType.Unknown; public ItemId ItemIdParent; public ItemId ItemIdChild; public List ItemLinks { get; set; } diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs index 24b9d12..17dcc95 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs @@ -1,43 +1,36 @@ using Microsoft.AspNetCore.Mvc.Filters; using Newtonsoft.Json; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; -using Sarand.BusinessMgr.Web.Portal.App; +using Sarand.BusinessMgr.Net.Core.Web.Components; 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.Web.Portal.App; +using Sarand.BusinessMgr.Web.Portal.Helpers; +using Sarand.BusinessMgr.Web.Portal.Models; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; -using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Helpers; -using Sarand.Net.Standard.Base.Security; -using Sarand.Net.Standard.Base.Utils; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; -using System.Web; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config.Database; -using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; -using Sarand.BusinessMgr.Net.Core.Web.Helpers; -using Sarand.BusinessMgr.Web.Portal.Helpers; -using DocumentFormat.OpenXml.EMMA; -using DocumentFormat.OpenXml.Wordprocessing; -using Sarand.BusinessMgr.Net.Core.Web.Models; -using Sarand.BusinessMgr.Web.Portal.Models; -using Sarand.BusinessMgr.Net.Standard.Base.Consoles; 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.Helpers; 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.Collections.Specialized; +using System.Diagnostics; +using System.Linq; +using System.Web; namespace Sarand.BusinessMgr.Web.Portal.Controllers { @@ -68,42 +61,42 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers //------------------------------------------------------------------- // Properties. - public SbmInternals Internals { get { if (internals == null && UserContext_Core != null) { internals = new SbmInternals(UserContext_Core); } return internals; } } + protected SbmInternals Internals { get { if (internals == null && UserContext_Core != null) { internals = new SbmInternals(UserContext_Core); } return internals; } } // 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; } } + protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } } + protected SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } } + protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } } + protected SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } } + protected SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } } + protected SbmStockMgr StockMgr { get { return Internals.StockMgr; } } + protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } } + protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } } // 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; } } + protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } + protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } } + protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } + protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } + protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } } + protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } } + protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } } + protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } } + protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } } + protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } } // Configurations. - public SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } - public SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } + protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } + protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } // System codes. - public List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); } + protected List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); } // Email. - public SaEmailConfig EmailConfig { get { return Internals.EmailConfig; } } - public SbmEmailConsole EmailConsole { get { return Internals.EmailConsole; } } + protected SaEmailConfig EmailConfig { get { return Internals.EmailConfig; } } + protected SbmEmailConsole EmailConsole { get { return Internals.EmailConsole; } } //------------------------------------------------------------------- // Session data. /// Portal session data protected SbmSessionData_Portal SessionData_Portal { get { return SessionData as SbmSessionData_Portal; } } - public override ISbmUserOrganisationContext UserContext_Core { get { return SessionData_Portal; } } + protected ISbmUserOrganisationContext UserContext_Core { get { return SessionData_Portal; } } /// /// Session data deserialisation. /// @@ -209,6 +202,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers // Create session. if (!OpenUserSession(sessionDataForUser)) { + Debugger.Break(); SaLogger.Warn($"{SysUtil.Fn} Failed to open user session. Repository context: {sessionDataForUser.RepositoryContext}. Email: {securityItemUser.EmailAddress}."); errorMessage = Localiser["security.msg.signin.invalid"]; return false; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs index d55c3fb..e9abe68 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs @@ -1,34 +1,24 @@ using Microsoft.AspNetCore.Mvc; -using NPOI.SS.Formula.Functions; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Helpers; -using Sarand.BusinessMgr.Web.Portal.App; -using Sarand.BusinessMgr.Web.Portal.Models; 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.Helpers; using Sarand.BusinessMgr.Net.Standard.Base.Mgr; -using Sarand.BusinessMgr.Net.Standard.Dbas.App; +using Sarand.BusinessMgr.Web.Portal.App; +using Sarand.BusinessMgr.Web.Portal.Helpers; +using Sarand.BusinessMgr.Web.Portal.Models; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Email; -using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; -using System.Threading.Tasks; using System.Web; -using DocumentFormat.OpenXml.EMMA; -using static Sarand.Net.Standard.Base.Bus.SaErrorStateItem; -using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; -using Sarand.BusinessMgr.Web.Portal.Helpers; namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security { @@ -80,7 +70,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security if (!(SessionData_Portal?.ValidUser ?? false)) { SaLogger.Warn($"{SysUtil.Fn} Failed to identify Suitable database. Context: {model.RepositoryContext}. Email: {model.EmailAddress}."); - return Json(responseData.SetControlError(nameof(model.EmailAddress), model.Localiser["security.msg.signin.invalid"])); + return Json(responseData.SetControlError(nameof(model.EmailAddress), Localiser["security.msg.signin.invalid"])); } // Construct response. diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Transactions/TransactionController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Transactions/TransactionController-Ajax.cs index 9e3875f..0fcf7f7 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Transactions/TransactionController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Transactions/TransactionController-Ajax.cs @@ -12,7 +12,6 @@ using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Web.Portal.Controllers.Transactions { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Helpers/SbmSessionContextHelper_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Helpers/SbmSessionContextHelper_Portal.cs index 1e86276..2921ea1 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Helpers/SbmSessionContextHelper_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Helpers/SbmSessionContextHelper_Portal.cs @@ -9,7 +9,6 @@ using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Dbas.Data; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm.Config.Database; namespace Sarand.BusinessMgr.Web.Portal.Helpers { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset-Config.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset-Config.cs new file mode 100644 index 0000000..8b4b134 --- /dev/null +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset-Config.cs @@ -0,0 +1,311 @@ +using Sarand.BusinessMgr.Net.Standard.Base.App; +using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Bus; +using System; +using System.Collections.Generic; + +namespace Sarand.BusinessMgr.Web.Portal.Models.Assets +{ + //======================================================================= + // Asset model - Configuration. + //======================================================================= + partial class Model_Asset + { + //------------------------------------------------------------------- + + /// Prefix for field names. + public const String FieldNamePrefix = "AssetCat"; + + /// Item fields. + public enum ItemField + { + // Asset properties. + Id, + // Identity. + Category, + SerialNumber, + ReferenceExt, + DescBrief, + // Purchase. + Supplier, + PurchaseDate, + PurchaseAmount, + PurchaseTaxCode, + PurchaseAmountGross, + PurchaseInvoiceRef, + PaymentTerms, + PurchaseAmountSettlementGross, + PurchaseAmountEnhancementGross, + // Sale. + Customer, + SaleOn, + SaleCategory, + SaleAmount, + SaleTaxCode, + SaleAmountGross, + SaleTaxCodeProfit, + // Associated properties. + VehicleCount, + // Common. + Notes, + Status, + CreatedOn, + UpdatedOn, + Actions, + } + + /// + /// Identifier used by form fields to show control specific messages generated by model validation etc. + /// - Both page and model should use this method to consistently generate the field name. + /// + public static String GetFieldName(ItemField field) + { + return $"{FieldNamePrefix}{field}"; + } + + // List configuration. + public class ListConfigData + { + // Actions. + public class ActionData + { + public class AllowData + { + public bool? Create { get; set; } + public bool? Update { get; set; } + } + public AllowData Allow { get; } = new AllowData(); + } + public ActionData Action { get; } = new ActionData(); + // List columns. + public class ColumnData + { + // Column name prefix. + public String Prefix { get; } = Model_Asset.FieldNamePrefix; + // Hide column. + public HashSet Hide { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); + // Column labels. + public Dictionary Label { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + } + public ColumnData Column { get; } = new ColumnData(); + } + public ListConfigData ListConfig { get; private set; } + + //------------------------------------------------------------------- + /// + /// Populate Asset list configuration data - only required on initial page construction. + /// + public void PopulateListConfig() + { + ListConfig = new ListConfigData(); + PopulateListConfig(ListConfig); + } + public void PopulateListConfig(ListConfigData config) + { + ViewMode pageMode = GetFilterMode(); + bool modeIsSearch = pageMode == ViewMode.Search; + bool modeIsMaintain = pageMode == ViewMode.Maintain; + bool assetPurchaseAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Purchase); + bool assetSaleAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Sale); + bool assetRentalAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Rental); + bool assetDisposalAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Disposal); + bool userCanCreateAssets = SessionData_Portal.SecurityProfile.UserCanCreateItemType(Sbm.ItemType.Asset); + bool userCanUpdateAssets = SessionData_Portal.SecurityProfile.UserCanUpdateItemType(Sbm.ItemType.Asset); + + // Actions. + + if (userCanCreateAssets) + config.Action.Allow.Create = true; + if (userCanUpdateAssets) + config.Action.Allow.Update = true; + + // List columns. + + if (SysId.IsValid(GetFilterAssetCategoryId())) + config.Column.Hide.Add($"{ItemField.Category}"); + + // Asset Category Assets. + if (!modeIsMaintain || !SessionConsole.AllowOption(Sbm.ConfigOption.Vehicles)) + config.Column.Hide.Add($"{ItemField.VehicleCount}"); + + // Actions. + if (!modeIsMaintain) + config.Column.Hide.Add($"{ItemField.Actions}"); + } + + //------------------------------------------------------------------- + // Item configuration. + //------------------------------------------------------------------- + // Legacy Asset dialog tabs and panels. + // Dialog: + // - Category, SerialNumber, DescBrief, Status. + // Tab 1 'Properties': + // Item - Item info Html panel. + // Purchase - price, tax code, on, net price, invoice ref, settlement, payment terms, enhancement, supplier. + // Sale - price, tax code, category, net price, sold price, sold on. + // Rental - cost, cost unit, price, price unit. + // Disposal - method, dispose on. + // Notes. + // Tab 2 'Processes'. + //------------------------------------------------------------------- + + public class ItemConfigData + { + // Update dialog title. + public String Title { get; set; } + // Pre-select Asset type. + public class TypeData + { + public TypeData(string code, String desc) + { + Code = code; + Desc = desc; + } + public String Code { get; set; } + public String Desc { get; set; } + } + public TypeData Type { get; set; } + // Field name prefix. + public String Prefix { get; } = Model_Asset.FieldNamePrefix; + // Control flags. + public bool? ManagedByAccounts { get; set; } + public bool? LocalPricing { get; set; } + // Allowed actions. + public class AllowData + { + public bool? UpdateCode { get; set; } + } + public AllowData Allow { get; } = new AllowData(); + // Item fields. + public class FieldData + { + // Field name prefix. + public String Prefix { get; } = Model_Asset.FieldNamePrefix; + // Hide field. + public HashSet Hide { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); + // Read-only field. + public HashSet Readonly { get; } = new HashSet(StringComparer.InvariantCultureIgnoreCase); + // Field labels. + public Dictionary Label { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + } + public FieldData Field { get; } = new FieldData(); + } + /// + /// Populate item configuration for existing vehicle. + /// + public void PopulateItemConfig(ItemConfigData config, SbmAsset asset, SbmAssetCategory assetCategory) + { + PopulateItemConfig(config, asset.GetItemId(), assetCategory?.AssetType ?? Sbm.AssetType.Unknown); + } + /// + /// Populate item configuration for new or existing vehicle. + /// + public void PopulateItemConfig(ItemConfigData config, ItemId assetId, Sbm.AssetType assetType) + { + // Session configuration. + bool assetPurchaseAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Purchase); + bool assetSaleAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Sale); + bool assetRentalAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Rental); + bool assetDisposalAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Disposal); + bool userCanCreateAssets = SessionData_Portal.SecurityProfile.UserCanCreateItemType(Sbm.ItemType.Asset); + bool userCanUpdateAssets = SessionData_Portal.SecurityProfile.UserCanUpdateItemType(Sbm.ItemType.Asset); + + // Update dialog title. + config.Title = Localiser["caption.vehicle.update"]; + + //--------------------------------------------------------------- + // Identity. + + // Asset category. + // ToDo - Asset type readonly if any associated items. + if (!userCanUpdateAssets || ItemId.IsValid(assetId)) + config.Field.Readonly.Add($"{ItemField.Category}"); + + // Serial Number. + if (!userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.SerialNumber}"); + + // Description. + if (!userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.DescBrief}"); + + //--------------------------------------------------------------- + // Purchase. + + // Purchase net price. + if (!assetPurchaseAllowed||!userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseAmount}"); + + // Purchase tax code. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseTaxCode}"); + + // Purchase gross price. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseAmountGross}"); + + // Purchase date. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseDate}"); + + // Invoice reference. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseInvoiceRef}"); + + // Payment terms. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PaymentTerms}"); + + // Purchase Settlement gross price. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseAmountSettlementGross}"); + + // Purchase Enhancenment gross price. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.PurchaseAmountEnhancementGross}"); + + // Supplier. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.Supplier}"); + + //--------------------------------------------------------------- + // Sale. + + // Sale net price. + if (!assetSaleAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.SaleAmount}"); + + // Tax code. + if (!assetSaleAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.SaleTaxCode}"); + + // Sale gross price. + if (!assetSaleAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.SaleAmountGross}"); + + // Tax code - profit. + if (!userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.SaleTaxCodeProfit}"); + + // Customer. + if (!assetPurchaseAllowed || !userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.Customer}"); + + //--------------------------------------------------------------- + // Common properties. + + // Status. + if (!userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.Status}"); + + // Notes. + if (!userCanUpdateAssets) + config.Field.Readonly.Add($"{ItemField.Notes}"); + + //--------------------------------------------------------------- + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset.cs index 143a357..250c0b1 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_Asset.cs @@ -1,6 +1,6 @@ using DocumentFormat.OpenXml.Spreadsheet; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; @@ -17,6 +17,13 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets //======================================================================= public partial class Model_Asset : SbmModel_Portal { + //------------------------------------------------------------------- + // Definitions. + public enum ViewMode + { + Search, Maintain, AssetsForItem + } + //------------------------------------------------------------------- // Construction. public Model_Asset(SbmLocaliser localiser) : @@ -28,14 +35,24 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets // Filter properties. public class FilterData { + public String Mode { get; set; } + public String AssetCategoryId { get; set; } public String Search { get; set; } public String StatusCat { get; set; } - public SbmAsset.StatusCat GetStatusCat() - { - return EnumUtil.ParseEnum(StatusCat, SbmAsset.StatusCat.NotDeleted); - } } public FilterData Filter { get; } = new FilterData(); + public ViewMode GetFilterMode() + { + return EnumUtil.ParseEnum(Filter.Mode, ViewMode.Search); + } + public SysId GetFilterAssetCategoryId() + { + return SysId.ToSysId(Filter.AssetCategoryId); + } + public SbmAsset.StatusCat GetFilterStatusCat() + { + return EnumUtil.ParseEnum(Filter.StatusCat, SbmAsset.StatusCat.NotDeleted); + } //------------------------------------------------------------------- // Item properties. @@ -44,7 +61,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets public String Exists { get; set; } public String Id { get; set; } public String CategoryId { get; set; } - public String SerialNumber{ get; set; } + public String SerialNumber { get; set; } public String DescBrief { get; set; } public String Notes { get; set; } public String StatusCode { get; set; } @@ -94,7 +111,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets } // Notes. - if (Asset.Notes!= null) + if (Asset.Notes != null) { String controlName = "AssetNotes"; responseData.SetControlValue(controlName, Asset.Notes); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory-Config.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory-Config.cs index e3d1863..0828695 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory-Config.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory-Config.cs @@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus; using System; using System.Collections.Generic; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Web.Portal.Models.Assets { @@ -107,7 +106,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets // List columns. - if (GetFilterAssetType() <= 0) + if (GetFilterAssetType() > 0) config.Column.Hide.Add($"{ItemField.Type}"); // Asset Category Assets. diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory.cs index fe57cb1..98aad96 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Assets/Model_AssetCategory.cs @@ -1,7 +1,7 @@ using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Http; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_Code.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_Code.cs index bf80a98..7f22a52 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_Code.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_Code.cs @@ -1,6 +1,6 @@ using DocumentFormat.OpenXml.Spreadsheet; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_CodeType.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_CodeType.cs index d71518b..57641f7 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_CodeType.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Codes/Model_CodeType.cs @@ -1,6 +1,6 @@ using DocumentFormat.OpenXml.Spreadsheet; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs index b8bc7fe..499b066 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity.cs @@ -1,20 +1,12 @@ -using Microsoft.AspNetCore.Http; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +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.Helpers; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; -using static Sarand.BusinessMgr.Web.Portal.Models.Contacts.Model_Contact; namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs index b21dcb0..9a361f7 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Association.cs @@ -1,19 +1,10 @@ -using Microsoft.AspNetCore.Mvc.Rendering; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +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.Helpers; using Sarand.Net.Standard.Base.App; -using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs index 5243848..281787e 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Contacts/Model_Contact.cs @@ -1,19 +1,12 @@ -using DocumentFormat.OpenXml.EMMA; -using Microsoft.AspNetCore.Mvc.Rendering; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +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.Helpers; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Home.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Home.cs index 7447bc7..4516c89 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Home.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Home.cs @@ -1,13 +1,4 @@ using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; -using Sarand.BusinessMgr.Net.Standard.Base.Bus; -using Sarand.BusinessMgr.Net.Standard.Base.Helpers; -using Sarand.Net.Standard.Base.Helpers; -using Sarand.Net.Standard.Base.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Sarand.BusinessMgr.Web.Portal.Models { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Security.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Security.cs index 0d8168b..a017da0 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Security.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Model_Security.cs @@ -1,5 +1,5 @@ using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Helpers; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs index 2773162..964b58e 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs @@ -1,23 +1,35 @@ using Microsoft.AspNetCore.Mvc.Rendering; -using NPOI.SS.Formula.Functions; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Models; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; -using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.BusinessMgr.Net.Standard.Base.Consoles; +using Sarand.BusinessMgr.Net.Standard.Base.Mgr; using Sarand.BusinessMgr.Web.Portal.App; +using Sarand.Net.Standard.Base.CodeTypes; using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Diary; +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.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Web.Portal.Models { //======================================================================= public class SbmModel_Portal : SbmModel_Base { + //------------------------------------------------------------------- + // Data members. + private SbmInternals internals; + //------------------------------------------------------------------- // Protected construction. protected SbmModel_Portal(SbmLocaliser localiser) : @@ -25,22 +37,60 @@ namespace Sarand.BusinessMgr.Web.Portal.Models { } + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (internals != null) internals.Dispose(); internals = null; + } + base.Dispose(disposing); + } + //------------------------------------------------------------------- // Properties. - public SbmSessionData_Portal SessionData_Portal { get { return SessionData as SbmSessionData_Portal; } } - public override ISbmUserOrganisationContext UserContext_Core { get { return SessionData_Portal; } } + protected SbmSessionData_Portal SessionData_Portal { get { return SessionData_Web as SbmSessionData_Portal; } } public String OrganisationName { get { return SessionData_Portal?.Organisation?.DisplayName ?? ""; } } //------------------------------------------------------------------- // Security profile. public bool UserCanViewFinancials() { return SessionData_Portal.SecurityProfile.UserCanViewFinancials(); } - public bool UserCanViewCommodityFinancials_Supply() { return SessionData_Portal.SecurityProfile.UserCanViewFinancials(FinancialType.CommoditySupply); } - public bool UserCanViewCommodityFinancials_Sales() { return SessionData_Portal.SecurityProfile.UserCanViewFinancials(FinancialType.CommoditySales); } + public bool UserCanViewCommodityFinancials_Supply() { return SessionData_Portal.SecurityProfile.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); } + public bool UserCanViewCommodityFinancials_Sales() { return SessionData_Portal.SecurityProfile.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); } public bool UserCanUpdateFinancials() { return SessionData_Portal.SecurityProfile.UserCanUpdateFinancials(); } - public bool UserCanStockTake() { return SessionData_Portal.SecurityProfile.UserHasSecurityRight(SecurityRight.StockTake); } + public bool UserCanStockTake() { return SessionData_Portal.SecurityProfile.UserHasSecurityRight(Sbm.SecurityRight.StockTake); } public bool UserCanCreateItem(Sbm.ItemType itemType) { return SessionData_Portal.SecurityProfile.UserCanCreateItemType(itemType); } public bool UserCanUpdateItem(Sbm.ItemType itemType) { return SessionData_Portal.SecurityProfile.UserCanUpdateItemType(itemType); } + //------------------------------------------------------------------- + // Business components. + // NB Keep these accessors protected to avoid them being called by the model binding logic before the session data is ready. + protected SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(SessionData_Portal); return internals; } } + // Managers. + protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } } + protected SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } } + protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } } + protected SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } } + protected SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } } + protected SbmStockMgr StockMgr { get { return Internals.StockMgr; } } + protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } } + protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } } + // Consoles. + protected SbmSessionConsole SessionConsole { get { return Internals.SessionConsole; } } + protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } } + protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } } + protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } } + protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } } + protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } } + protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } } + protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } } + protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } } + protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } } + // Configurations. + protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } + protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } + // System codes. + protected List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); } + //------------------------------------------------------------------- // Page menu options. @@ -109,6 +159,28 @@ namespace Sarand.BusinessMgr.Web.Portal.Models //------------------------------------------------------------------- // View reference data. //------------------------------------------------------------------- + // NB Use methods rather than accessors for properties that depend on session data + // to avoid the model binding logic invoking a getter before it's ready for use. + + /// List of Code Types for dropdown. + public IEnumerable GetCodeTypesForSelect() + { + List codeTypes = new List(); + SaCodeType.Params prmCodeType = new SaCodeType.Params(); + prmCodeType.SortColumns.Add(CodeTypeConsole.GetCodeTypeColumnDfn(SaCodeType.Column.Name)); + foreach (SaCodeType codeType in CodeTypeConsole.GetCodeTypeList(prmCodeType)) + codeTypes.Add(codeType.Code, codeType.Name); + return new SelectList(codeTypes, "Code", "Desc"); + } + + /// List of Code Type Codes for dropdown. + public IEnumerable GetCodeTypeCodesForSelect(Sbm.ApplCodeType codeType, bool activeOnly = true) + { + List codes = new List(); + foreach (SaCode code in CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(codeType), activeOnly)) + codes.Add(code.Code, code.Description); + return new SelectList(codes, "Code", "Desc"); + } //------------------------------------------------------------------- // View reference data - Contacts. @@ -153,7 +225,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models commodityTypes.Add(Sbm.CommodityType.Any, "", Localiser["label.any"]); foreach (TypeCodeDesc commodityType in GetCodesOfType(Sbm.SystemCode.CommodityType)) { - if (commodityType.Type == (int)Sbm.CommodityType.Asset && !SessionConsole.AllowOption(ConfigOption.Assets)) continue; + if (commodityType.Type == (int)Sbm.CommodityType.Asset && !SessionConsole.AllowOption(Sbm.ConfigOption.Assets)) continue; commodityTypes.Add(commodityType); } return new SelectList(commodityTypes, "Code", "Desc"); @@ -167,7 +239,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models List commodityTypes = new List(); foreach (TypeCodeDesc commodityType in GetCodesOfType(Sbm.SystemCode.CommodityType)) { - if (commodityType.Type == (int)Sbm.CommodityType.Asset && !SessionConsole.AllowOption(ConfigOption.Assets)) continue; + if (commodityType.Type == (int)Sbm.CommodityType.Asset && !SessionConsole.AllowOption(Sbm.ConfigOption.Assets)) continue; commodityTypes.Add(commodityType); } return new SelectList(commodityTypes, "Code", "Desc"); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Transactions/Model_Transaction.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Transactions/Model_Transaction.cs index e675395..cbdae23 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Transactions/Model_Transaction.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Transactions/Model_Transaction.cs @@ -1,20 +1,11 @@ -using Microsoft.AspNetCore.Http; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +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.Helpers; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; -using static Sarand.BusinessMgr.Web.Portal.Models.Contacts.Model_Contact; namespace Sarand.BusinessMgr.Web.Portal.Models.Transactions { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_Vehicle.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_Vehicle.cs index 7583f17..83b2e00 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_Vehicle.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_Vehicle.cs @@ -1,6 +1,6 @@ using DocumentFormat.OpenXml.Spreadsheet; using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +using Sarand.BusinessMgr.Net.Core.Web.Components; using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_VehicleClass.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_VehicleClass.cs index 26d6643..99969cc 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_VehicleClass.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Vehicles/Model_VehicleClass.cs @@ -1,15 +1,10 @@ -using DocumentFormat.OpenXml.Spreadsheet; -using Sarand.BusinessMgr.Net.Core.Web.App; -using Sarand.BusinessMgr.Net.Core.Web.Controllers; +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.Bus.Control; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; -using Sarand.Net.Standard.Base.Helpers; using Sarand.Net.Standard.Base.Utils; -using System; namespace Sarand.BusinessMgr.Web.Portal.Models.Vehicles { diff --git a/SaBusinessMgrCoreWebPortal/SaBusinessMgrCoreWebPortal.csproj b/SaBusinessMgrCoreWebPortal/SaBusinessMgrCoreWebPortal.csproj index 1f566c7..dac5a96 100644 --- a/SaBusinessMgrCoreWebPortal/SaBusinessMgrCoreWebPortal.csproj +++ b/SaBusinessMgrCoreWebPortal/SaBusinessMgrCoreWebPortal.csproj @@ -40,6 +40,10 @@ true PreserveNewest + + true + PreserveNewest + true PreserveNewest @@ -51,7 +55,6 @@ - diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Index.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Index.cshtml index 4d87466..ac29fb7 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Index.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Index.cshtml @@ -3,213 +3,6 @@ @inject SbmLocaliser Localiser @{ ViewData["Title"] = "Assets"; - Model.AdditionalFiles_JS.Add("js/sbm-asset.js"); } -
- - - -
- - @* Filter form - wrap header to include paging controls. *@ - @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssetFilter", @class = "sbm-form", @onSubmit = "return false;" })) - { - -
-
-
- -
-
@Localiser["label.assets"]
-
- @* Burger menu *@ - -
-
-
- - @* Filter Panel *@ -
-
-
@Localiser["label.search"]
-
- @Html.TextBoxFor(model => model.Filter.Search, new { @id = "", @class = "FilterSearch", @maxlength = "32" }) -
-
-
- - } - -
- - - - - - - - - - - - -
@Localiser["label.category"]@Localiser["label.serial"]@Localiser["label.description"]@Localiser["label.status"]
-
- - @* Element templates *@ -
- @* Filter Burger option template - ul is ignored *@ -
    -
  • XXX
  • -
- @* Asset row template - table is ignored. *@ - - - - - - - - -
-
- @* Burger menu *@ - -
-
- @* Item Burger option template - ul is ignored *@ -
    -
  • XXX
  • -
-
- - @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssetId", @onSubmit = "return false;" })) - { - @Html.HiddenFor(model => model.Asset.Id, new { @id = "", @class = "AssetId" }) - } - @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmCategories", @onSubmit = "return false;" })) - { - } -
-
- @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAsset", @class = "sbm-form", @onSubmit = "return false;" })) - { - @Html.HiddenFor(model => model.Asset.Exists, new { @id = "", @class = "AssetExists" }) - @Html.HiddenFor(model => model.Asset.Id, new { @id = "", @class = "AssetId" }) - - @* Type *@ -
-
-
-
- -
-
-
-
-
- @Html.HiddenFor(model => model.Asset.CategoryId, new { @id = "", @class = "AssetCategoryId" }) - -
-
-
-
-
-
-
-
-
- - @* Serial Number*@ -
-
-
-
- -
-
-
-
- @Html.TextBoxFor(model => model.Asset.SerialNumber, new { @id = "ifAssetSerialNumber", @class = "AssetSerialNumber sbm-input upper", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber) }) -
-
-
-
-
- - @* Description *@ -
-
-
-
- -
-
-
-
- @Html.TextBoxFor(model => model.Asset.DescBrief, new { @id = "ifAssetDescription", @class = "AssetDescription sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.SaAsset_DescBrief) }) -
-
-
-
-
- - @* Status *@ -
-
-
-
- -
-
-
-
- -
-
-
-
-
- - @* Notes *@ -
-
-
-
- -
-
-
-
- @Html.TextAreaFor(model => model.Asset.Notes, new { @id = "ifAssetNotes", @class = "AssetNotes sbm-textarea", @rows = 3, @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.SaAsset_Notes) }) -
-
-
-
-
- - } -
-
- - @* Select Item dialog and script *@ - - -
- -
+ diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetDialog.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetDialog.cshtml new file mode 100644 index 0000000..8d50358 --- /dev/null +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetDialog.cshtml @@ -0,0 +1,121 @@ +@* Asset - Dialog Panel *@ +@* View is decoupled from Asset model as it may be included in other views, eg. Vehicles. *@ +@model SbmModel_Portal +@inject SbmLocaliser Localiser +@{ + // Ensure view is only included once in page. + if (!Model.RegisterView("Views/Assets/Asset/Panel-AssetSelect")) return; + Model.AdditionalFiles_JS.Add("js/sbm-asset.js"); +} + +@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssetId", @onSubmit = "return false;" })) +{ + @Html.Hidden("Asset.Id", "", new { @id = "", @class = "AssetId" }) +} +@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmCategories", @onSubmit = "return false;" })) +{ +} +
+
+ @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAsset", @class = "sbm-form", @onSubmit = "return false;" })) + { + @Html.Hidden("Asset.Exists", "", new { @id = "", @class = "AssetExists" }) + @Html.Hidden("Asset.Id", "", new { @id = "", @class = "AssetId" }) + + @* Type *@ +
+
+
+
+ +
+
+
+
+
+ @Html.Hidden("Asset.CategoryId", "", new { @id = "", @class = "AssetCategoryId" }) + +
+
+
+
+
+
+
+
+
+ + @* Serial Number*@ +
+
+
+
+ +
+
+
+
+ @Html.TextBox("Asset.SerialNumber", "", new { @id = "ifAssetSerialNumber", @class = "AssetSerialNumber sbm-input upper", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber) }) +
+
+
+
+
+ + @* Description *@ +
+
+
+
+ +
+
+
+
+ @Html.TextBox("Asset.DescBrief", "", new { @id = "ifAssetDescription", @class = "AssetDescription sbm-input", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.SaAsset_DescBrief) }) +
+
+
+
+
+ + @* Status *@ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + @* Notes *@ +
+
+
+
+ +
+
+
+
+ @Html.TextArea("Asset.Notes", "", new { @id = "ifAssetNotes", @class = "AssetNotes sbm-textarea", @rows = 3, @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.SaAsset_Notes) }) +
+
+
+
+
+ + } +
+
+ +@* Select Item dialog and script *@ + diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetList.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetList.cshtml new file mode 100644 index 0000000..81b07ca --- /dev/null +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetList.cshtml @@ -0,0 +1,55 @@ +@* Asset - Maintain Panel *@ +@* View is decoupled from Asset model as it may be included in other views, eg. Vehicles. *@ +@model SbmModel_Portal +@inject SbmLocaliser Localiser +@{ + /* NB Can potentially appear more than once on a page. */ +} + +
+ + + + + + + + + + + + +
@Localiser["label.category"]@Localiser["label.serial"]@Localiser["label.description"]@Localiser["label.status"]
+
+ +@* Element templates *@ +
+ @* Filter Burger option template - ul is ignored *@ +
    +
  • XXX
  • +
+ @* Asset row template - table is ignored. *@ + + + + + + + + +
+
+ @* Burger menu *@ + +
+
+ @* Item Burger option template - ul is ignored *@ +
    +
  • XXX
  • +
+
diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetMaintain.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetMaintain.cshtml new file mode 100644 index 0000000..62d0ac4 --- /dev/null +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetMaintain.cshtml @@ -0,0 +1,71 @@ +@* Asset - Maintain Panel *@ +@* View is decoupled from Asset model as it may be included in other views, eg. Vehicles. *@ +@model SbmModel_Portal +@inject SbmLocaliser Localiser +@{ + // Ensure view is only included once in page. + if (!Model.RegisterView("Views/Assets/Asset/Panel-AssetMaintain")) return; + Model.AdditionalFiles_JS.Add("js/sbm-asset.js"); +} + +
+ + + +
+ + @* Filter form - wrap header to include paging controls. *@ + @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssetFilter", @class = "sbm-form", @onSubmit = "return false;" })) + { + @Html.Hidden("Filter.Mode", Model_Asset.ViewMode.Maintain, new { @id = "" }) + +
+
+
+ +
+
@Localiser["label.assets"]
+
+ @* Burger menu *@ + +
+
+
+ + @* Filter Panel *@ +
+
+
+
@Localiser["label.category"]
+
+ @Html.Hidden("Filter.AssetCategoryId", "", new { @id = "", @class = "FilterAssetCategoryId", @maxlength = "32" }) + +
+
+
+
@Localiser["label.search"]
+
+ @Html.TextBox("Filter.Search", "", new { @id = "", @class = "FilterSearch", @maxlength = "32" }) +
+
+
+
+ + } + + + +
+
+ + + diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetSelect.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetSelect.cshtml new file mode 100644 index 0000000..ae09798 --- /dev/null +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/Asset/Panel-AssetSelect.cshtml @@ -0,0 +1,43 @@ +@* Asset - Maintain Panel *@ +@* View is decoupled from Asset model as it may be included in other views, eg. Vehicles. *@ +@model SbmModel_Portal +@inject SbmLocaliser Localiser +@{ + // Ensure view is only included once in page. + if (!Model.RegisterView("Views/Assets/Asset/Panel-AssetSelect")) return; + Model.AdditionalFiles_JS.Add("js/sbm-asset.js"); +} + + + +
+ + @using (@Html.BeginForm(FormMethod.Post, new { @id = "", @class = "frmAssetFilter sbm-form", @onSubmit = "return false;" })) + { + @Html.Hidden("Filter.Mode", Model_Asset.ViewMode.Search, new { @id = "" }) + + @* Filter Panel *@ +
+
+
+ @* Asset type *@ +
@Localiser["label.type"]
+
+ @Html.DropDownList("Filter.AssetType", Model.GetAssetTypeCodesForFilterDropdown(), Localiser["label.any"], new { @id = "", @class = "FilterAssetType sbm-select" }) +
+
+
+ @* Asset filter - name etc. *@ +
@Localiser["label.search"]
+
+ @Html.TextBox("Filter.Search", "", new { @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" }) +
+
+
+
+ } + + + +
diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryDialog.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryDialog.cshtml index 3296fa1..a3d7310 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryDialog.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryDialog.cshtml @@ -1,10 +1,11 @@ -@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ +@* Asset Category - Dialog panel *@ +@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ @model SbmModel_Portal @inject SbmLocaliser Localiser @{ - /* Asset Category - Dialog panel */ // Ensure view is only included once in page. if (!Model.RegisterView("Views/Assets/AssetCategory/Panel-AssetCategoryDialog")) return; + Model.AdditionalFiles_JS.Add("js/sbm-asset-cat.js"); } @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssetCategoryId", @onSubmit = "return false;" })) diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryList.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryList.cshtml index 5e4d64d..4a95f28 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryList.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryList.cshtml @@ -1,8 +1,8 @@ -@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ +@* Asset Category - List panel *@ +@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ @model SbmModel_Portal @inject SbmLocaliser Localiser @{ - /* Asset Category - List panel */ /* NB Can potentially appear more than once on a page. */ } @@ -15,6 +15,7 @@ @Localiser["label.code"] @Localiser["label.description"] @Localiser["label.notes"] + @Localiser["label.assets"] @Localiser["label.status"] @@ -39,6 +40,7 @@ +
diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryMaintain.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryMaintain.cshtml index 8212b00..6892f5d 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryMaintain.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategoryMaintain.cshtml @@ -1,8 +1,8 @@ -@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ +@* Asset Category - Maintain Panel *@ +@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ @model SbmModel_Portal @inject SbmLocaliser Localiser @{ - /* Asset Category - Maintain panel */ // Ensure view is only included once in page. if (!Model.RegisterView("Views/Assets/AssetCategory/Panel-AssetCategoryMaintain")) return; Model.AdditionalFiles_JS.Add("js/sbm-asset-cat.js"); @@ -18,7 +18,7 @@
@* Filter form - wrap header to include paging controls. *@ - @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssetCategoryFilter", @class = "sbm-form", @onSubmit = "return false;" })) + @using (@Html.BeginForm(FormMethod.Post, new { @id = "", @class = "frmAssetCategoryFilter sbm-form", @onSubmit = "return false;" })) { @Html.Hidden("Filter.Mode", Model_AssetCategory.ViewMode.Maintain, new { @id = "" }) diff --git a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategorySelect.cshtml b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategorySelect.cshtml index 7a43e6b..1f3d7c5 100644 --- a/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategorySelect.cshtml +++ b/SaBusinessMgrCoreWebPortal/Views/Assets/AssetCategory/Panel-AssetCategorySelect.cshtml @@ -1,8 +1,8 @@ -@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ +@* Asset Category - Select panel *@ +@* View is decoupled from Asset Category model as it may be included in other views, eg. Assets. *@ @model SbmModel_Portal @inject SbmLocaliser Localiser @{ - /* Asset Category - Select panel */ // Ensure view is only included once in page. if (!Model.RegisterView("Views/Assets/AssetCategory/Panel-AssetCategorySelect")) return; Model.AdditionalFiles_JS.Add("js/sbm-asset-cat.js"); @@ -24,7 +24,7 @@ @* AssetCategory type *@
@Localiser["label.type"]
- @Html.DropDownList("Filter.AssetCategoryType", Model.GetAssetTypeCodesForFilterDropdown(), Localiser["label.any"], new { @id = "", @class = "FilterAssetCategoryType sbm-select" }) + @Html.DropDownList("Filter.AssetType", Model.GetAssetTypeCodesForFilterDropdown(), Localiser["label.any"], new { @id = "", @class = "FilterAssetType sbm-select" })
diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css index 837105f..af6ae17 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-data.css @@ -71,6 +71,13 @@ padding: 2px 8px 0 0; } +.sbm-panel-filter input[type="text"], +.sbm-panel-filter textarea, +.sbm-panel-filter select +{ + max-width: 96%; +} + /* Data panel - Content */ .sbm-panel-data .sbm-content diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css index fb7a111..f6d2642 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css +++ b/SaBusinessMgrCoreWebPortal/wwwroot/css/sbm-main.css @@ -54,9 +54,9 @@ body /* Responsive */ -body > .container, header > .container, footer > .container +#sbm-page-body > .container, header > .container, footer > .container { - padding: 0 0.5%; + padding: 0 4px; } @media (min-width: 992px) diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset-cat.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset-cat.js index dc2fcb1..d18ecd4 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset-cat.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset-cat.js @@ -79,6 +79,10 @@ $('.' + prefix + 'Status', $item).text(item.statusDesc).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase()); if (!env.mode.search) { + let $assetCount = $('.' + prefix + 'AssetCount', $item).off('click'); + sbm.debug($assetCount.text()); + if ($assetCount.text() > 0) + $assetCount.on('click', function () { sbm.navigateTo('Assets/Asset'); }).addClass('sbm-action-text'); // Actions. let fnUpd = function () { ac.updateItem(env, item.id) }; var $bgr = $('.sbm-burger', $item).invisible(); @@ -221,7 +225,7 @@ //sbm.debug('selectAssetCategory', prm); let env = ac.env.select; env.prmSelect = prm; - env.$frm.filter.find('.FilterAssetCategoryType').val(''); + env.$frm.filter.find('.FilterAssetType').val(''); env.$frm.filter.find('.FilterSearch').val(prm.search || ''); env.$pnl.table.find('tbody tr').remove(); sbm.openDialog(env.$dlg.select, 1000, 800); @@ -238,7 +242,7 @@ { //sbm.debug('selectItem', env, env.prmSelect.item); env.$dlg.select.dialog('close'); - env.prmSelect.fnSuccess(env.prmSelect.item); + if (env.prmSelect.fnSuccess) env.prmSelect.fnSuccess(env.prmSelect.item); delete env.prmSelect; } @@ -254,7 +258,7 @@ ac.onItemEdited = function (env, item) { //sbm.debug('ac.onItemEdited', env, item); - env.prmEdit.fnSuccess(item); + if (env.prmEdit.fnSuccess) env.prmEdit.fnSuccess(item); delete env.prmEdit; } @@ -271,7 +275,7 @@ env.$pnl.msgs = env.$pnl.table.find('.sbm-panel-messages'); env.$pnl.tmpls = env.$pnl.items.find('.sbm-panel-item-template'); - env.$frm.filter = $('#frmAssetCategoryFilter').on('input', '.FilterSearch', function () { ac.refreshResults(250); }); + env.$frm.filter = env.$pnl.items.find('.frmAssetCategoryFilter').on('input', '.FilterSearch', function () { ac.refreshResults(250); }); env.$frm.itemId = $('#frmAssetCategoryId'); var opt = sbm.dlgOpts(); diff --git a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset.js b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset.js index aa893df..df55641 100644 --- a/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset.js +++ b/SaBusinessMgrCoreWebPortal/wwwroot/js/sbm-asset.js @@ -24,7 +24,7 @@ } ac.handleAssets = function (response) { - sbm.debug('handleAssets', response); + //sbm.debug('handleAssets', response); delete ac.awaitingRefreshResponse; let $table = $('table', $pnl.table).find('tbody tr').remove().end(); $pnl.msgs.hide().empty(); @@ -198,6 +198,16 @@ delete ac.data.assets; } + //-------------------------------------------------------------- + ac.onSelectFilterAssetCategory=function(env, item) + { + sbm.debug('onSelectFilterAssetCategory', env, item); + env.$frm.filter.find('.FilterAssetCategoryId').val(item.id); + env.$frm.filter.find('.FilterAssetCategory').val(item.name); + + setTimeout(ac.refreshResults, 250); + } + //-------------------------------------------------------------- $(function () { @@ -209,7 +219,8 @@ $pnl.tmpls = $('.sbm-panel-item-template', $pnl.items); $frm.filter = $('#frmAssetFilter'); - $('.FilterSearch', $frm.filter).on('input', function () { ac.refreshResults(250); }); + $frm.filter.on('input', '.FilterSearch', function () { ac.refreshResults(250); }); + $frm.filter.on('dblclick', '.FilterAssetCategory', function () { sbm.fn.selectAssetCategory({ fnSuccess: function (item) { ac.onSelectFilterAssetCategory(env, item); } }); }); $frm.itemId = $('#frmAssetId'); $frm.categories = $('#frmCategories');