Portal application - initial.

This commit is contained in:
2021-07-08 20:50:46 +01:00
parent 13c79a8da4
commit 01ae03ddfc
1208 changed files with 186342 additions and 1690 deletions
@@ -0,0 +1,45 @@
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
static partial class Sbm
{
//-------------------------------------------------------------------
// Application version.
//-------------------------------------------------------------------
public static class Version
{
private static String version { get; } = "3.0.0.0";
// Retrieve version.
public static String GetFullVersion() { return version; }
public static String GetAppVersion()
{
if (!SbmSystem.DebugMode)
{
try
{
// Live instance version is only first 3 elements.
String[] versionElements = version.Split('.');
return String.Join(".", versionElements.Take(3));
}
catch (Exception exc) { SaLogger.Warn("Sbm.Version.ToString " + ExceptionUtil.GetErrorStateMessage(exc)); }
}
return version;
}
}
//-------------------------------------------------------------------
// Version history.
//-------------------------------------------------------------------
// 3.0.0 ?-Jul-2021 Initial demo test version.
// - .
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -1,21 +1,106 @@
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using System;
using System.Collections.Generic;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public static class Sbm
public static partial class Sbm
{
//-------------------------------------------------------------------
// Application configuration defaults.
public static class Config
{
public static String Context_Defaults { get; } = "Defaults";
public static class Security
{
public static class Password
{
}
public static class Activation
{
public static int EmailLinkExpiresMins_Default { get; } = 60;
public static int EmailLinkExpiresMins_Min { get; } = 30;
public static int EmailLinkExpiresMins_Max { get; } = 60 * 24;
}
public static class SignIn
{
public static class PasswordRequest
{
public static int EmailLinkExpiresMins_Default { get; } = 60;
public static int EmailLinkExpiresMins_Min { get; } = 30;
public static int EmailLinkExpiresMins_Max { get; } = 60 * 24;
}
public static class KeepLoggedIn
{
public static bool Allowed_Default { get; } = true;
public static int CookieExpiresDays_Default { get; } = 10;
public static int CookieExpiresDays_Min { get; } = 1;
public static int CookieExpiresDays_Max { get; } = 30;
}
}
}
public class Online
{
public static class Session
{
public static class Cookie
{
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
public static String Name { get; } = "BusinessMgr.Online.Session";
public static bool HttpOnly { get; } = true;
public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(60);
public static long RememberMeTimeoutMilis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds;
}
}
public static class DataCache
{
public static class RefreshIntervalSecs
{
public static int Initial { get; } = SacsSystem.DebugMode ? 2 : 5;
public static int Periodic { get; } = SacsSystem.DebugMode ? 60 : 1800;
}
}
}
public class Admin
{
public static class Session
{
public static class Cookie
{
/// <summary>Default cookie name: '.AspNetCore.Session'</summary>
public static String Name { get; } = "BusinessMgr.Admin.Session";
public static bool HttpOnly { get; } = true;
public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(15);
public static long KeepLoggedInTimeoutMillis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds;
}
}
}
}
//-------------------------------------------------------------------
// Definitions.
public static String Version { get; } = "3.0.0.0";
public static String ApplicationCaption { get; } = "Sarand BusinessMgr";
// Option values.
public static String ValueYes { get; } = "YES";
public static String ValueNo { get; } = "NO";
public static List<CodeDesc> ValuesYesNo { get; } = new List<CodeDesc>() { new CodeDesc(ValueYes, "Yes"), new CodeDesc(ValueNo, "No") };
//-------------------------------------------------------------------
public enum Application
{
WebControl,
WebPortal,
}
public enum InstanceType
{
Production,
UAT,
QC,
Dev
}
//-------------------------------------------------------------------
// Configuration console.
public enum ConfigConsole
+19 -16
View File
@@ -12,9 +12,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// A p p l i c a t i o n V i e w s
//-------------------------------------------------------------------
public static bool IsViewApplicable(SbmUserContext userContext, Sbm.View view)
// Jul-2021 ConfigConsole parameter added to avoid local creation. To be reviewed/replaced.
public static bool IsViewApplicable(SbmUserContext userContext, SbmConfigConsole configConsole, Sbm.View view)
{
SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(userContext.SessionContext);
//SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(userContext.SessionContext);
SbmSecurityProfile securityProfile = userContext.SecurityProfile;
switch (view)
{
@@ -223,11 +224,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
case Sbm.View.SystemUsers:
if (!configConsole.AllowOption(userContext, Sbm.ConfigOption.AllowContacts)) return false;
// Interfaces must be available.
SaInterfaceConsole interfaceConsole = SbmGlobals.Application.GetInterfaceConsole(userContext);
if (interfaceConsole == null || !interfaceConsole.DatabaseIsValid) return false;
// System Account & User tables must be available.
if (!SbmGlobals.Application.TableExists(userContext.SessionContext, SbmDbDfn.TableIdx.SystemAccount)) return false;
if (!SbmGlobals.Application.TableExists(userContext.SessionContext, SbmDbDfn.TableIdx.SystemUser)) return false;
using (SaInterfaceConsole interfaceConsole = SbmGlobals.Application.CreateInterfaceConsole(userContext))
{
if (interfaceConsole == null || !interfaceConsole.DatabaseIsValid) return false;
// System Account & User tables must be available.
if (!SbmGlobals.Application.BusMgrTableExists(userContext.SessionContext, SbmDbDfn.TableIdx.SystemAccount)) return false;
if (!SbmGlobals.Application.BusMgrTableExists(userContext.SessionContext, SbmDbDfn.TableIdx.SystemUser)) return false;
}
return true;
}
@@ -257,7 +260,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// A p p l i c a t i o n M e n u
//-------------------------------------------------------------------
public static bool IsMenuOptionApplicable(SbmUserContext userContext, Sbm.MenuOption menuOption)
public static bool IsMenuOptionApplicable(SbmUserContext userContext, SbmConfigConsole configConsole, Sbm.MenuOption menuOption)
{
String fn = ClassName + ".IsMenuOptionApplicable";
if (!userContext.ValidUser)
@@ -268,7 +271,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
Sbm.View view = GetViewForMenuOption(userContext.SessionContext, menuOption);
if (view != Sbm.View.Unknown)
// View options.
return IsViewApplicable(userContext, GetViewForMenuOption(userContext.SessionContext, menuOption));
return IsViewApplicable(userContext, configConsole, GetViewForMenuOption(userContext.SessionContext, menuOption));
// Non-view options.
switch (menuOption)
@@ -278,16 +281,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
case Sbm.MenuOption.Config_Organisation:
return true;
case Sbm.MenuOption.Config_CodeTypes:
return (SbmGlobals.Application.GetCodeTypeConsole(userContext) != null);
return true; // (SbmGlobals.Application.GetCodeTypeConsole(userContext) != null);
case Sbm.MenuOption.Config_Interfaces:
return (SbmGlobals.Application.GetInterfaceConsole(userContext) != null);
return true; // (SbmGlobals.Application.GetInterfaceConsole(userContext) != null);
case Sbm.MenuOption.Security_Manage:
return (SbmGlobals.Application.GetSecurityConsole(userContext) != null);
//-----------------------------------------------------------
// Actions.
return true; // (SbmGlobals.Application.GetSecurityConsole(userContext) != null);
//-----------------------------------------------------------
// Actions.
case Sbm.MenuOption.Timesheet:
return SbmGlobals.Application.GetConfigConsole(userContext.SessionContext).AllowOption(userContext, Sbm.ConfigOption.TimeRecording);
//-----------------------------------------------------------
return configConsole.AllowOption(userContext, Sbm.ConfigOption.TimeRecording);
//-----------------------------------------------------------
}
SaLogger.Warn(fn + " Unsupport menu option - " + menuOption.ToString());
return false;
+36 -47
View File
@@ -1,9 +1,10 @@
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
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;
@@ -42,55 +43,43 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
//-------------------------------------------------------------------
// Properties.
public abstract SbmSystem System { get; }
// Database.
public abstract ISacsDatabase GetDatabase(SbmSessionContext sessionContext);
public abstract bool TableExists(SbmSessionContext sessionContext, SbmDbDfn.TableIdx tableIdx);
public abstract bool ColumnExists(SbmSessionContext sessionContext, SbmDbDfn.ColumnIdx columnIdx);
public abstract ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext);
public abstract IDatabaseInfo CreateBusMgrDbInfo(SbmSessionContext sessionContext);
public bool BusMgrTableExists(SbmSessionContext sessionContext, SbmDbDfn.TableIdx tableIdx)
{
ISacsDatabase db = GetBusMgrDatabase(sessionContext);
return db?.TableExists(SbmDbDfn.GetTableName(tableIdx)) ?? false;
}
public bool BusMgrColumnExists(SbmSessionContext sessionContext, SbmDbDfn.ColumnIdx columnIdx)
{
ISacsDatabase db = GetBusMgrDatabase(sessionContext);
return db?.ColumnExists(SbmDbDfn.GetTableName(SbmDbDfn.GetTableForColumn(columnIdx)), SbmDbDfn.GetColumnName(columnIdx, false)) ?? false;
}
// Application instance.
public abstract Sbm.InstanceType InstanceType { get; }
public bool IsLiveHost() { return InstanceType == Sbm.InstanceType.Production; }
public bool IsTestHost() { return InstanceType != Sbm.InstanceType.Production; }
public bool IsDevHost() { return InstanceType == Sbm.InstanceType.Dev; }
public abstract String EnvironmentName { get; }
// Email configuration.
public abstract SbmEmailConfig EmailConfig { get; }
//-------------------------------------------------------------------
// Config Console.
public abstract SbmConfigConsole GetConfigConsole(SbmSessionContext sessionContext);
//-------------------------------------------------------------------
// Managers.
public abstract SbmAccountMgr CreateAccountMgr(SbmUserContext userContext);
public abstract SbmTransactionMgr CreateTransactionMgr(SbmUserContext userContext);
//-------------------------------------------------------------------
// Diary console.
public abstract SaDiaryConsole GetDiaryConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Security console.
public abstract SaSecurityConsole GetSecurityConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Code Type console.
public abstract SaCodeTypeConsole GetCodeTypeConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Reference Data console.
public abstract SaReferenceDataConsole GetReferenceDataConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Item Data console.
public abstract Sarand.Net.Standard.Base.ItemData.SaItemDataConsole GetItemDataConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Item Doc console.
public abstract SaItemDocConsole GetItemDocConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Item Option console.
public abstract SaItemOptionConsole GetItemOptionConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Interface console.
public abstract SaInterfaceConsole GetInterfaceConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
// Update Log console.
public abstract SaUpdateLogConsole GetUpdateLogConsole(SbmUserContext userContext);
// Create consoles.
public abstract SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext);
public abstract SaDiaryConsole CreateDiaryConsole(SbmUserContext userContext);
public abstract SaSecurityConsole CreateSecurityConsole(SbmUserContext userContext);
public abstract SaCodeTypeConsole CreateCodeTypeConsole(SbmUserContext userContext);
public abstract SaReferenceDataConsole CreateReferenceDataConsole(SbmUserContext userContext);
public abstract SaItemDataConsole CreateItemDataConsole(SbmUserContext userContext);
public abstract SaItemDocConsole CreateItemDocConsole(SbmUserContext userContext);
public abstract SaItemOptionConsole CreateItemOptionConsole(SbmUserContext userContext);
public abstract SaInterfaceConsole CreateInterfaceConsole(SbmUserContext userContext);
public abstract SaUpdateLogConsole CreateUpdateLogConsole(SbmUserContext userContext);
public abstract SbmEmailConsole CreateEmailConsole(SbmUserContext userContext);
//-------------------------------------------------------------------
}
@@ -77,7 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
protected SbmConfigConsole(Sbm.ConfigConsole configConsole, SbmVersion consoleVersion, SbmSessionContext sessionContext)
{
ConfigConsole = configConsole;
AppVersion = new SbmVersion("BusinessMgr", Sbm.Version, SbmSystem.AssemblyBuildAt);
AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SbmSystem.AssemblyBuildAt);
ConsoleVersion = consoleVersion;
SessionContext = sessionContext;
}
@@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
String fn = "SbmConfigConsole.CreateConsole";
SaLogger.Warn(fn + ".CreateConsole Creating default configuration console.");
// Default console.
SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version, SbmSystem.AssemblyBuildAt);
SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SbmSystem.AssemblyBuildAt);
return new SbmConfigConsole(Sbm.ConfigConsole.Generic, consoleVersion, sessionContext);
}
@@ -593,7 +593,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public virtual bool SetMinTransactionId(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
{
bool set = false;
if (SbmGlobals.Application.GetDatabase(SessionContext) != null)
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
String nextIdKey = GetTransactionNextIdKey(userContext, AffiliateId_Owner, idAssoc, transTypes);
// ToDo set = SbmGlobals.Database.SetMinNextId(nextIdKey, iId, false);
@@ -607,7 +607,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
String Ref = "";
if (SbmGlobals.Application.GetDatabase(SessionContext) != null)
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
String NextIdKey = GetTransactionNextIdKey(userContext, AffiliateId_Owner, idAssoc, transTypes);
// ToDo long iRefNext = SbmGlobals.Database.GetNextId(NextIdKey, false);
@@ -1,39 +0,0 @@
using Sarand.Net.Standard.Base.CodeTypes;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.ReferenceData;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.UpdateLog;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public abstract class SbmConsoleHelper
{
//-------------------------------------------------------------------
// Protected construction - use derived objects.
protected SbmConsoleHelper()
{
}
//-------------------------------------------------------------------
// Database.
public abstract ISacsDatabase GetDatabase(SbmSessionContext sessionContext);
//-------------------------------------------------------------------
// Create local consoles.
//-------------------------------------------------------------------
// Retrieve Global Consoles by session context.
public abstract SaSecurityConsole GetSecurityConsole(SbmSessionContext sessionContext);
public abstract SaCodeTypeConsole GetCodeTypeConsole(SbmSessionContext sessionContext);
public abstract SaReferenceDataConsole GetReferenceDataConsole(SbmSessionContext sessionContext);
public abstract SaItemOptionConsole GetItemOptionConsole(SbmSessionContext sessionContext);
public abstract SaInterfaceConsole GetInterfaceConsole(SbmSessionContext sessionContext);
public abstract SaUpdateLogConsole GetUpdateLogConsole(SbmSessionContext sessionContext);
//-------------------------------------------------------------------
}
//=======================================================================
}
+2 -72
View File
@@ -24,79 +24,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// Database.
public static ISacsDatabase GetDatabase(SbmSessionContext sessionContext)
public static ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext)
{
return Application != null ? Application.GetDatabase(sessionContext) : null;
}
//-------------------------------------------------------------------
// Configuration console.
public static SbmConfigConsole GetConfigConsole(SbmSessionContext sessionContext)
{
return Application != null ? Application.GetConfigConsole(sessionContext) : null;
}
//-------------------------------------------------------------------
// Diary.
public static SaDiaryConsole GetDiaryConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetDiaryConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Security console.
public static SaSecurityConsole GetSecurityConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetSecurityConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Code Type console.
public static SaCodeTypeConsole GetCodeTypeConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetCodeTypeConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Reference Data console.
public static SaReferenceDataConsole GetReferenceDataConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetReferenceDataConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Item Data console.
public static SaItemDataConsole GetItemDataConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetItemDataConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Item Doc console.
public static SaItemDocConsole GetItemDocConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetItemDocConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Item Option console.
public static SaItemOptionConsole GetItemOptionConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetItemOptionConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Interface console.
public static SaInterfaceConsole GetInterfaceConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetInterfaceConsole(userContext) : null;
}
//-------------------------------------------------------------------
// Update Log console.
public static SaUpdateLogConsole GetUpdateLogConsole(SbmUserContext userContext)
{
return Application != null ? Application.GetUpdateLogConsole(userContext) : null;
return Application != null ? Application.GetBusMgrDatabase(sessionContext) : null;
}
//-------------------------------------------------------------------
+72 -8
View File
@@ -1,10 +1,14 @@
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.Bus;
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.Email;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.ItemData;
using Sarand.Net.Standard.Base.ItemDocs;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.ReferenceData;
@@ -34,6 +38,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
private SbmDataItemMgr dataItemMgr;
// Consoles.
private SbmConfigConsole configConsole;
private SaDiaryConsole diaryConsole;
private SaSecurityConsole securityConsole;
private SaCodeTypeConsole codeTypeConsole;
private SaReferenceDataConsole referenceDataConsole;
@@ -41,6 +46,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
private SaInterfaceConsole interfaceConsole;
private SaItemDocConsole itemDocConsole;
private SaItemOptionConsole itemOptionConsole;
private SaItemDataConsole itemDataConsole;
public SbmEmailConsole emailConsole;
// Configurations.
private SbmStockControlConfig stockControlConfig;
private SbmRequirementCostingConfig requirementCostingConfig;
@@ -59,6 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
if (disposing)
{
// Managers.
if (accountMgr != null) accountMgr.Dispose();
if (assetMgr != null) assetMgr.Dispose();
if (commodityMgr != null) commodityMgr.Dispose();
@@ -70,17 +78,42 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
if (currencies != null) currencies.ClearAndDispose();
if (taxCodes != null) taxCodes.ClearAndDispose();
if (unitsOfMeasure != null) unitsOfMeasure.ClearAndDispose();
// Consoles.
if (configConsole != null) configConsole.Dispose();
if (diaryConsole != null) diaryConsole.Dispose();
if (securityConsole != null) securityConsole.Dispose();
if (codeTypeConsole != null) codeTypeConsole.Dispose();
if (referenceDataConsole != null) referenceDataConsole.Dispose();
if (updateLogConsole != null) updateLogConsole.Dispose();
if (interfaceConsole != null) interfaceConsole.Dispose();
if (itemDocConsole != null) itemDocConsole.Dispose();
if (itemOptionConsole != null) itemOptionConsole.Dispose();
if (itemDataConsole != null) itemDataConsole.Dispose();
if (itemDataConsole != null) itemDataConsole.Dispose();
}
}
//-------------------------------------------------------------------
// Session properties.
public SbmApplication Application { get { return SbmGlobals.Application; } }
public SbmUserContext UserContext { get; }
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
public SbmSecurityProfile SecurityProfile { get { return UserContext.SecurityProfile; } }
public SbmAccountsDfn AccountsDfn { get { if (accountsDfn == null) accountsDfn = new SbmAccountsDfn(UserContext); { return accountsDfn; } } }
// Database.
public ISacsDatabase BusMgrDatabase { get { return Application.GetBusMgrDatabase(SessionContext); } }
public DbUpdateInfo DbUpdateInfo { get { return UserContext.DbUpdateInfo; } }
//-------------------------------------------------------------------
// System codes.
private Dictionary<Sbm.SystemCode, List<TypeCodeDesc>> systemCodeCache = new Dictionary<Sbm.SystemCode, List<TypeCodeDesc>>();
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode)
{
if (!systemCodeCache.ContainsKey(systemCode))
systemCodeCache.Add(systemCode, SbmSystem.GetCodesOfType(UserContext, systemCode));
return systemCodeCache.GetValueOrDefault(systemCode, new List<TypeCodeDesc>());
}
//-------------------------------------------------------------------
// Managers.
public SbmAccountMgr AccountMgr
@@ -163,16 +196,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (configConsole == null)
configConsole = SbmGlobals.GetConfigConsole(SessionContext);
configConsole = Application.CreateConfigConsole(SessionContext);
return configConsole;
}
}
public SaDiaryConsole DiaryConsole
{
get
{
if (diaryConsole == null)
diaryConsole = Application.CreateDiaryConsole(UserContext);
return DiaryConsole;
}
}
public SaSecurityConsole SecurityConsole
{
get
{
if (securityConsole == null)
securityConsole = SbmGlobals.GetSecurityConsole(UserContext);
securityConsole = Application.CreateSecurityConsole(UserContext);
return securityConsole;
}
}
@@ -181,7 +223,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (codeTypeConsole == null)
codeTypeConsole = SbmGlobals.GetCodeTypeConsole(UserContext);
codeTypeConsole = Application.CreateCodeTypeConsole(UserContext);
return codeTypeConsole;
}
}
@@ -190,7 +232,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (referenceDataConsole == null)
referenceDataConsole = SbmGlobals.GetReferenceDataConsole(UserContext);
referenceDataConsole = Application.CreateReferenceDataConsole(UserContext);
return referenceDataConsole;
}
}
@@ -199,7 +241,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (updateLogConsole == null)
updateLogConsole = SbmGlobals.GetUpdateLogConsole(UserContext);
updateLogConsole = Application.CreateUpdateLogConsole(UserContext);
return updateLogConsole;
}
}
@@ -208,7 +250,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (interfaceConsole == null)
interfaceConsole = SbmGlobals.GetInterfaceConsole(UserContext);
interfaceConsole = Application.CreateInterfaceConsole(UserContext);
return interfaceConsole;
}
}
@@ -217,7 +259,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (itemDocConsole == null)
itemDocConsole = SbmGlobals.GetItemDocConsole(UserContext);
itemDocConsole = Application.CreateItemDocConsole(UserContext);
return itemDocConsole;
}
}
@@ -226,10 +268,32 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
get
{
if (itemOptionConsole == null)
itemOptionConsole = SbmGlobals.GetItemOptionConsole(UserContext);
itemOptionConsole = Application.CreateItemOptionConsole(UserContext);
return itemOptionConsole;
}
}
public SaItemDataConsole ItemDataConsole
{
get
{
if (itemDataConsole == null)
itemDataConsole = Application.CreateItemDataConsole(UserContext);
return itemDataConsole;
}
}
//-------------------------------------------------------------------
// Email.
public SaEmailConfig EmailConfig { get { return Application.EmailConfig; } }
public SbmEmailConsole EmailConsole
{
get
{
if (emailConsole == null)
emailConsole = Application.CreateEmailConsole(UserContext);
return emailConsole;
}
}
//-------------------------------------------------------------------
// Configurations.
@@ -39,7 +39,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// Refresh profile.
public void RefreshProfile(SaSecurityConsole securityConsole, SysId userId, List<TypeCodeDesc> securityRights)
public void RefreshProfile(SbmConfigConsole configConsole, SaSecurityConsole securityConsole, SysId userId, List<TypeCodeDesc> securityRights)
{
String fn = GetType().Name + ".RefreshProfile";
ClearErrorState();
@@ -62,53 +62,33 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
SaLogger.Debug(fn + " User: '" + UserDisplayName + "' [Id: " + UserId + "]" + (SysId.IsValid(previousUserId) ? ". Previous UserId: " + SysId.ToString(previousUserId) : ""));
RefreshProfileSettings();
RefreshProfileSettings(configConsole);
}
protected void RefreshProfile(SaSecurityProfile userSecurityProfile, SaSecurityProfile hostSecurityProfile)
protected void RefreshProfile(SbmConfigConsole configConsole, SaSecurityProfile userSecurityProfile, SaSecurityProfile hostSecurityProfile)
{
this.userSecurityProfile = userSecurityProfile;
this.hostSecurityProfile = hostSecurityProfile;
RefreshProfileSettings();
RefreshProfileSettings(configConsole);
}
private void RefreshProfileSettings()
private void RefreshProfileSettings(SbmConfigConsole configConsole)
{
// Admin.
Admin.CanManageSecurity = UserHasSecurityRight(Sbm.SecurityRight.Security_Admin);
Admin.CanManageDatabase = UserHasSecurityRight(Sbm.SecurityRight.Database_Admin);
Admin.CanManageReferenceData = UserHasSecurityRight(Sbm.SecurityRight.ReferenceData_Admin);
Admin.CanManageInterfaces = UserHasSecurityRight(Sbm.SecurityRight.InterfaceConfig);
// Manage.
Manage.CanManageTasks = UserHasSecurityRight(Sbm.SecurityRight.TaskManager);
Manage.CanManageTimesheets = UserHasSecurityRight(Sbm.SecurityRight.TimesheetManager);
//Financials.
Financial.CanViewFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_View);
Financial.CanUpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update);
Financial.CanViewCommoditySupplyFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySupply);
Financial.CanUpdateCommoditySupplyFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySupply);
Financial.CanViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales);
Financial.CanUpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales);
// Contacts.
Contacts.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update));
Contacts.CanCreate = (Contacts.CanUpdate || UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Create));
// Transactions.
Transaction.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update));
Transaction.CanCreate = (Transaction.CanUpdate || UserHasSecurityRight(Sbm.SecurityRight.Transaction_View));
RefreshAdminProfile(configConsole);
RefreshManageProfile(configConsole);
RefreshFinancialProfile(configConsole);
RefreshContactsProfile(configConsole);
RefreshTransactionProfile(configConsole);
RefreshItemTypeProfile(configConsole);
// ToDo Commodities.
}
private void ClearProfile()
{
// Reset security profiles.
Admin.Clear();
Manage.Clear();
Financial.Clear();
Contacts.Clear();
Transaction.Clear();
Admin = new AdminProfile(this);
Manage = new ManageProfile(this);
Financial = new FinancialProfile(this);
Contacts = new ContactsProfile(this);
Transaction = new TransactionsProfile(this);
}
//-------------------------------------------------------------------
@@ -152,15 +132,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public bool CanManageDatabase { get; internal set; } = false;
public bool CanManageReferenceData { get; internal set; } = false;
public bool CanManageInterfaces { get; internal set; } = false;
internal void Clear()
{
CanManageSecurity = false;
CanManageDatabase = false;
CanManageReferenceData = false;
CanManageInterfaces = false;
}
}
public AdminProfile Admin { get; }
public AdminProfile Admin { get; internal set; }
private void RefreshAdminProfile(SbmConfigConsole configConsole)
{
Admin.CanManageSecurity = UserHasSecurityRight(Sbm.SecurityRight.Security_Admin);
Admin.CanManageDatabase = UserHasSecurityRight(Sbm.SecurityRight.Database_Admin);
Admin.CanManageReferenceData = UserHasSecurityRight(Sbm.SecurityRight.ReferenceData_Admin);
Admin.CanManageInterfaces = UserHasSecurityRight(Sbm.SecurityRight.InterfaceConfig);
}
//-------------------------------------------------------------------
// Security rights - Manage.
@@ -173,12 +153,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
public bool CanManageTasks { get; internal set; } = false;
public bool CanManageTimesheets { get; internal set; } = false;
internal void Clear()
{
CanManageTasks = false;
}
}
public ManageProfile Manage { get; }
public ManageProfile Manage { get; internal set; }
private void RefreshManageProfile(SbmConfigConsole configConsole)
{
Manage.CanManageTasks = UserHasSecurityRight(Sbm.SecurityRight.TaskManager);
Manage.CanManageTimesheets = UserHasSecurityRight(Sbm.SecurityRight.TimesheetManager);
}
//-------------------------------------------------------------------
// Security rights - Financials.
@@ -189,28 +170,30 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
this.securityProfile = securityProfile;
}
public bool CanViewFinancials { get; internal set; } = false;
public bool CanUpdateFinancials { get; internal set; } = false;
public bool CanViewCommoditySupplyFinancials { get; internal set; } = false;
public bool CanUpdateCommoditySupplyFinancials { get; internal set; } = false;
public bool CanViewCommoditySalesFinancials { get; internal set; } = false;
public bool CanUpdateCommoditySalesFinancials { get; internal set; } = false;
internal void Clear()
{
CanViewFinancials = false;
CanUpdateFinancials = false;
CanViewCommoditySupplyFinancials = false;
CanUpdateCommoditySupplyFinancials = false;
CanViewCommoditySalesFinancials = false;
CanUpdateCommoditySalesFinancials = false;
}
public bool CanViewFinancials { get; internal set; }
public bool CanUpdateFinancials { get; internal set; }
public bool CanViewCommoditySupplyFinancials { get; internal set; }
public bool CanUpdateCommoditySupplyFinancials { get; internal set; }
public bool CanViewCommoditySalesFinancials { get; internal set; }
public bool CanUpdateCommoditySalesFinancials { get; internal set; }
public bool ConfigOption_AllowFinancialsAccessControl { get; internal set; }
}
public FinancialProfile Financial { get; internal set; }
private void RefreshFinancialProfile(SbmConfigConsole configConsole)
{
Financial.CanViewFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_View);
Financial.CanUpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update);
Financial.CanViewCommoditySupplyFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySupply);
Financial.CanUpdateCommoditySupplyFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySupply);
Financial.CanViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales);
Financial.CanUpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales);
// Config options.
Financial.ConfigOption_AllowFinancialsAccessControl = (configConsole != null && !configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowFinancialsAccessControl));
}
public FinancialProfile Financial { get; }
public bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
{
SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(UserContext.SessionContext);
if (configConsole != null && !configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowFinancialsAccessControl)) return true;
if (Financial.ConfigOption_AllowFinancialsAccessControl) return true;
if (IsSecurityRightGranted(Sbm.SecurityRight.Financial_Update) || IsSecurityRightGranted(Sbm.SecurityRight.Financial_View))
{
// If specific type of financial is requested, check that view is not denied.
@@ -223,8 +206,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public bool UserCanUpdateFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
{
SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(UserContext.SessionContext);
if (configConsole != null && !configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowFinancialsAccessControl)) return true;
if (Financial.ConfigOption_AllowFinancialsAccessControl) return true;
if (IsSecurityRightGranted(Sbm.SecurityRight.Financial_Update))
{
// If specific type of financial is requested, check that update is not denied.
@@ -264,13 +246,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
public bool CanCreate { get; internal set; } = false;
public bool CanUpdate { get; internal set; } = false;
internal void Clear()
{
CanCreate = false;
CanUpdate = false;
}
}
public ContactsProfile Contacts { get; }
public ContactsProfile Contacts { get; internal set; }
private void RefreshContactsProfile(SbmConfigConsole configConsole)
{
Contacts.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update));
Contacts.CanCreate = (Contacts.CanUpdate || UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Create));
}
//-------------------------------------------------------------------
// Security rights - Transactions.
@@ -308,13 +290,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
return true;
}
internal void Clear()
{
CanCreate = false;
CanUpdate = false;
}
}
public TransactionsProfile Transaction { get; }
public TransactionsProfile Transaction { get; internal set; }
private void RefreshTransactionProfile(SbmConfigConsole configConsole)
{
Transaction.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update));
Transaction.CanCreate = (Transaction.CanUpdate || UserHasSecurityRight(Sbm.SecurityRight.Transaction_View));
}
public bool UserCanAccessTransactionsOfType(Sbm.TransactionType transactionType)
{
if ((int)transactionType < 1) return false;
@@ -329,22 +312,44 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public class ItemTypesProfile
{
internal ItemTypesProfile() { }
public bool CanCreate { get; internal set; } = false;
public bool CanUpdate { get; internal set; } = false;
public bool CanRemove { get; internal set; } = false;
internal void Clear()
{
CanCreate = false;
CanUpdate = false;
CanRemove = false;
}
public bool CanCreate { get; internal set; }
public bool CanUpdate { get; internal set; }
public bool CanRemove { get; internal set; }
// Config options.
public bool ConfigOption_AllowProcesses { get; internal set; }
public bool ConfigOption_AllowContacts { get; internal set; }
public bool ConfigOption_AllowCommodities { get; internal set; }
public bool ConfigOption_AllowPortfolios { get; internal set; }
public bool ConfigOption_AllowPriceSets { get; internal set; }
public bool ConfigOption_CommodityCustomers { get; internal set; }
public bool ConfigOption_CommoditySuppliers { get; internal set; }
public bool ConfigOption_AllowTransactions { get; internal set; }
public bool ConfigOption_AllowAssets { get; internal set; }
public bool ConfigOption_AllowVehicles { get; internal set; }
public bool ConfigOption_AllowStockLocations { get; internal set; }
public bool ConfigOption_AllowStockContainers { get; internal set; }
public bool ConfigOption_AllowStockControl { get; internal set; }
}
public ItemTypesProfile ItemType { get; } = new ItemTypesProfile();
private void RefreshItemTypeProfile(SbmConfigConsole configConsole)
{
ItemType.ConfigOption_AllowProcesses = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowProcesses);
ItemType.ConfigOption_AllowContacts = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowContacts);
ItemType.ConfigOption_AllowCommodities = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowCommodities);
ItemType.ConfigOption_AllowPortfolios = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPortfolios);
ItemType.ConfigOption_AllowPriceSets = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPriceSets);
ItemType.ConfigOption_CommodityCustomers = configConsole.AllowOption(UserContext, Sbm.ConfigOption.CommodityCustomers);
ItemType.ConfigOption_CommoditySuppliers = configConsole.AllowOption(UserContext, Sbm.ConfigOption.CommoditySuppliers);
ItemType.ConfigOption_AllowTransactions = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowTransactions);
ItemType.ConfigOption_AllowAssets = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowAssets);
ItemType.ConfigOption_AllowVehicles = configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowVehicles);
ItemType.ConfigOption_AllowStockLocations = configConsole.GetStockControlConfig(UserContext).AllowStockLocations();
ItemType.ConfigOption_AllowStockContainers = configConsole.GetStockControlConfig(UserContext).AllowStockContainers();
ItemType.ConfigOption_AllowStockControl = configConsole.GetStockControlConfig(UserContext).AllowStockControl();
}
public bool ItemTypeIsAllowed(Sbm.ItemType itemType)
{
SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(UserContext.SessionContext);
if (configConsole == null) return false;
switch (itemType)
{
//case Sbm.ItemType.SecItem:
@@ -353,37 +358,37 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//case Sbm.ItemType.Language:
//case Sbm.ItemType.TaxCode:
//case Sbm.ItemType.UnitMeasure:
case Sbm.ItemType.Process: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowProcesses);
case Sbm.ItemType.Process: return ItemType.ConfigOption_AllowProcesses;
case Sbm.ItemType.Affiliate:
case Sbm.ItemType.Address: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowContacts);
case Sbm.ItemType.Commodity: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowCommodities);
case Sbm.ItemType.PortfolioItem: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPortfolios);
case Sbm.ItemType.Location: return configConsole.GetStockControlConfig(UserContext).AllowStockLocations();
case Sbm.ItemType.Address: return ItemType.ConfigOption_AllowContacts;
case Sbm.ItemType.Commodity: return ItemType.ConfigOption_AllowCommodities;
case Sbm.ItemType.PortfolioItem: return ItemType.ConfigOption_AllowPortfolios;
case Sbm.ItemType.Location: return ItemType.ConfigOption_AllowStockLocations;
case Sbm.ItemType.Container:
case Sbm.ItemType.ContainerItem: return configConsole.GetStockControlConfig(UserContext).AllowStockContainers();
case Sbm.ItemType.ContainerItem: return ItemType.ConfigOption_AllowStockContainers;
case Sbm.ItemType.Movement:
case Sbm.ItemType.StockLevel: return configConsole.GetStockControlConfig(UserContext).AllowStockControl();
case Sbm.ItemType.StockLevel: return ItemType.ConfigOption_AllowStockControl;
case Sbm.ItemType.PriceSet:
case Sbm.ItemType.Price: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowPriceSets);
case Sbm.ItemType.CommodityCustomer: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.CommodityCustomers);
case Sbm.ItemType.CommoditySupplier: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.CommoditySuppliers);
case Sbm.ItemType.Price: return ItemType.ConfigOption_AllowPriceSets;
case Sbm.ItemType.CommodityCustomer: return ItemType.ConfigOption_CommodityCustomers;
case Sbm.ItemType.CommoditySupplier: return ItemType.ConfigOption_CommoditySuppliers;
//case Sbm.ItemType.Association:
case Sbm.ItemType.Transaction:
case Sbm.ItemType.Requirement:
case Sbm.ItemType.Constituent: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowTransactions);
case Sbm.ItemType.Constituent: return ItemType.ConfigOption_AllowTransactions;
//case Sbm.ItemType.SystemAccount:
//case Sbm.ItemType.SystemUser:
//case Sbm.ItemType.SystemAccountUser:
case Sbm.ItemType.AssetCategory:
case Sbm.ItemType.AssetCategoryProcess:
case Sbm.ItemType.Asset:
case Sbm.ItemType.AssetProcess: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowAssets);
case Sbm.ItemType.AssetProcess: return ItemType.ConfigOption_AllowAssets;
case Sbm.ItemType.VehicleClass:
case Sbm.ItemType.Vehicle:
case Sbm.ItemType.VehicleEvent:
case Sbm.ItemType.VehicleFeature: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowVehicles);
case Sbm.ItemType.CommodityProcess: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowProcesses);
case Sbm.ItemType.RequirementProcess: return configConsole.AllowOption(UserContext, Sbm.ConfigOption.AllowProcesses);
case Sbm.ItemType.VehicleFeature: return ItemType.ConfigOption_AllowVehicles;
case Sbm.ItemType.CommodityProcess: return ItemType.ConfigOption_AllowProcesses;
case Sbm.ItemType.RequirementProcess: return ItemType.ConfigOption_AllowProcesses;
//case Sbm.ItemType.Interface:
}
return true;
@@ -1,19 +1,21 @@
namespace Sarand.BusinessMgr.Net.Standard.Base.App
using Sarand.Net.Standard.Base.App;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public class SbmSessionContext
public class SbmSessionContext : SacsSessionContext
{
//-------------------------------------------------------------------
// Construction.
protected SbmSessionContext(ushort index)
protected SbmSessionContext(ushort index, Sbm.Application application) : base(index)
{
Index = index;
Application = application;
}
//-------------------------------------------------------------------
// Properties.
public ushort Index { get; }
//public Sbm.Instance Instance { get; protected set; }
public Sbm.Application Application { get; private set; }
//-------------------------------------------------------------------
}
@@ -0,0 +1,136 @@
using Newtonsoft.Json;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Bus;
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.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public abstract class SbmSessionData
{
//-------------------------------------------------------------------
private static long sessionIdxRoot = SacsRandomHelper.GetInt32(1000, 1999);
//-------------------------------------------------------------------
// Construction.
/// <summary>Protected constructor for deserialisation only.</summary>
protected SbmSessionData(long sessionIdx, int itemIdx, SbmSessionContext sessionContext)
{
SessionIdx = sessionIdx;
ItemIdx = itemIdx;
SessionContext = sessionContext;
userData = CreateUserData(SessionContext, null, null);
}
/// <summary>
/// Primary constructor - on user login.
/// <para>SessionContext and UserAccount must be supplied.</para>
/// <para>Roles list is optional.</para>
/// </summary>
protected SbmSessionData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser)
{
SessionIdx = ++sessionIdxRoot;
ItemIdx = 1000;
SessionContext = sessionContext;
userData = CreateUserData(SessionContext, securityItemUser, affiliateUser);
}
//-------------------------------------------------------------------
// Properties.
// Session and Item indexers.
public long SessionIdx { get; }
public int ItemIdx { get; private set; }
[JsonIgnore]
public int NextItemIdx { get { return ++ItemIdx; } }
// Session context.
public SbmSessionContext SessionContext { get; }
[JsonIgnore]
public bool ValidUserSession { get { return SysId.IsValid(User.AffiliateId) && SysId.IsValid(User.AffiliateId); } }
[JsonIgnore]
public DbUpdateInfo DbUpdateInfo
{
get
{
return new DbUpdateInfo(User.AffiliateId, StringUtil.OnEmpty(User.DisplayName, User.EmailAddress), SbmSystem.ComputerName);
}
}
//-------------------------------------------------------------------
// User.
public class UserData
{
protected UserData() { }
protected UserData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser)
{
if (securityItemUser != null)
{
SecurityItemId = securityItemUser.Id;
}
if (affiliateUser != null)
{
AffiliateId = affiliateUser.Id;
Refresh(securityItemUser, affiliateUser);
if (sessionContext.Application == Sbm.Application.WebControl)
KeepLoggedIn = affiliateUser.KeepLoggedIn_Control;
else if (sessionContext.Application == Sbm.Application.WebPortal)
KeepLoggedIn = affiliateUser.KeepLoggedIn_Portal;
else Debugger.Break();
}
}
protected UserData(UserData userData)
{
SecurityItemId = userData.SecurityItemId;
AffiliateId = userData.AffiliateId;
Title = userData.Title;
FirstName = userData.FirstName;
LastName = userData.LastName;
DisplayName = userData.DisplayName;
EmailAddress = userData.EmailAddress;
KeepLoggedIn = userData.KeepLoggedIn;
}
// Properties.
public SysId SecurityItemId { get; protected set; }
public SysId AffiliateId { get; protected set; }
public String Title { get; protected set; }
public String FirstName { get; protected set; }
public String LastName { get; protected set; }
public String DisplayName { get; protected set; }
public String EmailAddress { get; protected set; }
public bool KeepLoggedIn { get; protected set; }
public bool UserAccountSupplied { get; protected set; }
// Refresh properties.
protected bool Refresh(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser)
{
// Check that user matches the session.
if (!SysId.IsValid(SecurityItemId) || !SysId.IsValid(securityItemUser?.Id ?? null) || !SecurityItemId.Equals(securityItemUser.Id)) return false;
if (!SysId.IsValid(AffiliateId) || !SysId.IsValid(affiliateUser?.Id ?? null) || !AffiliateId.Equals(affiliateUser.Id)) return false;
// Refresh properties.
EmailAddress = securityItemUser.EmailAddress;
Title = affiliateUser.Title;
FirstName = affiliateUser.FirstName;
LastName = affiliateUser.LastName;
DisplayName = affiliateUser.GetDisplayName();
return true;
}
}
protected abstract UserData CreateUserData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser);
private UserData userData;
public UserData User { get { return userData; } }
/// <summary>User - JSON deserialisation route.</summary>
protected void SetUser(UserData user)
{
if (this.userData != null && User.UserAccountSupplied)
throw new NotSupportedException("Session User cannot be replaced.");
this.userData = user;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -5,6 +5,7 @@ using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.Security;
using System.Collections.Generic;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
@@ -96,7 +97,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
userContext.RefreshUser(affiliateUser, userSupervisedOwners);
// Populate security rights.
SecurityProfile.RefreshProfile(SbmGlobals.Application.GetSecurityConsole(UserContext), userId, securityRights);
using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext))
using (SaSecurityConsole securityConsole = SbmGlobals.Application.CreateSecurityConsole(UserContext))
{
SecurityProfile.RefreshProfile(configConsole, securityConsole, userId, securityRights);
}
// Reinstate previous owner if defined and verify that it is in the supervised list.
SysId affiliateIdOwner = UserContext.Organisation.AffiliateId;
@@ -23,10 +23,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// R e g i s t e r C o d e T y p e s
//-------------------------------------------------------------------
public static void RegisterCodeTypes(SaCodeTypeConsole codeTypeConsole, SbmUserContext userContext)
public static void RegisterCodeTypes(SbmConfigConsole configConsole, SaCodeTypeConsole codeTypeConsole, SbmUserContext userContext)
{
SbmConfigConsole configConsole = SbmGlobals.Application.GetConfigConsole(userContext.SessionContext);
//---------------------------------------------------------------
// C o m m o d i t i e s
//---------------------------------------------------------------
+1 -1
View File
@@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
}
public static List<TypeCodeDesc> GetCodesOfType(SbmUserContext userContext, Sbm.SystemCode systemCode)
{
SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(userContext.SessionContext);
SbmConfigConsole configConsole = null; // SbmGlobals.GetConfigConsole(userContext.SessionContext);
switch (systemCode)
{
case Sbm.SystemCode.ItemType:
@@ -111,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//-------------------------------------------------------------------
// Construction.
public SbmUserContext(SbmSessionContext sessionContext)
protected SbmUserContext(SbmSessionContext sessionContext)
{
SessionContext = sessionContext;
organisationData = new OrganisationData_Internal();
@@ -307,14 +307,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
ItemId associationItemId_Owner = new ItemId((short)Sbm.ItemType.Association, organisationData.AssociationId);
if (!organisationData.configOptionsCache.ItemIdRef.Id.Equals(affiliateItemId_Owner))
{
SaItemOptionConsole itemOptionConsole = SbmGlobals.Application.GetItemOptionConsole(this);
organisationData.configOptionsCache.Clear();
if (itemOptionConsole != null)
using (SaItemOptionConsole itemOptionConsole = SbmGlobals.Application.CreateItemOptionConsole(this))
{
// Retrieve the options for this association.
organisationData.configOptionsCache.Reset(associationItemId_Owner, affiliateItemId_Owner);
organisationData.configOptionsCache.ItemOptions.AddRange(itemOptionConsole.GetItemOptionsForItem(associationItemId_Owner));
SaLogger.Debug(fn + " Populated organisation options: " + organisationData.configOptionsCache.ItemOptions.Count);
organisationData.configOptionsCache.Clear();
if (itemOptionConsole != null)
{
// Retrieve the options for this association.
organisationData.configOptionsCache.Reset(associationItemId_Owner, affiliateItemId_Owner);
organisationData.configOptionsCache.ItemOptions.AddRange(itemOptionConsole.GetItemOptionsForItem(associationItemId_Owner));
SaLogger.Debug(fn + " Populated organisation options: " + organisationData.configOptionsCache.ItemOptions.Count);
}
}
}
}
@@ -280,13 +280,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
{
// Only populated when needed as reads Code Types from db.
contexts_StockCategoryAction = new List<CodeDesc>();
codes_StockCategoryAction = SbmGlobals.GetCodeTypeConsole(UserContext).GetCodeDescsForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.CommodityCategory));
foreach (CodeDesc commodityCategory in codes_StockCategoryAction)
using (SaCodeTypeConsole codeTypeConsole = SbmGlobals.Application.CreateCodeTypeConsole(UserContext))
{
// Ignore categories where code is same as description.
// We're only interested in the ones which have been given a description.
if (commodityCategory.Code.EqualsCI(commodityCategory.Desc)) continue;
contexts_StockCategoryAction.Add(commodityCategory);
codes_StockCategoryAction = codeTypeConsole.GetCodeDescsForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.CommodityCategory));
foreach (CodeDesc commodityCategory in codes_StockCategoryAction)
{
// Ignore categories where code is same as description.
// We're only interested in the ones which have been given a description.
if (commodityCategory.Code.EqualsCI(commodityCategory.Desc)) continue;
contexts_StockCategoryAction.Add(commodityCategory);
}
}
}
return new List<CodeDesc>(contexts_StockCategoryAction);
@@ -329,6 +329,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
// Data members.
private readonly Data data = new Data();
public static readonly Byte Flag_Prospect = 0x01;
public static readonly Byte Flag_KeepLoggedIn_Portal = 0x02;
public static readonly Byte Flag_KeepLoggedIn_Control = 0x03;
//-------------------------------------------------------------------
// Construction.
@@ -697,6 +699,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
get { return GetFlag(Flag_Prospect); }
set { SetFlag(Flag_Prospect, value); }
}
public bool KeepLoggedIn_Portal
{
get { return GetFlag(Flag_KeepLoggedIn_Portal); }
set { SetFlag(Flag_KeepLoggedIn_Portal, value); }
}
public bool KeepLoggedIn_Control
{
get { return GetFlag(Flag_KeepLoggedIn_Control); }
set { SetFlag(Flag_KeepLoggedIn_Control, value); }
}
//-------------------------------------------------------------------
// A s s o c i a t e d D a t a E l e m e n t s
+75 -73
View File
@@ -1872,83 +1872,85 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
// Utilities.
public List<StringPair> GetDisplayValues(SbmUserContext userContext)
{
SbmConfigConsole configConsole = SbmGlobals.Application.GetConfigConsole(userContext.SessionContext);
SbmAccountMgr accountMgr = null;
List<StringPair> lValue = new List<StringPair>();
// Commodities to exclude.
if (IncludedIds.Count > 0) lValue.Add("Included commodities", IncludedIds.Count.ToString());
if (ExcludedIds.Count > 0) lValue.Add("Excluded commodities", ExcludedIds.Count.ToString());
// Commodity type.
if (CommodityType > 0) lValue.Add("Type", SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.CommodityType).GetDescForType(CommodityType, CommodityType.ToString()));
else if (CommodityType == Sbm.CommodityType.AnyProduct) lValue.Add("Type", "Any product");
if (StockItemsOnly) lValue.Add("Stock items only", "True");
// Commodity code.
if (!StringUtil.IsEmpty(CodeFull)) lValue.Add("Code", CodeFull);
else if (!StringUtil.IsEmpty(CodePartial)) lValue.Add("Code contains", CodePartial);
// Drawing number.
if (!StringUtil.IsEmpty(DrawingNoFull)) lValue.Add("Drawing no", DrawingNoFull);
else if (!StringUtil.IsEmpty(DrawingNoPartial)) lValue.Add("Drawing no starts", DrawingNoPartial);
if (!StringUtil.IsEmpty(DrawingIssueFull)) lValue.Add("Drawing issue", DrawingIssueFull);
else if (!StringUtil.IsEmpty(DrawingIssuePartial)) lValue.Add("Drawing issue starts", DrawingIssuePartial);
// Commodity description.
if (!StringUtil.IsEmpty(DescBriefFull)) lValue.Add("Description", DescBriefFull);
if (!StringUtil.IsEmpty(DescBriefPartial)) lValue.Add("Description starts", DescBriefPartial);
// Category.
if (Categories.Count > 0) lValue.Add("Categories", Categories.Concat(","));
// Catalog reference.
if (!StringUtil.IsEmpty(CatalogRefPartial)) lValue.Add("Catalog ref start", CatalogRefPartial);
// Codings.
if (!StringUtil.IsEmpty(RangeCode)) lValue.Add("Range code", RangeCode);
if (!StringUtil.IsEmpty(ColourCode)) lValue.Add("Colour code", ColourCode);
if (!StringUtil.IsEmpty(SourceCode)) lValue.Add("Source code", SourceCode);
if (!StringUtil.IsEmpty(SupplyMethodCode)) lValue.Add("SupplyMethod code", SupplyMethodCode);
if (!StringUtil.IsEmpty(HandlingCode)) lValue.Add("Handling code", HandlingCode);
if (!StringUtil.IsEmpty(DeliveryCode)) lValue.Add("Delivery code", DeliveryCode);
if (!StringUtil.IsEmpty(MaterialCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material") + " code", MaterialCode);
if (!StringUtil.IsEmpty(FinishCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish") + " code", FinishCode);
if (!StringUtil.IsEmpty(PromotionCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion") + " code", PromotionCode);
// Price sets.
if (PriceSetIdsIncluded.Count > 0) lValue.Add("Included in price sets", PriceSetIdsIncluded.Count.ToString());
if (PriceSetIdsExcluded.Count > 0) lValue.Add("Excluded from price sets", PriceSetIdsExcluded.Count.ToString());
// Customer.
if (SysId.IsValid(AssociationIdCustomer))
using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(userContext.SessionContext))
{
if (accountMgr == null) accountMgr = SbmGlobals.System.CreateAccountMgr(userContext);
lValue.Add("Customer", accountMgr.GetAssociationTargetName(AssociationIdCustomer));
// Commodities to exclude.
if (IncludedIds.Count > 0) lValue.Add("Included commodities", IncludedIds.Count.ToString());
if (ExcludedIds.Count > 0) lValue.Add("Excluded commodities", ExcludedIds.Count.ToString());
// Commodity type.
if (CommodityType > 0) lValue.Add("Type", SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.CommodityType).GetDescForType(CommodityType, CommodityType.ToString()));
else if (CommodityType == Sbm.CommodityType.AnyProduct) lValue.Add("Type", "Any product");
if (StockItemsOnly) lValue.Add("Stock items only", "True");
// Commodity code.
if (!StringUtil.IsEmpty(CodeFull)) lValue.Add("Code", CodeFull);
else if (!StringUtil.IsEmpty(CodePartial)) lValue.Add("Code contains", CodePartial);
// Drawing number.
if (!StringUtil.IsEmpty(DrawingNoFull)) lValue.Add("Drawing no", DrawingNoFull);
else if (!StringUtil.IsEmpty(DrawingNoPartial)) lValue.Add("Drawing no starts", DrawingNoPartial);
if (!StringUtil.IsEmpty(DrawingIssueFull)) lValue.Add("Drawing issue", DrawingIssueFull);
else if (!StringUtil.IsEmpty(DrawingIssuePartial)) lValue.Add("Drawing issue starts", DrawingIssuePartial);
// Commodity description.
if (!StringUtil.IsEmpty(DescBriefFull)) lValue.Add("Description", DescBriefFull);
if (!StringUtil.IsEmpty(DescBriefPartial)) lValue.Add("Description starts", DescBriefPartial);
// Category.
if (Categories.Count > 0) lValue.Add("Categories", Categories.Concat(","));
// Catalog reference.
if (!StringUtil.IsEmpty(CatalogRefPartial)) lValue.Add("Catalog ref start", CatalogRefPartial);
// Codings.
if (!StringUtil.IsEmpty(RangeCode)) lValue.Add("Range code", RangeCode);
if (!StringUtil.IsEmpty(ColourCode)) lValue.Add("Colour code", ColourCode);
if (!StringUtil.IsEmpty(SourceCode)) lValue.Add("Source code", SourceCode);
if (!StringUtil.IsEmpty(SupplyMethodCode)) lValue.Add("SupplyMethod code", SupplyMethodCode);
if (!StringUtil.IsEmpty(HandlingCode)) lValue.Add("Handling code", HandlingCode);
if (!StringUtil.IsEmpty(DeliveryCode)) lValue.Add("Delivery code", DeliveryCode);
if (!StringUtil.IsEmpty(MaterialCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material") + " code", MaterialCode);
if (!StringUtil.IsEmpty(FinishCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish") + " code", FinishCode);
if (!StringUtil.IsEmpty(PromotionCode)) lValue.Add(configConsole.GetAttributeCaption(userContext, SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion") + " code", PromotionCode);
// Price sets.
if (PriceSetIdsIncluded.Count > 0) lValue.Add("Included in price sets", PriceSetIdsIncluded.Count.ToString());
if (PriceSetIdsExcluded.Count > 0) lValue.Add("Excluded from price sets", PriceSetIdsExcluded.Count.ToString());
// Customer.
if (SysId.IsValid(AssociationIdCustomer))
{
if (accountMgr == null) accountMgr = SbmGlobals.System.CreateAccountMgr(userContext);
lValue.Add("Customer", accountMgr.GetAssociationTargetName(AssociationIdCustomer));
}
if (!StringUtil.IsEmpty(CustomerName)) lValue.Add("Customer name starts", CustomerName);
if (!StringUtil.IsEmpty(SupplierName)) lValue.Add("Supplier name starts", SupplierName);
if (!StringUtil.IsEmpty(SalesOrderRef)) lValue.Add("SO reference starts", SalesOrderRef);
if (!StringUtil.IsEmpty(PurchaseOrderRef)) lValue.Add("PO reference starts", PurchaseOrderRef);
// Transaction.
if (!StringUtil.IsEmpty(OrderRef)) lValue.Add("Transaction reference", OrderRef);
// Stock:
if (StockLocationFilter == Sbm.LocationFilter.Sales) lValue.Add("Stock location", "Sales locations only");
else if (StockLocationFilter == Sbm.LocationFilter.Calc) lValue.Add("Stock location", "Calculated locations only");
else if (StockLocationFilter == Sbm.LocationFilter.All) lValue.Add("Stock location", "All locations");
if (SysId.IsValid(LocationIdStock)) lValue.Add("Stock location", SysId.ToString(LocationIdStock));
if (DateUtil.IsValid(StockSoldFrom)) lValue.Add("Stock sold from", DateUtil.Format(StockSoldFrom, "d-MMM-yyyy"));
if (DateUtil.IsValid(StockSoldTo)) lValue.Add("Stock sold to", DateUtil.Format(StockSoldTo, "d-MMM-yyyy"));
if (DateUtil.IsValid(ProjectedSalesFrom)) lValue.Add("Proj sales from", DateUtil.Format(ProjectedSalesFrom, "d-MMM-yyyy"));
if (DateUtil.IsValid(ProjectedSalesTo)) lValue.Add("Proj sales to", DateUtil.Format(ProjectedSalesTo, "d-MMM-yyyy"));
if (StockLevelMin > decimal.MinValue) lValue.Add("Stock level >= ", StockLevelMin.ToString("N2"));
if (StockLevelMax > decimal.MinValue) lValue.Add("Stock level <= ", StockLevelMax.ToString("N2"));
// Commodities with definitions for Customer.
if (SysId.IsValid(AssociationIdCommodityCustomer))
{
if (accountMgr == null) accountMgr = SbmGlobals.System.CreateAccountMgr(userContext);
lValue.Add("Commodity definitions for customer", accountMgr.GetAssociationTargetName(AssociationIdCommodityCustomer));
}
if (!StringUtil.IsEmpty(AccountCodeCommodityCustomer))
lValue.Add("Commodity definitions for customer", AccountCodeCommodityCustomer);
// Commodity status category.
if (StatusCat == StatusCat.Current)
lValue.Add("Status", "Current");
}
if (!StringUtil.IsEmpty(CustomerName)) lValue.Add("Customer name starts", CustomerName);
if (!StringUtil.IsEmpty(SupplierName)) lValue.Add("Supplier name starts", SupplierName);
if (!StringUtil.IsEmpty(SalesOrderRef)) lValue.Add("SO reference starts", SalesOrderRef);
if (!StringUtil.IsEmpty(PurchaseOrderRef)) lValue.Add("PO reference starts", PurchaseOrderRef);
// Transaction.
if (!StringUtil.IsEmpty(OrderRef)) lValue.Add("Transaction reference", OrderRef);
// Stock:
if (StockLocationFilter == Sbm.LocationFilter.Sales) lValue.Add("Stock location", "Sales locations only");
else if (StockLocationFilter == Sbm.LocationFilter.Calc) lValue.Add("Stock location", "Calculated locations only");
else if (StockLocationFilter == Sbm.LocationFilter.All) lValue.Add("Stock location", "All locations");
if (SysId.IsValid(LocationIdStock)) lValue.Add("Stock location", SysId.ToString(LocationIdStock));
if (DateUtil.IsValid(StockSoldFrom)) lValue.Add("Stock sold from", DateUtil.Format(StockSoldFrom, "d-MMM-yyyy"));
if (DateUtil.IsValid(StockSoldTo)) lValue.Add("Stock sold to", DateUtil.Format(StockSoldTo, "d-MMM-yyyy"));
if (DateUtil.IsValid(ProjectedSalesFrom)) lValue.Add("Proj sales from", DateUtil.Format(ProjectedSalesFrom, "d-MMM-yyyy"));
if (DateUtil.IsValid(ProjectedSalesTo)) lValue.Add("Proj sales to", DateUtil.Format(ProjectedSalesTo, "d-MMM-yyyy"));
if (StockLevelMin > decimal.MinValue) lValue.Add("Stock level >= ", StockLevelMin.ToString("N2"));
if (StockLevelMax > decimal.MinValue) lValue.Add("Stock level <= ", StockLevelMax.ToString("N2"));
// Commodities with definitions for Customer.
if (SysId.IsValid(AssociationIdCommodityCustomer))
{
if (accountMgr == null) accountMgr = SbmGlobals.System.CreateAccountMgr(userContext);
lValue.Add("Commodity definitions for customer", accountMgr.GetAssociationTargetName(AssociationIdCommodityCustomer));
}
if (!StringUtil.IsEmpty(AccountCodeCommodityCustomer))
lValue.Add("Commodity definitions for customer", AccountCodeCommodityCustomer);
// Commodity status category.
if (StatusCat == StatusCat.Current)
lValue.Add("Status", "Current");
// Portfolio:
//PortfolioIdInclude;
@@ -857,9 +857,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
// Nov-08 Current thinking is that the only differences is whether the 'In Progress' date has been specified and whether that should be used in preference to the 'Raised' date.
if (DateUtil.IsValid(inProgress) && (transactionStatusCat == SbmTransaction.StatusCat.Open || transactionStatusCat == SbmTransaction.StatusCat.Closed))
{
SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(userContext.SessionContext);
if (configConsole != null && configConsole.UseInProgressTaxDateAsTaxPoint(userContext, transactionType))
return inProgress;
using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(userContext.SessionContext))
{
if (configConsole != null && configConsole.UseInProgressTaxDateAsTaxPoint(userContext, transactionType))
return inProgress;
}
}
// Otherwise, use 'Raised' date.
if (DateUtil.IsValid(raised))
@@ -0,0 +1,77 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Email;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{
//=======================================================================
public class SbmEmailConfig : SaEmailConfig
{
public SbmEmailConfig(String context) : base(context)
{
}
}
//=======================================================================
public abstract class SbmEmailConsole : SaEmailConsole
{
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Protected construction.
protected SbmEmailConsole(SbmEmailConfig emailConfig)
{
EmailConfig = emailConfig;
}
//-------------------------------------------------------------------
// Properties.
public SbmEmailConfig EmailConfig { get; }
public static String EmailTag_Header { get; } = "[#Email.Header]";
public static String EmailTag_Footer { get; } = "[#Email.Footer]";
public static String EmailTag_Caption { get; } = "[#Email.Caption]";
public static String EmailTag_MainStylesheet { get; } = "[#Email.MainStylesheet]";
//-------------------------------------------------------------------
/// <summary>
/// Replace dynamic tags in email message body.
/// <para></para>
/// </summary>
public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, SbmSessionData sessionData)
{
// Replace core tags, eg. main stylesheet.
SaEmailConsole.ReplaceDynamicEmailTags(emailData);
// Replace tags known to the web application.
// Main stylesheet.
if (EmailContainsTag(emailData, EmailTag_MainStylesheet))
{
// Tag replacement is expanded to avoid reading main stylesheet resource unless required.
ReplaceDynamicEmailTag(emailData, EmailTag_MainStylesheet, "<style>\n" + SbmResourceHelper.GetTextResource(SbmResourceHelper.TextResource.Email_Main_Css) + "</style>");
}
// Partial content - Header.
if (EmailContainsTag(emailData, EmailTag_Header))
{
// Tag replacement is expanded to avoid reading Header resource unless required.
ReplaceDynamicEmailTag(emailData, EmailTag_Header, SbmResourceHelper.GetTextResource(SbmResourceHelper.TextResource.Email_Header_Html));
}
// Partial content - Footer.
if (EmailContainsTag(emailData, EmailTag_Footer))
{
// Tag replacement is expanded to avoid reading Footer resource unless required.
ReplaceDynamicEmailTag(emailData, EmailTag_Footer, SbmResourceHelper.GetTextResource(SbmResourceHelper.TextResource.Email_Footer_Html));
}
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,138 @@
using Microsoft.AspNetCore.Identity;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
{
//=======================================================================
public class SbmPasswordHelper
{
//-------------------------------------------------------------------
// Configuration parameters.
public class PasswordParams
{
public int MinLength = 8;
public int MinLengthNoComplexity = 12;
}
public static PasswordParams Params { get; } = new PasswordParams();
//-------------------------------------------------------------------
/// <summary>Validate password against parameters.</summary>
public static bool IsValidPassword(String password)
{
return GetPasswordStrength(password) >= 4;
}
/// <summary>
/// Assess the password strength - 4+ is valid.
/// <para>0 - Blank</para>
/// <para>1 - &lt; min length - 2 [red]</para>
/// <para>1 - &lt; min length and only 1 character type [red]</para>
/// <para>2 - &lt; min length and only 2 character types [red]</para>
/// <para>2 - &lt; min length without complexity - 2 and only 1 character type [red]</para>
/// <para>3 - &lt; min length, min length with 3 character types [amber]</para>
/// <para>3 - Min length without complexity - 2 [amber]</para>
/// <para>3 - Other invalid passwords [amber]</para>
/// <para>4 - Min length with 4 character types [green]</para>
/// <para>4 - Min length without complexity [green]</para>
/// <para>5 - Min lenth + 2 with 4 character types [green]</para>
/// <para>5 - Min length without complexity with 3 character types [green]</para>
/// </summary>
public static int GetPasswordStrength(String password)
{
String fn = "PasswordHelper.GetPasswordStrength";
// 0 - Blank.
if (StringUtil.IsEmpty(password)) return 0;
// Count number of different types of character.
int characterTypeCount = 0;
try
{
if (Regex.Matches(password, "[A-Z]").Count > 0) characterTypeCount++;
if (Regex.Matches(password, "[a-z]").Count > 0) characterTypeCount++;
if (Regex.Matches(password, "[0-9]").Count > 0) characterTypeCount++;
if (Regex.Matches(password, "[^a-zA-Z0-9]").Count > 0) characterTypeCount++;
}
catch (Exception exc)
{
SaLogger.Debug(fn + " " + ExceptionUtil.GetLogMessage(exc));
}
int passwordLength = StringUtil.GetLength(password);
// 1 - Less than min length - 2;
if (passwordLength < Params.MinLength - 2)
return 1;
// 1 - Less than min length and only 1 character type.
if (passwordLength < Params.MinLength && characterTypeCount == 1)
return 1;
// 2 - Less than min length and only 2 character types.
if (passwordLength < Params.MinLength && characterTypeCount == 2)
return 2;
// 2 - Less than min length without complexity - 2 and only 1 character type.
if (passwordLength < Params.MinLengthNoComplexity - 2 && characterTypeCount == 1)
return 2;
// 3 - Less than minimum length.
if (passwordLength < Params.MinLength)
return 3;
// 3 - Minimum length with only 3 character types.
if (passwordLength >= Params.MinLength && passwordLength < Params.MinLengthNoComplexity && characterTypeCount == 3)
return 3;
// 3 - Minimum length without complexity - 2 with less than 4 character types.
if (passwordLength >= Params.MinLengthNoComplexity - 2 && passwordLength < Params.MinLengthNoComplexity && characterTypeCount < 4)
return 3;
// 3 Catch-all - ensure only valid passwords score 4 or more.
if (passwordLength < Params.MinLengthNoComplexity && characterTypeCount < 4)
return 3;
// 4 - Min length with 4 character types.
if (passwordLength < Params.MinLengthNoComplexity)
return 4;
// 4 - Min length without complexity.
if (passwordLength >= Params.MinLengthNoComplexity && passwordLength < Params.MinLengthNoComplexity + 2 && characterTypeCount < 4)
return 4;
// 5 - Anything more complex.
return 5;
}
//-------------------------------------------------------------------
private static PasswordHasher<SaSecurityItem> passwordHasher = new PasswordHasher<SaSecurityItem>();
/// <summary>Get the hashed value that corresponds to the password.</summary>
public static String GetPasswordHash(SaSecurityItem securityItemUser, String password)
{
return passwordHasher.HashPassword(securityItemUser, password);
}
/// <summary>Verify password against hashed value stored against user account.</summary>
public static bool VerifyHashedPassword(SaSecurityItem securityItemUser, String password)
{
return passwordHasher.VerifyHashedPassword(securityItemUser, securityItemUser.PasswordHash, password) != PasswordVerificationResult.Failed;
}
/// <summary>Verify password against hashed value with user account as reference.</summary>
public static bool VerifyHashedPassword(SaSecurityItem securityItemUser, String password, String passwordHashed)
{
return passwordHasher.VerifyHashedPassword(securityItemUser, passwordHashed, password) != PasswordVerificationResult.Failed;
}
/// <summary>Check whether the password needs rehashing.</summary>
public static bool PasswordRequiresRehash(SaSecurityItem securityItemUser, String password)
{
return passwordHasher.VerifyHashedPassword(securityItemUser, securityItemUser.PasswordHash, password) == PasswordVerificationResult.SuccessRehashNeeded;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,103 @@
using Sarand.Net.Standard.Base.Helpers;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.Helpers
{
//=======================================================================
public static class SbmResourceHelper
{
//-------------------------------------------------------------------
// Definitions.
public enum TextResource
{
// Email stylesheets.
Email_Main_Css,
// Email partial content.
Email_Header_Html,
Email_Footer_Html,
// Email templates.
Email_ContactUs_Html,
Email_Signup_Activate_Html,
Email_Signup_Welcome_Html,
Email_RequestPassword_Html,
// Data - CSV files etc.
}
public enum ImageResource
{
BusinessMgr_logo_h75_png,
}
//-------------------------------------------------------------------
// Text resources.
public static String GetTextResource(TextResource textResource)
{
String partialPath = "";
String resourceFilename = "";
switch (textResource)
{
// Email stylesheet.
case TextResource.Email_Main_Css:
resourceFilename = "sax-email-main.css";
break;
// Email partial content.
case TextResource.Email_Header_Html:
resourceFilename = "sax-email-header.html";
break;
case TextResource.Email_Footer_Html:
resourceFilename = "sax-email-footer.html";
break;
// Email templates.
case TextResource.Email_ContactUs_Html:
resourceFilename = "sax-email-contact-us.html";
break;
case TextResource.Email_Signup_Activate_Html:
resourceFilename = "sax-email-signup-activate.html";
break;
case TextResource.Email_Signup_Welcome_Html:
resourceFilename = "sax-email-signup-welcome.html";
break;
case TextResource.Email_RequestPassword_Html:
resourceFilename = "sax-email-request-password.html";
break;
// Data.
}
if (!StringUtil.IsEmpty(resourceFilename))
{
var assembly = typeof(SbmResourceHelper).GetTypeInfo().Assembly;
String resourceText = SacsResourceHelper.GetManifestResourceAsText(assembly, partialPath, resourceFilename);
if (!StringUtil.IsEmpty(resourceText))
return resourceText;
}
return "";
}
//-------------------------------------------------------------------
// Image resources.
public static byte[] GetImageResource(ImageResource imageResource)
{
String partialPath = "";
String resourceFilename = "";
switch (imageResource)
{
case ImageResource.BusinessMgr_logo_h75_png:
resourceFilename = "BusinessMgr-logo-h75.png";
break;
}
if (!StringUtil.IsEmpty(resourceFilename))
{
var assembly = typeof(SbmResourceHelper).GetTypeInfo().Assembly;
byte[] resourceData = SacsResourceHelper.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename);
if (resourceData != null)
return resourceData;
}
return new byte[0];
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -217,344 +217,345 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
private OrganisationOptionData InitOrganisationOptionData()
{
OrganisationOptionData orgOptData = new OrganisationOptionData();
SbmConfigConsole console = SbmGlobals.GetConfigConsole(UserContext.SessionContext);
SbmAccountsDfn accounts = new SbmAccountsDfn(UserContext);
// Option types.
orgOptData.associationOptionTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssociationOption));
// Yes/No.
orgOptData.Values_YesNo.Add(orgOptData.Value_Yes, "Yes");
orgOptData.Values_YesNo.Add(orgOptData.Value_No, "No");
// Organisation configuration.
bool bAllowContacts = (AllowConfigOption(Sbm.ConfigOption.AllowContacts));
bool bAllowCustomers = (AllowAssociationType(Sbm.AssociationType.Customer));
bool bAllowStockists = (AllowAssociationType(Sbm.AssociationType.Stockist));
bool bAllowFinanceAgencies = (AllowAssociationType(Sbm.AssociationType.FinanceAgency));
bool bAllowCommodities = (AllowConfigOption(Sbm.ConfigOption.AllowCommodities));
bool bAllowVehicles = (AllowConfigOption(Sbm.ConfigOption.AllowVehicles));
bool bAllowAssets = (AllowConfigOption(Sbm.ConfigOption.AllowAssets));
bool bAllowTransactions = (AllowConfigOption(Sbm.ConfigOption.AllowTransactions));
bool bAllowSalesOrders = ((AllowTransactionType(Sbm.TransactionType.SalesOrder) || AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)));
bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch));
bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice)));
bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)));
bool bAllowInterfaces = (console.AllowInterfaces(UserContext));
bool bAllowInterfaces_File = (bAllowInterfaces && console.AllowInterfaceCategory(UserContext, SaInterfaceCategory.File));
// Values:
List<TypeCodeDesc> orgOptionValues = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Value);
if (bAllowTransactions)
using (SbmConfigConsole console = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext))
using (SbmAccountsDfn accounts = new SbmAccountsDfn(UserContext))
{
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter));
if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion))
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText));
if (console.GetRequirementCostingConfig(UserContext).AllowRequirementCosting(Sbm.TransactionType.SalesOrder))
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CostLabourRateDefault));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice));
if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes))
{
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk1Caption));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk2Caption));
}
// Default Email content.
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailSubject));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailBody));
}
if (accounts.IsUsingSageInterface())
{
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultSalesCarriageNominal));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal));
}
// Option types.
orgOptData.associationOptionTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssociationOption));
// Folders:
List<TypeCodeDesc> lOrgOptionFolder = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Folder);
if (bAllowCommodities)
{
orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityImage));
orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityBarcodeImage));
}
// Yes/No.
orgOptData.Values_YesNo.Add(orgOptData.Value_Yes, "Yes");
orgOptData.Values_YesNo.Add(orgOptData.Value_No, "No");
// Allow option contexts:
List<TypeCodeDesc> lAllowOption = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_AllowOption);
if (bAllowContacts)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.UpdateAssociationCode));
if (bAllowCustomers)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.CustomerAccountDetails));
if (bAllowStockists)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.StockistAssociations));
if (bAllowFinanceAgencies)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.FinanceAgencyAssociations));
}
if (bAllowCommodities)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_SalesBudget));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter));
// Organisation configuration.
bool bAllowContacts = (AllowConfigOption(Sbm.ConfigOption.AllowContacts));
bool bAllowCustomers = (AllowAssociationType(Sbm.AssociationType.Customer));
bool bAllowStockists = (AllowAssociationType(Sbm.AssociationType.Stockist));
bool bAllowFinanceAgencies = (AllowAssociationType(Sbm.AssociationType.FinanceAgency));
bool bAllowCommodities = (AllowConfigOption(Sbm.ConfigOption.AllowCommodities));
bool bAllowVehicles = (AllowConfigOption(Sbm.ConfigOption.AllowVehicles));
bool bAllowAssets = (AllowConfigOption(Sbm.ConfigOption.AllowAssets));
bool bAllowTransactions = (AllowConfigOption(Sbm.ConfigOption.AllowTransactions));
bool bAllowSalesOrders = ((AllowTransactionType(Sbm.TransactionType.SalesOrder) || AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)));
bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch));
bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice)));
bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)));
bool bAllowInterfaces = (console.AllowInterfaces(UserContext));
bool bAllowInterfaces_File = (bAllowInterfaces && console.AllowInterfaceCategory(UserContext, SaInterfaceCategory.File));
// Values:
List<TypeCodeDesc> orgOptionValues = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Value);
if (bAllowTransactions)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_EditHistoryItem));
}
if (bAllowTransactions)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_AnyStatus));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRef));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRefExt));
if (bAllowInterfaces_File)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionExport_FixedContent));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Order_BillingAddress));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails));
{
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter));
if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion))
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText));
if (console.GetRequirementCostingConfig(UserContext).AllowRequirementCosting(Sbm.TransactionType.SalesOrder))
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CostLabourRateDefault));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice));
if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes))
{
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk1Caption));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk2Caption));
}
// Default Email content.
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailSubject));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailBody));
}
if (accounts.IsUsingSageInterface())
{
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultSalesCarriageNominal));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal));
}
// Folders:
List<TypeCodeDesc> lOrgOptionFolder = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Folder);
if (bAllowCommodities)
{
orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityImage));
orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityBarcodeImage));
}
// Allow option contexts:
List<TypeCodeDesc> lAllowOption = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_AllowOption);
if (bAllowContacts)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.UpdateAssociationCode));
if (bAllowCustomers)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.CustomerAccountDetails));
if (bAllowStockists)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.StockistAssociations));
if (bAllowFinanceAgencies)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.FinanceAgencyAssociations));
}
if (bAllowCommodities)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_SalesBudget));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter));
if (bAllowTransactions)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_EditHistoryItem));
}
if (bAllowTransactions)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_AnyStatus));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRef));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRefExt));
if (bAllowInterfaces_File)
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionExport_FixedContent));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Order_BillingAddress));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails));
if (StockControlConfig.AllowStockControl())
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Transaction_RetainCurrentViewOnRaise));
}
if (bAllowSalesOrders)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_OnHold));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_ReplacementOrders));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails));
if (bAllowSalesInvoices)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_PartialInvoice));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_RaiseInvoiceOnCompletion));
}
}
if (bAllowSalesOrders && bAllowPurchaseOrders)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems));
}
if (StockControlConfig.AllowStockControl())
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Transaction_RetainCurrentViewOnRaise));
}
if (bAllowSalesOrders)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_OnHold));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_ReplacementOrders));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails));
if (bAllowSalesInvoices)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_PartialInvoice));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_RaiseInvoiceOnCompletion));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ImminentStock));
if (StockControlConfig.AllowStockContainers())
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ManageContainerMovemements));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock));
}
}
}
if (bAllowSalesOrders && bAllowPurchaseOrders)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems));
}
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ImminentStock));
if (StockControlConfig.AllowStockContainers())
if (bAllowAssets)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ManageContainerMovemements));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Sale));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Rental));
}
}
if (bAllowAssets)
{
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Sale));
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Rental));
}
// Caption contexts:
orgOptData.Contexts_Caption.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Caption));
// Caption contexts:
orgOptData.Contexts_Caption.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Caption));
// Show field contexts.
// NB This list must be kept up to date with equivalent in 'SapphireConsole::DisplayAttribute':
List<TypeCodeDesc> lShowField = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowField);
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget));
if (ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Address_LastVisitOn));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingNo));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Department));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Volume));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Density));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_MaterialCost))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative));
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3));
}
// Show column contexts:
List<TypeCodeDesc> lShowColumn = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowColumn);
if (bAllowSalesOrders)
{
// Show field contexts.
// NB This list must be kept up to date with equivalent in 'SapphireConsole::DisplayAttribute':
List<TypeCodeDesc> lShowField = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowField);
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget));
if (ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Address_LastVisitOn));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingNo));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Department));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Volume));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Density));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_MaterialCost))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative));
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2));
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3));
}
// Show column contexts:
List<TypeCodeDesc> lShowColumn = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowColumn);
if (bAllowSalesOrders)
{
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy));
}
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_Group))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Group));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_Weight));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale));
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable));
}
if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl())
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Order_AllocationInd));
if (bAllowSalesOrders && CodeTypeHasCodes(Sbm.ApplCodeType.DeliveryCourier))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier));
if (bAllowSalesOrders || bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice));
if (bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Transaction_ContactArea));
if (bAllowSalesInvoices && accounts.IsTransactionTypeManagedByAccounts(Sbm.TransactionType.SalesInvoice))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef));
if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation));
}
if (bAllowSalesDispatches)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched));
if (bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced));
// Check for processes:
if (ProcessMgr.HasProcesses(Sbm.ProcessCategory.Commodity))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess));
// Check for vehicles:
if (bAllowVehicles)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation));
// Field label contexts:
List<TypeCodeDesc> lFieldLabel = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_FieldLabel);
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Dimensions));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CostPrice));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_SpecSummary));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_FinishCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DescDetail));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Abbrev));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Nature));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_Location));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountManagerCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountTypeCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountRatingCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactAreaCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactMethodCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_Ref));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_RefExt));
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3));
}
// Commodity status filter.
List<TypeCodeDesc> lCmdStatusCat = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityStatusCat);
orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Any));
orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Current));
// Commodity Stock Category filter.
List<CodeDesc> commodityCategories = GetCodeDescsForCodeType(Sbm.ApplCodeType.CommodityCategory, true);
orgOptData.Values_CommodityStockCat.AddRange(commodityCategories);
// Container status caption.
if (CommodityMgr.ContainerDatabaseIsValid && StockControlConfig.AllowStockContainers())
orgOptData.Contexts_ContainerStatus.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ContainerStatusCaption));
// Generic options:
orgOptData.Contexts_Minutes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Minutes));
orgOptData.Contexts_PeriodDays.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodDays));
orgOptData.Contexts_PeriodWeeks.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodWeeks));
// Minutes.
for (int iMins = 0; iMins <= 30; iMins++)
orgOptData.Values_Minutes.Add(iMins.ToString(), iMins.ToString() + " min" + (iMins == 1 ? "" : "s"));
// Period - days.
orgOptData.Values_PeriodDays.Add("1", "1 day");
orgOptData.Values_PeriodDays.Add("2", "2 days");
orgOptData.Values_PeriodDays.Add("3", "3 days");
orgOptData.Values_PeriodDays.Add("7", "1 week");
orgOptData.Values_PeriodDays.Add("14", "2 weeks");
orgOptData.Values_PeriodDays.Add("21", "3 weeks");
orgOptData.Values_PeriodDays.Add("30", "30 days");
orgOptData.Values_PeriodDays.Add("60", "60 days");
orgOptData.Values_PeriodDays.Add("90", "90 days");
orgOptData.Values_PeriodDays.Add("120", "120 days");
orgOptData.Values_PeriodDays.Add("150", "150 days");
orgOptData.Values_PeriodDays.Add("300", "300 days");
// Period - weeks.
orgOptData.Values_PeriodWeeks.Add("0", "0 weeks");
orgOptData.Values_PeriodWeeks.Add("1", "1 week");
orgOptData.Values_PeriodWeeks.Add("2", "2 weeks");
orgOptData.Values_PeriodWeeks.Add("3", "3 weeks");
orgOptData.Values_PeriodWeeks.Add("4", "4 weeks");
orgOptData.Values_PeriodWeeks.Add("5", "5 weeks");
orgOptData.Values_PeriodWeeks.Add("6", "6 weeks");
orgOptData.Values_PeriodWeeks.Add("7", "7 weeks");
orgOptData.Values_PeriodWeeks.Add("8", "8 weeks");
orgOptData.Values_PeriodWeeks.Add("9", "9 weeks");
orgOptData.Values_PeriodWeeks.Add("10", "10 weeks");
orgOptData.Values_PeriodWeeks.Add("11", "11 weeks");
orgOptData.Values_PeriodWeeks.Add("12", "12 weeks");
orgOptData.Values_PeriodWeeks.Add("13", "13 weeks");
orgOptData.Values_PeriodWeeks.Add("14", "14 weeks");
orgOptData.Values_PeriodWeeks.Add("15", "15 weeks");
orgOptData.Values_PeriodWeeks.Add("16", "16 weeks");
orgOptData.Values_PeriodWeeks.Add("17", "17 weeks");
orgOptData.Values_PeriodWeeks.Add("18", "18 weeks");
orgOptData.Values_PeriodWeeks.Add("19", "19 weeks");
orgOptData.Values_PeriodWeeks.Add("20", "20 weeks");
orgOptData.Values_PeriodWeeks.Add("21", "21 weeks");
orgOptData.Values_PeriodWeeks.Add("22", "22 weeks");
orgOptData.Values_PeriodWeeks.Add("23", "23 weeks");
orgOptData.Values_PeriodWeeks.Add("24", "24 weeks");
orgOptData.Values_PeriodWeeks.Add("25", "25 weeks");
orgOptData.Values_PeriodWeeks.Add("26", "26 weeks");
orgOptData.Values_PeriodWeeks.Add("27", "27 weeks");
orgOptData.Values_PeriodWeeks.Add("28", "28 weeks");
orgOptData.Values_PeriodWeeks.Add("29", "29 weeks");
orgOptData.Values_PeriodWeeks.Add("30", "30 weeks");
// Numeric Decimals:
orgOptData.Contexts_NumericDecimals.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_NumericDecimals));
orgOptData.Values_Decimals_0To2.Add("0", "None");
orgOptData.Values_Decimals_0To2.Add("1", "1 places");
orgOptData.Values_Decimals_0To2.Add("2", "2 places");
orgOptData.Values_Decimals_0To4.Add("0", "None");
orgOptData.Values_Decimals_0To4.Add("1", "1 places");
orgOptData.Values_Decimals_0To4.Add("2", "2 places");
orgOptData.Values_Decimals_0To4.Add("3", "3 places");
orgOptData.Values_Decimals_0To4.Add("4", "4 places");
// Commodity types.
orgOptData.Contexts_CommodityType.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType));
orgOptData.Values_CommodityTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType));
// Sales locations.
orgOptData.Contexts_SalesLocation.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_StockLocation));
SbmLocation.Params prmLocation = new SbmLocation.Params();
prmLocation.RestrictToSalesStock = true;
prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly;
foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation))
orgOptData.Values_SalesLocation.Add(SysId.ToString(location.Id), location.Name);
}
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_Group))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Group));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_Weight));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale));
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable));
}
if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl())
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Order_AllocationInd));
if (bAllowSalesOrders && CodeTypeHasCodes(Sbm.ApplCodeType.DeliveryCourier))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier));
if (bAllowSalesOrders || bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice));
if (bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Transaction_ContactArea));
if (bAllowSalesInvoices && accounts.IsTransactionTypeManagedByAccounts(Sbm.TransactionType.SalesInvoice))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef));
if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available));
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation));
}
if (bAllowSalesDispatches)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched));
if (bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced));
// Check for processes:
if (ProcessMgr.HasProcesses(Sbm.ProcessCategory.Commodity))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess));
// Check for vehicles:
if (bAllowVehicles)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation));
// Field label contexts:
List<TypeCodeDesc> lFieldLabel = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_FieldLabel);
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Dimensions));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CostPrice));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_SpecSummary));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_FinishCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DescDetail));
if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned))
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Abbrev));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Nature));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_Location));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountManagerCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountTypeCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountRatingCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactAreaCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactMethodCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_Ref));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_RefExt));
if (StockControlConfig.AllowStockControl())
{
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3));
}
// Commodity status filter.
List<TypeCodeDesc> lCmdStatusCat = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityStatusCat);
orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Any));
orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Current));
// Commodity Stock Category filter.
List<CodeDesc> commodityCategories = GetCodeDescsForCodeType(Sbm.ApplCodeType.CommodityCategory, true);
orgOptData.Values_CommodityStockCat.AddRange(commodityCategories);
// Container status caption.
if (CommodityMgr.ContainerDatabaseIsValid && StockControlConfig.AllowStockContainers())
orgOptData.Contexts_ContainerStatus.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ContainerStatusCaption));
// Generic options:
orgOptData.Contexts_Minutes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Minutes));
orgOptData.Contexts_PeriodDays.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodDays));
orgOptData.Contexts_PeriodWeeks.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodWeeks));
// Minutes.
for (int iMins = 0; iMins <= 30; iMins++)
orgOptData.Values_Minutes.Add(iMins.ToString(), iMins.ToString() + " min" + (iMins == 1 ? "" : "s"));
// Period - days.
orgOptData.Values_PeriodDays.Add("1", "1 day");
orgOptData.Values_PeriodDays.Add("2", "2 days");
orgOptData.Values_PeriodDays.Add("3", "3 days");
orgOptData.Values_PeriodDays.Add("7", "1 week");
orgOptData.Values_PeriodDays.Add("14", "2 weeks");
orgOptData.Values_PeriodDays.Add("21", "3 weeks");
orgOptData.Values_PeriodDays.Add("30", "30 days");
orgOptData.Values_PeriodDays.Add("60", "60 days");
orgOptData.Values_PeriodDays.Add("90", "90 days");
orgOptData.Values_PeriodDays.Add("120", "120 days");
orgOptData.Values_PeriodDays.Add("150", "150 days");
orgOptData.Values_PeriodDays.Add("300", "300 days");
// Period - weeks.
orgOptData.Values_PeriodWeeks.Add("0", "0 weeks");
orgOptData.Values_PeriodWeeks.Add("1", "1 week");
orgOptData.Values_PeriodWeeks.Add("2", "2 weeks");
orgOptData.Values_PeriodWeeks.Add("3", "3 weeks");
orgOptData.Values_PeriodWeeks.Add("4", "4 weeks");
orgOptData.Values_PeriodWeeks.Add("5", "5 weeks");
orgOptData.Values_PeriodWeeks.Add("6", "6 weeks");
orgOptData.Values_PeriodWeeks.Add("7", "7 weeks");
orgOptData.Values_PeriodWeeks.Add("8", "8 weeks");
orgOptData.Values_PeriodWeeks.Add("9", "9 weeks");
orgOptData.Values_PeriodWeeks.Add("10", "10 weeks");
orgOptData.Values_PeriodWeeks.Add("11", "11 weeks");
orgOptData.Values_PeriodWeeks.Add("12", "12 weeks");
orgOptData.Values_PeriodWeeks.Add("13", "13 weeks");
orgOptData.Values_PeriodWeeks.Add("14", "14 weeks");
orgOptData.Values_PeriodWeeks.Add("15", "15 weeks");
orgOptData.Values_PeriodWeeks.Add("16", "16 weeks");
orgOptData.Values_PeriodWeeks.Add("17", "17 weeks");
orgOptData.Values_PeriodWeeks.Add("18", "18 weeks");
orgOptData.Values_PeriodWeeks.Add("19", "19 weeks");
orgOptData.Values_PeriodWeeks.Add("20", "20 weeks");
orgOptData.Values_PeriodWeeks.Add("21", "21 weeks");
orgOptData.Values_PeriodWeeks.Add("22", "22 weeks");
orgOptData.Values_PeriodWeeks.Add("23", "23 weeks");
orgOptData.Values_PeriodWeeks.Add("24", "24 weeks");
orgOptData.Values_PeriodWeeks.Add("25", "25 weeks");
orgOptData.Values_PeriodWeeks.Add("26", "26 weeks");
orgOptData.Values_PeriodWeeks.Add("27", "27 weeks");
orgOptData.Values_PeriodWeeks.Add("28", "28 weeks");
orgOptData.Values_PeriodWeeks.Add("29", "29 weeks");
orgOptData.Values_PeriodWeeks.Add("30", "30 weeks");
// Numeric Decimals:
orgOptData.Contexts_NumericDecimals.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_NumericDecimals));
orgOptData.Values_Decimals_0To2.Add("0", "None");
orgOptData.Values_Decimals_0To2.Add("1", "1 places");
orgOptData.Values_Decimals_0To2.Add("2", "2 places");
orgOptData.Values_Decimals_0To4.Add("0", "None");
orgOptData.Values_Decimals_0To4.Add("1", "1 places");
orgOptData.Values_Decimals_0To4.Add("2", "2 places");
orgOptData.Values_Decimals_0To4.Add("3", "3 places");
orgOptData.Values_Decimals_0To4.Add("4", "4 places");
// Commodity types.
orgOptData.Contexts_CommodityType.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType));
orgOptData.Values_CommodityTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType));
// Sales locations.
orgOptData.Contexts_SalesLocation.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_StockLocation));
SbmLocation.Params prmLocation = new SbmLocation.Params();
prmLocation.RestrictToSalesStock = true;
prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly;
foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation))
orgOptData.Values_SalesLocation.Add(SysId.ToString(location.Id), location.Name);
return orgOptData;
}
+2 -2
View File
@@ -232,14 +232,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
{
SbmApplication application = SbmGlobals.Application;
if (application != null)
return application.TableExists(SessionContext, tableIdx);
return application.BusMgrTableExists(SessionContext, tableIdx);
return false;
}
public bool ColumnExists(SbmDbDfn.ColumnIdx columnIdx)
{
SbmApplication application = SbmGlobals.Application;
if (application != null)
return application.ColumnExists(SessionContext, columnIdx);
return application.BusMgrColumnExists(SessionContext, columnIdx);
return false;
}
@@ -260,7 +260,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
// Standard notes length:
maxTranNotesLength = (int)SbmDbDfn.GetColTextLen(SbmDbDfn.ColumnIdx.Transaction_Notes);
// Check if this database allows longer notes:
ISacsDatabase db = SbmGlobals.Application.GetDatabase(SessionContext);
ISacsDatabase db = SbmGlobals.Application.GetBusMgrDatabase(SessionContext);
if (db != null)
{
DbDfnTable tableDfn = db.GetTableDfn(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction, false));
@@ -7,27 +7,23 @@ using Sarand.Net.Standard.Base.Procs;
namespace Sarand.BusinessMgr.Net.Standard.Base.Procs
{
//=======================================================================
public abstract class SbmReport_Base : SacsReport
public abstract class SbmReport_Base : SaReport_Base
{
//-------------------------------------------------------------------
// Configuration.
public new class Config : SacsReport.Config
public new class Config : SaReport_Base.Config
{
protected Config(SbmUserContext userContext, DbUpdateInfo dbUpdateInfo)
protected Config(SbmUserContext userContext)
{
UserContext = userContext;
DbUpdateInfo = dbUpdateInfo;
}
public SbmUserContext UserContext { get; }
public DbUpdateInfo DbUpdateInfo { get; }
}
//-------------------------------------------------------------------
// Data members.
private Config config;
private SbmAccountMgr accountMgr = null;
private SbmCommodityMgr commodityMgr = null;
private SbmTransactionMgr transactionMgr = null;
private SbmInternals internals = null;
//-------------------------------------------------------------------
// Construction.
@@ -39,44 +35,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Procs
{
if (disposing)
{
if (accountMgr != null) accountMgr.Dispose();
if (commodityMgr != null) commodityMgr.Dispose();
if (transactionMgr != null) transactionMgr.Dispose();
if (internals != null) internals.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
protected SaCodeTypeConsole CodeTypeConsole { get { return SbmGlobals.Application.GetCodeTypeConsole(config.UserContext); } }
protected SbmAccountMgr AccountMgr
{
get
{
if (accountMgr == null)
accountMgr = SbmGlobals.System.CreateAccountMgr(config.UserContext);
return accountMgr;
}
}
protected SbmCommodityMgr CommodityMgr
{
get
{
if (commodityMgr == null)
commodityMgr = SbmGlobals.System.CreateCommodityMgr(config.UserContext);
return commodityMgr;
}
}
protected SbmTransactionMgr TransactionMgr
{
get
{
if (transactionMgr == null)
transactionMgr = SbmGlobals.System.CreateTransactionMgr(config.UserContext);
return transactionMgr;
}
}
protected DbUpdateInfo DbUpdateInfo { get { return config.DbUpdateInfo; } }
protected SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(config.UserContext); return internals; } }
protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } }
protected SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } }
protected DbUpdateInfo DbUpdateInfo { get { return Internals.DbUpdateInfo; } }
//-------------------------------------------------------------------
}
@@ -13,12 +13,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog
// Configuration.
public new class Config : SaUpdateLogItemMonitor.Config
{
public Config(SbmUserContext userContext) :
base(SbmGlobals.Application.GetUpdateLogConsole(userContext), userContext.DbUpdateInfo)
public Config(SbmInternals internals) :
base(internals.UpdateLogConsole, internals.DbUpdateInfo)
{
UserContext = userContext;
Internals = internals;
}
public SbmUserContext UserContext { get; }
public SbmInternals Internals { get; }
}
//-------------------------------------------------------------------
@@ -35,7 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog
//-------------------------------------------------------------------
// Properties.
public SbmUserContext UserContext { get { return config.UserContext; } }
public SbmUserContext UserContext { get { return config.Internals.UserContext; } }
//-------------------------------------------------------------------
// Internal utilities.
@@ -43,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog
{
if (!config.UpdateLogConsole.CanUpdateDatabase) return false;
if (configConsole == null)
configConsole = SbmGlobals.Application.GetConfigConsole(config.UserContext.SessionContext);
configConsole = config.Internals.ConfigConsole;
if (!configConsole.IsColumnChangeLogged(UserContext, columnIdx)) return false;
return true;
}
@@ -5,7 +5,6 @@ using Sarand.Net.Standard.Base.Data;
using Sarand.Net.Standard.Base.Net;
using Sarand.Net.Standard.Base.Tasks;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Base.Xml;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -1,7 +1,6 @@
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Base.Xml;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -3,7 +3,6 @@ using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Net;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Base.Xml;
using System;
using System.Collections.Generic;
using System.Xml.Linq;