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