Asset Categories

This commit is contained in:
Andy Howard
2025-01-27 10:01:32 +00:00
parent 03b3a81dab
commit a3ac029d55
130 changed files with 1809 additions and 1423 deletions
@@ -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))
{
@@ -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()
-4
View File
@@ -19,8 +19,4 @@
<ProjectReference Include="..\SaBusMgrStandardDbas\SaBusMgrStandardDbas.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Web\Core\" />
</ItemGroup>
</Project>
@@ -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<SaInterfaceCategory> InterfaceCategories_Allowed = new HashSet<SaInterfaceCategory>();
private readonly HashSet<SaInterfaceCategory> InterfaceCategories_Disallowed = new HashSet<SaInterfaceCategory>();
/// <summary>
/// Whether the Interface Category is allowed.
/// </summary>
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<SbmDbDfn.ColumnIdx> ColumnChangeLogged_Allowed = new HashSet<SbmDbDfn.ColumnIdx>();
private readonly HashSet<SbmDbDfn.ColumnIdx> ColumnChangeLogged_Disallowed = new HashSet<SbmDbDfn.ColumnIdx>();
/// <summary>
/// Are changes to values in the specified database column recorded in the Change Log.
/// </summary>
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;
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -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;
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -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.
@@ -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(); } }
/// <summary>Store session data, eg. to start a new user session on sign-in.</summary>
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);
//-------------------------------------------------------------------
}
@@ -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); } }
/// <summary>Maximum length allowed for password entry: sign-up, change password etc.</summary>
public int PasswordMaxLength { get; } = 32;
//-------------------------------------------------------------------
/// <summary>
/// Form control value max length - Security tables.
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
/// </summary>
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;
}
/// <summary>
/// Form control value max length - code type tables.
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
/// </summary>
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;
}
/// <summary>
/// Form control value max length - BusinessMgr tables.
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
/// </summary>
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.
/// <summary>
/// User session index to identify the site resources, eg. database.
/// <para>Equivalent to the Site index on the login form.</para>
/// <para>Populates value on logout form to identify default site for next login.</para>
/// </summary>
public ushort SessionIdx { get { return SessionContext?.Index ?? 0; } }
public string FormAction { get; set; }
//-------------------------------------------------------------------
}
//=======================================================================
}
-287
View File
@@ -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<TypeCodeDesc> 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; } }
/// <summary>Maximum length allowed for password entry: sign-up, change password etc.</summary>
public int PasswordMaxLength { get; } = 32;
//-------------------------------------------------------------------
/// <summary>
/// Form control value max length - Security tables.
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
/// </summary>
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;
}
/// <summary>
/// Form control value max length - code type tables.
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
/// </summary>
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;
}
/// <summary>
/// Form control value max length - BusinessMgr tables.
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
/// </summary>
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.
/// <summary>List of Code Types for dropdown.</summary>
public IEnumerable<SelectListItem> GetCodeTypesForSelect()
{
List<CodeDesc> codeTypes = new List<CodeDesc>();
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");
}
/// <summary>List of Code Type Codes for dropdown.</summary>
public IEnumerable<SelectListItem> GetCodeTypeCodesForSelect(Sbm.ApplCodeType codeType, bool activeOnly = true)
{
List<CodeDesc> codes = new List<CodeDesc>();
foreach (SaCode code in CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(codeType), activeOnly))
codes.Add(code.Code, code.Description);
return new SelectList(codes, "Code", "Desc");
}
//-------------------------------------------------------------------
// Form properties.
/// <summary>
/// User session index to identify the site resources, eg. database.
/// <para>Equivalent to the Site index on the login form.</para>
/// <para>Populates value on logout form to identify default site for next login.</para>
/// </summary>
public ushort SessionIdx { get { return SessionContext?.Index ?? 0; } }
public String FormAction { get; set; }
//-------------------------------------------------------------------
}
//=======================================================================
}
+2
View File
@@ -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,
}
//-------------------------------------------------------------------
@@ -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
/// </summary>
public abstract bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse);
//-------------------------------------------------------------------
// Update Log.
public abstract bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column, bool defaultResponse);
//-------------------------------------------------------------------
}
//=======================================================================
+61 -35
View File
@@ -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<SaCurrency> currencies = null;
private List<SaTaxCode> taxCodes = null;
private List<SaUnitMeasure> unitsOfMeasure = null;
private Dictionary<SysId, SaRegion> regions = null;
private Dictionary<SysId, SaCurrency> currencies = null;
private Dictionary<SysId, SaTaxCode> taxCodes = null;
private Dictionary<SysId, SaUnitMeasure> unitsOfMeasure = null;
//-------------------------------------------------------------------
// Construction.
/// <summary>
/// Sessionless construction - minimal context information.
/// <para>- Used by Instance Data Cache and Control application.</para>
/// </summary>
public SbmInternals(SbmSessionContext sessionContext)
{
UserContext = new SbmSessionData_Internals(sessionContext);
ReadOnly = true;
}
// Session dependent construction.
/// <summary>
/// Session dependent construction.
/// </summary>
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<SaRegion> GetRegions()
{
populateRegions();
return new List<SaRegion>(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<SaCurrency> GetCurrencies()
{
populateCurrencies();
return new List<SaCurrency>(currencies);
return new List<SaCurrency>(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<SaTaxCode> GetTaxCodes()
{
populateTaxCodes();
return new List<SaTaxCode>(taxCodes);
return new List<SaTaxCode>(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<SaUnitMeasure> GetUnitsOfMeasure()
{
populateUnitsOfMeasure();
return new List<SaUnitMeasure>(unitsOfMeasure);
return new List<SaUnitMeasure>(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<SaUnitMeasure> GetUnitsOfMeasureByCategory(SaUomCategory uomCategory)
{
if (uomCategory == 0) return null;
populateUnitsOfMeasure();
return unitsOfMeasure.Find(item => item.Id.Equals(currencyId));
return new List<SaUnitMeasure>(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();
}
//-------------------------------------------------------------------
@@ -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; }
}
/// <summary>
/// Registered Security Rights to identify code for enumerated right.
/// <para> Optinised for speed of conversin and serialised storage.</para>
/// </summary>
[JsonProperty("SecurityRights")]
public List<SecurityRightData> SecurityRights { get; private set; } = new List<SecurityRightData>();
public Dictionary<int, String> SecurityRights { get; private set; } = new Dictionary<int, string>();
private void PopulateSecurityRights(List<SaSecurityRight> 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<GroupData> Groups { get; private set; } = new List<GroupData>();
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<SaSecurityProfile.RightData> 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<RightData>();
Granted.Add(rightData);
if (Granted == null) Granted = new Dictionary<string, List<RightData>>();
if (!Granted.ContainsKey(right.Code)) Granted[right.Code] = new List<RightData>();
Granted[right.Code].Add(rightData);
}
else
{
if (Denied == null) Denied = new HashSet<RightData>();
Denied.Add(rightData);
if (Denied == null) Denied = new Dictionary<string, List<RightData>>();
if (!Denied.ContainsKey(right.Code)) Denied[right.Code] = new List<RightData>();
Denied[right.Code].Add(rightData);
}
}
}
@@ -214,8 +212,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
Granted = null;
Denied = null;
}
public HashSet<RightData> Granted { get; private set; }
public HashSet<RightData> Denied { get; private set; }
public Dictionary<String, List<RightData>> Granted { get; private set; }
public Dictionary<String, List<RightData>> 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)
@@ -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
@@ -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
{
@@ -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<SysId> GetInterfaceIds(bool activeOnly)
public HashSet<SysId> GetInterfaceIds(bool activeOnly)
{
List<SysId> interfaceIds = new List<SysId>();
HashSet<SysId> interfaceIds = new HashSet<SysId>();
if (SysId.IsValid(sageParams.InterfaceId) && (!activeOnly || sageParams.dfnInt_Sage.Active))
interfaceIds.Add(qbkParams.InterfaceId);
if (SysId.IsValid(qbkParams.InterfaceId) && (!activeOnly || qbkParams.dfnInt_QBooks.Active))
+13 -28
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool FindPrimary(this List<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> 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<SbmAddress> values)
{
@@ -767,8 +767,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Contact status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
}
//=======================================================================
+11 -24
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Asset status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> value = new List<StringPair>();
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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmAddress> 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<SbmAddress> 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));
}
}
//=======================================================================
@@ -382,8 +382,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// AssetCategory.
public Sbm.AssetType AssetType { get; set; }
public String Search { get; set; }
@@ -232,8 +232,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Asset Process status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
+15 -15
View File
@@ -873,8 +873,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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<String> AccountManagerCodes { get; } = new List<String>();
public List<String> AccountHandlerCodes { get; } = new List<String>();
public List<String> AccountTypeCodes { get; } = new List<String>();
public List<String> AccountRatingCodes { get; } = new List<String>();
public List<String> ContactAreaCodes { get; } = new List<String>();
public List<String> ContactHandlerCodes { get; } = new List<String>();
public List<String> ContactMethodCodes { get; } = new List<String>();
public List<String> ContactCallCycleCodes { get; } = new List<String>();
public List<String> OrderLeadTimeCodes { get; } = new List<String>();
public List<String> DeliveryTypeCodes { get; } = new List<String>();
public List<String> DeliveryMethodCodes { get; } = new List<String>();
public List<String> DeliveryCourierCodes { get; } = new List<String>();
public List<String> DeliveryBookInCodes { get; } = new List<String>();
public HashSet<String> AccountManagerCodes { get; } = new HashSet<String>();
public HashSet<String> AccountHandlerCodes { get; } = new HashSet<String>();
public HashSet<String> AccountTypeCodes { get; } = new HashSet<String>();
public HashSet<String> AccountRatingCodes { get; } = new HashSet<String>();
public HashSet<String> ContactAreaCodes { get; } = new HashSet<String>();
public HashSet<String> ContactHandlerCodes { get; } = new HashSet<String>();
public HashSet<String> ContactMethodCodes { get; } = new HashSet<String>();
public HashSet<String> ContactCallCycleCodes { get; } = new HashSet<String>();
public HashSet<String> OrderLeadTimeCodes { get; } = new HashSet<String>();
public HashSet<String> DeliveryTypeCodes { get; } = new HashSet<String>();
public HashSet<String> DeliveryMethodCodes { get; } = new HashSet<String>();
public HashSet<String> DeliveryCourierCodes { get; } = new HashSet<String>();
public HashSet<String> DeliveryBookInCodes { get; } = new HashSet<String>();
// 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).
/// <summary>Transaction status - Value other than 'Any' triggers transaction filter.</summary>
public SbmTransaction.StatusCat TransactionStatusCat { get; set; } = SbmTransaction.StatusCat.Any;
@@ -1787,8 +1787,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// Commodity Ids.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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<String> Categories { get; } = new List<string>();
public HashSet<String> Categories { get; } = new HashSet<string>();
// 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<SysId> PriceSetIdsIncluded { get; } = new List<SysId>();
public List<SysId> PriceSetIdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> PriceSetIdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> PriceSetIdsExcluded { get; } = new HashSet<SysId>();
// Stock Control.
public Sbm.LocationFilter StockLocationFilter { get; set; }
public SysId LocationIdStock { get; set; }
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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;
/// <summary>Commodity Customer status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -257,26 +252,26 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmCommodityCustomerList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmCommodityCustomer> 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<SbmCommodityCustomer> 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<SbmCommodityCustomer> 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<SbmCommodityCustomer> 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));
}
}
//=======================================================================
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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;
/// <summary>Commodity Supplier status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -246,21 +241,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmCommoditySupplierList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmCommoditySupplier> 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<SbmCommoditySupplier> 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<SbmCommoditySupplier> 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));
}
}
//=======================================================================
@@ -660,8 +660,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static int CompareEffectiveAscend(SbmConstituent constituent1, SbmConstituent constituent2)
{
if (constituent1 != null || constituent2 != null) return 0;
+6 -11
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Container status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -340,16 +335,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmContainerList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmContainer> 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<SbmContainer> 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));
}
}
//=======================================================================
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// Item properties.
public SysId ContainerId { get; set; }
public short ItemSeq { get; set; }
public Sbm.ItemType ItemType { get; set; }
public List<SysId> ItemIds { get; } = new List<SysId>();
public HashSet<SysId> ItemIds { get; } = new HashSet<SysId>();
public Sbm.ItemType ItemTypeSource { get; set; }
public List<SysId> ItemIdsSource { get; } = new List<SysId>();
public HashSet<SysId> ItemIdsSource { get; } = new HashSet<SysId>();
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;
/// <summary>Container Item status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -315,21 +310,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmContainerItemList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmContainerItem> 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<SbmContainerItem> 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<SbmContainerItem> 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));
}
//-------------------------------------------------------------------
@@ -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<SaStatus> containerItemStatuses = new List<SaStatus>()
private static readonly List<SaStatus> costEstimateStatuses = new List<SaStatus>()
{
SaStatus.Active,
SaStatus.Disabled,
};
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
public static List<SaStatus> CostEstimateStatuses { get { return new List<SaStatus>(containerItemStatuses); } }
public static List<SaStatus> CostEstimateStatuses { get { return new List<SaStatus>(costEstimateStatuses); } }
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
{
switch (status)
@@ -179,7 +173,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//-------------------------------------------------------------------
// Utilities.
public List<TypeCodeDesc> GetCategories(Sbm.CostEstimateCategoryType costEstimateCategoryType, bool includeCommodityCode)
public List<TypeCodeDesc> GetCategories(Sbm.CostEstimateCategoryType categoryType, bool includeCommodityCode)
{
List<TypeCodeDesc> categories = new List<TypeCodeDesc>();
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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
//-------------------------------------------------------------------
// Find in List.
public static bool Find(this List<SbmCostEstimate> values, SbmCostEstimate containerItem)
public static bool Find(this List<SbmCostEstimate> 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<SbmCostEstimate> values, Sbm.CostEstimateCategory costEstimateCategory, String type)
public static bool FindByCategoryType(this List<SbmCostEstimate> 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<SbmCostEstimate> values, Sbm.CostEstimateCategory costEstimateCategory)
public static bool HasCostsByCategory(this List<SbmCostEstimate> 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<String> GetCostCodesByCategory(this List<SbmCostEstimate> values, Sbm.CostEstimateCategory costEstimateCategory)
public static List<String> GetCostCodesByCategory(this List<SbmCostEstimate> values, Sbm.CostEstimateCategory category)
{
List<String> codes = new List<String>();
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<SbmCostEstimate> GetCostsByCategory(this List<SbmCostEstimate> values, Sbm.CostEstimateCategory costEstimateCategory)
public static List<SbmCostEstimate> GetCostsByCategory(this List<SbmCostEstimate> values, Sbm.CostEstimateCategory category)
{
List<SbmCostEstimate> costEstimateCosts = new List<SbmCostEstimate>();
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;
@@ -222,8 +222,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
}
//=======================================================================
}
+9 -8
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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
{
//-------------------------------------------------------------------
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmItemLink> 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<SbmItemLink> 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<SbmItemLink> 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<SbmItemLink> 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<SbmItemLink> 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<SbmItemLink> 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));
}
//-------------------------------------------------------------------
+10 -15
View File
@@ -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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
//-------------------------------------------------------------------
//Find.
public static bool Find(this List<SbmItemPrice> 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<SbmItemPrice> values, String type)
{
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
///
//-------------------------------------------------------------------
// Get list of process Ids (valid values only).
public static List<SysId> GetProcessIds(this List<SbmItemProcess> values)
{
List<SysId> processIds = new List<SysId>();
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<SysId>(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<SbmItemProcess> 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<SbmItemProcess> values, SaStatus status)
+6 -11
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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;
/// <summary>Location status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -249,16 +244,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmLocationList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmLocation> 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<SbmLocation> 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));
}
}
//=======================================================================
+5 -11
View File
@@ -305,16 +305,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// Movement.
public Sbm.ItemType ItemType { get; set; }
public Sbm.ItemType ItemTypeSource { get; set; }
public List<SysId> ItemIds { get; set; }
public List<SysId> ItemIdsSource { get; set; }
public HashSet<SysId> ItemIds { get; set; }
public HashSet<SysId> ItemIdsSource { get; set; }
public Sbm.ItemType ContainerItemType { get; set; }
public SysId ContainerItemId { get; set; }
public List<SysId> ItemIdSource { get; set; }
public HashSet<SysId> 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; }
/// <summary>Movement status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -329,14 +329,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// Hierarchy.
public SysId ParentItemId { get; set; }
public SysId AncestorItemId { get; set; }
// Commodity.
public List<SysId> IncludedCommodityIds { get; } = new List<SysId>();
public List<SysId> ExcludedCommodityIds { get; } = new List<SysId>();
public HashSet<SysId> CommodityIdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> CommodityIdsExcluded { get; } = new HashSet<SysId>();
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; }
/// <summary>Portfolio Item status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
+1 -11
View File
@@ -292,16 +292,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public Sbm.PriceRounderDirection RounderDirection { get; set; } = Sbm.PriceRounderDirection.Unknown;
/// <summary>Price status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
}
//=======================================================================
+2 -8
View File
@@ -231,8 +231,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// Item Ids.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Price Set status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
+6 -5
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// Process.
public Sbm.ProcessCategory ProcessCategory { get; set; }
@@ -305,7 +306,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmProcessList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
//-------------------------------------------------------------------
// 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<SbmProcess> 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<SbmContainer> 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));
}
//-------------------------------------------------------------------
}
@@ -1232,9 +1232,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public SysId CommodityId { get; set; }
public SysId AssetId { get; set; }
// Requirement.
public List<SysId> RequirementIdsIncluded { get; } = new List<SysId>();
public List<SysId> RequirementIdsExcluded { get; } = new List<SysId>();
public List<SysId> RequirementIdsSource { get; } = new List<SysId>();
public HashSet<SysId> RequirementIdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> RequirementIdsExcluded { get; } = new HashSet<SysId>();
public HashSet<SysId> RequirementIdsSource { get; } = new HashSet<SysId>();
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<SysId> TransactionIdsIncluded { get; } = new List<SysId>();
public List<SysId> TransactionIdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> TransactionIdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> TransactionIdsExcluded { get; } = new HashSet<SysId>();
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; }
/// <summary>Requirement status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.Default;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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<SbmStockLevel> 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<SbmStockLevel> 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<SbmRequirement> 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<SbmRequirement> 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));
}
}
+3 -3
View File
@@ -229,8 +229,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmTransaction> values, Sbm.SysParamCategory category, String name, SysId idAffOwner, SysId idAffTarget, SysId idAssoc)
{
return true;
@@ -245,8 +245,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// SystemAccount.
public Sbm.SystemAccountType Type { get; set; } = Sbm.SystemAccountType.Customer;
public SysId InterfaceId { get; set; }
@@ -173,8 +173,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// SystemAccountUser.
public SysId InterfaceId { get; set; }
public SysId AccountId { get; set; }
@@ -219,8 +219,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public new class Params : SacsHierarchyItem.Params
{
// List filtering.
public List<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>System User status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.Any;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmTransaction> 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<SbmTransaction> 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));
}
}
@@ -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
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
//-------------------------------------------------------------------
// Find.
public static bool Find(this List<SbmTransactionPayment> 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<SbmTransactionPayment> 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<SbmTransactionPayment> values, List<SaCodeDfn> typeCodeDfns)
+6 -11
View File
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Vehicle status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.Any;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -604,16 +599,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmVehicleList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmVehicle> 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<SbmVehicle> 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));
}
}
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
/// <summary>Generic property search - make, model, derivative etc.</summary>
public String Search { get; set; }
// Item properties.
@@ -446,12 +447,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public String VehicleCategoryCode { get; set; }
/// <summary>Vehicle Class status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -462,16 +457,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmVehicleClassList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmVehicleClass> 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<SbmVehicleClass> 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));
}
}
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Vehicle Event status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.Any;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -346,16 +341,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmVehicleEventList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmVehicleEvent> 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<SbmVehicleEvent> 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));
}
}
@@ -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<SysId> IdsIncluded { get; } = new List<SysId>();
public List<SysId> IdsExcluded { get; } = new List<SysId>();
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
// 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; }
/// <summary>Vehicle Feature status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.Any;
// Utilities.
public List<StringPair> GetDisplayValues()
{
List<StringPair> values = new List<StringPair>();
return values;
}
}
//-------------------------------------------------------------------
@@ -332,21 +327,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//=======================================================================
public static class SbmVehicleFeatureList
{
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
/// <summary>Check whether item exists/locate in list with specified Id.</summary>
public static bool Find(this List<SbmVehicleFeature> 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<SbmVehicleFeature> 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<SbmVehicleFeature> 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<SbmVehicleFeature> GetFeaturesOfSource(this List<SbmVehicleFeature> values, Sbm.VehicleFeatureSource vehicleFeatureSource)
{
@@ -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);
}
//-------------------------------------------------------------------
@@ -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
/// </summary>
bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse);
//-------------------------------------------------------------------
// Update Log.
bool IsColumnChangeLogged(SbmDbDfn.ColumnIdx column, bool defaultResponse);
//-------------------------------------------------------------------
}
//=======================================================================
@@ -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);
//-------------------------------------------------------------------
}
@@ -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
@@ -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;
@@ -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:
@@ -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<SysId> portfolioIdsPublished = new List<SysId>();
List<SaInterfaceDfn> interfaceDfns = InterfaceConsole.GetInterfaceDfns(UserContext.OrganisationInterfaceContext, SaInterfaceCategory.Website, (short)Sbm.InterfaceType_Website.WebStore, false);
foreach (SaInterfaceDfn interfaceDfn in interfaceDfns)
List<SaInterfaceConsole.SaInterfaceDfn> 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)))
+12 -48
View File
@@ -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<TypeCodeDesc> currencyCodes;
public List<SaCurrency> currencies;
public List<SaLanguage> languages;
public List<SaRegion> regions;
public List<SaTaxCode> taxCodes;
public List<SaUnitMeasure> 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<SaUnitMeasure> FindUnitsOfMeasureByCategory(SaUomCategory uomCategory)
{
PopulateUnitsOfMeasure();
return mbr.unitsOfMeasure.FindAll(item => item.Category == uomCategory);
return Internals.GetUnitsOfMeasureByCategory(uomCategory);
}
//-------------------------------------------------------------------
@@ -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)
@@ -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<SaItemData> 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<SaItemData> 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<SaItemData> itemDatas = internals.ItemDataConsole.GetItemDataList(prmItemData);
foreach (SaItemData itemData in itemDatas)
{
@@ -43,6 +43,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
// Consoles.
public override SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
//-------------------------------------------------------------------
// Default population.
// Regions.
//-------------------------------------------------------------------
}
//=======================================================================
@@ -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}");
//---------------------------------------------------------------
@@ -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<SbmAssetCategory> assetCategories = new List<SbmAssetCategory>();
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<ColumnDfn> 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));
}
@@ -26,7 +26,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
{
//-------------------------------------------------------------------
// Data members.
private bool locationIdListPopulated = false;
private bool locationIdListsPopulated = false;
private readonly List<SysId> locationIds_All = new List<SysId>();
private readonly List<SysId> locationIds_Calc = new List<SysId>();
private readonly List<SysId> locationIds_Sales = new List<SysId>();
@@ -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);
@@ -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 + ")");
@@ -25,9 +25,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
//*******************************************************************
// Data members.
private bool locationIdsPopulated = false;
private List<SysId> locationIds_All = new List<SysId>();
private List<SysId> locationIds_Sales = new List<SysId>();
private List<SysId> locationIds_Calc = new List<SysId>();
private HashSet<SysId> locationIds_All = new HashSet<SysId>();
private HashSet<SysId> locationIds_Sales = new HashSet<SysId>();
private HashSet<SysId> locationIds_Calc = new HashSet<SysId>();
private int orderQuantityDecimals;
@@ -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<SysId>(locationIds_NonSales);
locationIds_Sales = new HashSet<SysId>(locationIds_NonSales);
locationIds_NonSales.Clear();
}
}
@@ -2142,8 +2142,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
if (bAccountInvoiceRef)
{
// Identify the accounts interface.
List<SysId> accountsIdsInterface = new List<SysId>();
accountsIdsInterface = AccountsDfn.GetInterfaceIds(true);
HashSet<SysId> accountsIdsInterface = AccountsDfn.GetInterfaceIds(true);
if (accountsIdsInterface.Count > 0)
{
if (prm.TransactionType == Sbm.TransactionType.ProformaSalesInvoice)
@@ -31,10 +31,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
private int weightDecimals;
bool locationIdListsPopulated = false;
private List<SysId> locationIds_All;
private List<SysId> locationIds_Calc;
private List<SysId> locationIds_Sales;
private List<SysId> locationIds_NonSales;
private HashSet<SysId> locationIds_All;
private HashSet<SysId> locationIds_Calc;
private HashSet<SysId> locationIds_Sales;
private HashSet<SysId> locationIds_NonSales;
//-------------------------------------------------------------------
// Construction.
@@ -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;
@@ -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(); }
@@ -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;
@@ -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
{
@@ -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
{
@@ -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)
@@ -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.
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -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
{
@@ -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
{
@@ -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
/// <summary>Control session data</summary>
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<SbmSessionData_Control>(sessionDataJson, SessionDataJsonDeserializerSettings);
@@ -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;
}
@@ -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.
@@ -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;
@@ -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;
@@ -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;
@@ -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);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -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.
@@ -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
{
@@ -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<SelectListItem> GetInstanceContextsForSelect()
@@ -459,4 +459,16 @@
<data name="caption.vehicle.create" xml:space="preserve">
<value>Create Vehicle</value>
</data>
<data name="label.active" xml:space="preserve">
<value>Active</value>
</data>
<data name="label.total" xml:space="preserve">
<value>Total</value>
</data>
<data name="label.deleted" xml:space="preserve">
<value>Deleted</value>
</data>
<data name="label.count" xml:space="preserve">
<value>Count</value>
</data>
</root>
@@ -1,9 +1,56 @@
@model Model_Home
@inject SbmLocaliser Localiser
@{
ViewData["Title"] = "Home Page";
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<h1 class="display-4">Welcome</h1>
</div>
<style>
#tblWelcome
{
margin: 0 auto;
font-size: 20px;
border-spacing: 0;
}
#tblWelcome tr:hover
{
background-color: lightyellow;
}
#tblWelcome tr th
{
padding: 4px 4px;
font-size: 20px;
}
#tblWelcome tr td
{
padding: 4px 4px;
font-size: 16px;
}
</style>
<div class="">
<table id="tblWelcome" class="table-hover">
<tr style="font-weight:bold;background-color:lightsteelblue;">
<th style="min-width:200px;">@Localiser["label.context"]</th>
<th class="center" style="min-width:80px;">@Localiser["label.count"]</th>
</tr>
<tr>
<td class="">Owners</td>
<td class="center sbc-action-text" onclick="sbc.navigateTo('Instance/Owner')">@Model.GetOwnerCount()</td>
</tr>
<tr>
<td class="">Repositories</td>
<td class="center sbc-action-text" onclick="sbc.navigateTo('Instance/Repository')">@Model.GetRepositoryCount()</td>
</tr>
<tr>
<td class="">Users</td>
<td class="center sbc-action-text" onclick="sbc.navigateTo('Account/UserAccount')">@Model.GetUserAccountCount()</td>
</tr>
</table>
</div>
@@ -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)
@@ -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
{
@@ -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
{
@@ -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);
@@ -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);
@@ -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<SbmItemLink> ItemLinks { get; set; }
@@ -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<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); }
protected List<TypeCodeDesc> 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.
/// <summary>Portal session data</summary>
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; } }
/// <summary>
/// Session data deserialisation.
/// </summary>
@@ -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;
@@ -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.
@@ -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
{

Some files were not shown because too many files have changed in this diff Show More