Session Console and Internals.

This commit is contained in:
Andy Howard
2025-01-16 13:19:58 +00:00
parent ee988b1f76
commit 61ecd59794
187 changed files with 4681 additions and 3647 deletions
@@ -24,7 +24,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// I n t e r f a c e O p t i o n D e f i n i t i o n s // I n t e r f a c e O p t i o n D e f i n i t i o n s
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static List<SaItemOptionDfn> GetInterfaceItemOptionDfns(ISbmUserContext_Core userContext, SaInterfaceCategory interfaceCategory, short interfaceType) public static List<SaItemOptionDfn> GetInterfaceItemOptionDfns(ISbmUserOrganisationContext userContext, SaInterfaceCategory interfaceCategory, short interfaceType)
{ {
switch (interfaceCategory) switch (interfaceCategory)
{ {
@@ -59,7 +59,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// P r o c e s s i n g O p t i o n s // P r o c e s s i n g O p t i o n s
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static List<SaProcess_Base.GroupData> GetProcessingOptions(ISbmUserContext_Core userContext, SaInterface interfaceObj) public static List<SaProcess_Base.GroupData> GetProcessingOptions(ISbmUserOrganisationContext userContext, SaInterface interfaceObj)
{ {
if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return new List<SaProcess_Base.GroupData>(); if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return new List<SaProcess_Base.GroupData>();
List<SaProcess_Base.GroupData> optionGroups = null; List<SaProcess_Base.GroupData> optionGroups = null;
@@ -90,7 +90,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// C o n f i g u r e P r o c e s s // C o n f i g u r e P r o c e s s
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static SbmInterfaceProcess ConfigureProcess(ISbmUserContext_Core userContext, SaInterface interfaceObj, SaProcess_Base.GroupData processGroup) public static SbmInterfaceProcess ConfigureProcess(ISbmUserOrganisationContext userContext, SaInterface interfaceObj, SaProcess_Base.GroupData processGroup)
{ {
if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return null; if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return null;
switch (interfaceObj.Category) switch (interfaceObj.Category)
@@ -120,7 +120,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// P r o c e s s I n t e r f a c e // P r o c e s s I n t e r f a c e
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static bool ProcessInterface(ISbmUserContext_Core userContext, SaInterface interfaceObj) public static bool ProcessInterface(ISbmUserOrganisationContext userContext, SaInterface interfaceObj)
{ {
if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return false; if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return false;
switch (interfaceObj.Category) switch (interfaceObj.Category)
@@ -149,7 +149,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
// I n v o k e P r o c e s s D e f i n i t i o n // I n v o k e P r o c e s s D e f i n i t i o n
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Invoke process based on definition from command line argument. // Invoke process based on definition from command line argument.
public static bool InvokeProcessDefinition(ISbmUserContext_Core userContext, SacsProcessDefinition processDfn) public static bool InvokeProcessDefinition(ISbmUserOrganisationContext userContext, SacsProcessDefinition processDfn)
{ {
//---------------------------------------------------------------- //----------------------------------------------------------------
// Log process definition. // Log process definition.
@@ -186,11 +186,11 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Retrieve interface. // Retrieve interface.
private static SaInterface GetSystemInterfaceByType(ISbmUserContext_Core userContext, short interfaceType, String caption) private static SaInterface GetSystemInterfaceByType(ISbmUserOrganisationContext userContext, short interfaceType, String caption)
{ {
return GetInterfaceByCategoryType(userContext, SaInterfaceCategory.System, interfaceType, caption); return GetInterfaceByCategoryType(userContext, SaInterfaceCategory.System, interfaceType, caption);
} }
private static SaInterface GetInterfaceByCategoryType(ISbmUserContext_Core userContext, SaInterfaceCategory interfaceCategory, short interfaceType, String caption) private static SaInterface GetInterfaceByCategoryType(ISbmUserOrganisationContext userContext, SaInterfaceCategory interfaceCategory, short interfaceType, String caption)
{ {
SaInterface saInterface = null; SaInterface saInterface = null;
SaInterface.Params prmInterface = new SaInterface.Params(); SaInterface.Params prmInterface = new SaInterface.Params();
@@ -30,7 +30,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
} }
public new class Config : SbmProcess_Base.Config public new class Config : SbmProcess_Base.Config
{ {
protected Config(ISbmUserContext_Core userContext) : base(userContext) protected Config(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
} }
public SysId InterfaceId { get; set; } public SysId InterfaceId { get; set; }
@@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
// Configuration. // Configuration.
public new class Config : SbmInterfaceProcess.Config public new class Config : SbmInterfaceProcess.Config
{ {
public Config(ISbmUserContext_Core userContext) : base(userContext) public Config(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
ItemType = Sbm.ItemType.Commodity; ItemType = Sbm.ItemType.Commodity;
ProcessType = ProcessType.ExportData; ProcessType = ProcessType.ExportData;
@@ -120,7 +120,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
public SbmInterfaceProcess_Commodity_Export(Config config) : base(config) public SbmInterfaceProcess_Commodity_Export(Config config) : base(config)
{ {
this.config = config; this.config = config;
interfaceOptions = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceOption); interfaceOptions = Internals.GetSystemCodes(Sbm.SystemCode.InterfaceOption);
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
@@ -677,7 +677,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
for (int i = 1; i <= kiMaxDataColumn; i++) for (int i = 1; i <= kiMaxDataColumn; i++)
optionContexts_Column.Add(i, StringUtil.PadLeft(i.ToString(), 3, '0'), "Column " + StringUtil.PadLeft(i.ToString(), 2, '0')); optionContexts_Column.Add(i, StringUtil.PadLeft(i.ToString(), 3, '0'), "Column " + StringUtil.PadLeft(i.ToString(), 2, '0'));
} }
optionValues_Mode = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.FileInterface_Mode); optionValues_Mode = Internals.GetSystemCodes(Sbm.SystemCode.FileInterface_Mode);
if (optionValues_Column == null) if (optionValues_Column == null)
{ {
optionValues_Column = new List<TypeCodeDesc>(); optionValues_Column = new List<TypeCodeDesc>();
@@ -707,7 +707,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
} }
AddColumnValue(SbmCommodity.Column.Location, "Cmd_Location", "Location"); AddColumnValue(SbmCommodity.Column.Location, "Cmd_Location", "Location");
AddColumnValue(SbmCommodity.Column.Department, "Cmd_Department", "Department"); AddColumnValue(SbmCommodity.Column.Department, "Cmd_Department", "Department");
if (UserContext.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef)) if (SessionConsole.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef))
AddColumnValue(SbmCommodity.Column.CatalogRef, "Cmd_CatalogRef", "Catalog ref"); AddColumnValue(SbmCommodity.Column.CatalogRef, "Cmd_CatalogRef", "Catalog ref");
AddColumnValue(SbmCommodity.Column.Weight, "Cmd_Weight", "Weight"); AddColumnValue(SbmCommodity.Column.Weight, "Cmd_Weight", "Weight");
//AddColumnValue(SbmCommodity.Column.WeightUomId, "Cmd_WeightUomId", "Weight","UOM Id"); //AddColumnValue(SbmCommodity.Column.WeightUomId, "Cmd_WeightUomId", "Weight","UOM Id");
@@ -847,7 +847,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
// Stock take: // Stock take:
AddColumnValue(SbmCommodity.Column.StockTake_Date, "Cmd_StockTake_Date", "Stock take date (derived)"); AddColumnValue(SbmCommodity.Column.StockTake_Date, "Cmd_StockTake_Date", "Stock take date (derived)");
// Sales budget: // Sales budget:
if (UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_SalesBudget)) if (SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_SalesBudget))
{ {
AddColumnValue(SbmCommodity.Column.SalesProj_Annual, "Cmd_SalesProj_Annual", "Sales proj - Annual"); AddColumnValue(SbmCommodity.Column.SalesProj_Annual, "Cmd_SalesProj_Annual", "Sales proj - Annual");
AddColumnValue(SbmCommodity.Column.SalesProj_Jan, "Cmd_SalesProj_Jan", "Sales proj - Jan"); AddColumnValue(SbmCommodity.Column.SalesProj_Jan, "Cmd_SalesProj_Jan", "Sales proj - Jan");
@@ -1011,7 +1011,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
// Portfolio items: // Portfolio items:
AddColumnValue(SbmCommodity.Column.PortfolioItem_Count, "Cmd_Portfolio_ItemCount", "Portfolio item count"); AddColumnValue(SbmCommodity.Column.PortfolioItem_Count, "Cmd_Portfolio_ItemCount", "Portfolio item count");
// Barcode images (if a barcode image path is defined): // Barcode images (if a barcode image path is defined):
if (!UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityBarcodeImage).IsEmpty()) if (!SessionConsole.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityBarcodeImage).IsEmpty())
{ {
AddColumnValue(SbmCommodity.Column.BarcodeImagePath, "Cmd_BarcodeImagePath", "Barcode image path"); AddColumnValue(SbmCommodity.Column.BarcodeImagePath, "Cmd_BarcodeImagePath", "Barcode image path");
AddColumnValue(SbmCommodity.Column.BarcodeImage, "Cmd_BarcodeImage", "Barcode image"); AddColumnValue(SbmCommodity.Column.BarcodeImage, "Cmd_BarcodeImage", "Barcode image");
@@ -1038,7 +1038,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
switch (SbmDbDfn.GetTableForColumn(eDbCol)) switch (SbmDbDfn.GetTableForColumn(eDbCol))
{ {
case SbmDbDfn.TableIdx.PortfolioItem: case SbmDbDfn.TableIdx.PortfolioItem:
allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.AllowPortfolios); allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.Portfolios);
if (allowColumn) if (allowColumn)
allowColumn = CommodityMgr.PortfolioDatabaseIsValid; allowColumn = CommodityMgr.PortfolioDatabaseIsValid;
break; break;
@@ -1049,7 +1049,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
break; break;
case SbmDbDfn.TableIdx.Transaction: case SbmDbDfn.TableIdx.Transaction:
case SbmDbDfn.TableIdx.Requirement: case SbmDbDfn.TableIdx.Requirement:
allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.AllowTransactions); allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.Transactions);
break; break;
} }
@@ -1072,7 +1072,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
Export_Commodities, Export_Commodities,
} }
/// <summary>Configure processing options.</summary> /// <summary>Configure processing options.</summary>
public static List<SaProcess_Base.GroupData> GetProcessingOptions(ISbmUserContext_Core userContext, SaInterface interfaceObj) public static List<SaProcess_Base.GroupData> GetProcessingOptions(ISbmUserOrganisationContext userContext, SaInterface interfaceObj)
{ {
List<SaProcess_Base.GroupData> optionGroups = new List<SaProcess_Base.GroupData>(); List<SaProcess_Base.GroupData> optionGroups = new List<SaProcess_Base.GroupData>();
@@ -1087,7 +1087,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//------------------------------------------------------------------- //-------------------------------------------------------------------
/// <summary>Process interface using selected options.</summary> /// <summary>Process interface using selected options.</summary>
public static SbmInterfaceProcess ConfigureProcess(ISbmUserContext_Core userContext, SaInterface interfaceObj, SaProcess_Base.GroupData processGroup) public static SbmInterfaceProcess ConfigureProcess(ISbmUserOrganisationContext userContext, SaInterface interfaceObj, SaProcess_Base.GroupData processGroup)
{ {
if (processGroup.OptionGroup.Type == (int)InterfaceProcessGroup.Export) if (processGroup.OptionGroup.Type == (int)InterfaceProcessGroup.Export)
{ {
@@ -40,11 +40,16 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
} }
public new class Config : SaProcess.Config public new class Config : SaProcess.Config
{ {
protected Config(ISbmUserContext_Core userContext) : base(userContext.DbUpdateInfo) protected Config(SbmInternals internals) : base(internals.UserContext.DbUpdateInfo)
{
this.Internals = internals;
UserContext = internals.UserContext;
}
protected Config(ISbmUserOrganisationContext userContext) : base(userContext.DbUpdateInfo)
{ {
UserContext = userContext; UserContext = userContext;
} }
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
/// <summary>Specific type of data item being handled.</summary> /// <summary>Specific type of data item being handled.</summary>
public Sbm.ItemType ItemType { get; set; } = Sbm.ItemType.Unknown; public Sbm.ItemType ItemType { get; set; } = Sbm.ItemType.Unknown;
/// <summary>Format to import/export data.</summary> /// <summary>Format to import/export data.</summary>
@@ -106,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
} }
} }
// Context. // Context.
public ISbmUserContext_Core UserContext { get { return config.UserContext; } } public ISbmUserOrganisationContext UserContext { get { return config.UserContext; } }
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
protected SbmInternals Internals protected SbmInternals Internals
{ {
@@ -24,7 +24,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
// Configuration. // Configuration.
public new class Config : SbmProcess_Base.Config public new class Config : SbmProcess_Base.Config
{ {
public Config(ISbmUserContext_Core userContext) : base(userContext) public Config(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
ItemType = Sbm.ItemType.Commodity; ItemType = Sbm.ItemType.Commodity;
DataFormat = DataFormatType.Excel; DataFormat = DataFormatType.Excel;
@@ -330,7 +330,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.DescBrief, "Description", 240)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.DescBrief, "Description", 240));
if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityCategory)) if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityCategory))
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Category1_Desc)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Category1_Desc));
if (UserContext.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef)) if (SessionConsole.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef))
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.CatalogRef)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.CatalogRef));
if (config.ExportType == ExportType.StockControl) if (config.ExportType == ExportType.StockControl)
@@ -411,9 +411,9 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.SalesPrice)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.SalesPrice));
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.RetailPrice)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.RetailPrice));
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.PackQtySale)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.PackQtySale));
if (UserContext.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_Weight)) if (SessionConsole.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_Weight))
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Weight_ValueUnits)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Weight_ValueUnits));
if (UserContext.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale)) if (SessionConsole.GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale))
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.PackQtySale)); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.PackQtySale));
if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_Volume)) if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_Volume))
{ {
@@ -438,7 +438,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
additionalQueryColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Stock_CurrentLevel)); additionalQueryColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Stock_CurrentLevel));
additionalQueryColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Stock_Due_Imminently)); additionalQueryColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Stock_Due_Imminently));
// Sales budget: // Sales budget:
if (UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_SalesBudget)) if (Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_SalesBudget))
{ {
for (int monthIdx = 0; monthIdx < 12; monthIdx++) for (int monthIdx = 0; monthIdx < 12; monthIdx++)
displayColumns.Add(CommodityMgr.GetCommodityColumnDfn((SbmCommodity.Column)(SbmCommodity.Column.SalesProj_Jan + monthIdx))); displayColumns.Add(CommodityMgr.GetCommodityColumnDfn((SbmCommodity.Column)(SbmCommodity.Column.SalesProj_Jan + monthIdx)));
+1 -1
View File
@@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Reports
// Configuration. // Configuration.
public new class Config : SbmReport_Base.Config public new class Config : SbmReport_Base.Config
{ {
protected Config(ISbmUserContext_Core userContext) : protected Config(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
+12 -12
View File
@@ -98,39 +98,39 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Create consoles. // Create consoles.
public override SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext) public override SbmSessionConsole CreateSessionConsole(ISbmUserOrganisationContext userContext)
{ {
return SbmSessionConsole.CreateConsole(userContext); return SbmSessionConsole.CreateConsole(userContext);
} }
public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext) public override SaDiaryConsole CreateDiaryConsole(ISbmUserOrganisationContext userContext)
{ {
return null; return null;
} }
public override SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext) public override SaSecurityConsole CreateSecurityConsole(ISbmUserOrganisationContext userContext)
{ {
return new SbmSecurityConsole_Web(userContext); return new SbmSecurityConsole_Web(userContext);
} }
public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext_Core userContext) public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserOrganisationContext userContext)
{ {
return new SbmCodeTypeConsole_Web(userContext); return new SbmCodeTypeConsole_Web(userContext);
} }
public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext) public override SaItemDataConsole CreateItemDataConsole(ISbmUserOrganisationContext userContext)
{ {
return null; return null;
} }
public override SaItemDocConsole CreateItemDocConsole(ISbmUserContext_Core userContext) public override SaItemDocConsole CreateItemDocConsole(ISbmUserOrganisationContext userContext)
{ {
return null; return null;
} }
public override SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext_Core userContext) public override SaItemOptionConsole CreateItemOptionConsole(ISbmUserOrganisationContext userContext)
{
return new SbmItemOptionConsole_Web(userContext);
}
public override SaInterfaceConsole CreateInterfaceConsole(ISbmUserOrganisationContext userContext)
{ {
return null; return null;
} }
public override SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext_Core userContext) public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserOrganisationContext userContext)
{
return null;
}
public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext_Core userContext)
{ {
return new SbmUpdateLogConsole_Web(userContext); return new SbmUpdateLogConsole_Web(userContext);
} }
@@ -7,7 +7,9 @@ using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
namespace Sarand.BusinessMgr.Net.Core.Web.App namespace Sarand.BusinessMgr.Net.Core.Web.App
{ {
@@ -16,10 +18,17 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Definitions. // Definitions.
protected const String ParamContext_Config = "Config"; protected const String ParamContext_OptionAllowed = "OptionAllowed";
protected const String ParamContext_ConfigPrefix = "Config-"; protected const String ParamContext_AffiliateTypeAllowed = "AffiliateTypeAllowed";
protected const String ApplicationOptionValue_Allow = "Allow"; protected const String ParamContext_AssociationTypeAllowed = "AssociationTypeAllowed";
protected const String ApplicationOptionValue_Disallow = "Disallow"; protected const String ParamContext_TransactionTypeAllowed = "TransactionTypeAllowed";
protected const String ParamContext_TransactionCreation = "TransactionCreation";
protected const String ParamContext_TransactionReferencePrefix = "TransactionReferencePrefix";
protected const String ParamContext_StockControl = "StockControl";
protected const String ParamContext_InterfaceCategoryAllowed = "InterfaceCategoryAllowed";
protected const String ParamContext_InterfaceTypeAllowed = "InterfaceTYpeAllowed";
protected const String ParamContext_DefaultValue = "DefaultValue";
protected const String ParamContext_ColumnChangeLogged = "ColumnChangeLogged";
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Data members. // Data members.
@@ -39,17 +48,10 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
// Owner/Instance configuration parameters. // Owner/Instance configuration parameters.
public enum ConfigParamType public enum ConfigParamType
{ {
// Affiliate types. AffiliateTypeAllowed,
AllowedAffiliateTypes, AssociationTypeAllowed,
DisallowedAffiliateTypes, TransactionTypeAllowed,
// Association types. ApplicationOptionAllowed,
AllowedAssociationTypes,
DisallowedAssociationTypes,
// Transaction types.
AllowedTransactionTypes,
DisallowedTransactionTypes,
// Application options.
ApplicationOption,
} }
public class ConfigParamData public class ConfigParamData
{ {
@@ -60,52 +62,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
public bool Password { get; set; } public bool Password { get; set; }
} }
public bool IsConfigParamOfType(ConfigParamType configParam, SbmcItemParam itemParam)
{
switch (configParam)
{
// Affiliate types.
case ConfigParamType.AllowedAffiliateTypes:
case ConfigParamType.DisallowedAffiliateTypes:
// Association types.
case ConfigParamType.AllowedAssociationTypes:
case ConfigParamType.DisallowedAssociationTypes:
// Transaction types.
case ConfigParamType.AllowedTransactionTypes:
case ConfigParamType.DisallowedTransactionTypes:
return itemParam.Context.EqualsCI(ParamContext_Config) && itemParam.Name.EqualsCI(configParam.ToString());
// Application options.
case ConfigParamType.ApplicationOption:
return itemParam.Context.EqualsCI($"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}");
}
return false;
}
public ConfigParamData GetConfigParamData(ConfigParamType configParam)
{
switch (configParam)
{
// Affiliate types.
case ConfigParamType.AllowedAffiliateTypes:
case ConfigParamType.DisallowedAffiliateTypes:
// Association types.
case ConfigParamType.AllowedAssociationTypes:
case ConfigParamType.DisallowedAssociationTypes:
// Transaction types.
case ConfigParamType.AllowedTransactionTypes:
case ConfigParamType.DisallowedTransactionTypes:
return new ConfigParamData() { ConfigParam = configParam, Context = ParamContext_Config, Name = configParam.ToString() };
}
return null;
}
public ConfigParamData GetAllowOptionConfigParamData(Sbm.ConfigOption option)
{
ConfigParamData configParamData = new ConfigParamData() { ConfigParam = ConfigParamType.ApplicationOption, Context = $"{ParamContext_ConfigPrefix}{ConfigParamType.ApplicationOption.ToString()}", Name = option.ToString() };
configParamData.Values.UnionWith(new List<String>() { ApplicationOptionValue_Allow, ApplicationOptionValue_Disallow });
return configParamData;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Populate Repository Configuration parameters. // Populate Repository Configuration parameters.
private void PopulateControlParams() private void PopulateControlParams()
@@ -138,74 +94,93 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
} }
private void PopulateControlParam(SbmcItemParam itemParam) private void PopulateControlParam(SbmcItemParam itemParam)
{ {
// Affiliate types. if (itemParam.Context.EqualsCI(ParamContext_OptionAllowed))
if (IsConfigParamOfType(ConfigParamType.AllowedAffiliateTypes, itemParam))
AffiliateTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.AffiliateType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
else if (IsConfigParamOfType(ConfigParamType.DisallowedAffiliateTypes, itemParam))
AffiliateTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.AffiliateType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
// Association types.
else if (IsConfigParamOfType(ConfigParamType.AllowedAssociationTypes, itemParam))
AssociationTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.AssociationType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
else if (IsConfigParamOfType(ConfigParamType.DisallowedAssociationTypes, itemParam))
AssociationTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.AssociationType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
// Transaction types.
else if (IsConfigParamOfType(ConfigParamType.AllowedTransactionTypes, itemParam))
TransactionTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.TransactionType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
else if (IsConfigParamOfType(ConfigParamType.DisallowedTransactionTypes, itemParam))
TransactionTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.TransactionType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
// Application options.
else if (IsConfigParamOfType(ConfigParamType.ApplicationOption, itemParam))
{ {
// Application options.
Sbm.ConfigOption option = EnumUtil.ParseEnum(itemParam.Name, Sbm.ConfigOption.Unknown); Sbm.ConfigOption option = EnumUtil.ParseEnum(itemParam.Name, Sbm.ConfigOption.Unknown);
if (option != Sbm.ConfigOption.Unknown) if (option != Sbm.ConfigOption.Unknown)
{ {
if (itemParam.Value.EqualsCI(ApplicationOptionValue_Allow)) if (StringUtil.ToBool(itemParam.Value))
ApplicationOptions_Allowed.Add(option); ApplicationOptions_Allowed.Add(option);
else if (itemParam.Value.EqualsCI(ApplicationOptionValue_Disallow)) else
ApplicationOptions_Disallowed.Add(option); ApplicationOptions_Disallowed.Add(option);
}
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option: {itemParam.Name}.");
}
else if (itemParam.Context.EqualsCI(ParamContext_AffiliateTypeAllowed))
{
// Affiliate types.
Sbm.AffiliateType affiliateType = EnumUtil.ParseEnum(itemParam.Name, Sbm.AffiliateType.Unknown);
if (affiliateType != AffiliateType.Unknown)
{
if (StringUtil.ToBool(itemParam.Value))
AffiliateTypes_Allowed.Add(affiliateType);
else else
SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option value: {itemParam.Value}. Option: {option}."); AffiliateTypes_Disallowed.Add(affiliateType);
} }
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised Affiliate type: {itemParam.Name}.");
}
else if (itemParam.Context.EqualsCI(ParamContext_AssociationTypeAllowed))
{
// Association types.
Sbm.AssociationType associationType = EnumUtil.ParseEnum(itemParam.Name, Sbm.AssociationType.Unknown);
if (associationType != AssociationType.Unknown)
{
if (StringUtil.ToBool(itemParam.Value))
AssociationTypes_Allowed.Add(associationType);
else else
SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option: {itemParam.Name}."); AssociationTypes_Disallowed.Add(associationType);
} }
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised Association type: {itemParam.Name}.");
}
else if (itemParam.Context.EqualsCI(ParamContext_TransactionTypeAllowed))
{
// Transaction types.
Sbm.TransactionType transactionType = EnumUtil.ParseEnum(itemParam.Name, Sbm.TransactionType.Unknown);
if (transactionType != TransactionType.Unknown)
{
if (StringUtil.ToBool(itemParam.Value))
TransactionTypes_Allowed.Add(transactionType);
else
TransactionTypes_Disallowed.Add(transactionType);
}
else SaLogger.Warn($"{SysUtil.Fn} Unrecognised Transaction type: {itemParam.Name}.");
}
else if (itemParam.Context.EqualsCI(ParamContext_TransactionCreation))
{
// Transaction Creation.
}
else if (itemParam.Context.EqualsCI(ParamContext_TransactionReferencePrefix))
{
// Transaction Reference Prefix.
}
else if (itemParam.Context.EqualsCI(ParamContext_StockControl))
{
// Stock Control.
}
else if (itemParam.Context.EqualsCI(ParamContext_InterfaceCategoryAllowed))
{
// Interface Category.
}
else if (itemParam.Context.EqualsCI(ParamContext_InterfaceTypeAllowed))
{
// Interface Type.
}
else if (itemParam.Context.EqualsCI(ParamContext_DefaultValue))
{
// Default Value.
}
else if (itemParam.Context.EqualsCI(ParamContext_ColumnChangeLogged))
{
// Update Log.
}
else SaLogger.Debug($"{SysUtil.Fn} Unrecognised option. Context: {itemParam.Context}. Name: {itemParam.Name}.");
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Allowed data component types. // Configuration rules.
//-------------------------------------------------------------------
// Supported affiliate types.
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Allowed = new HashSet<Sbm.AffiliateType>();
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Disallowed = new HashSet<Sbm.AffiliateType>();
public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType, bool defaultResponse)
{
if (AffiliateTypes_Disallowed.Contains(affiliateType)) return false;
if (AffiliateTypes_Allowed.Contains(affiliateType)) return true;
return defaultResponse;
}
// Supported affiliate types.
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Allowed = new HashSet<Sbm.AssociationType>();
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Disallowed = new HashSet<Sbm.AssociationType>();
public override bool AllowAssociationType(Sbm.AssociationType affiliateType, bool defaultResponse)
{
if (AssociationTypes_Disallowed.Contains(affiliateType)) return false;
if (AssociationTypes_Allowed.Contains(affiliateType)) return true;
return defaultResponse;
}
// Supported affiliate types.
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Allowed = new HashSet<Sbm.TransactionType>();
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Disallowed = new HashSet<Sbm.TransactionType>();
public override bool AllowTransactionType(Sbm.TransactionType affiliateType, bool defaultResponse)
{
if (TransactionTypes_Disallowed.Contains(affiliateType)) return false;
if (TransactionTypes_Allowed.Contains(affiliateType)) return true;
return defaultResponse;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Application options.
// Supported application options. // Supported application options.
private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Allowed = new HashSet<Sbm.ConfigOption>(); private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Allowed = new HashSet<Sbm.ConfigOption>();
@@ -217,6 +192,54 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
return defaultResponse; return defaultResponse;
} }
//-------------------------------------------------------------------
// Contacts.
// Supported Affiliate types.
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Allowed = new HashSet<Sbm.AffiliateType>();
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Disallowed = new HashSet<Sbm.AffiliateType>();
public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType, bool defaultResponse)
{
if (AffiliateTypes_Disallowed.Contains(affiliateType)) return false;
if (AffiliateTypes_Allowed.Contains(affiliateType)) return true;
return defaultResponse;
}
// Supported Association types.
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Allowed = new HashSet<Sbm.AssociationType>();
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Disallowed = new HashSet<Sbm.AssociationType>();
public override bool AllowAssociationType(Sbm.AssociationType affiliateType, bool defaultResponse)
{
if (AssociationTypes_Disallowed.Contains(affiliateType)) return false;
if (AssociationTypes_Allowed.Contains(affiliateType)) return true;
return defaultResponse;
}
// Supported Transaction types.
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Allowed = new HashSet<Sbm.TransactionType>();
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Disallowed = new HashSet<Sbm.TransactionType>();
public override bool AllowTransactionType(Sbm.TransactionType affiliateType, bool defaultResponse)
{
if (TransactionTypes_Disallowed.Contains(affiliateType)) return false;
if (TransactionTypes_Allowed.Contains(affiliateType)) return true;
return defaultResponse;
}
//-------------------------------------------------------------------
// Interfaces.
private readonly HashSet<SaInterfaceCategory> InterfaceCategories_Allowed = new HashSet<SaInterfaceCategory>();
private readonly HashSet<SaInterfaceCategory> InterfaceCategories_Disallowed = new HashSet<SaInterfaceCategory>();
/// <summary>
/// Whether the Interface Category is allowed.
/// </summary>
public override bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse)
{
if (InterfaceCategories_Allowed.Contains(interfaceCategory)) return false;
if (InterfaceCategories_Disallowed.Contains(interfaceCategory)) return true;
return defaultResponse;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
} }
//======================================================================= //=======================================================================
@@ -39,28 +39,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
private SbmSessionContext_Web SessionContext { get; } private SbmSessionContext_Web SessionContext { get; }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Allowed data component types. // Configuration rules.
//-------------------------------------------------------------------
// Supported affiliate types.
public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType, bool defaultResponse)
{
return defaultResponse;
}
// Supported affiliate types.
public override bool AllowAssociationType(Sbm.AssociationType affiliateType, bool defaultResponse)
{
return defaultResponse;
}
// Supported affiliate types.
public override bool AllowTransactionType(Sbm.TransactionType affiliateType, bool defaultResponse)
{
return defaultResponse;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Application options.
// Supported application options. // Supported application options.
public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse) public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse)
@@ -68,6 +49,38 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
return defaultResponse; return defaultResponse;
} }
//-------------------------------------------------------------------
// Contacts.
// Supported Affiliate types.
public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType, bool defaultResponse)
{
return defaultResponse;
}
// Supported Association types.
public override bool AllowAssociationType(Sbm.AssociationType affiliateType, bool defaultResponse)
{
return defaultResponse;
}
//-------------------------------------------------------------------
// Transactions.
// Supported Transaction types.
public override bool AllowTransactionType(Sbm.TransactionType affiliateType, bool defaultResponse)
{
return defaultResponse;
}
//-------------------------------------------------------------------
// Interfaces.
public override bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse)
{
return defaultResponse;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
} }
//======================================================================= //=======================================================================
+16 -5
View File
@@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Utils;
@@ -140,11 +142,11 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode codeType) public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode codeType)
{ {
if (!codes.ContainsKey(codeType)) if (!codes.ContainsKey(codeType))
codes.Add(codeType, SbmSystem.GetCodesOfType(null, codeType)); codes.Add(codeType, SbmSystem.GetSystemCodes(codeType));
return codes.GetValueOrDefault(codeType, new List<TypeCodeDesc>()); return codes.GetValueOrDefault(codeType, new List<TypeCodeDesc>());
} }
} }
private CodeCache codes = new CodeCache(); private readonly CodeCache systemCodes = new CodeCache();
// Status. // Status.
public String GetStatusCaption(SaStatus status) public String GetStatusCaption(SaStatus status)
@@ -158,7 +160,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
{ {
if ((int)affiliateType < 1) return ""; if ((int)affiliateType < 1) return "";
// ToDo Affiliate Type localisation. // ToDo Affiliate Type localisation.
List<TypeCodeDesc> affiliateTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AffiliateType); List<TypeCodeDesc> affiliateTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.AffiliateType);
return affiliateTypeCodes.GetDescForType(affiliateType, affiliateTypeCodes.GetCodeForType(affiliateType)); return affiliateTypeCodes.GetDescForType(affiliateType, affiliateTypeCodes.GetCodeForType(affiliateType));
} }
@@ -167,7 +169,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
{ {
if ((int)associationType < 1) return ""; if ((int)associationType < 1) return "";
// ToDo Association Type localisation. // ToDo Association Type localisation.
List<TypeCodeDesc> associationTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssociationType); List<TypeCodeDesc> associationTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.AssociationType);
return associationTypeCodes.GetDescForType(associationType, associationTypeCodes.GetCodeForType(associationType)); return associationTypeCodes.GetDescForType(associationType, associationTypeCodes.GetCodeForType(associationType));
} }
@@ -176,10 +178,19 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
{ {
if ((int)assetType < 1) return ""; if ((int)assetType < 1) return "";
// ToDo Asset Type localisation. // ToDo Asset Type localisation.
List<TypeCodeDesc> assetTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssetType); List<TypeCodeDesc> assetTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.AssetType);
return assetTypeCodes.GetDescForType(assetType, assetTypeCodes.GetCodeForType(assetType)); return assetTypeCodes.GetDescForType(assetType, assetTypeCodes.GetCodeForType(assetType));
} }
// Transaction Type.
public String GetTransactionTypeCaption(Sbm.TransactionType transactionType)
{
if ((int)transactionType < 1) return "";
// ToDo Transaction Type localisation.
List<TypeCodeDesc> transactionTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.TransactionType);
return transactionTypeCodes.GetDescForType(transactionType, transactionTypeCodes.GetCodeForType(transactionType));
}
// To be completed. // To be completed.
//------------------------------------------------------------------- //-------------------------------------------------------------------
@@ -1,5 +1,6 @@
using Sarand.BusinessMgr.Net.Standard.Base.App; using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Dbas.App;
using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Security; using Sarand.Net.Standard.Base.Security;
using System; using System;
@@ -9,7 +10,7 @@ using System.Text;
namespace Sarand.BusinessMgr.Net.Core.Web.App namespace Sarand.BusinessMgr.Net.Core.Web.App
{ {
//======================================================================= //=======================================================================
public class SbmUserContext_Web : SbmUserContext public class SbmUserContext_Web : SbmUserContext_Dbas
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Data members. // Data members.
@@ -14,7 +14,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmCodeTypeConsole_Web(ISbmUserContext_Core userContext) : base(userContext) public SbmCodeTypeConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
} }
@@ -0,0 +1,46 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles;
using Sarand.Net.Standard.Base.Interfaces;
using Sarand.Net.Standard.Base.UpdateLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
{
//=======================================================================
public class SbmItemOptionConsole_Web : SbmItemOptionConsole_Dbas
{
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Construction.
public SbmItemOptionConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext)
{
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>
/// 'Show Item Options' dialog only for desktop and mobile applications.
/// </summary>
protected override ShowItemOptionsDialogFunction ShowItemOptionsDialogFn => throw new NotImplementedException();
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -17,7 +17,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmSecurityConsole_Web(ISbmUserContext_Core userContext) : base(userContext) public SbmSecurityConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@@ -16,7 +16,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmUpdateLogConsole_Web(ISbmUserContext_Core userContext) : base(userContext) public SbmUpdateLogConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } } protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
public App.SbmAppConfig AppConfig { get { return App.AppConfig; } } public App.SbmAppConfig AppConfig { get { return App.AppConfig; } }
public abstract SbmSessionContext SessionContext { get; } public abstract SbmSessionContext SessionContext { get; }
public abstract ISbmUserContext_Core UserContext_Core { get; } public abstract ISbmUserOrganisationContext UserContext_Core { get; }
// Business components. // Business components.
public SbmInternals Internals { get { if (internals == null && UserContext_Core != null) { internals = new SbmInternals(UserContext_Core); } return internals; } } public SbmInternals Internals { get { if (internals == null && UserContext_Core != null) { internals = new SbmInternals(UserContext_Core); } return internals; } }
public SbmInternals_Control Internals_Control { get { if (internals_Control == null) { internals_Control = new SbmInternals_Control(); } return internals_Control; } } public SbmInternals_Control Internals_Control { get { if (internals_Control == null) { internals_Control = new SbmInternals_Control(); } return internals_Control; } }
@@ -98,7 +98,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
public SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } public SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
public SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } public SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
// System codes. // System codes.
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); } public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); }
// Email. // Email.
public SaEmailConfig EmailConfig { get { return Internals.EmailConfig; } } public SaEmailConfig EmailConfig { get { return Internals.EmailConfig; } }
public SbmEmailConsole EmailConsole { get { return Internals.EmailConsole; } } public SbmEmailConsole EmailConsole { get { return Internals.EmailConsole; } }
+2 -2
View File
@@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
public SbmSessionData SessionData { get { return SessionData_Web; } } public SbmSessionData SessionData { get { return SessionData_Web; } }
public SbmSessionData_Web SessionData_Web { get; set; } public SbmSessionData_Web SessionData_Web { get; set; }
public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } } public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
public abstract ISbmUserContext_Core UserContext_Core { get; } public abstract ISbmUserOrganisationContext UserContext_Core { get; }
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } } public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } }
public SbmLocaliser Localiser { get; } public SbmLocaliser Localiser { get; }
// Request properties. // Request properties.
@@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
// System codes. // System codes.
protected List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); } protected List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Security. // Security.
+96 -30
View File
@@ -1,4 +1,5 @@
using Sarand.Net.Standard.Base.App; using Newtonsoft.Json.Serialization;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Dbas;
using System; using System;
@@ -324,20 +325,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
/// <summary>Display dialog bar.</summary> /// <summary>Display dialog bar.</summary>
DialogBar = 11, DialogBar = 11,
// Core application modules. // Core application modules.
AllowConsoleView = 20, /* Default: True */ ConsoleView = 20, /* Default: True */
AllowOrganisationUpdate, /* Default: True */ OrganisationUpdate, /* Default: True */
AllowContacts, /* Default: True */ Contacts, /* Default: True */
AllowProcesses, /* Default: True */ ComputerHardware,
AllowAssets, Commodities, /* Default: True */
AllowVehicles, CommodityAssociations,
AllowComputerHardware, Processes, /* Default: True */
AllowCommodities, /* Default: True */ Assets,
AllowCommodityAssociations, Vehicles,
AllowPortfolios, Portfolios,
AllowPriceSets, PriceSets,
AllowTransactions, /* Default: True */ Transactions, /* Default: True */
AllowItemDocuments, ItemDocuments,
AllowFinancialsAccessControl, FinancialsAccessControl,
//--------------------------------------------------------------- //---------------------------------------------------------------
// Navigation (view) options. // Navigation (view) options.
DiaryView = 60, /* Default: True */ DiaryView = 60, /* Default: True */
@@ -346,7 +347,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
AnyTransactionView, AnyTransactionView,
Jobs = 70, Jobs = 70,
TimeRecording, TimeRecording,
AllowTasks, Tasks,
//--------------------------------------------------------------- //---------------------------------------------------------------
// Associations. // Associations.
AssocMaxTransAmount = 100, AssocMaxTransAmount = 100,
@@ -366,21 +367,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
TransactionUpperRefExt, TransactionUpperRefExt,
ShowSiteAddrOnTransView, ShowSiteAddrOnTransView,
ShowTransRefInDropdown, ShowTransRefInDropdown,
AllowRaiseOrderWithQuoteRef, RaiseOrderWithQuoteRef,
TransactionEstimatedAmount, TransactionEstimatedAmount,
TransactionPayments, TransactionPayments,
TransactionDeliveryCosts, TransactionDeliveryCosts,
TransactionSplitTimes, TransactionSplitTimes,
AllowFixedSalesQuoteToWordExport, FixedSalesQuoteToWordExport,
//--------------------------------------------------------------- //---------------------------------------------------------------
// Requirements. // Requirements.
AllowPurchasingPlanning = 220, PurchasingPlanning = 220,
AllowProductionControl, ProductionControl,
AllowDeliveryPlanning, DeliveryPlanning,
/// <summary>For quicker addition of items to order (all with quantity=0).</summary> /// <summary>For quicker addition of items to order (all with quantity=0).</summary>
AllowOrderSelectCommodities, OrderSelectCommodities,
/// <summary>Direct update from main view (default: true).</summary> /// <summary>Direct update from main view (default: true).</summary>
AllowRequirementUpdateInline, RequirementUpdateInline,
/// <summary>Using cost and labour codes (unit and job).</summary> /// <summary>Using cost and labour codes (unit and job).</summary>
EstimateSalesQuotesByCosts, EstimateSalesQuotesByCosts,
/// <summary>To derive processes for commodities from quote cost estimates.</summary> /// <summary>To derive processes for commodities from quote cost estimates.</summary>
@@ -738,13 +739,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
ItemDataType, ItemDataType,
// Contacts. // Contacts.
AffiliateType, AffiliateType,
AssociationType,
AssociationStatusCat,
AddressType, AddressType,
AssociationType,
SystemAccountType, SystemAccountType,
// Transactions. // Transactions.
TransactionType, TransactionType,
/// <summary>Ref. SbmTransaction.StatusCat</summary>
TransactionStatusCat, TransactionStatusCat,
RequirementType, RequirementType,
TaskCodeType, TaskCodeType,
@@ -753,19 +752,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
ConstituentStatusCat, ConstituentStatusCat,
// Miscellaneous. // Miscellaneous.
ItemLinkData, ItemLinkData,
SysParamCategory,
// Commodities. // Commodities.
CommodityType, CommodityType,
CommodityStatusCat, CommodityStatusCat,
PortfolioItemType, PortfolioItemType,
LocationCategory,
LocationFilter,
ContainerCategory, ContainerCategory,
ContainerType, ContainerType,
// Stock. // Stock.
LocationCategory,
LocationFilter,
MovementType, MovementType,
StockLevelType, StockLevelType,
StockLevelSource, StockLevelSource,
SysParamCategory,
// Processes. // Processes.
ProcessCategory, ProcessCategory,
ProcessType, ProcessType,
@@ -782,8 +781,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
VehicleTransType, VehicleTransType,
FuelType, FuelType,
OdometerUnits, OdometerUnits,
// Reference.
RegionType, RegionType,
// Unit of measure.
UnitMeasureCategory, UnitMeasureCategory,
UnitMeasureType, UnitMeasureType,
FinancialType, FinancialType,
@@ -1138,6 +1137,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
Asset_Sale, Asset_Sale,
Asset_Rental, Asset_Rental,
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
public enum OrgOption_Caption public enum OrgOption_Caption
{ {
@@ -1174,6 +1174,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
MenuOpt_ProformaPurchaseInvoices, MenuOpt_ProformaPurchaseInvoices,
MenuOpt_PurchaseInvoices, MenuOpt_PurchaseInvoices,
} }
public static Sbm.OrgOption_Caption TransTypeToOrgOption(Sbm.TransactionType transactionType)
{
switch (transactionType)
{
case TransactionType.Project: return Sbm.OrgOption_Caption.TransType_Project;
case TransactionType.SalesLead: return Sbm.OrgOption_Caption.TransType_SalesLead;
case TransactionType.SalesQuote: return Sbm.OrgOption_Caption.TransType_SalesQuote;
case TransactionType.SalesPO: return Sbm.OrgOption_Caption.TransType_SalesPO;
case TransactionType.ProformaSalesOrder: return Sbm.OrgOption_Caption.TransType_ProformaSalesOrder;
case TransactionType.SalesOrder: return Sbm.OrgOption_Caption.TransType_SalesOrder;
case TransactionType.SalesDispatch: return Sbm.OrgOption_Caption.TransType_SalesDispatch;
case TransactionType.ProformaSalesInvoice: return Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice;
case TransactionType.SalesInvoice: return Sbm.OrgOption_Caption.TransType_SalesInvoice;
case TransactionType.PurchaseQuote: return Sbm.OrgOption_Caption.TransType_PurchaseQuote;
case TransactionType.PurchaseSO: return Sbm.OrgOption_Caption.TransType_PurchaseSO;
case TransactionType.ProformaPurchaseOrder: return Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder;
case TransactionType.PurchaseOrder: return Sbm.OrgOption_Caption.TransType_PurchaseOrder;
case TransactionType.PurchaseDelivery: return Sbm.OrgOption_Caption.TransType_PurchaseDelivery;
case TransactionType.ProformaPurchaseInvoice: return Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice;
case TransactionType.PurchaseInvoice: return Sbm.OrgOption_Caption.TransType_PurchaseInvoice;
}
return 0;
}
public static Sbm.TransactionType OrgOptionToTransType(Sbm.OrgOption_Caption caption)
{
switch (caption)
{
case Sbm.OrgOption_Caption.TransType_Project: return TransactionType.Project;
case Sbm.OrgOption_Caption.TransType_SalesLead: return TransactionType.SalesLead;
case Sbm.OrgOption_Caption.TransType_SalesQuote: return TransactionType.SalesQuote;
case Sbm.OrgOption_Caption.TransType_SalesPO: return TransactionType.SalesPO;
case Sbm.OrgOption_Caption.TransType_ProformaSalesOrder: return TransactionType.ProformaSalesOrder;
case Sbm.OrgOption_Caption.TransType_SalesOrder: return TransactionType.SalesOrder;
case Sbm.OrgOption_Caption.TransType_SalesDispatch: return TransactionType.SalesDispatch;
case Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice: return TransactionType.ProformaSalesInvoice;
case Sbm.OrgOption_Caption.TransType_SalesInvoice: return TransactionType.SalesInvoice;
case Sbm.OrgOption_Caption.TransType_PurchaseQuote: return TransactionType.PurchaseQuote;
case Sbm.OrgOption_Caption.TransType_PurchaseSO: return TransactionType.PurchaseSO;
case Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder: return TransactionType.ProformaPurchaseOrder;
case Sbm.OrgOption_Caption.TransType_PurchaseOrder: return TransactionType.PurchaseOrder;
case Sbm.OrgOption_Caption.TransType_PurchaseDelivery: return TransactionType.PurchaseDelivery;
case Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice: return TransactionType.ProformaPurchaseInvoice;
case Sbm.OrgOption_Caption.TransType_PurchaseInvoice: return TransactionType.PurchaseInvoice;
case Sbm.OrgOption_Caption.MenuOpt_Projects: return TransactionType.Project;
case Sbm.OrgOption_Caption.MenuOpt_SalesLeads: return TransactionType.SalesLead;
case Sbm.OrgOption_Caption.MenuOpt_SalesQuotes: return TransactionType.SalesQuote;
case Sbm.OrgOption_Caption.MenuOpt_SalesPOs: return TransactionType.SalesPO;
case Sbm.OrgOption_Caption.MenuOpt_ProformaSalesOrders: return TransactionType.ProformaSalesOrder;
case Sbm.OrgOption_Caption.MenuOpt_SalesOrders: return TransactionType.SalesOrder;
case Sbm.OrgOption_Caption.MenuOpt_SalesDispatches: return TransactionType.SalesDispatch;
case Sbm.OrgOption_Caption.MenuOpt_ProformaSalesInvoices: return TransactionType.ProformaSalesInvoice;
case Sbm.OrgOption_Caption.MenuOpt_SalesInvoices: return TransactionType.SalesInvoice;
case Sbm.OrgOption_Caption.MenuOpt_PurchaseQuotes: return TransactionType.PurchaseQuote;
case Sbm.OrgOption_Caption.MenuOpt_PurchaseSOs: return TransactionType.PurchaseSO;
case Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseOrders: return TransactionType.ProformaPurchaseOrder;
case Sbm.OrgOption_Caption.MenuOpt_PurchaseOrders: return TransactionType.PurchaseOrder;
case Sbm.OrgOption_Caption.MenuOpt_PurchaseDeliveries: return TransactionType.PurchaseDelivery;
case Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseInvoices: return TransactionType.ProformaPurchaseInvoice;
case Sbm.OrgOption_Caption.MenuOpt_PurchaseInvoices: return TransactionType.PurchaseInvoice;
}
return 0;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
public enum OrgOption_ShowColumn public enum OrgOption_ShowColumn
{ {
@@ -1633,6 +1698,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
Personal = -2, // Task management only. Personal = -2, // Task management only.
NotInternal = -1, NotInternal = -1,
Any = 0, Any = 0,
Unknown = Any,
// NB Do not change the positive values, as tied to the database. // NB Do not change the positive values, as tied to the database.
Internal = 1, Internal = 1,
Customer = 2, Customer = 2,
+95 -95
View File
@@ -21,9 +21,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// A p p l i c a t i o n V i e w s // A p p l i c a t i o n V i e w s
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Jul-2021 SessionConfig parameter added to avoid local creation. To be reviewed/replaced. // Jul-2021 SessionConfig parameter added to avoid local creation. To be reviewed/replaced.
public static bool IsViewApplicable(SbmSessionConsole sessionConfig, Sbm.View view) public static bool IsViewApplicable(SbmSessionConsole sessionConsole, Sbm.View view)
{ {
ISbmSecurityProfile_Core securityProfile = sessionConfig.UserContext.SecurityProfile_Core; ISbmSecurityProfile_Core securityProfile = sessionConsole.UserContext.SecurityProfile_Core;
switch (view) switch (view)
{ {
//----------------------------------------------------------- //-----------------------------------------------------------
@@ -32,210 +32,210 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
case Sbm.View.Main: case Sbm.View.Main:
return true; return true;
case Sbm.View.Console: case Sbm.View.Console:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowConsoleView)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.ConsoleView)) return false;
if (!sessionConfig.GetConsoleViewDfn().HasContent()) return false; if (!sessionConsole.GetConsoleViewDfn().HasContent()) return false;
return true; return true;
case Sbm.View.Diary: case Sbm.View.Diary:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.DiaryView)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.DiaryView)) return false;
return true; return true;
//----------------------------------------------------------- //-----------------------------------------------------------
// Contacts. // Contacts.
case Sbm.View.Contacts_Affiliates: case Sbm.View.Contacts_Affiliates:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
return true; return true;
case Sbm.View.Contacts_ContactGroups: case Sbm.View.Contacts_ContactGroups:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
return true; return true;
case Sbm.View.Contacts_Associations: case Sbm.View.Contacts_Associations:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AnyAssociationView)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.AnyAssociationView)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_Customer: case Sbm.View.Contacts_Associations_Customer:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_Supplier: case Sbm.View.Contacts_Associations_Supplier:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_Associate: case Sbm.View.Contacts_Associations_Associate:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Associate)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Associate)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_Stockist: case Sbm.View.Contacts_Associations_Stockist:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Stockist)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Stockist)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_FinanceAgency: case Sbm.View.Contacts_Associations_FinanceAgency:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.FinanceAgency)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.FinanceAgency)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_Member: case Sbm.View.Contacts_Associations_Member:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Member)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Member)) return false;
return true; return true;
case Sbm.View.Contacts_Associations_Contractor: case Sbm.View.Contacts_Associations_Contractor:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Contractor)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Contractor)) return false;
return true; return true;
//----------------------------------------------------------- //-----------------------------------------------------------
// Commodities. // Commodities.
case Sbm.View.Commodities: case Sbm.View.Commodities:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false;
return true; return true;
case Sbm.View.Commodity_Locations: case Sbm.View.Commodity_Locations:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false;
return true; return true;
case Sbm.View.Commodity_Containers: case Sbm.View.Commodity_Containers:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false;
return true; return true;
case Sbm.View.Commodity_Portfolio: case Sbm.View.Commodity_Portfolio:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false;
return true; return true;
case Sbm.View.Commodity_SalesBudget: case Sbm.View.Commodity_SalesBudget:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false;
return true; return true;
case Sbm.View.PriceSets: case Sbm.View.PriceSets:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false;
//if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowPriceSets)) return false; //if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowPriceSets)) return false;
return true; return true;
//----------------------------------------------------------- //-----------------------------------------------------------
// Assets. // Assets.
case Sbm.View.AssetCategories: case Sbm.View.AssetCategories:
case Sbm.View.Assets: case Sbm.View.Assets:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Assets)) return false;
return true; return true;
case Sbm.View.VehicleClasses: case Sbm.View.VehicleClasses:
case Sbm.View.Vehicles: case Sbm.View.Vehicles:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Assets)) return false;
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles)) return false;
return true; return true;
//----------------------------------------------------------- //-----------------------------------------------------------
// Transactions. // Transactions.
case Sbm.View.Transactions: case Sbm.View.Transactions:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AnyTransactionView)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.AnyTransactionView)) return false;
return true; return true;
case Sbm.View.Transactions_Project: case Sbm.View.Transactions_Project:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.Project)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.Project)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.Project)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.Project)) return false;
return true; return true;
case Sbm.View.Transactions_PurchaseQuote: case Sbm.View.Transactions_PurchaseQuote:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseQuote)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseQuote)) return false;
return true; return true;
case Sbm.View.Transactions_ProformaPurchaseOrder: case Sbm.View.Transactions_ProformaPurchaseOrder:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseOrder)) return false;
return true; return true;
case Sbm.View.Transactions_PurchaseOrder: case Sbm.View.Transactions_PurchaseOrder:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseOrder)) return false;
return true; return true;
case Sbm.View.Transactions_PurchaseSO: case Sbm.View.Transactions_PurchaseSO:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseSO)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseSO)) return false;
return true; return true;
case Sbm.View.Transactions_PurchaseDelivery: case Sbm.View.Transactions_PurchaseDelivery:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseDelivery)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseDelivery)) return false;
return true; return true;
case Sbm.View.Transactions_ProformaPurchaseInvoice: case Sbm.View.Transactions_ProformaPurchaseInvoice:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false;
return true; return true;
case Sbm.View.Transactions_PurchaseInvoice: case Sbm.View.Transactions_PurchaseInvoice:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseInvoice)) return false;
return true; return true;
case Sbm.View.Transactions_SalesLead: case Sbm.View.Transactions_SalesLead:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesLead)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesLead)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesLead)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesLead)) return false;
return true; return true;
case Sbm.View.Transactions_SalesQuote: case Sbm.View.Transactions_SalesQuote:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesQuote)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesQuote)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesQuote)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesQuote)) return false;
return true; return true;
case Sbm.View.Transactions_ProformaSalesOrder: case Sbm.View.Transactions_ProformaSalesOrder:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaSalesOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaSalesOrder)) return false;
return true; return true;
case Sbm.View.Transactions_SalesOrder: case Sbm.View.Transactions_SalesOrder:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesOrder)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesOrder)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesOrder)) return false;
return true; return true;
case Sbm.View.Transactions_SalesPO: case Sbm.View.Transactions_SalesPO:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesPO)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesPO)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesPO)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesPO)) return false;
return true; return true;
case Sbm.View.Transactions_SalesDispatch: case Sbm.View.Transactions_SalesDispatch:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesDispatch)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesDispatch)) return false;
return true; return true;
case Sbm.View.Transactions_ProformaSalesInvoice: case Sbm.View.Transactions_ProformaSalesInvoice:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false;
return true; return true;
case Sbm.View.Transactions_SalesInvoice: case Sbm.View.Transactions_SalesInvoice:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false;
if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false;
if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false;
return true; return true;
//----------------------------------------------------------- //-----------------------------------------------------------
// Planning. // Planning.
case Sbm.View.Transactions_PurchasingPlanning: case Sbm.View.Transactions_PurchasingPlanning:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowPurchasingPlanning)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.PurchasingPlanning)) return false;
return true; return true;
case Sbm.View.Transactions_ProductionControl: case Sbm.View.Transactions_ProductionControl:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowProductionControl)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.ProductionControl)) return false;
return true; return true;
case Sbm.View.Transactions_DeliveryPlanning: case Sbm.View.Transactions_DeliveryPlanning:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false;
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowDeliveryPlanning)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.DeliveryPlanning)) return false;
return true; return true;
//----------------------------------------------------------- //-----------------------------------------------------------
// Other. // Other.
case Sbm.View.SystemAccounts: case Sbm.View.SystemAccounts:
case Sbm.View.SystemUsers: case Sbm.View.SystemUsers:
if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false;
// Interfaces must be available. // Interfaces must be available.
using (SaInterfaceConsole interfaceConsole = SbmGlobals.Application.CreateInterfaceConsole(sessionConfig.UserContext)) using (SaInterfaceConsole interfaceConsole = SbmGlobals.Application.CreateInterfaceConsole(sessionConsole.UserContext))
{ {
if (interfaceConsole == null || !interfaceConsole.DatabaseIsValid) return false; if (interfaceConsole == null || !interfaceConsole.DatabaseIsValid) return false;
// System Account & User tables must be available. // System Account & User tables must be available.
ISacsDatabase busMgrDb = SbmGlobals.Application.GetBusMgrDatabase(sessionConfig.UserContext.SessionContext); ISacsDatabase busMgrDb = SbmGlobals.Application.GetBusMgrDatabase(sessionConsole.UserContext.SessionContext);
if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemAccount)) return false; if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemAccount)) return false;
if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemUser)) return false; if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemUser)) return false;
} }
@@ -268,17 +268,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// A p p l i c a t i o n M e n u // A p p l i c a t i o n M e n u
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static bool IsMenuOptionApplicable(SbmSessionConsole sessionConfig, Sbm.MenuOption menuOption) public static bool IsMenuOptionApplicable(SbmSessionConsole sessionConsole, Sbm.MenuOption menuOption)
{ {
if (!sessionConfig.UserContext.ValidUser) if (!sessionConsole.UserContext.ValidUser)
{ {
// ToDo Only Login menu option available. // ToDo Only Login menu option available.
return false; return false;
} }
Sbm.View view = GetViewForMenuOption(sessionConfig.UserContext.SessionContext, menuOption); Sbm.View view = GetViewForMenuOption(sessionConsole.UserContext.SessionContext, menuOption);
if (view != Sbm.View.Unknown) if (view != Sbm.View.Unknown)
// View options. // View options.
return IsViewApplicable(sessionConfig, GetViewForMenuOption(sessionConfig.UserContext.SessionContext, menuOption)); return IsViewApplicable(sessionConsole, GetViewForMenuOption(sessionConsole.UserContext.SessionContext, menuOption));
// Non-view options. // Non-view options.
switch (menuOption) switch (menuOption)
@@ -296,7 +296,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//----------------------------------------------------------- //-----------------------------------------------------------
// Actions. // Actions.
case Sbm.MenuOption.Timesheet: case Sbm.MenuOption.Timesheet:
return sessionConfig.AllowOption(Sbm.ConfigOption.TimeRecording); return sessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording);
//----------------------------------------------------------- //-----------------------------------------------------------
} }
SaLogger.Warn($"{SysUtil.Fn} Unsupport menu option - {menuOption.ToString()}"); SaLogger.Warn($"{SysUtil.Fn} Unsupport menu option - {menuOption.ToString()}");
+14 -12
View File
@@ -58,8 +58,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
return GetBusMgrDatabase(sessionContext).CreateDbInfo(); return GetBusMgrDatabase(sessionContext).CreateDbInfo();
} }
// Instance configuration. // Instance and Organisation profiles.
public abstract SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext); public abstract SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext);
public abstract SbmInstanceDataCache GetInstanceDataCache(SbmSessionContext sessionContext);
public abstract SbmOrganisationConfig GetOrganisationConfig(ISbmUserOrganisationContext userContext);
// Database utilities. // Database utilities.
public IDatabaseInfo CreateDbInfo(ISacsDatabase db) public IDatabaseInfo CreateDbInfo(ISacsDatabase db)
{ {
@@ -84,17 +86,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Create consoles. // Create consoles.
public abstract SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext); public abstract SbmSessionConsole CreateSessionConsole(ISbmUserOrganisationContext userContext);
public abstract SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext); public abstract SaDiaryConsole CreateDiaryConsole(ISbmUserOrganisationContext userContext);
public abstract SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext); public abstract SaSecurityConsole CreateSecurityConsole(ISbmUserOrganisationContext userContext);
public abstract SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext_Core userContext); public abstract SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserOrganisationContext userContext);
public abstract SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext); public abstract SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserOrganisationContext userContext);
public abstract SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext); public abstract SaItemDataConsole CreateItemDataConsole(ISbmUserOrganisationContext userContext);
public abstract SaItemDocConsole CreateItemDocConsole(ISbmUserContext_Core userContext); public abstract SaItemDocConsole CreateItemDocConsole(ISbmUserOrganisationContext userContext);
public abstract SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext_Core userContext); public abstract SaItemOptionConsole CreateItemOptionConsole(ISbmUserOrganisationContext userContext);
public abstract SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext_Core userContext); public abstract SaInterfaceConsole CreateInterfaceConsole(ISbmUserOrganisationContext userContext);
public abstract SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext_Core userContext); public abstract SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserOrganisationContext userContext);
public abstract SbmEmailConsole CreateEmailConsole(ISbmUserContext_Core userContext); public abstract SbmEmailConsole CreateEmailConsole(ISbmUserOrganisationContext userContext);
//------------------------------------------------------------------- //-------------------------------------------------------------------
} }
@@ -101,7 +101,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public virtual String LinkSuffix { get { return ""; } } public virtual String LinkSuffix { get { return ""; } }
//--------------------------------------------------------------- //---------------------------------------------------------------
// Utilities. // Utilities.
public virtual bool Refresh(ISbmUserContext_Core userContext) public virtual bool Refresh(ISbmUserOrganisationContext userContext)
{ {
ItemCount = 0; ItemCount = 0;
switch (LinkType) switch (LinkType)
@@ -1,6 +1,7 @@
using Org.BouncyCastle.Math.EC; using Org.BouncyCastle.Math.EC;
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -13,25 +14,42 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
//======================================================================= //=======================================================================
/// <summary> /// <summary>
/// Application configuration associated with an instance. /// Application and Owner configuration associated with an instance.
/// </summary> /// </summary>
public abstract class SbmInstanceConfig public abstract class SbmInstanceConfig : ISbmInstanceConfig
{ {
//-------------------------------------------------------------------
// Construction.
protected SbmInstanceConfig() { }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Application options. // Application options.
public abstract bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse); public abstract bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse);
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Allowed data component types. // Contacts.
// Supported affiliate types. // Supported affiliate types.
public abstract bool AllowAffiliateType(Sbm.AffiliateType type, bool defaultResponse); public abstract bool AllowAffiliateType(Sbm.AffiliateType type, bool defaultResponse);
// Supported Association types. // Supported Association types.
public abstract bool AllowAssociationType(Sbm.AssociationType type, bool defaultResponse); public abstract bool AllowAssociationType(Sbm.AssociationType type, bool defaultResponse);
//-------------------------------------------------------------------
// Transactions.
// Supported Transaction types. // Supported Transaction types.
public abstract bool AllowTransactionType(Sbm.TransactionType type, bool defaultResponse); public abstract bool AllowTransactionType(Sbm.TransactionType type, bool defaultResponse);
//-------------------------------------------------------------------
// Interfaces.
/// <summary>
/// Whether the Interface Category is allowed.
/// </summary>
public abstract bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse);
//------------------------------------------------------------------- //-------------------------------------------------------------------
} }
//======================================================================= //=======================================================================
@@ -0,0 +1,32 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.ItemOptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
/// <summary>
/// Practically persistant/static data stored in instance database, eg. Owner configuration options.
/// </summary>
public abstract class SbmInstanceDataCache : SacsDisposable
{
//-------------------------------------------------------------------
// Construction.
public SbmInstanceDataCache() { }
protected override void Dispose(bool disposing)
{
}
//-------------------------------------------------------------------
// Retrieve Item Options for Owner Organisation configuration.
public abstract List<SaItemOption> GetOwnerOptions(ISbmUserOrganisationContext userContext);
//-------------------------------------------------------------------
}
//=======================================================================
}
+254 -104
View File
@@ -20,37 +20,58 @@ using Sarand.Net.Standard.Base.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
namespace Sarand.BusinessMgr.Net.Standard.Base.App namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
//======================================================================= //=======================================================================
public class SbmInternals : SacsDisposable public class SbmInternals : SacsDisposable, ISbmOrganisationConfig
{ {
//-------------------------------------------------------------------
// Definitions.
/// <summary>
/// Internal User Context for read-only database access when this class is used outside of user specific sessions.
/// <para>- data caches etc.</para>
/// </summary>
private class SbmUserContext_Internal : SbmUserContext
{
public SbmUserContext_Internal(SbmSessionContext sessionContext) : base(sessionContext) { }
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Data members. // Data members.
private readonly SbmSystem system = SbmGlobals.System; private readonly SbmSystem system = SbmGlobals.System;
private SbmAccountsDfn accountsDfn; private SbmAccountsDfn accountsDfn;
// Managers. // Managers.
private SbmAccountMgr accountMgr; private class Managers
private SbmAssetMgr assetMgr; {
private SbmCommodityMgr commodityMgr; public SbmAccountMgr accountMgr;
private SbmPriceMgr priceMgr; public SbmAssetMgr assetMgr;
private SbmTransactionMgr transactionMgr; public SbmCommodityMgr commodityMgr;
private SbmStockMgr stockMgr; public SbmPriceMgr priceMgr;
private SbmProcessMgr processMgr; public SbmTransactionMgr transactionMgr;
private SbmDataItemMgr dataItemMgr; public SbmStockMgr stockMgr;
public SbmProcessMgr processMgr;
public SbmDataItemMgr dataItemMgr;
}
private readonly Managers mgr = new Managers();
// Consoles. // Consoles.
private SbmSessionConsole sessionConsole; private class Consoles
private SaDiaryConsole diaryConsole; {
private SaSecurityConsole securityConsole; public SbmSessionConsole sessionConsole;
private SaCodeTypeConsole codeTypeConsole; public SaDiaryConsole diaryConsole;
private SaReferenceDataConsole referenceDataConsole; public SaSecurityConsole securityConsole;
private SaUpdateLogConsole updateLogConsole; public SaCodeTypeConsole codeTypeConsole;
private SaInterfaceConsole interfaceConsole; public SaReferenceDataConsole referenceDataConsole;
private SaItemDocConsole itemDocConsole; public SaUpdateLogConsole updateLogConsole;
private SaItemOptionConsole itemOptionConsole; public SaInterfaceConsole interfaceConsole;
private SaItemDataConsole itemDataConsole; public SaItemDocConsole itemDocConsole;
public SaItemOptionConsole itemOptionConsole;
public SaItemDataConsole itemDataConsole;
public SbmEmailConsole emailConsole; public SbmEmailConsole emailConsole;
}
private readonly Consoles con = new Consoles();
// Configurations. // Configurations.
private SbmStockControlConfig stockControlConfig; private SbmStockControlConfig stockControlConfig;
private SbmRequirementCostingConfig requirementCostingConfig; private SbmRequirementCostingConfig requirementCostingConfig;
@@ -61,46 +82,53 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmInternals(ISbmUserContext_Core userContext) public SbmInternals(SbmSessionContext sessionContext)
{
UserContext = new SbmUserContext_Internal(sessionContext);
ReadOnly = true;
}
public SbmInternals(ISbmUserOrganisationContext userContext)
{ {
UserContext = userContext; UserContext = userContext;
ReadOnly = false;
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing) if (disposing)
{ {
// Managers. // Managers.
if (accountMgr != null) accountMgr.Dispose(); if (mgr.accountMgr != null) mgr.accountMgr.Dispose();
if (assetMgr != null) assetMgr.Dispose(); if (mgr.assetMgr != null) mgr.assetMgr.Dispose();
if (commodityMgr != null) commodityMgr.Dispose(); if (mgr.commodityMgr != null) mgr.commodityMgr.Dispose();
if (priceMgr != null) priceMgr.Dispose(); if (mgr.priceMgr != null) mgr.priceMgr.Dispose();
if (transactionMgr != null) transactionMgr.Dispose(); if (mgr.transactionMgr != null) mgr.transactionMgr.Dispose();
if (stockMgr != null) stockMgr.Dispose(); if (mgr.stockMgr != null) mgr.stockMgr.Dispose();
if (processMgr != null) processMgr.Dispose(); if (mgr.processMgr != null) mgr.processMgr.Dispose();
if (dataItemMgr != null) dataItemMgr.Dispose(); if (mgr.dataItemMgr != null) mgr.dataItemMgr.Dispose();
// Reference data. // Reference data.
if (currencies != null) currencies.ClearAndDispose(); if (currencies != null) currencies.ClearAndDispose();
if (taxCodes != null) taxCodes.ClearAndDispose(); if (taxCodes != null) taxCodes.ClearAndDispose();
if (unitsOfMeasure != null) unitsOfMeasure.ClearAndDispose(); if (unitsOfMeasure != null) unitsOfMeasure.ClearAndDispose();
// Consoles. // Consoles.
if (sessionConsole != null) sessionConsole.Dispose(); if (con.sessionConsole != null) con.sessionConsole.Dispose();
if (diaryConsole != null) diaryConsole.Dispose(); if (con.diaryConsole != null) con.diaryConsole.Dispose();
if (securityConsole != null) securityConsole.Dispose(); if (con.securityConsole != null) con.securityConsole.Dispose();
if (codeTypeConsole != null) codeTypeConsole.Dispose(); if (con.codeTypeConsole != null) con.codeTypeConsole.Dispose();
if (referenceDataConsole != null) referenceDataConsole.Dispose(); if (con.referenceDataConsole != null) con.referenceDataConsole.Dispose();
if (updateLogConsole != null) updateLogConsole.Dispose(); if (con.updateLogConsole != null) con.updateLogConsole.Dispose();
if (interfaceConsole != null) interfaceConsole.Dispose(); if (con.interfaceConsole != null) con.interfaceConsole.Dispose();
if (itemDocConsole != null) itemDocConsole.Dispose(); if (con.itemDocConsole != null) con.itemDocConsole.Dispose();
if (itemOptionConsole != null) itemOptionConsole.Dispose(); if (con.itemOptionConsole != null) con.itemOptionConsole.Dispose();
if (itemDataConsole != null) itemDataConsole.Dispose(); if (con.itemDataConsole != null) con.itemDataConsole.Dispose();
if (itemDataConsole != null) itemDataConsole.Dispose(); if (con.itemDataConsole != null) con.itemDataConsole.Dispose();
} }
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Session properties. // Session properties.
public SbmApplication Application { get { return SbmGlobals.Application; } } public SbmApplication Application { get { return SbmGlobals.Application; } }
public ISbmUserContext_Core UserContext { get; } public bool ReadOnly { get; }
public ISbmUserOrganisationContext UserContext { get; }
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
public ISbmSecurityProfile_Core SecurityProfile { get { return UserContext.SecurityProfile_Core; } } public ISbmSecurityProfile_Core SecurityProfile { get { return UserContext.SecurityProfile_Core; } }
public SbmAccountsDfn AccountsDfn { get { if (accountsDfn == null) accountsDfn = new SbmAccountsDfn(UserContext); { return accountsDfn; } } } public SbmAccountsDfn AccountsDfn { get { if (accountsDfn == null) accountsDfn = new SbmAccountsDfn(UserContext); { return accountsDfn; } } }
@@ -111,17 +139,75 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// System codes. // System codes.
private Dictionary<Sbm.SystemCode, List<TypeCodeDesc>> systemCodeCache = new Dictionary<Sbm.SystemCode, List<TypeCodeDesc>>(); private Dictionary<Sbm.SystemCode, List<TypeCodeDesc>> systemCodeCache = new Dictionary<Sbm.SystemCode, List<TypeCodeDesc>>();
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) public List<TypeCodeDesc> GetSystemCodes(Sbm.SystemCode systemCode)
{ {
if (!systemCodeCache.ContainsKey(systemCode)) if (!systemCodeCache.ContainsKey(systemCode))
systemCodeCache.Add(systemCode, SbmSystem.GetCodesOfType(UserContext, systemCode)); {
List<TypeCodeDesc> codes = new List<TypeCodeDesc>();
foreach (TypeCodeDesc code in SbmSystem.GetSystemCodes(systemCode))
{
switch (systemCode)
{
case Sbm.SystemCode.AffiliateType:
if (!SessionConsole.AllowAffiliateType((Sbm.AffiliateType)code.Type)) continue;
break;
case Sbm.SystemCode.AssociationType:
if (!SessionConsole.AllowAssociationType((Sbm.AssociationType)code.Type)) continue;
break;
case Sbm.SystemCode.TransactionType:
if (!SessionConsole.AllowTransactionType((Sbm.TransactionType)code.Type)) continue;
break;
case Sbm.SystemCode.CommodityType:
if (code.Type == (int)Sbm.CommodityType.Asset && (!SessionConsole.AllowOption(Sbm.ConfigOption.Assets) || !AssetMgr.AssetDatabaseIsValid())) continue;
break;
case Sbm.SystemCode.ProcessCategory:
if (code.Type == (int)Sbm.ProcessCategory.Commodity && !SessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) continue;
if (code.Type == (int)Sbm.ProcessCategory.Asset && (!SessionConsole.AllowOption(Sbm.ConfigOption.Assets) || !AssetMgr.AssetDatabaseIsValid())) continue;
break;
case Sbm.SystemCode.FinancialType:
if ((code.Type == (int)Sbm.FinancialType.CommoditySupply || code.Type == (int)Sbm.FinancialType.CommoditySales) && !SessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) continue;
break;
case Sbm.SystemCode.InterfaceType_Website:
if (code.Type == (int)Sbm.InterfaceType_Website.WebStore && !SessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_Website.JoomlaVirtueMart && !SessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_Website.MiMoWeb && !SessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)code.Type)) continue;
break;
case Sbm.SystemCode.InterfaceType_System:
if (code.Type == (int)Sbm.InterfaceType_System.MSOutlook && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.PostcodeAnywhere && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Bac && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Pvh && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Cap && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Hpi && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Anchor_OrderFulfilment && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
if (code.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
break;
case Sbm.SystemCode.OrgOption_PeriodDays:
if (code.Type == (int)Sbm.OrgOption_PeriodDays.UpdateClosedTransaction_DispatchDetails && !SessionConsole.AllowOption(ConfigOption.DeliveryPlanning)) continue;
if (code.Type == (int)Sbm.OrgOption_PeriodDays.UpdateStockLevelsInPast && !SessionConsole.AllowInterface(SaInterfaceCategory.System, (short)code.Type)) continue;
break;
case Sbm.SystemCode.OrgOption_PeriodWeeks:
if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.Timesheets && !SessionConsole.AllowOption(ConfigOption.TimeRecording)) continue;
if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control && !SessionConsole.AllowOption(ConfigOption.TimeRecording)) continue;
if (code.Type == (int)Sbm.OrgOption_PeriodWeeks.ImminentStockDue && !SessionConsole.GetOwnerOption_AllowOption(OrgOption_AllowOption.ImminentStock)) continue;
break;
case Sbm.SystemCode.OrgOption_Caption:
if (!SessionConsole.AllowTransactionType(Sbm.OrgOptionToTransType((Sbm.OrgOption_Caption)code.Type))) continue;
break;
}
codes.Add(code);
}
systemCodeCache.Add(systemCode, codes);
}
return new List<TypeCodeDesc>(systemCodeCache.GetValueOrDefault(systemCode, new List<TypeCodeDesc>())); return new List<TypeCodeDesc>(systemCodeCache.GetValueOrDefault(systemCode, new List<TypeCodeDesc>()));
} }
public List<TypeCodeDesc> AffiliateTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AffiliateType); } } // Selection of specific system code types.
public List<TypeCodeDesc> AssociationTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AssociationType); } } public List<TypeCodeDesc> AffiliateTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AffiliateType); } }
public List<TypeCodeDesc> CommodityTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.CommodityType); } } public List<TypeCodeDesc> AssociationTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AssociationType); } }
public List<TypeCodeDesc> AssetTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AssetType); } } public List<TypeCodeDesc> CommodityTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.CommodityType); } }
public List<TypeCodeDesc> TransactionTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.TransactionType); } } public List<TypeCodeDesc> AssetTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AssetType); } }
public List<TypeCodeDesc> TransactionTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.TransactionType); } }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Code types. // Code types.
@@ -143,72 +229,72 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
get get
{ {
if (accountMgr == null) if (mgr.accountMgr == null)
accountMgr = system.CreateAccountMgr(UserContext); mgr.accountMgr = system.CreateAccountMgr(this);
return accountMgr; return mgr.accountMgr;
} }
} }
public SbmAssetMgr AssetMgr public SbmAssetMgr AssetMgr
{ {
get get
{ {
if (assetMgr == null) if (mgr.assetMgr == null)
assetMgr = system.CreateAssetMgr(UserContext); mgr.assetMgr = system.CreateAssetMgr(this);
return assetMgr; return mgr.assetMgr;
} }
} }
public SbmCommodityMgr CommodityMgr public SbmCommodityMgr CommodityMgr
{ {
get get
{ {
if (commodityMgr == null) if (mgr.commodityMgr == null)
commodityMgr = system.CreateCommodityMgr(UserContext); mgr.commodityMgr = system.CreateCommodityMgr(this);
return commodityMgr; return mgr.commodityMgr;
} }
} }
public SbmPriceMgr PriceMgr public SbmPriceMgr PriceMgr
{ {
get get
{ {
if (priceMgr == null) if (mgr.priceMgr == null)
priceMgr = system.CreatePriceMgr(UserContext); mgr.priceMgr = system.CreatePriceMgr(this);
return priceMgr; return mgr.priceMgr;
} }
} }
public SbmTransactionMgr TransactionMgr public SbmTransactionMgr TransactionMgr
{ {
get get
{ {
if (transactionMgr == null) if (mgr.transactionMgr == null)
transactionMgr = system.CreateTransactionMgr(UserContext); mgr.transactionMgr = system.CreateTransactionMgr(this);
return transactionMgr; return mgr.transactionMgr;
} }
} }
public SbmStockMgr StockMgr public SbmStockMgr StockMgr
{ {
get get
{ {
if (stockMgr == null) if (mgr.stockMgr == null)
stockMgr = system.CreateStockMgr(UserContext); mgr.stockMgr = system.CreateStockMgr(this);
return stockMgr; return mgr.stockMgr;
} }
} }
public SbmProcessMgr ProcessMgr public SbmProcessMgr ProcessMgr
{ {
get get
{ {
if (processMgr == null) if (mgr.processMgr == null)
processMgr = system.CreateProcessMgr(UserContext); mgr.processMgr = system.CreateProcessMgr(this);
return processMgr; return mgr.processMgr;
} }
} }
public SbmDataItemMgr DataItemMgr public SbmDataItemMgr DataItemMgr
{ {
get get
{ {
if (dataItemMgr == null) if (mgr.dataItemMgr == null)
dataItemMgr = SbmGlobals.System.CreateDataItemMgr(UserContext); mgr.dataItemMgr = SbmGlobals.System.CreateDataItemMgr(this);
return dataItemMgr; return mgr.dataItemMgr;
} }
} }
@@ -218,90 +304,90 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
get get
{ {
if (sessionConsole == null) if (con.sessionConsole == null)
sessionConsole = Application.CreateSessionConsole(UserContext); con.sessionConsole = Application.CreateSessionConsole(UserContext);
return sessionConsole; return con.sessionConsole;
} }
} }
public SaDiaryConsole DiaryConsole public SaDiaryConsole DiaryConsole
{ {
get get
{ {
if (diaryConsole == null) if (con.diaryConsole == null)
diaryConsole = Application.CreateDiaryConsole(UserContext); con.diaryConsole = Application.CreateDiaryConsole(UserContext);
return DiaryConsole; return con.diaryConsole;
} }
} }
public SaSecurityConsole SecurityConsole public SaSecurityConsole SecurityConsole
{ {
get get
{ {
if (securityConsole == null) if (con.securityConsole == null)
securityConsole = Application.CreateSecurityConsole(UserContext); con.securityConsole = Application.CreateSecurityConsole(UserContext);
return securityConsole; return con.securityConsole;
} }
} }
public SaCodeTypeConsole CodeTypeConsole public SaCodeTypeConsole CodeTypeConsole
{ {
get get
{ {
if (codeTypeConsole == null) if (con.codeTypeConsole == null)
codeTypeConsole = Application.CreateCodeTypeConsole(UserContext); con.codeTypeConsole = Application.CreateCodeTypeConsole(UserContext);
return codeTypeConsole; return con.codeTypeConsole;
} }
} }
public SaReferenceDataConsole ReferenceDataConsole public SaReferenceDataConsole ReferenceDataConsole
{ {
get get
{ {
if (referenceDataConsole == null) if (con.referenceDataConsole == null)
referenceDataConsole = Application.CreateReferenceDataConsole(UserContext); con.referenceDataConsole = Application.CreateReferenceDataConsole(UserContext);
return referenceDataConsole; return con.referenceDataConsole;
} }
} }
public SaUpdateLogConsole UpdateLogConsole public SaUpdateLogConsole UpdateLogConsole
{ {
get get
{ {
if (updateLogConsole == null) if (con.updateLogConsole == null)
updateLogConsole = Application.CreateUpdateLogConsole(UserContext); con.updateLogConsole = Application.CreateUpdateLogConsole(UserContext);
return updateLogConsole; return con.updateLogConsole;
} }
} }
public SaInterfaceConsole InterfaceConsole public SaInterfaceConsole InterfaceConsole
{ {
get get
{ {
if (interfaceConsole == null) if (con.interfaceConsole == null)
interfaceConsole = Application.CreateInterfaceConsole(UserContext); con.interfaceConsole = Application.CreateInterfaceConsole(UserContext);
return interfaceConsole; return con.interfaceConsole;
} }
} }
public SaItemDocConsole ItemDocConsole public SaItemDocConsole ItemDocConsole
{ {
get get
{ {
if (itemDocConsole == null) if (con.itemDocConsole == null)
itemDocConsole = Application.CreateItemDocConsole(UserContext); con.itemDocConsole = Application.CreateItemDocConsole(UserContext);
return itemDocConsole; return con.itemDocConsole;
} }
} }
public SaItemOptionConsole ItemOptionConsole public SaItemOptionConsole ItemOptionConsole
{ {
get get
{ {
if (itemOptionConsole == null) if (con.itemOptionConsole == null)
itemOptionConsole = Application.CreateItemOptionConsole(UserContext); con.itemOptionConsole = Application.CreateItemOptionConsole(UserContext);
return itemOptionConsole; return con.itemOptionConsole;
} }
} }
public SaItemDataConsole ItemDataConsole public SaItemDataConsole ItemDataConsole
{ {
get get
{ {
if (itemDataConsole == null) if (con.itemDataConsole == null)
itemDataConsole = Application.CreateItemDataConsole(UserContext); con.itemDataConsole = Application.CreateItemDataConsole(UserContext);
return itemDataConsole; return con.itemDataConsole;
} }
} }
@@ -312,9 +398,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
get get
{ {
if (emailConsole == null) if (con.emailConsole == null)
emailConsole = Application.CreateEmailConsole(UserContext); con.emailConsole = Application.CreateEmailConsole(UserContext);
return emailConsole; return con.emailConsole;
} }
} }
@@ -438,6 +524,70 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
return unitsOfMeasure.Find(item => item.Category == uomCategory && item.UnitType == uomType); return unitsOfMeasure.Find(item => item.Category == uomCategory && item.UnitType == uomType);
} }
//-------------------------------------------------------------------
// Organisation configuration.
//-------------------------------------------------------------------
public String GetOrganisationOption(Sbm.OrganisationOption option, String context)
{
return SessionConsole.OrganisationConfig.GetOrganisationOption(option, context);
}
public String GetOrganisationOption(String optionName, String context)
{
return SessionConsole.OrganisationConfig.GetOrganisationOption(optionName, context);
}
public String GetOwnerOption_Value(Sbm.OrgOption_Value value)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_Value(value);
}
public String GetOwnerOption_Folder(Sbm.OrgOption_Folder folder)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_Folder(folder);
}
public bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption option)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_AllowOption(option);
}
public String GetOwnerOption_Caption(Sbm.OrgOption_Caption caption, String defaultValue)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_Caption(caption, defaultValue);
}
public bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx column)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_ShowField(column);
}
public bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn column)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_ShowColumn(column);
}
public String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx column, String defautValue)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_FieldLabel(column, defautValue);
}
public int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes limit, int defautValue)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_Minutes(limit, defautValue);
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays limit, int defautValue)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_UpdateLimit(limit, defautValue);
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks limit, int defautValue)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_UpdateLimit(limit, defautValue);
}
public int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals decimals, int defautValue = 2)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_NumericDecimals(decimals, defautValue);
}
public Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityType)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_CommodityType(commodityType);
}
public SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation stockLocation)
{
return SessionConsole.OrganisationConfig.GetOwnerOption_StockLocation(stockLocation);
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
} }
//======================================================================= //=======================================================================
@@ -0,0 +1,181 @@
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Base.App
{
//=======================================================================
public abstract class SbmOrganisationConfig : SacsDisposable, ISbmOrganisationConfig
{
//-------------------------------------------------------------------
// Data members.
private List<TypeCodeDesc> assocOptions;
private List<TypeCodeDesc> contextValues;
private List<TypeCodeDesc> contextFolders;
private List<TypeCodeDesc> contextAllowOptions;
private List<TypeCodeDesc> contextCaptions;
private List<TypeCodeDesc> contextShowColumns;
private List<TypeCodeDesc> contextShowFields;
private List<TypeCodeDesc> contextFieldLabels;
private List<TypeCodeDesc> contextMinutes;
private List<TypeCodeDesc> contextPeriodDays;
private List<TypeCodeDesc> contextPeriodWeeks;
private List<TypeCodeDesc> contextNumericDecimals;
private List<TypeCodeDesc> contextCommodityTypes;
private List<TypeCodeDesc> commodityTypes;
private List<TypeCodeDesc> contextSalesLocations;
//-------------------------------------------------------------------
// Construction.
protected SbmOrganisationConfig()
{
}
protected override void Dispose(bool disposing) { }
//-------------------------------------------------------------------
// Properties.
protected abstract ISbmUserOrganisationContext UserContext { get; }
protected abstract SbmInstanceDataCache InstanceDataCache { get; }
//-------------------------------------------------------------------
// Organisation configuration.
public String GetOrganisationOption(Sbm.OrganisationOption option, String context)
{
if (assocOptions == null) assocOptions = SbmSystem.GetSystemCodes(Sbm.SystemCode.AssociationOption);
String optionName = assocOptions.GetCodeForType(option);
return GetOrganisationOption(optionName, context);
}
public String GetOrganisationOption(String optionName, String context)
{
// Retrieve the requested value from the cache.
return InstanceDataCache.GetOwnerOptions(UserContext).GetOptionValue(optionName, context);
}
public String GetOwnerOption_Value(Sbm.OrgOption_Value value)
{
if (contextValues == null) contextValues = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_Value);
String context = contextValues.GetCodeForType(value);
return GetOrganisationOption(Sbm.OrganisationOption.Value, context).Trim();
}
public String GetOwnerOption_Folder(Sbm.OrgOption_Folder folder)
{
if (contextFolders == null) contextFolders = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_Folder);
String context = contextFolders.GetCodeForType(folder);
return GetOrganisationOption(Sbm.OrganisationOption.Folder, context).Trim();
}
public bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption option)
{
if (contextAllowOptions == null) contextAllowOptions = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_AllowOption);
String context = contextAllowOptions.GetCodeForType(option);
String value = GetOrganisationOption(Sbm.OrganisationOption.AllowOption, context).Trim();
return StringUtil.ToBool(value);
}
public String GetOwnerOption_Caption(Sbm.OrgOption_Caption caption, String defaultValue)
{
if (contextCaptions == null) contextCaptions = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_Caption);
String context = contextCaptions.GetCodeForType(caption);
String value = GetOrganisationOption(Sbm.OrganisationOption.Caption, context).Trim();
return (!value.IsEmpty() ? value : defaultValue);
}
public bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx column)
{
if (contextShowFields == null) contextShowFields = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_ShowField);
String context = contextShowFields.GetCodeForType(column);
if (context.IsEmpty()) return true; // Automatically show fields that are not in the 'Show Field' list.
String value = GetOrganisationOption(Sbm.OrganisationOption.ShowField, context).Trim();
return StringUtil.ToBool(value);
}
public bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn column)
{
if (contextShowColumns == null) contextShowColumns = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_ShowColumn);
String context = contextShowColumns.GetCodeForType(column);
String value = GetOrganisationOption(Sbm.OrganisationOption.ShowColumn, context).Trim();
return StringUtil.ToBool(value);
}
public String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx column, String defautValue)
{
if (contextFieldLabels == null) contextFieldLabels = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_FieldLabel);
String context = contextFieldLabels.GetCodeForType(column);
String value = GetOrganisationOption(Sbm.OrganisationOption.FieldLabel, context).Trim();
return (!value.IsEmpty() ? value : defautValue); // Return default if no label defined.
}
public int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes limit, int defautValue)
{
if (contextMinutes == null) contextMinutes = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_Minutes);
String context = contextMinutes.GetCodeForType(limit);
String value = GetOrganisationOption(Sbm.OrganisationOption.Minutes, context).Trim();
if (!value.IsEmpty())
{
int iUpdateLimit = value.ToShort();
if (iUpdateLimit > 0)
return iUpdateLimit;
}
return defautValue;
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays limit, int defautValue)
{
if (contextPeriodDays == null) contextPeriodDays = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_PeriodDays);
String context = contextPeriodDays.GetCodeForType(limit);
String value = GetOrganisationOption(Sbm.OrganisationOption.PeriodDays, context).Trim();
if (!value.IsEmpty())
{
int iUpdateLimit = value.ToShort();
if (iUpdateLimit > 0)
return iUpdateLimit;
}
return defautValue;
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks limit, int defautValue)
{
if (contextPeriodWeeks == null) contextPeriodWeeks = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_PeriodWeeks);
String context = contextPeriodWeeks.GetCodeForType(limit);
String value = GetOrganisationOption(Sbm.OrganisationOption.PeriodWeeks, context).Trim();
if (!value.IsEmpty())
{
int iUpdateLimit = value.ToShort();
if (iUpdateLimit > 0)
return iUpdateLimit;
}
return defautValue;
}
public int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals decimals, int defautValue = 2)
{
if (contextNumericDecimals == null) contextNumericDecimals = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_NumericDecimals);
String context = contextNumericDecimals.GetCodeForType(decimals);
String value = GetOrganisationOption(Sbm.OrganisationOption.NumericDecimals, context).Trim();
int iNumDecimals = defautValue;
if (!value.IsEmpty())
iNumDecimals = value.ToShort();
iNumDecimals = Math.Min(4, Math.Max(0, iNumDecimals));
return iNumDecimals;
}
public Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityType)
{
if (contextCommodityTypes == null) contextCommodityTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_CommodityType);
if (commodityTypes == null) commodityTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.CommodityType);
String context = contextCommodityTypes.GetCodeForType(commodityType);
String value = GetOrganisationOption(Sbm.OrganisationOption.CommodityType, context).Trim();
Sbm.CommodityType eCmdType = (Sbm.CommodityType)commodityTypes.GetTypeForCode(value);
return eCmdType;
}
public SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation stockLocation)
{
if (contextSalesLocations == null) contextSalesLocations = SbmSystem.GetSystemCodes(Sbm.SystemCode.OrgOption_StockLocation);
String context = contextSalesLocations.GetCodeForType(stockLocation);
String value = GetOrganisationOption(Sbm.OrganisationOption.SalesLocation, context).Trim();
SysId idLoc = new SysId();
if (!StringUtil.IsEmpty(value))
idLoc = new SysId(StringUtil.ToInt(value));
return idLoc;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -27,7 +27,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Construction. // Construction.
[JsonConstructor] [JsonConstructor]
private SbmSecurityProfile() { } private SbmSecurityProfile() { }
public SbmSecurityProfile(ISbmUserContext_Core userContext, bool includeHostSecurityProfile) public SbmSecurityProfile(ISbmUserOrganisationContext userContext, bool includeHostSecurityProfile)
{ {
this.UserContext = userContext; this.UserContext = userContext;
this.includeHostSecurityProfile = includeHostSecurityProfile; this.includeHostSecurityProfile = includeHostSecurityProfile;
@@ -41,7 +41,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
[JsonIgnore] [JsonIgnore]
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Refresh profile. // Refresh profile.
@@ -76,14 +76,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
this.hostSecurityProfile = hostSecurityProfile; this.hostSecurityProfile = hostSecurityProfile;
RefreshProfileSettings(sessionConsole); RefreshProfileSettings(sessionConsole);
} }
private void RefreshProfileSettings(SbmSessionConsole sessionConfig) private void RefreshProfileSettings(SbmSessionConsole sessionConsole)
{ {
RefreshAdminProfile(sessionConfig); RefreshAdminProfile(sessionConsole);
RefreshManageProfile(sessionConfig); RefreshManageProfile(sessionConsole);
RefreshFinancialProfile(sessionConfig); RefreshFinancialProfile(sessionConsole);
RefreshContactsProfile(sessionConfig); RefreshContactsProfile(sessionConsole);
RefreshTransactionProfile(sessionConfig); RefreshTransactionProfile(sessionConsole);
RefreshItemTypeProfile(sessionConfig); RefreshItemTypeProfile(sessionConsole);
// ToDo Commodities. // ToDo Commodities.
} }
private void ClearProfile() private void ClearProfile()
@@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public bool CanManageInterfaces { get; internal set; } = false; public bool CanManageInterfaces { get; internal set; } = false;
} }
public AdminProfile Admin { get; internal set; } public AdminProfile Admin { get; internal set; }
private void RefreshAdminProfile(SbmSessionConsole sessionConfig) private void RefreshAdminProfile(SbmSessionConsole sessionConsole)
{ {
Admin.CanManageSecurity = UserHasSecurityRight(Sbm.SecurityRight.Security_Admin); Admin.CanManageSecurity = UserHasSecurityRight(Sbm.SecurityRight.Security_Admin);
Admin.CanManageDatabase = UserHasSecurityRight(Sbm.SecurityRight.Database_Admin); Admin.CanManageDatabase = UserHasSecurityRight(Sbm.SecurityRight.Database_Admin);
@@ -152,7 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public bool CanManageTimesheets { get; internal set; } = false; public bool CanManageTimesheets { get; internal set; } = false;
} }
public ManageProfile Manage { get; internal set; } public ManageProfile Manage { get; internal set; }
private void RefreshManageProfile(SbmSessionConsole sessionConfig) private void RefreshManageProfile(SbmSessionConsole sessionConsole)
{ {
Manage.CanManageTasks = UserHasSecurityRight(Sbm.SecurityRight.TaskManager); Manage.CanManageTasks = UserHasSecurityRight(Sbm.SecurityRight.TaskManager);
Manage.CanManageTimesheets = UserHasSecurityRight(Sbm.SecurityRight.TimesheetManager); Manage.CanManageTimesheets = UserHasSecurityRight(Sbm.SecurityRight.TimesheetManager);
@@ -172,7 +172,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public bool FinancialsAccessControl { get; internal set; } public bool FinancialsAccessControl { get; internal set; }
} }
public FinancialProfile Financial { get; internal set; } public FinancialProfile Financial { get; internal set; }
private void RefreshFinancialProfile(SbmSessionConsole sessionConfig) private void RefreshFinancialProfile(SbmSessionConsole sessionConsole)
{ {
Financial.ViewFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_View); Financial.ViewFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_View);
Financial.UpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update); Financial.UpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update);
@@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
Financial.ViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales); Financial.ViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales);
Financial.UpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales); Financial.UpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales);
// Config options. // Config options.
Financial.FinancialsAccessControl = (sessionConfig != null && !sessionConfig.AllowOption(Sbm.ConfigOption.AllowFinancialsAccessControl)); Financial.FinancialsAccessControl = (sessionConsole != null && !sessionConsole.AllowOption(Sbm.ConfigOption.FinancialsAccessControl));
} }
private bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType) private bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType)
@@ -245,7 +245,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public ContactsProfile Contacts { get; internal set; } public ContactsProfile Contacts { get; internal set; }
public bool UserCanCreateContacts() { return Contacts.Create; } public bool UserCanCreateContacts() { return Contacts.Create; }
public bool UserCanUpdateContacts() { return Contacts.Update; } public bool UserCanUpdateContacts() { return Contacts.Update; }
private void RefreshContactsProfile(SbmSessionConsole sessionConfig) private void RefreshContactsProfile(SbmSessionConsole sessionConsole)
{ {
Contacts.Update = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update)); Contacts.Update = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update));
Contacts.Create = (Contacts.Update || UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Create)); Contacts.Create = (Contacts.Update || UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Create));
@@ -285,7 +285,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
} }
} }
public TransactionsProfile Transaction { get; internal set; } public TransactionsProfile Transaction { get; internal set; }
private void RefreshTransactionProfile(SbmSessionConsole sessionConfig) private void RefreshTransactionProfile(SbmSessionConsole sessionConsole)
{ {
Transaction.Update = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update)); Transaction.Update = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update));
Transaction.Create = (Transaction.Update || UserHasSecurityRight(Sbm.SecurityRight.Transaction_View)); Transaction.Create = (Transaction.Update || UserHasSecurityRight(Sbm.SecurityRight.Transaction_View));
@@ -324,21 +324,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public bool StockControl { get; internal set; } public bool StockControl { get; internal set; }
} }
public ItemTypesProfile ItemType { get; } = new ItemTypesProfile(); public ItemTypesProfile ItemType { get; } = new ItemTypesProfile();
private void RefreshItemTypeProfile(SbmSessionConsole sessionConfig) private void RefreshItemTypeProfile(SbmSessionConsole sessionConsole)
{ {
ItemType.Processes = sessionConfig.AllowOption(Sbm.ConfigOption.AllowProcesses); ItemType.Processes = sessionConsole.AllowOption(Sbm.ConfigOption.Processes);
ItemType.Contacts = sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts); ItemType.Contacts = sessionConsole.AllowOption(Sbm.ConfigOption.Contacts);
ItemType.Commodities = sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities); ItemType.Commodities = sessionConsole.AllowOption(Sbm.ConfigOption.Commodities);
ItemType.Portfolios = sessionConfig.AllowOption(Sbm.ConfigOption.AllowPortfolios); ItemType.Portfolios = sessionConsole.AllowOption(Sbm.ConfigOption.Portfolios);
ItemType.PriceSets = sessionConfig.AllowOption(Sbm.ConfigOption.AllowPriceSets); ItemType.PriceSets = sessionConsole.AllowOption(Sbm.ConfigOption.PriceSets);
ItemType.CommodityCustomers = sessionConfig.AllowOption(Sbm.ConfigOption.CommodityCustomers); ItemType.CommodityCustomers = sessionConsole.AllowOption(Sbm.ConfigOption.CommodityCustomers);
ItemType.CommoditySuppliers = sessionConfig.AllowOption(Sbm.ConfigOption.CommoditySuppliers); ItemType.CommoditySuppliers = sessionConsole.AllowOption(Sbm.ConfigOption.CommoditySuppliers);
ItemType.Transactions = sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions); ItemType.Transactions = sessionConsole.AllowOption(Sbm.ConfigOption.Transactions);
ItemType.Assets = sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets); ItemType.Assets = sessionConsole.AllowOption(Sbm.ConfigOption.Assets);
ItemType.Vehicles = sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles); ItemType.Vehicles = sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles);
ItemType.StockLocations = sessionConfig.GetStockControlConfig().AllowStockLocations(); ItemType.StockLocations = sessionConsole.GetStockControlConfig().AllowStockLocations();
ItemType.StockContainers = sessionConfig.GetStockControlConfig().AllowStockContainers(); ItemType.StockContainers = sessionConsole.GetStockControlConfig().AllowStockContainers();
ItemType.StockControl = sessionConfig.GetStockControlConfig().AllowStockControl(); ItemType.StockControl = sessionConsole.GetStockControlConfig().AllowStockControl();
} }
public bool ItemTypeIsAllowed(Sbm.ItemType itemType) public bool ItemTypeIsAllowed(Sbm.ItemType itemType)
@@ -49,7 +49,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmSysParamCache(ISbmUserContext_Core userContext, SysId affiliateIdUser) public SbmSysParamCache(ISbmUserOrganisationContext userContext, SysId affiliateIdUser)
{ {
this.UserContext = userContext; this.UserContext = userContext;
this.AffiliateIdUser = affiliateIdUser; this.AffiliateIdUser = affiliateIdUser;
@@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
public SysId AffiliateIdUser { get; } public SysId AffiliateIdUser { get; }
public bool Modified { get; private set; } public bool Modified { get; private set; }
@@ -25,17 +25,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// R e g i s t e r C o d e T y p e s // R e g i s t e r C o d e T y p e s
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static void RegisterCodeTypes(SbmSessionConsole sessionConfig, SaCodeTypeConsole codeTypeConsole) public static void RegisterCodeTypes(SbmSessionConsole sessionConsole, SaCodeTypeConsole codeTypeConsole)
{ {
//--------------------------------------------------------------- //---------------------------------------------------------------
// C o m m o d i t i e s // C o m m o d i t i e s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Commodities))
{ {
// Commodity category. // Commodity category.
SaCodeTypeDfn codeTypeCommodityCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityCategory), 12); SaCodeTypeDfn codeTypeCommodityCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityCategory), 12);
codeTypeConsole.RegisterCodeType(codeTypeCommodityCategory); codeTypeConsole.RegisterCodeType(codeTypeCommodityCategory);
codeTypeConsole.RegisterCodesOfType(codeTypeCommodityCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityCategory)); codeTypeConsole.RegisterCodesOfType(codeTypeCommodityCategory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityCategory));
// Commodity range. // Commodity range.
SaCodeTypeDfn codeTypeCommodityRange = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityRange), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityRange), 12); SaCodeTypeDfn codeTypeCommodityRange = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityRange), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityRange), 12);
@@ -62,97 +62,97 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//codeTypeConsole.RegisterCodeType(codeTypeCommodityDelivery); //codeTypeConsole.RegisterCodeType(codeTypeCommodityDelivery);
// Commodity material. // Commodity material.
String commodityMaterialLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material"); String commodityMaterialLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, "Material");
if (!commodityMaterialLabel.ContainsCI("Commodity")) commodityMaterialLabel = "Commodity " + commodityMaterialLabel; if (!commodityMaterialLabel.ContainsCI("Commodity")) commodityMaterialLabel = "Commodity " + commodityMaterialLabel;
SaCodeTypeDfn codeTypeCommodityMaterial = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityMaterial), commodityMaterialLabel, 12); SaCodeTypeDfn codeTypeCommodityMaterial = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityMaterial), commodityMaterialLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeCommodityMaterial); codeTypeConsole.RegisterCodeType(codeTypeCommodityMaterial);
codeTypeConsole.RegisterCodesOfType(codeTypeCommodityMaterial.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityMaterial)); codeTypeConsole.RegisterCodesOfType(codeTypeCommodityMaterial.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityMaterial));
// Commodity finish. // Commodity finish.
String commodityFinishLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish"); String commodityFinishLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_FinishCode, "Finish");
if (!commodityFinishLabel.ContainsCI("Commodity")) commodityFinishLabel = "Commodity " + commodityFinishLabel; if (!commodityFinishLabel.ContainsCI("Commodity")) commodityFinishLabel = "Commodity " + commodityFinishLabel;
SaCodeTypeDfn codeTypeCommodityFinish = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityFinish), commodityFinishLabel, 12); SaCodeTypeDfn codeTypeCommodityFinish = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityFinish), commodityFinishLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeCommodityFinish); codeTypeConsole.RegisterCodeType(codeTypeCommodityFinish);
codeTypeConsole.RegisterCodesOfType(codeTypeCommodityFinish.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityFinish)); codeTypeConsole.RegisterCodesOfType(codeTypeCommodityFinish.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityFinish));
// Commodity promotion. // Commodity promotion.
String commodityPromotionLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion"); String commodityPromotionLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Commodity_PromotionCode, "Promotion");
if (!commodityPromotionLabel.ContainsCI("Commodity")) commodityPromotionLabel = "Commodity " + commodityPromotionLabel; if (!commodityPromotionLabel.ContainsCI("Commodity")) commodityPromotionLabel = "Commodity " + commodityPromotionLabel;
SaCodeTypeDfn codeTypeCommodityPromotion = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityPromotion), commodityPromotionLabel, 12); SaCodeTypeDfn codeTypeCommodityPromotion = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityPromotion), commodityPromotionLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeCommodityPromotion); codeTypeConsole.RegisterCodeType(codeTypeCommodityPromotion);
codeTypeConsole.RegisterCodesOfType(codeTypeCommodityPromotion.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityPromotion)); codeTypeConsole.RegisterCodesOfType(codeTypeCommodityPromotion.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityPromotion));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// P r o c e s s e s // P r o c e s s e s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowProcesses)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Processes))
{ {
// Process type. // Process type.
SaCodeTypeDfn codeTypeProcessType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ProcessType), codeTypes.GetDescForType(Sbm.ApplCodeType.ProcessType), 12); SaCodeTypeDfn codeTypeProcessType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ProcessType), codeTypes.GetDescForType(Sbm.ApplCodeType.ProcessType), 12);
codeTypeConsole.RegisterCodeType(codeTypeProcessType); codeTypeConsole.RegisterCodeType(codeTypeProcessType);
codeTypeConsole.RegisterCodesOfType(codeTypeProcessType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ProcessType)); codeTypeConsole.RegisterCodesOfType(codeTypeProcessType.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ProcessType));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// R e f e r r a l // R e f e r r a l
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null) if (sessionConsole != null)
{ {
// Refer type. // Refer type.
SaCodeTypeDfn codeTypeReferType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ReferType), codeTypes.GetDescForType(Sbm.ApplCodeType.ReferType), 12); SaCodeTypeDfn codeTypeReferType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ReferType), codeTypes.GetDescForType(Sbm.ApplCodeType.ReferType), 12);
codeTypeReferType.AllowSequence = true; codeTypeReferType.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeReferType); codeTypeConsole.RegisterCodeType(codeTypeReferType);
codeTypeConsole.RegisterCodesOfType(codeTypeReferType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ReferType)); codeTypeConsole.RegisterCodesOfType(codeTypeReferType.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ReferType));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// T a s k s // T a s k s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowTasks)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Tasks))
{ {
// Task category. // Task category.
SaCodeTypeDfn codeTypeTaskCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.TaskCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.TaskCategory), 12); SaCodeTypeDfn codeTypeTaskCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.TaskCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.TaskCategory), 12);
codeTypeTaskCategory.AllowSequence = true; codeTypeTaskCategory.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeTaskCategory); codeTypeConsole.RegisterCodeType(codeTypeTaskCategory);
codeTypeConsole.RegisterCodesOfType(codeTypeTaskCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.TaskCategory)); codeTypeConsole.RegisterCodesOfType(codeTypeTaskCategory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.TaskCategory));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// A s s e t s // A s s e t s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Assets))
{ {
// Asset sell category. // Asset sell category.
SaCodeTypeDfn codeTypeAssetSellCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AssetSellCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.AssetSellCategory), 8); SaCodeTypeDfn codeTypeAssetSellCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AssetSellCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.AssetSellCategory), 8);
codeTypeConsole.RegisterCodeType(codeTypeAssetSellCategory); codeTypeConsole.RegisterCodeType(codeTypeAssetSellCategory);
codeTypeConsole.RegisterCodesOfType(codeTypeAssetSellCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.AssetSellCategory)); codeTypeConsole.RegisterCodesOfType(codeTypeAssetSellCategory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.AssetSellCategory));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// V e h i c l e s // V e h i c l e s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles))
{ {
// Vehicle category. // Vehicle category.
SaCodeTypeDfn codeTypeVehicleCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleCategory), 8); SaCodeTypeDfn codeTypeVehicleCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleCategory), 8);
codeTypeConsole.RegisterCodeType(codeTypeVehicleCategory); codeTypeConsole.RegisterCodeType(codeTypeVehicleCategory);
codeTypeConsole.RegisterCodesOfType(codeTypeVehicleCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleCategory)); codeTypeConsole.RegisterCodesOfType(codeTypeVehicleCategory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleCategory));
// Vehicle make. // Vehicle make.
SaCodeTypeDfn codeTypeVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleMake), 8); SaCodeTypeDfn codeTypeVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleMake), 8);
codeTypeConsole.RegisterCodeType(codeTypeVehicleMake); codeTypeConsole.RegisterCodeType(codeTypeVehicleMake);
codeTypeConsole.RegisterCodesOfType(codeTypeVehicleMake.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleMake)); codeTypeConsole.RegisterCodesOfType(codeTypeVehicleMake.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleMake));
// Vehicle service history. // Vehicle service history.
SaCodeTypeDfn codeTypeVehicleServiceHistory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleServiceHistory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleServiceHistory), 12); SaCodeTypeDfn codeTypeVehicleServiceHistory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleServiceHistory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleServiceHistory), 12);
codeTypeConsole.RegisterCodeType(codeTypeVehicleServiceHistory); codeTypeConsole.RegisterCodeType(codeTypeVehicleServiceHistory);
codeTypeConsole.RegisterCodesOfType(codeTypeVehicleServiceHistory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleServiceHistory)); codeTypeConsole.RegisterCodesOfType(codeTypeVehicleServiceHistory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleServiceHistory));
// Vehicle insurance. // Vehicle insurance.
SaCodeTypeDfn codeTypeVehicleInsurance = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleInsurance), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleInsurance), 3); SaCodeTypeDfn codeTypeVehicleInsurance = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleInsurance), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleInsurance), 3);
codeTypeConsole.RegisterCodeType(codeTypeVehicleInsurance); codeTypeConsole.RegisterCodeType(codeTypeVehicleInsurance);
codeTypeConsole.RegisterCodesOfType(codeTypeVehicleInsurance.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleInsurance)); codeTypeConsole.RegisterCodesOfType(codeTypeVehicleInsurance.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleInsurance));
// Vehicle tacho. // Vehicle tacho.
SaCodeTypeDfn codeTypeVehicleTacho = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleTacho), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleTacho), 8); SaCodeTypeDfn codeTypeVehicleTacho = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleTacho), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleTacho), 8);
@@ -163,83 +163,83 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//--------------------------------------------------------------- //---------------------------------------------------------------
// H P I V e h i c l e s // H P I V e h i c l e s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowInterface(SaInterfaceCategory.System, (int)Sbm.InterfaceType_System.Hpi)) if (sessionConsole != null && sessionConsole.AllowInterface(SaInterfaceCategory.System, (int)Sbm.InterfaceType_System.Hpi))
{ {
// HPI vehicle make. // HPI vehicle make.
SaCodeTypeDfn codeTypeHpiVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleMake), 12); SaCodeTypeDfn codeTypeHpiVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleMake), 12);
codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleMake); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleMake);
codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleMake.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleMake)); codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleMake.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleMake));
// HPI vehicle model. // HPI vehicle model.
SaCodeTypeDfn codeTypeHpiVehicleModel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleModel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleModel), 12); SaCodeTypeDfn codeTypeHpiVehicleModel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleModel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleModel), 12);
codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleModel); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleModel);
codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleModel.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleModel)); codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleModel.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleModel));
// HPI vehicle colour. // HPI vehicle colour.
SaCodeTypeDfn codeTypeHpiVehicleColour = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleColour), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleColour), 12); SaCodeTypeDfn codeTypeHpiVehicleColour = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleColour), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleColour), 12);
codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleColour); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleColour);
codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleColour.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleColour)); codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleColour.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleColour));
// HPI vehicle fuel. // HPI vehicle fuel.
SaCodeTypeDfn codeTypeHpiVehicleFuel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleFuel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleFuel), 12); SaCodeTypeDfn codeTypeHpiVehicleFuel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleFuel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleFuel), 12);
codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleFuel); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleFuel);
codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleFuel.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleFuel)); codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleFuel.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleFuel));
// HPI vehicle transmission. // HPI vehicle transmission.
SaCodeTypeDfn codeTypeHpiVehicleTrans = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleTrans), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleTrans), 12); SaCodeTypeDfn codeTypeHpiVehicleTrans = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleTrans), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleTrans), 12);
codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleTrans); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleTrans);
codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleTrans.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleTrans)); codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleTrans.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleTrans));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// C o n t a c t M a n a g e m e n t // C o n t a c t M a n a g e m e n t
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null) if (sessionConsole != null)
{ {
// Account manager. // Account manager.
String accountManagerLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, "Account manager"); String accountManagerLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, "Account manager");
SaCodeTypeDfn codeTypeAccountManager = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountManager), accountManagerLabel, 12, "Account management group"); SaCodeTypeDfn codeTypeAccountManager = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountManager), accountManagerLabel, 12, "Account management group");
codeTypeConsole.RegisterCodeType(codeTypeAccountManager); codeTypeConsole.RegisterCodeType(codeTypeAccountManager);
// Account handler. // Account handler.
String accountHandlerLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, "Account handler"); String accountHandlerLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, "Account handler");
SaCodeTypeDfn codeTypeAccountHandler = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountHandler), accountHandlerLabel, 12, "Account handling group"); SaCodeTypeDfn codeTypeAccountHandler = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountHandler), accountHandlerLabel, 12, "Account handling group");
codeTypeConsole.RegisterCodeType(codeTypeAccountHandler); codeTypeConsole.RegisterCodeType(codeTypeAccountHandler);
// Account type. // Account type.
String accountTypeLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountTypeCode, "Account type"); String accountTypeLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountTypeCode, "Account type");
SaCodeTypeDfn codeTypeAccountType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountType), accountTypeLabel, 12, "Grouping by nature of business"); SaCodeTypeDfn codeTypeAccountType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountType), accountTypeLabel, 12, "Grouping by nature of business");
codeTypeConsole.RegisterCodeType(codeTypeAccountType); codeTypeConsole.RegisterCodeType(codeTypeAccountType);
// Account rating. // Account rating.
String accountRatingLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountRatingCode, "Account rating"); String accountRatingLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_AccountRatingCode, "Account rating");
SaCodeTypeDfn codeTypeAccountRating = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountRating), accountRatingLabel, 12); SaCodeTypeDfn codeTypeAccountRating = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AccountRating), accountRatingLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeAccountRating); codeTypeConsole.RegisterCodeType(codeTypeAccountRating);
// Contact title. // Contact title.
String contactTitleLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Affiliate_Title, "Contact title"); String contactTitleLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Affiliate_Title, "Contact title");
SaCodeTypeDfn codeTypeContactTitle = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactTitle), contactTitleLabel, 12); SaCodeTypeDfn codeTypeContactTitle = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactTitle), contactTitleLabel, 12);
codeTypeContactTitle.AllowSequence = true; codeTypeContactTitle.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeContactTitle); codeTypeConsole.RegisterCodeType(codeTypeContactTitle);
codeTypeConsole.RegisterCodesOfType(codeTypeContactTitle.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ContactTitle)); codeTypeConsole.RegisterCodesOfType(codeTypeContactTitle.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ContactTitle));
// Contact area. // Contact area.
String contactAreaLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area"); String contactAreaLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area");
SaCodeTypeDfn codeTypeContactArea = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactArea), contactAreaLabel, 12, "Geographic region"); SaCodeTypeDfn codeTypeContactArea = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactArea), contactAreaLabel, 12, "Geographic region");
codeTypeConsole.RegisterCodeType(codeTypeContactArea); codeTypeConsole.RegisterCodeType(codeTypeContactArea);
// Contact handler. // Contact handler.
String contactHandlerLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, "Contact handler"); String contactHandlerLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, "Contact handler");
SaCodeTypeDfn codeTypeContactHandler = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactHandler), contactHandlerLabel, 12); SaCodeTypeDfn codeTypeContactHandler = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactHandler), contactHandlerLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeContactHandler); codeTypeConsole.RegisterCodeType(codeTypeContactHandler);
// Contact method. // Contact method.
String contactMethodLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactMethodCode, "Contact method"); String contactMethodLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactMethodCode, "Contact method");
SaCodeTypeDfn codeTypeContactMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactMethod), contactMethodLabel, 12); SaCodeTypeDfn codeTypeContactMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactMethod), contactMethodLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeContactMethod); codeTypeConsole.RegisterCodeType(codeTypeContactMethod);
// Contact call cycle. // Contact call cycle.
String contactCallCycleLabel = sessionConfig.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, "Contact call cycle"); String contactCallCycleLabel = sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, "Contact call cycle");
SaCodeTypeDfn codeTypeContactCallCycle = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactCallCycle), contactCallCycleLabel, 12); SaCodeTypeDfn codeTypeContactCallCycle = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ContactCallCycle), contactCallCycleLabel, 12);
codeTypeConsole.RegisterCodeType(codeTypeContactCallCycle); codeTypeConsole.RegisterCodeType(codeTypeContactCallCycle);
@@ -252,7 +252,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// C o s t E s t i m a t e s // C o s t E s t i m a t e s
//--------------------------------------------------------------- //---------------------------------------------------------------
FlagDfn estimateDefaultFlag = new FlagDfn((Byte)Sbm.ApplCodeFlag.EstimateType_QuoteDefault, "Default to quote", "Default"); FlagDfn estimateDefaultFlag = new FlagDfn((Byte)Sbm.ApplCodeFlag.EstimateType_QuoteDefault, "Default to quote", "Default");
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.EstimateSalesQuotesByCosts)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.EstimateSalesQuotesByCosts))
{ {
// Cost per unit. // Cost per unit.
SaCodeTypeDfn codeTypeCostPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerUnit), 12); SaCodeTypeDfn codeTypeCostPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerUnit), 12);
@@ -264,61 +264,61 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
codeTypeCostPerUnit.FlagDefinitions.Add(new FlagDfn(4, "Flag 4", "#4")); codeTypeCostPerUnit.FlagDefinitions.Add(new FlagDfn(4, "Flag 4", "#4"));
#endif #endif
codeTypeConsole.RegisterCodeType(codeTypeCostPerUnit); codeTypeConsole.RegisterCodeType(codeTypeCostPerUnit);
codeTypeConsole.RegisterCodesOfType(codeTypeCostPerUnit.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerUnit)); codeTypeConsole.RegisterCodesOfType(codeTypeCostPerUnit.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerUnit));
// Cost per job. // Cost per job.
SaCodeTypeDfn codeTypeCostPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerJob), 12); SaCodeTypeDfn codeTypeCostPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerJob), 12);
codeTypeCostPerJob.AllowSequence = true; codeTypeCostPerJob.AllowSequence = true;
codeTypeCostPerJob.FlagDefinitions.Add(estimateDefaultFlag); codeTypeCostPerJob.FlagDefinitions.Add(estimateDefaultFlag);
codeTypeConsole.RegisterCodeType(codeTypeCostPerJob); codeTypeConsole.RegisterCodeType(codeTypeCostPerJob);
codeTypeConsole.RegisterCodesOfType(codeTypeCostPerJob.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerJob)); codeTypeConsole.RegisterCodesOfType(codeTypeCostPerJob.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerJob));
} }
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.EstimateLabourByMinutes)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.EstimateLabourByMinutes))
{ {
// Labour cost per unit. // Labour cost per unit.
SaCodeTypeDfn codeTypeLabourPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerUnit), 12); SaCodeTypeDfn codeTypeLabourPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerUnit), 12);
codeTypeLabourPerUnit.AllowSequence = true; codeTypeLabourPerUnit.AllowSequence = true;
codeTypeLabourPerUnit.FlagDefinitions.Add(estimateDefaultFlag); codeTypeLabourPerUnit.FlagDefinitions.Add(estimateDefaultFlag);
codeTypeConsole.RegisterCodeType(codeTypeLabourPerUnit); codeTypeConsole.RegisterCodeType(codeTypeLabourPerUnit);
codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerUnit.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerUnit)); codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerUnit.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerUnit));
// Labour cost per job. // Labour cost per job.
SaCodeTypeDfn codeTypeLabourPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerJob), 12); SaCodeTypeDfn codeTypeLabourPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerJob), 12);
codeTypeLabourPerJob.AllowSequence = true; codeTypeLabourPerJob.AllowSequence = true;
codeTypeLabourPerJob.FlagDefinitions.Add(estimateDefaultFlag); codeTypeLabourPerJob.FlagDefinitions.Add(estimateDefaultFlag);
codeTypeConsole.RegisterCodeType(codeTypeLabourPerJob); codeTypeConsole.RegisterCodeType(codeTypeLabourPerJob);
codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerJob.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerJob)); codeTypeConsole.RegisterCodesOfType(codeTypeLabourPerJob.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.LabourPerJob));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// D e l i v e r y // D e l i v e r y
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails)) if (sessionConsole != null && sessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails))
{ {
// Delivery status. // Delivery status.
SaCodeTypeDfn codeTypeDeliveryStatus = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryStatus), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryStatus), 3); SaCodeTypeDfn codeTypeDeliveryStatus = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryStatus), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryStatus), 3);
codeTypeDeliveryStatus.AllowSequence = true; codeTypeDeliveryStatus.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeDeliveryStatus); codeTypeConsole.RegisterCodeType(codeTypeDeliveryStatus);
codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryStatus.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryStatus)); codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryStatus.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryStatus));
// Delivery type. // Delivery type.
SaCodeTypeDfn codeTypeDeliveryType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryType), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryType), 12); SaCodeTypeDfn codeTypeDeliveryType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryType), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryType), 12);
codeTypeDeliveryType.AllowSequence = true; codeTypeDeliveryType.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeDeliveryType); codeTypeConsole.RegisterCodeType(codeTypeDeliveryType);
codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryType)); codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryType.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryType));
// Delivery method. // Delivery method.
SaCodeTypeDfn codeTypeDeliveryMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryMethod), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryMethod), 12); SaCodeTypeDfn codeTypeDeliveryMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryMethod), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryMethod), 12);
codeTypeDeliveryMethod.AllowSequence = true; codeTypeDeliveryMethod.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeDeliveryMethod); codeTypeConsole.RegisterCodeType(codeTypeDeliveryMethod);
codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryMethod.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryMethod)); codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryMethod.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryMethod));
// Delivery courier. // Delivery courier.
SaCodeTypeDfn codeTypeDeliveryCourier = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryCourier), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryCourier), 12); SaCodeTypeDfn codeTypeDeliveryCourier = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryCourier), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryCourier), 12);
codeTypeDeliveryCourier.AllowSequence = true; codeTypeDeliveryCourier.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeDeliveryCourier); codeTypeConsole.RegisterCodeType(codeTypeDeliveryCourier);
codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryCourier.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryCourier)); codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryCourier.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryCourier));
// Delivery book-in. // Delivery book-in.
SaCodeTypeDfn codeTypeDeliveryBookIn = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryBookIn), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryBookIn), 12); SaCodeTypeDfn codeTypeDeliveryBookIn = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryBookIn), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryBookIn), 12);
@@ -336,13 +336,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
SaCodeTypeDfn codeTypeStockPicker = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.StockPicker), codeTypes.GetDescForType(Sbm.ApplCodeType.StockPicker), 12); SaCodeTypeDfn codeTypeStockPicker = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.StockPicker), codeTypes.GetDescForType(Sbm.ApplCodeType.StockPicker), 12);
codeTypeStockPicker.AllowSequence = true; codeTypeStockPicker.AllowSequence = true;
codeTypeConsole.RegisterCodeType(codeTypeStockPicker); codeTypeConsole.RegisterCodeType(codeTypeStockPicker);
codeTypeConsole.RegisterCodesOfType(codeTypeStockPicker.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.StockPicker)); codeTypeConsole.RegisterCodesOfType(codeTypeStockPicker.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.StockPicker));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
// I t e m D o c u m e n t s // I t e m D o c u m e n t s
//--------------------------------------------------------------- //---------------------------------------------------------------
if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowItemDocuments)) if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.ItemDocuments))
{ {
// PDF document types. // PDF document types.
SaCodeTypeDfn codeTypeDocType_Pdf = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DocType_Pdf), codeTypes.GetDescForType(Sbm.ApplCodeType.DocType_Pdf), 12); SaCodeTypeDfn codeTypeDocType_Pdf = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DocType_Pdf), codeTypes.GetDescForType(Sbm.ApplCodeType.DocType_Pdf), 12);
@@ -350,7 +350,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
codeTypeDocType_Pdf.AllowMixedCode = true; codeTypeDocType_Pdf.AllowMixedCode = true;
codeTypeDocType_Pdf.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Pdf_WebPublish, "WebPublish", "Publish to Web")); codeTypeDocType_Pdf.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Pdf_WebPublish, "WebPublish", "Publish to Web"));
codeTypeConsole.RegisterCodeType(codeTypeDocType_Pdf); codeTypeConsole.RegisterCodeType(codeTypeDocType_Pdf);
codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Pdf.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Pdf)); codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Pdf.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Pdf));
// Image document types. // Image document types.
SaCodeTypeDfn codeTypeDocType_Image = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DocType_Image), codeTypes.GetDescForType(Sbm.ApplCodeType.DocType_Image), 12); SaCodeTypeDfn codeTypeDocType_Image = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DocType_Image), codeTypes.GetDescForType(Sbm.ApplCodeType.DocType_Image), 12);
@@ -358,7 +358,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
codeTypeDocType_Image.AllowMixedCode = true; codeTypeDocType_Image.AllowMixedCode = true;
codeTypeDocType_Image.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Image_WebPublish, "WebPublish", "Publish to Web")); codeTypeDocType_Image.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Image_WebPublish, "WebPublish", "Publish to Web"));
codeTypeConsole.RegisterCodeType(codeTypeDocType_Image); codeTypeConsole.RegisterCodeType(codeTypeDocType_Image);
codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Image.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Image)); codeTypeConsole.RegisterCodesOfType(codeTypeDocType_Image.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DocType_Image));
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
File diff suppressed because it is too large Load Diff
+22 -411
View File
@@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Sarand.BusinessMgr.Net.Standard.Base.App namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
@@ -77,423 +78,33 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
//------------------------------------------------------------------- //-------------------------------------------------------------------
// S y s t e m C o d e s // S y s t e m C o d e s
//------------------------------------------------------------------- //-------------------------------------------------------------------
private static String GetOwnerOption_Caption(ISbmUserContext_Core userContext, Sbm.OrgOption_Caption orgOption_Caption, String defaultValue) public static List<TypeCodeDesc> GetSystemCodes(Sbm.SystemCode systemCode)
{ {
// In case user context not specified, eg. Security Console initialising list of transaction types before user logged in. List<TypeCodeDesc> codes = systemCodes.GetValueOrDefault(systemCode);
if (userContext != null) if (codes == null)
return userContext.GetOwnerOption_Caption(orgOption_Caption, defaultValue); SaLogger.Warn($"{SysUtil.Fn} Unrecognised system code type: {systemCode}.");
return defaultValue; return codes;
}
public static List<TypeCodeDesc> GetCodesOfType(ISbmUserContext_Core userContext, Sbm.SystemCode systemCode)
{
using (SbmInternals internals = new SbmInternals(userContext))
{
SbmSessionConsole sessionConsole = internals.SessionConsole;
switch (systemCode)
{
case Sbm.SystemCode.ItemType:
return new List<TypeCodeDesc>(itemTypes);
case Sbm.SystemCode.AffiliateType:
return new List<TypeCodeDesc>(affiliateTypes);
case Sbm.SystemCode.AssociationType:
return new List<TypeCodeDesc>(associationTypes);
case Sbm.SystemCode.TransactionType:
// Transaction types.
return new List<TypeCodeDesc>()
{
new TypeCodeDesc((int) Sbm.TransactionType.Project, "PRO", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_Project, "Project")),
new TypeCodeDesc((int)Sbm.TransactionType.SalesLead, "SLD", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesLead, "Sales Lead")),
new TypeCodeDesc((int)Sbm.TransactionType.SalesQuote, "SQT", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesQuote, "Sales Quote")),
new TypeCodeDesc((int)Sbm.TransactionType.SalesPO, "SPO", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesPO, "Sales Purchase Order")),
new TypeCodeDesc((int)Sbm.TransactionType.ProformaSalesOrder, "SAP", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_ProformaSalesOrder, "Proforma Sales Order")),
new TypeCodeDesc((int)Sbm.TransactionType.SalesOrder, "SAL", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesOrder, "Sales Order")),
new TypeCodeDesc((int)Sbm.TransactionType.SalesDispatch, "SDP", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesDispatch, "Sales Dispatch")),
new TypeCodeDesc((int)Sbm.TransactionType.ProformaSalesInvoice, "PSI", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice, "Proforma Sales Invoice")),
new TypeCodeDesc((int)Sbm.TransactionType.SalesInvoice, "SAI", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_SalesInvoice, "Sales Invoice")),
new TypeCodeDesc((int)Sbm.TransactionType.PurchaseQuote, "PQT", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_PurchaseQuote, "Purchase Quote")),
new TypeCodeDesc((int)Sbm.TransactionType.PurchaseSO, "PSO", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_PurchaseSO, "Purchase Sales Order")),
new TypeCodeDesc((int)Sbm.TransactionType.ProformaPurchaseOrder, "PUP", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder, "Proforma Purchase Order")),
new TypeCodeDesc((int)Sbm.TransactionType.PurchaseOrder, "PUR", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_PurchaseOrder, "Purchase Order")),
new TypeCodeDesc((int)Sbm.TransactionType.PurchaseDelivery, "PDL", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_PurchaseDelivery, "Purchase Delivery")),
new TypeCodeDesc((int)Sbm.TransactionType.ProformaPurchaseInvoice, "PPI", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice, "Proforma Purchase Invoice")),
new TypeCodeDesc((int)Sbm.TransactionType.PurchaseInvoice, "PUI", GetOwnerOption_Caption(userContext, Sbm.OrgOption_Caption.TransType_PurchaseInvoice, "Purchase Invoice")),
};
case Sbm.SystemCode.TransactionStatusCat:
return new List<TypeCodeDesc>(transactionStatusCats);
case Sbm.SystemCode.RequirementType:
return new List<TypeCodeDesc>(requirementTypes);
case Sbm.SystemCode.TaskCodeType:
return new List<TypeCodeDesc>(taskCodeTypes);
case Sbm.SystemCode.RequirementStatusCat:
return new List<TypeCodeDesc>(requirementStatusCats);
case Sbm.SystemCode.ConstituentType:
return new List<TypeCodeDesc>(constituentTypes);
case Sbm.SystemCode.ConstituentStatusCat:
return new List<TypeCodeDesc>(constituentStatusCats);
case Sbm.SystemCode.ItemLinkData:
return new List<TypeCodeDesc>(itemLinkDatas);
case Sbm.SystemCode.PortfolioItemType:
return new List<TypeCodeDesc>(portfolioItemTypes);
case Sbm.SystemCode.LocationCategory:
return new List<TypeCodeDesc>(locationCategories);
case Sbm.SystemCode.LocationFilter:
return new List<TypeCodeDesc>(locationFilters);
case Sbm.SystemCode.ContainerCategory:
return new List<TypeCodeDesc>(containerCategories);
case Sbm.SystemCode.ContainerType:
return new List<TypeCodeDesc>(containerTypes);
case Sbm.SystemCode.CommodityType:
{
// CommodityType.
List<TypeCodeDesc> CommodityType = new List<TypeCodeDesc>();
CommodityType.Add(Sbm.CommodityType.Stock, "STK", "Stock");
CommodityType.Add(Sbm.CommodityType.NonStock, "NST", "Non-stock");
CommodityType.Add(Sbm.CommodityType.Service, "SRV", "Service");
if (assetCommodityTypeAllowed < 0)
{
// ToDo SbmSystem assetCommodityTypeAllowed
using (SbmAssetMgr assetMgr = SbmGlobals.System.CreateAssetMgr(userContext))
{
//assetCommodityTypeAllowed = assetMgr != null && assetMgr.DatabaseIsValid();
}
}
if (assetCommodityTypeAllowed > 0)
CommodityType.Add(Sbm.CommodityType.Asset, "AST", "Asset");
return CommodityType;
}
case Sbm.SystemCode.CommodityStatusCat:
return new List<TypeCodeDesc>(commodityStatusCats);
case Sbm.SystemCode.MovementType:
return new List<TypeCodeDesc>(movementTypes);
case Sbm.SystemCode.StockLevelType:
return new List<TypeCodeDesc>(stockLevelTypes);
case Sbm.SystemCode.StockLevelSource:
return new List<TypeCodeDesc>(stockLevelSources);
case Sbm.SystemCode.AddressType:
return new List<TypeCodeDesc>(addressTypes);
case Sbm.SystemCode.SysParamCategory:
return new List<TypeCodeDesc>(sysParamCategories);
case Sbm.SystemCode.ProcessCategory:
{
List<TypeCodeDesc> ProcessCategory = new List<TypeCodeDesc>();
if (sessionConsole != null)
{
if (sessionConsole.AllowOption(Sbm.ConfigOption.AllowCommodities))
ProcessCategory.Add(Sbm.ProcessCategory.Commodity, "CMD", "Commodity");
if (sessionConsole.AllowOption(Sbm.ConfigOption.AllowAssets))
ProcessCategory.Add(Sbm.ProcessCategory.Asset, "ASSET", "Asset");
}
return ProcessCategory;
}
case Sbm.SystemCode.ProcessType:
return new List<TypeCodeDesc>(processTypes);
case Sbm.SystemCode.PaymentType:
return new List<TypeCodeDesc>(paymentTypes);
case Sbm.SystemCode.AssetIncomeType:
return new List<TypeCodeDesc>(assetIncomeTypes);
case Sbm.SystemCode.AssetType:
return new List<TypeCodeDesc>(assetTypes);
case Sbm.SystemCode.VehicleType:
return new List<TypeCodeDesc>(vehicleTypes);
case Sbm.SystemCode.VehicleEventType:
return new List<TypeCodeDesc>(vehicleEventTypes);
case Sbm.SystemCode.VehicleFeatureSource:
return new List<TypeCodeDesc>(vVehicleFeatureSources);
case Sbm.SystemCode.VehicleFeatureType:
return new List<TypeCodeDesc>(vehicleFeatureTypes);
case Sbm.SystemCode.VehicleOptionType:
return new List<TypeCodeDesc>(vehicleOptionTypes);
case Sbm.SystemCode.VehicleTransType:
return new List<TypeCodeDesc>(vehicleTransTypes);
case Sbm.SystemCode.FuelType:
return new List<TypeCodeDesc>(fuelTypes);
case Sbm.SystemCode.OdometerUnits:
return new List<TypeCodeDesc>(odometerUnits);
case Sbm.SystemCode.DiscountType:
return new List<TypeCodeDesc>(discountTypes);
case Sbm.SystemCode.DiscountMarkup:
return new List<TypeCodeDesc>(discountMarkups);
case Sbm.SystemCode.RegionType:
return new List<TypeCodeDesc>(regionTypes);
case Sbm.SystemCode.UnitMeasureCategory:
return new List<TypeCodeDesc>(unitMeasureCategories);
case Sbm.SystemCode.UnitMeasureType:
return new List<TypeCodeDesc>(unitMeasureTypes);
case Sbm.SystemCode.FinancialType:
{
List<TypeCodeDesc> FinancialType = new List<TypeCodeDesc>();
if (sessionConsole != null)
{
if (sessionConsole.AllowOption(Sbm.ConfigOption.AllowCommodities))
FinancialType.Add(Sbm.FinancialType.CommoditySupply, "CmdSup", "Commodity supply");
}
FinancialType.Add(Sbm.FinancialType.CommoditySales, "CmdSal", "Commodity sales");
return FinancialType;
}
case Sbm.SystemCode.PriceType:
return new List<TypeCodeDesc>(priceTypes);
case Sbm.SystemCode.PriceCalcMethod:
return new List<TypeCodeDesc>(priceCalcMethods);
case Sbm.SystemCode.PriceRounderMethod:
return new List<TypeCodeDesc>(priceRounderMethods);
case Sbm.SystemCode.PriceRounderDirection:
return new List<TypeCodeDesc>(priceRounderDirections);
case Sbm.SystemCode.SystemAccountType:
return new List<TypeCodeDesc>(systemAccountTypes);
case Sbm.SystemCode.ItemStatus:
return new List<TypeCodeDesc>(itemStatuses);
case Sbm.SystemCode.EventStatus:
return new List<TypeCodeDesc>(eventStatuses);
case Sbm.SystemCode.AssociationTab:
return new List<TypeCodeDesc>(associationTabs);
case Sbm.SystemCode.InterfaceType_Website:
{
// Interface types - Website.
// Duplicate static list and remove unsupported options.
List<TypeCodeDesc> codes = new List<TypeCodeDesc>(interfaceTypes_Website);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.WebStore)))
interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.WebStore);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.JoomlaVirtueMart)))
interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.JoomlaVirtueMart);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.Website, (short)(Sbm.InterfaceType_Website.MiMoWeb)))
interfaceTypes_Website.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_Website.MiMoWeb);
return new List<TypeCodeDesc>(codes);
}
case Sbm.SystemCode.InterfaceType_Accounts:
{
// Interface Type - Accounts.
// Duplicate static list and remove unsupported options.
List<TypeCodeDesc> codes = new List<TypeCodeDesc>(interfaceTypes_Accounts);
return new List<TypeCodeDesc>(codes);
}
case Sbm.SystemCode.InterfaceType_System:
{
// Interface Type - System.
// Duplicate static list and remove unsupported options.
List<TypeCodeDesc> codes = new List<TypeCodeDesc>(interfaceTypes_System);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.MSOutlook))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.MSOutlook);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.PostcodeAnywhere))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.PostcodeAnywhere);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Bac))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Bac);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Pvh))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Pvh);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cap))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cap);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Hpi))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Hpi);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Anchor_OrderFulfilment))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Anchor_OrderFulfilment);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase))
interfaceTypes_System.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase);
return new List<TypeCodeDesc>(codes);
}
case Sbm.SystemCode.InterfaceType_File:
{
// Interface Type - File.
// Duplicate static list and remove unsupported options.
List<TypeCodeDesc> codes = new List<TypeCodeDesc>(interfaceTypes_File);
if (sessionConsole == null || !sessionConsole.AllowInterface(SaInterfaceCategory.System, (short)Sbm.InterfaceType_File.LeasewayInvoice))
codes.RemoveAll(item => item.Type == (int)Sbm.InterfaceType_File.LeasewayInvoice);
return new List<TypeCodeDesc>(codes);
}
case Sbm.SystemCode.InterfaceDataType:
return new List<TypeCodeDesc>(interfaceDataTypes);
case Sbm.SystemCode.ItemDataType:
return new List<TypeCodeDesc>(itemDataTypes);
case Sbm.SystemCode.OrgOption_Value:
return new List<TypeCodeDesc>(orgOption_Values);
case Sbm.SystemCode.OrgOption_Folder:
return new List<TypeCodeDesc>(orgOption_Folders);
case Sbm.SystemCode.OrgOption_Minutes:
return new List<TypeCodeDesc>(OrgOption_Minutes);
case Sbm.SystemCode.OrgOption_PeriodDays:
{
List<TypeCodeDesc> OrgOption_PeriodDays = new List<TypeCodeDesc>();
OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.TransactionDatesInFuture, "TransDatesInFut", "Days in future that transaction dates can be set", "");
OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction, "UpdClosedTrans", "Grace period (days) for updating closed transactions", "Period after transaction closure during which updates are allowed (0-30 days)");
if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.AllowDeliveryPlanning))
OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction_DispatchDetails, "UpdDisDetCloTrans", "Grace period (days) for updating dispatch details on closed order", "Period after transaction closure during which dispatch updates are allowed (0-30 days)");
if (sessionConsole != null && sessionConsole.GetStockControlConfig().AllowStockControl())
OrgOption_PeriodDays.Add(Sbm.OrgOption_PeriodDays.UpdateStockLevelsInPast, "UpdStkLvlInPast", "Update stock levels in past");
return OrgOption_PeriodDays;
}
case Sbm.SystemCode.OrgOption_PeriodWeeks:
{
List<TypeCodeDesc> OrgOption_PeriodWeeks = new List<TypeCodeDesc>();
if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.TimeRecording))
{
OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.Timesheets, "Timesheets", "Weeks of timesheets to list (default 8)");
OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control, "UpdTimeRecsCtrl", "Weeks in past for admin user to update time records (default 2)");
}
OrgOption_PeriodWeeks.Add(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, "ImminStkDue", "Weeks of due stock to treat as imminent", "Weeks for which stock due is treated as imminent (0-12 weeks, default: 0)");
return OrgOption_PeriodWeeks;
}
case Sbm.SystemCode.OrgOption_AllowOption:
return new List<TypeCodeDesc>(orgOption_AllowOptions);
case Sbm.SystemCode.OrgOption_Caption:
{
List<TypeCodeDesc> OrgOption_Caption = new List<TypeCodeDesc>();
if (sessionConsole != null)
{
// Transaction type captions.
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.Project))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_Project, "Project", "Transaction type - Project");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesLead))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesLead, "SalLead", "Transaction type - Sales Lead");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesQuote))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesQuote, "SalQuote", "Transaction type - Sales quote");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesPO))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesPO, "SalPO", "Transaction type - Sales PO");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaSalesOrder, "SalPfOrder", "Transaction type - sales proforma order");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesOrder, "SalOrder", "Transaction type - sales order");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesDispatch))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesDispatch, "SalDispatch", "Transaction type - Sales dispatch");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice, "SalPfInvoice", "Transaction type - Proforma sales invoice");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_SalesInvoice, "SalInvoice", "Transaction type - Sales invoice");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseQuote))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseQuote, "PurQuote", "Transaction type - Purchase quote");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseSO))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseSO, "PurSO", "Transaction type - Purchase SO");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder, "PurPfOrder", "Transaction type - Purchase proforma order");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseOrder, "PurOrder", "Transaction type - Purchase order");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseDelivery, "PurDelivery", "Transaction type - Purchase Delivery");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice, "PurPfInvoice", "Transaction type - Proforma Purchase invoice");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.TransType_PurchaseInvoice, "PurInvoice", "Transaction type - Purchase invoice");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.Project))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_Projects, "MnuOptProject", "Caption - Projects menu option");
// Menu option captions:
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesLead))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesLeads, "MnuOptSalLead", "Caption - Sales leads menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesPO))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesPOs, "MnuOptSalPO", "Caption - Sales POs menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesQuote))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesQuotes, "MnuOptSalQuote", "Caption - Sales quotes menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaSalesOrders, "MnuOptSalPfOrder", "Caption - Proforma sales orders menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesOrders, "MnuOptSalOrder", "Caption - Sales orders menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesDispatch))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesDispatches, "MnuOptSalDispatch", "Caption - Sales dispatches menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaSalesInvoices, "MnuOptSalPfInvoice", "Caption - Proforma sales invoices menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_SalesInvoices, "MnuOptSalInvoice", "Caption - Sales invoices menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseQuote))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseQuotes, "MnuOptPurQuote", "Caption - Purchase quotes menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseSO))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseSOs, "MnuOptPurSO", "Caption - Purchase SOs menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseOrders, "MnuOptPurPfOrder", "Caption - Proforma purchase orders menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseOrder))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseOrders, "MnuOptPurOrder", "Caption - Purchase orders menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseDeliveries, "MnuOptPurDelivery", "Caption - Purchase Deliveries menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseInvoices, "MnuOptPurPfInvoice", "Caption - Proforma purchase invoices menu option");
if (sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice))
OrgOption_Caption.Add(Sbm.OrgOption_Caption.MenuOpt_PurchaseInvoices, "MnuOptPurInvoice", "Caption - Purchase invoices menu option");
}
return OrgOption_Caption;
}
case Sbm.SystemCode.OrgOption_ShowColumn:
{
List<TypeCodeDesc> OrgOption_ShowColumn = new List<TypeCodeDesc>();
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget, "Association:AnnualSalesTarget", "Association: Annual sales target");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised, "Association:Trans:LastSaleRaised", "Association: Last SO raised");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open, "Association:Trans:SalesValue:Open", "Association: SO value: Open");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd, "Association:Trans:SalesValue:Cytd", "Association: SO value: YTD");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy, "Association:Trans:SalesValue:Lcy", "Association: SO value: LCY");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Association_Group, "Association:Group", "Association: Group");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef, "Commodity:CatalogRef", "Commodity: Catalog reference");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_Weight, "Commodity:Weight", "Commodity: Weight");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale, "Commodity:PackQtySale", "Commodity: Pack qty - sale");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated, "Commodity:StockAllocated", "Commodity: Allocated stock");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales, "Commodity:StockLevelSales", "Commodity: Stock level (Sales)");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable, "Commodity:StockAvailable", "Commodity: Available stock");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Order_AllocationInd, "Order:AllocationInd", "Order: Allocation indicator");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier, "SalesOrder:DeliveryCourier", "Order: Delivery courier");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice, "SalesOrder:HasInvoice", "Order: Has invoice flag");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Transaction_ContactArea, "Transaction:ContactArea", "Transaction: " + sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area"));
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef, "Accounts:InvoiceRef", "Accounts: Invoice reference");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd, "OrderItem:AllocationInd", "Order item: Allocation indicator");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current, "OrderItem:StockCurrent", "Order item: Stock current");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available, "OrderItem:StockAvailable", "Order item: Stock available");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation, "OrderItem:StockBySalesLocation", "Order item: Stock by sales location");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched, "SalesOrderItem:QuantityDispatched", "Sales order item: qty dispatched");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced, "SalesOrderItem:QuantityInvoiced", "Sales order item: qty invoiced");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess, "SalesOrderItem:NextProcess", "Sales order item: Next process");
OrgOption_ShowColumn.Add(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation, "Vehicle:KeyLocation", "Vehicle: Key location");
return OrgOption_ShowColumn;
}
case Sbm.SystemCode.OrgOption_ShowField:
return new List<TypeCodeDesc>(orgOption_ShowFields);
case Sbm.SystemCode.OrgOption_FieldLabel:
return new List<TypeCodeDesc>(orgOption_FieldLabels);
case Sbm.SystemCode.OrgOption_TransactionCreationStatus:
return new List<TypeCodeDesc>(orgOption_TransactionCreationStatuses);
case Sbm.SystemCode.OrgOption_ContainerStatusCaption:
return new List<TypeCodeDesc>(orgOption_ContainerStatusCaptions);
case Sbm.SystemCode.OrgOption_NumericDecimals:
return new List<TypeCodeDesc>(orgOption_NumericDecimals);
case Sbm.SystemCode.OrgOption_CommodityType:
return new List<TypeCodeDesc>(orgOption_CommodityTypes);
case Sbm.SystemCode.OrgOption_StockLocation:
return new List<TypeCodeDesc>(orgOption_StockLocations);
case Sbm.SystemCode.OrgOption_TaxCodeColumn:
return new List<TypeCodeDesc>(orgOption_TaxCodeColumns);
case Sbm.SystemCode.OrgOption_SystemUserRight:
return new List<TypeCodeDesc>(orgOption_SystemUserRights);
case Sbm.SystemCode.SystemUserOption:
return new List<TypeCodeDesc>(systemUserOptions);
case Sbm.SystemCode.AssociationOption:
return new List<TypeCodeDesc>(associationOptions);
case Sbm.SystemCode.InterfaceOption:
return new List<TypeCodeDesc>(interfaceOptions);
case Sbm.SystemCode.InterfaceOption_WebFlag:
return new List<TypeCodeDesc>(interfaceOption_WebFlags);
case Sbm.SystemCode.InterfaceOption_WebUploadData:
return new List<TypeCodeDesc>(interfaceOption_WebUploadDatas);
case Sbm.SystemCode.InterfaceOption_WebUploadMethod:
return new List<TypeCodeDesc>(interfaceOption_WebUploadMethods);
case Sbm.SystemCode.InterfaceOption_WebDownloadData:
return new List<TypeCodeDesc>(interfaceOption_WebDownloadDatas);
case Sbm.SystemCode.InterfaceOption_WebDownloadMethod:
return new List<TypeCodeDesc>(interfaceOption_WebDownloadMethods);
case Sbm.SystemCode.FileInterface_RowColValue:
return new List<TypeCodeDesc>(fileInterface_RowColValues);
case Sbm.SystemCode.FileInterface_Mode:
return new List<TypeCodeDesc>(fileInterface_Modes);
}
}
return null;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// D a t a M a n a g e r s // D a t a M a n a g e r s
//------------------------------------------------------------------- //-------------------------------------------------------------------
public abstract SbmAccountMgr CreateAccountMgr(ISbmUserContext_Core userContext); public abstract SbmAccountMgr CreateAccountMgr(SbmInternals internals);
public abstract SbmAssetMgr CreateAssetMgr(ISbmUserContext_Core userContext); public abstract SbmAccountMgr CreateAccountMgr(ISbmUserOrganisationContext userContext);
public abstract SbmCommodityMgr CreateCommodityMgr(ISbmUserContext_Core userContext); public abstract SbmAssetMgr CreateAssetMgr(SbmInternals internals);
public abstract SbmPriceMgr CreatePriceMgr(ISbmUserContext_Core userContext); public abstract SbmAssetMgr CreateAssetMgr(ISbmUserOrganisationContext userContext);
public abstract SbmDataItemMgr CreateDataItemMgr(ISbmUserContext_Core userContext); public abstract SbmCommodityMgr CreateCommodityMgr(SbmInternals internals);
public abstract SbmProcessMgr CreateProcessMgr(ISbmUserContext_Core userContext); public abstract SbmCommodityMgr CreateCommodityMgr(ISbmUserOrganisationContext userContext);
public abstract SbmStockMgr CreateStockMgr(ISbmUserContext_Core userContext); public abstract SbmPriceMgr CreatePriceMgr(SbmInternals internals);
public abstract SbmTransactionMgr CreateTransactionMgr(ISbmUserContext_Core userContext); public abstract SbmPriceMgr CreatePriceMgr(ISbmUserOrganisationContext userContext);
public abstract SbmDataItemMgr CreateDataItemMgr(SbmInternals internals);
public abstract SbmDataItemMgr CreateDataItemMgr(ISbmUserOrganisationContext userContext);
public abstract SbmProcessMgr CreateProcessMgr(SbmInternals internals);
public abstract SbmProcessMgr CreateProcessMgr(ISbmUserOrganisationContext userContext);
public abstract SbmStockMgr CreateStockMgr(SbmInternals internals);
public abstract SbmStockMgr CreateStockMgr(ISbmUserOrganisationContext userContext);
public abstract SbmTransactionMgr CreateTransactionMgr(SbmInternals internals);
public abstract SbmTransactionMgr CreateTransactionMgr(ISbmUserOrganisationContext userContext);
// Control. // Control.
public abstract SbmcAccountMgr CreateControlAccountMgr(); public abstract SbmcAccountMgr CreateControlAccountMgr();
public abstract SbmcInstanceMgr CreateControlInstanceMgr(); public abstract SbmcInstanceMgr CreateControlInstanceMgr();
+4 -179
View File
@@ -14,7 +14,7 @@ using System.Collections.Generic;
namespace Sarand.BusinessMgr.Net.Standard.Base.App namespace Sarand.BusinessMgr.Net.Standard.Base.App
{ {
//======================================================================= //=======================================================================
public class SbmUserContext : ISbmUserContext_Core public class SbmUserContext : ISbmUserOrganisationContext
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Definitions. // Definitions.
@@ -69,8 +69,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public class OrganisationData public class OrganisationData
{ {
internal OrganisationData() { } internal OrganisationData() { }
// Organisation options.
internal readonly SaItemOption.Cache configOptionsCache = new SaItemOption.Cache();
/// <summary>Organisation Affiliate Id.</summary> /// <summary>Organisation Affiliate Id.</summary>
public SysId AffiliateId { get; protected set; } = new SysId(); public SysId AffiliateId { get; protected set; } = new SysId();
/// <summary>Organisation Affiliate Type.</summary> /// <summary>Organisation Affiliate Type.</summary>
@@ -81,8 +79,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
public String InterfaceContext { get; protected set; } = ""; public String InterfaceContext { get; protected set; } = "";
/// <summary>Organisation 'Internal' Association Id.</summary> /// <summary>Organisation 'Internal' Association Id.</summary>
public SysId AssociationId { get; protected set; } = new SysId(); public SysId AssociationId { get; protected set; } = new SysId();
/// <summary>Organisation configuration options</summary>
public List<SaItemOption> ConfigOptions { get { return new List<SaItemOption>(configOptionsCache.ItemOptions); } }
} }
private class OrganisationData_Internal : OrganisationData private class OrganisationData_Internal : OrganisationData
{ {
@@ -93,7 +89,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
AffiliateType = Sbm.AffiliateType.Unknown; AffiliateType = Sbm.AffiliateType.Unknown;
DisplayName = ""; DisplayName = "";
InterfaceContext = ""; InterfaceContext = "";
configOptionsCache.Clear();
} }
internal void Refresh(SbmAffiliate affiliateOrganisation, SbmAssociation associationInternal, String interfaceContext) internal void Refresh(SbmAffiliate affiliateOrganisation, SbmAssociation associationInternal, String interfaceContext)
{ {
@@ -109,21 +104,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Data members. // Data members.
private readonly UserData_Internal userData = new UserData_Internal(); private readonly UserData_Internal userData = new UserData_Internal();
private readonly OrganisationData_Internal organisationData; private readonly OrganisationData_Internal organisationData;
private List<TypeCodeDesc> assocOptions;
private List<TypeCodeDesc> contextValues;
private List<TypeCodeDesc> contextFolders;
private List<TypeCodeDesc> contextAllowOptions;
private List<TypeCodeDesc> contextCaptions;
private List<TypeCodeDesc> contextShowColumns;
private List<TypeCodeDesc> contextShowFields;
private List<TypeCodeDesc> contextFieldLabels;
private List<TypeCodeDesc> contextMinutes;
private List<TypeCodeDesc> contextPeriodDays;
private List<TypeCodeDesc> contextPeriodWeeks;
private List<TypeCodeDesc> contextNumericDecimals;
private List<TypeCodeDesc> contextCommodityTypes;
private List<TypeCodeDesc> commodityTypes;
private List<TypeCodeDesc> contextSalesLocations;
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
@@ -170,138 +150,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
private SbmSecurityProfile securityProfile { get; set; } private SbmSecurityProfile securityProfile { get; set; }
public ISbmSecurityProfile_Core SecurityProfile_Core { get { return securityProfile; } } public ISbmSecurityProfile_Core SecurityProfile_Core { get { return securityProfile; } }
//-------------------------------------------------------------------
// Organisation configuration.
public SaItemOption.Cache OrganisationConfigOptionsCache { get { return organisationData.configOptionsCache; } }
public String GetOrganisationOption(Sbm.OrganisationOption option, String context)
{
if (assocOptions == null) assocOptions = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.AssociationOption);
String optionName = assocOptions.GetCodeForType(option);
return GetOrganisationOption(optionName, context);
}
public String GetOrganisationOption(String optionName, String context)
{
// Retrieve the requested value from the cache.
return organisationData.configOptionsCache.ItemOptions.GetOptionValue(optionName, context);
}
public String GetOwnerOption_Value(Sbm.OrgOption_Value eCol)
{
if (contextValues == null) contextValues = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_Value);
String context = contextValues.GetCodeForType(eCol);
return GetOrganisationOption(Sbm.OrganisationOption.Value, context).Trim();
}
public String GetOwnerOption_Folder(Sbm.OrgOption_Folder eCol)
{
if (contextFolders == null) contextFolders = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_Folder);
String context = contextFolders.GetCodeForType(eCol);
return GetOrganisationOption(Sbm.OrganisationOption.Folder, context).Trim();
}
public bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption eCol)
{
if (contextAllowOptions == null) contextAllowOptions = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_AllowOption);
String context = contextAllowOptions.GetCodeForType(eCol);
String value = GetOrganisationOption(Sbm.OrganisationOption.AllowOption, context).Trim();
return StringUtil.ToBool(value);
}
public String GetOwnerOption_Caption(Sbm.OrgOption_Caption eCol, String defaultValue)
{
if (contextCaptions == null) contextCaptions = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_Caption);
String context = contextCaptions.GetCodeForType(eCol);
String value = GetOrganisationOption(Sbm.OrganisationOption.Caption, context).Trim();
return (!value.IsEmpty() ? value : defaultValue);
}
public bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx eCol)
{
if (contextShowFields == null) contextShowFields = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_ShowField);
String context = contextShowFields.GetCodeForType(eCol);
if (context.IsEmpty()) return true; // Automatically show fields that are not in the 'Show Field' list.
String value = GetOrganisationOption(Sbm.OrganisationOption.ShowField, context).Trim();
return StringUtil.ToBool(value);
}
public bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn eCol)
{
if (contextShowColumns == null) contextShowColumns = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_ShowColumn);
String context = contextShowColumns.GetCodeForType(eCol);
String value = GetOrganisationOption(Sbm.OrganisationOption.ShowColumn, context).Trim();
return StringUtil.ToBool(value);
}
public String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx eCol, String defautValue)
{
if (contextFieldLabels == null) contextFieldLabels = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_FieldLabel);
String context = contextFieldLabels.GetCodeForType(eCol);
String value = GetOrganisationOption(Sbm.OrganisationOption.FieldLabel, context).Trim();
return (!value.IsEmpty() ? value : defautValue); // Return default if no label defined.
}
public int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes eLimit, int defautValue)
{
if (contextMinutes == null) contextMinutes = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_Minutes);
String context = contextMinutes.GetCodeForType(eLimit);
String value = GetOrganisationOption(Sbm.OrganisationOption.Minutes, context).Trim();
if (!value.IsEmpty())
{
int iUpdateLimit = value.ToShort();
if (iUpdateLimit > 0)
return iUpdateLimit;
}
return defautValue;
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays eLimit, int defautValue)
{
if (contextPeriodDays == null) contextPeriodDays = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_PeriodDays);
String context = contextPeriodDays.GetCodeForType(eLimit);
String value = GetOrganisationOption(Sbm.OrganisationOption.PeriodDays, context).Trim();
if (!value.IsEmpty())
{
int iUpdateLimit = value.ToShort();
if (iUpdateLimit > 0)
return iUpdateLimit;
}
return defautValue;
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks eLimit, int defautValue)
{
if (contextPeriodWeeks == null) contextPeriodWeeks = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_PeriodWeeks);
String context = contextPeriodWeeks.GetCodeForType(eLimit);
String value = GetOrganisationOption(Sbm.OrganisationOption.PeriodWeeks, context).Trim();
if (!value.IsEmpty())
{
int iUpdateLimit = value.ToShort();
if (iUpdateLimit > 0)
return iUpdateLimit;
}
return defautValue;
}
public int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals eNumDecimals, int defautValue = 2)
{
if (contextNumericDecimals == null) contextNumericDecimals = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_NumericDecimals);
String context = contextNumericDecimals.GetCodeForType(eNumDecimals);
String value = GetOrganisationOption(Sbm.OrganisationOption.NumericDecimals, context).Trim();
int iNumDecimals = defautValue;
if (!value.IsEmpty())
iNumDecimals = value.ToShort();
iNumDecimals = Math.Min(4, Math.Max(0, iNumDecimals));
return iNumDecimals;
}
public Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityTypeContext)
{
if (contextCommodityTypes == null) contextCommodityTypes = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_CommodityType);
if (commodityTypes == null) commodityTypes = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.CommodityType);
String context = contextCommodityTypes.GetCodeForType(commodityTypeContext);
String value = GetOrganisationOption(Sbm.OrganisationOption.CommodityType, context).Trim();
Sbm.CommodityType eCmdType = (Sbm.CommodityType)commodityTypes.GetTypeForCode(value);
return eCmdType;
}
public SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation eLoc)
{
if (contextSalesLocations == null) contextSalesLocations = SbmSystem.GetCodesOfType(this, Sbm.SystemCode.OrgOption_StockLocation);
String context = contextSalesLocations.GetCodeForType(eLoc);
String value = GetOrganisationOption(Sbm.OrganisationOption.SalesLocation, context).Trim();
SysId idLoc = new SysId();
if (!StringUtil.IsEmpty(value))
idLoc = new SysId(StringUtil.ToInt(value));
return idLoc;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Modify properties - internal only. // Modify properties - internal only.
protected void SetUserData(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners) protected void SetUserData(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
@@ -319,44 +167,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
// Interface context for selected organisation. // Interface context for selected organisation.
String interfaceContext = SbmAccountMgr.GetInterfaceContext(affiliateIdOrganisation); String interfaceContext = SbmAccountMgr.GetInterfaceContext(affiliateIdOrganisation);
SbmAffiliate affiliateOrganisation = null;
SbmAssociation associationInternal = null;
if (SysId.IsValid(affiliateIdOrganisation)) if (SysId.IsValid(affiliateIdOrganisation))
{ {
using (SbmAccountMgr accountMgr = SbmGlobals.System.CreateAccountMgr(this)) using (SbmAccountMgr accountMgr = SbmGlobals.System.CreateAccountMgr(this))
{
// Affiliate. // Affiliate.
affiliateOrganisation = accountMgr.GetAffiliateById(affiliateIdOrganisation); using (SbmAffiliate affiliateOrganisation = accountMgr.GetAffiliateById(affiliateIdOrganisation))
// 'Internal' association. // 'Internal' association.
associationInternal = accountMgr.GetAssociationByOwnerTypeTarget(affiliateIdOrganisation, Sbm.AssociationType.Internal, affiliateIdOrganisation); using (SbmAssociation associationInternal = accountMgr.GetAssociationByOwnerTypeTarget(affiliateIdOrganisation, Sbm.AssociationType.Internal, affiliateIdOrganisation))
}
}
if (affiliateOrganisation != null && associationInternal != null) if (affiliateOrganisation != null && associationInternal != null)
{ {
// Refresh the organisation properties. // Refresh the organisation properties.
organisationData.Refresh(affiliateOrganisation, associationInternal, interfaceContext); organisationData.Refresh(affiliateOrganisation, associationInternal, interfaceContext);
// Refresh organisation options if required.
ItemId affiliateItemId_Owner = new ItemId((short)Sbm.ItemType.Affiliate, organisationData.AffiliateId);
ItemId associationItemId_Owner = new ItemId((short)Sbm.ItemType.Association, organisationData.AssociationId);
if (!organisationData.configOptionsCache.ItemIdRef.Id.Equals(affiliateItemId_Owner))
{
using (SaItemOptionConsole itemOptionConsole = SbmGlobals.Application.CreateItemOptionConsole(this))
{
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($"{SysUtil.Fn} Populated organisation options: {organisationData.configOptionsCache.ItemOptions.Count}.");
}
}
}
} }
else ClearOrganisationData(); else ClearOrganisationData();
if (affiliateOrganisation != null) affiliateOrganisation.Dispose(); affiliateOrganisation = null; }
if (associationInternal != null) associationInternal.Dispose(); associationInternal = null;
} }
protected void ClearOrganisationData() protected void ClearOrganisationData()
{ {
@@ -240,6 +240,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus.Control
public HashSet<ItemId> ItemIdsIncluded { get; } = new HashSet<ItemId>(); public HashSet<ItemId> ItemIdsIncluded { get; } = new HashSet<ItemId>();
/// <summary>Generic search value - name, contact, email, phone etc.</summary> /// <summary>Generic search value - name, contact, email, phone etc.</summary>
public String Search { get; set; } public String Search { get; set; }
public String Context { get; set; }
public String Name { get; set; }
public String NotesPartial { get; set; } public String NotesPartial { get; set; }
/// <summary>Contact status.</summary> /// <summary>Contact status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
@@ -155,7 +155,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
} }
private class QBooksParams private class QBooksParams
{ {
public QBooksParams(ISbmUserContext_Core userContext) public QBooksParams(ISbmUserOrganisationContext userContext)
{ {
} }
// QuickBooks interface definitions. // QuickBooks interface definitions.
@@ -324,7 +324,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
itemOption.DisplayOptions.Group = OptionGroup_Data; itemOption.DisplayOptions.Group = OptionGroup_Data;
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(QuickBooksInterfaceOption.TaxCodeColumn); itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(QuickBooksInterfaceOption.TaxCodeColumn);
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(QuickBooksInterfaceOption.TaxCodeColumn); itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(QuickBooksInterfaceOption.TaxCodeColumn);
itemOption.DisplayOptions.Values.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_TaxCodeColumn)); itemOption.DisplayOptions.Values.AddRange(internals.GetSystemCodes(Sbm.SystemCode.OrgOption_TaxCodeColumn));
//itemOption.DefaultValue = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1); //itemOption.DefaultValue = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1);
interfaceItemOptionDfns.Add(itemOption); interfaceItemOptionDfns.Add(itemOption);
@@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
} }
private class SageParams private class SageParams
{ {
public SageParams(ISbmUserContext_Core userContext, SbmInternals internals) public SageParams(ISbmUserOrganisationContext userContext, SbmInternals internals)
{ {
UserContext = userContext; UserContext = userContext;
this.internals = internals; this.internals = internals;
@@ -249,7 +249,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
SalesOrderColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.SalesOrder_Notes1), "Notes line 1"); SalesOrderColumnSources.Add(SageDbDfn.GetColumnName(SageDbDfn.ColumnIdx.SalesOrder_Notes1), "Notes line 1");
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
private ISbmUserContext_Core UserContext { get; } private ISbmUserOrganisationContext UserContext { get; }
private readonly SbmInternals internals; private readonly SbmInternals internals;
// Sage interface definitions. // Sage interface definitions.
public SaInterface.Data dfnInt_Sage { get; set; } = new SaInterface.Data(); public SaInterface.Data dfnInt_Sage { get; set; } = new SaInterface.Data();
@@ -579,7 +579,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
itemOption.DisplayOptions.Group = OptionGroup_Stock; itemOption.DisplayOptions.Group = OptionGroup_Stock;
itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.TaxCodeColumn); itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(SageInterfaceOption.TaxCodeColumn);
itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.TaxCodeColumn); itemOption.DisplayOptions.Caption = sageStatics.InterfaceOptions.GetDescForType(SageInterfaceOption.TaxCodeColumn);
itemOption.DisplayOptions.Values.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_TaxCodeColumn)); itemOption.DisplayOptions.Values.AddRange(internals.GetSystemCodes(Sbm.SystemCode.OrgOption_TaxCodeColumn));
//itemOption.DefaultValue = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1); //itemOption.DefaultValue = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1);
interfaceItemOptionDfns.Add(itemOption); interfaceItemOptionDfns.Add(itemOption);
@@ -63,13 +63,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmAccountsDfn(ISbmUserContext_Core userContext) public SbmAccountsDfn(ISbmUserOrganisationContext userContext)
{ {
UserContext = userContext; UserContext = userContext;
internals = new SbmInternals(userContext); internals = new SbmInternals(userContext);
sageParams = new SageParams(userContext, internals); sageParams = new SageParams(userContext, internals);
qbkParams = new QBooksParams(userContext); qbkParams = new QBooksParams(userContext);
interfaceOptions = SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.InterfaceOption); interfaceOptions = internals.GetSystemCodes(Sbm.SystemCode.InterfaceOption);
Reset(); Reset();
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
protected SaInterfaceConsole InterfaceConsole { get { return internals.InterfaceConsole; } } protected SaInterfaceConsole InterfaceConsole { get { return internals.InterfaceConsole; } }
protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } } protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } }
+1 -1
View File
@@ -356,7 +356,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAddress(ISbmUserContext_Core userContext, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.AddressType addressType) : protected SbmAddress(ISbmUserOrganisationContext userContext, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.AddressType addressType) :
base(userContext, id) base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
@@ -340,7 +340,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAffiliate(ISbmUserContext_Core userContext, SysId id, Sbm.AffiliateType affiliateType) : base(userContext, id) protected SbmAffiliate(ISbmUserOrganisationContext userContext, SysId id, Sbm.AffiliateType affiliateType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateType = affiliateType; AffiliateType = affiliateType;
+1 -1
View File
@@ -376,7 +376,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAsset(ISbmUserContext_Core userContext, SysId id, SysId assetCatId) : base(userContext, id) protected SbmAsset(ISbmUserOrganisationContext userContext, SysId id, SysId assetCatId) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
Id = id; Id = id;
@@ -215,7 +215,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
private readonly Data data = new Data(); private readonly Data data = new Data();
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAssetCategory(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.AssetType assetType) : base(userContext, id) protected SbmAssetCategory(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.AssetType assetType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffIdOwner = affiliateIdOwner; AffIdOwner = affiliateIdOwner;
@@ -122,7 +122,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
private readonly Data data = new Data(); private readonly Data data = new Data();
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAssetProcess(ISbmUserContext_Core userContext, SysId id, SysId assetId, SysId processId) : base(userContext, id) protected SbmAssetProcess(ISbmUserOrganisationContext userContext, SysId id, SysId assetId, SysId processId) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
Id = id; Id = id;
@@ -504,7 +504,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAssociation(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget) : base(userContext, id) protected SbmAssociation(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.AssociationType associationType, SysId affiliateIdTarget) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -1086,7 +1086,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmCommodity(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.CommodityType commodityType, String code) : base(userContext, id) protected SbmCommodity(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.CommodityType commodityType, String code) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -1858,7 +1858,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
/// <summary>Commodity status.</summary> /// <summary>Commodity status.</summary>
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
// Utilities. // Utilities.
public List<StringPair> GetDisplayValues(ISbmUserContext_Core userContext) public List<StringPair> GetDisplayValues(ISbmUserOrganisationContext userContext)
{ {
SbmAccountMgr accountMgr = null; SbmAccountMgr accountMgr = null;
List<StringPair> lValue = new List<StringPair>(); List<StringPair> lValue = new List<StringPair>();
@@ -1868,7 +1868,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
if (IdsIncluded.Count > 0) lValue.Add("Included commodities", IdsIncluded.Count.ToString()); if (IdsIncluded.Count > 0) lValue.Add("Included commodities", IdsIncluded.Count.ToString());
if (IdsExcluded.Count > 0) lValue.Add("Excluded commodities", IdsExcluded.Count.ToString()); if (IdsExcluded.Count > 0) lValue.Add("Excluded commodities", IdsExcluded.Count.ToString());
// Commodity type. // Commodity type.
if (CommodityType > 0) lValue.Add("Type", SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.CommodityType).GetDescForType(CommodityType, CommodityType.ToString())); if (CommodityType > 0) lValue.Add("Type", SbmSystem.GetSystemCodes(Sbm.SystemCode.CommodityType).GetDescForType(CommodityType, CommodityType.ToString()));
else if (CommodityType == Sbm.CommodityType.AnyProduct) lValue.Add("Type", "Any product"); else if (CommodityType == Sbm.CommodityType.AnyProduct) lValue.Add("Type", "Any product");
if (StockItemsOnly) lValue.Add("Stock items only", "True"); if (StockItemsOnly) lValue.Add("Stock items only", "True");
// Commodity code. // Commodity code.
@@ -125,7 +125,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmCommodityCustomer(ISbmUserContext_Core userContext, SysId commodityId, SysId assocIdCustomer) : base(userContext) protected SbmCommodityCustomer(ISbmUserOrganisationContext userContext, SysId commodityId, SysId assocIdCustomer) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
CommodityId = commodityId; CommodityId = commodityId;
@@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmCommoditySupplier(ISbmUserContext_Core userContext, SysId commodityId, SysId assocIdSupplier) : base(userContext) protected SbmCommoditySupplier(ISbmUserOrganisationContext userContext, SysId commodityId, SysId assocIdSupplier) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
CommodityId = commodityId; CommodityId = commodityId;
@@ -395,7 +395,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmConstituent(ISbmUserContext_Core userContext, SysId id, SysId affIdOwner, SysId assocId, Sbm.ConstituentType constituentType) : base(userContext) protected SbmConstituent(ISbmUserOrganisationContext userContext, SysId id, SysId affIdOwner, SysId assocId, Sbm.ConstituentType constituentType) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
Id = id; Id = id;
@@ -156,7 +156,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmContainer(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.ContainerCategory containerCategory, Sbm.ContainerType containerType) : base(userContext, id) protected SbmContainer(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ContainerCategory containerCategory, Sbm.ContainerType containerType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -159,7 +159,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmContainerItem(ISbmUserContext_Core userContext, SysId containerId, Sbm.ItemType itemType, SysId itemId) : base(userContext) protected SbmContainerItem(ISbmUserOrganisationContext userContext, SysId containerId, Sbm.ItemType itemType, SysId itemId) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
ContainerId = containerId; ContainerId = containerId;
@@ -134,13 +134,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmCostEstimate(ISbmUserContext_Core userContext, Sbm.CostEstimateCategory costEstimateCategory) : base(userContext) public SbmCostEstimate(ISbmUserOrganisationContext userContext, Sbm.CostEstimateCategory costEstimateCategory) : base(userContext)
{ {
CostEstimateCategory = costEstimateCategory; CostEstimateCategory = costEstimateCategory;
Status = DefaultStatus; Status = DefaultStatus;
} }
// Conversion from ItemLink. // Conversion from ItemLink.
public SbmCostEstimate(ISbmUserContext_Core userContext, String archive) : base(userContext) public SbmCostEstimate(ISbmUserOrganisationContext userContext, String archive) : base(userContext)
{ {
String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None); String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None);
costEstimateCategory = (Sbm.CostEstimateCategory)(data.Length > 0 ? StringUtil.ToShort(data[0]) : 0); costEstimateCategory = (Sbm.CostEstimateCategory)(data.Length > 0 ? StringUtil.ToShort(data[0]) : 0);
@@ -442,7 +442,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static void SetCommodityCosts(this List<SbmCostEstimate> values, ISbmUserContext_Core userContext, SbmInternals internals, SbmCommodity commodity, decimal quantity) public static void SetCommodityCosts(this List<SbmCostEstimate> values, ISbmUserOrganisationContext userContext, SbmInternals internals, SbmCommodity commodity, decimal quantity)
{ {
// Retrieve costs from commodity and remove unwanted costs (for other quantities). // Retrieve costs from commodity and remove unwanted costs (for other quantities).
List<SbmCostEstimate> costEstimatesCommodity = internals.CommodityMgr.GetCommodityCostEstimates(commodity); List<SbmCostEstimate> costEstimatesCommodity = internals.CommodityMgr.GetCommodityCostEstimates(commodity);
@@ -9,18 +9,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmHierarchyItem(ISbmUserContext_Core userContext) : base() protected SbmHierarchyItem(ISbmUserOrganisationContext userContext) : base()
{ {
UserContext = userContext; UserContext = userContext;
} }
protected SbmHierarchyItem(ISbmUserContext_Core userContext, SysId id) : base(id) protected SbmHierarchyItem(ISbmUserOrganisationContext userContext, SysId id) : base(id)
{ {
UserContext = userContext; UserContext = userContext;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
//------------------------------------------------------------------- //-------------------------------------------------------------------
} }
@@ -118,7 +118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmItemBatch(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.ItemBatchType itemBatchType, String refs) : base(userContext, id) protected SbmItemBatch(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ItemBatchType itemBatchType, String refs) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
+1 -1
View File
@@ -152,7 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmItemLink(ISbmUserContext_Core userContext, SysId id, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) : base(userContext, id) protected SbmItemLink(ISbmUserOrganisationContext userContext, SysId id, Sbm.ItemLinkType itemLinkType, Sbm.ItemType itemTypeFrom, SysId itemIdFrom, Sbm.ItemType itemTypeTo, SysId itemIdTo) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
ItemLinkType = itemLinkType; ItemLinkType = itemLinkType;
@@ -92,12 +92,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmItemPrice(ISbmUserContext_Core userContext) : base(userContext) public SbmItemPrice(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
Status = DefaultStatus; Status = DefaultStatus;
} }
// Conversion from ItemLink. // Conversion from ItemLink.
public SbmItemPrice(ISbmUserContext_Core userContext, String archive) : base(userContext) public SbmItemPrice(ISbmUserOrganisationContext userContext, String archive) : base(userContext)
{ {
String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None); String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None);
type = (data.Length > 1 ? data[1] : ""); type = (data.Length > 1 ? data[1] : "");
@@ -185,7 +185,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmItemProcess(ISbmUserContext_Core userContext, Sbm.ItemType itemType, SysId itemId, SysId processId) : base(userContext) protected SbmItemProcess(ISbmUserOrganisationContext userContext, Sbm.ItemType itemType, SysId itemId, SysId processId) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
ItemType = itemType; ItemType = itemType;
+1 -1
View File
@@ -113,7 +113,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmLocation(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.LocationCategory locationCategory) : base(userContext, id) protected SbmLocation(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.LocationCategory locationCategory) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
+1 -1
View File
@@ -171,7 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public static readonly Byte Flag_DiaryEntry = 0x01; public static readonly Byte Flag_DiaryEntry = 0x01;
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmMovement(ISbmUserContext_Core userContext, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.MovementType movementType) : base(userContext, id) protected SbmMovement(ISbmUserOrganisationContext userContext, SysId id, Sbm.ItemType itemType, SysId itemId, Sbm.MovementType movementType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
ItemType = itemType; ItemType = itemType;
@@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmPortfolioItem(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.PortfolioItemType portfolioItemType) : base(userContext, id) protected SbmPortfolioItem(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.PortfolioItemType portfolioItemType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
+1 -1
View File
@@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmPrice(ISbmUserContext_Core userContext, SysId priceSetId, SysId commodityId, Sbm.PriceType priceType) : base(userContext) protected SbmPrice(ISbmUserOrganisationContext userContext, SysId priceSetId, SysId commodityId, Sbm.PriceType priceType) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
PriceSetId = priceSetId; PriceSetId = priceSetId;
+1 -1
View File
@@ -121,7 +121,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmPriceSet(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, String reference, Sbm.PriceType priceType) : base(userContext, id) protected SbmPriceSet(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, String reference, Sbm.PriceType priceType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
+1 -1
View File
@@ -129,7 +129,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmProcess(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.ProcessCategory processCategory) : base(userContext, id) protected SbmProcess(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ProcessCategory processCategory) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -702,7 +702,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmRequirement(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, SysId associationId, SysId transactionId, Sbm.RequirementType requirementType) : base(userContext, id) protected SbmRequirement(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, SysId associationId, SysId transactionId, Sbm.RequirementType requirementType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -140,14 +140,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmRequirementCosts(ISbmUserContext_Core userContext) public SbmRequirementCosts(ISbmUserOrganisationContext userContext)
{ {
UserContext = userContext; UserContext = userContext;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Calculation. // Calculation.
@@ -279,8 +279,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
PurchaseCostsPopulated = true; PurchaseCostsPopulated = true;
int decimalsPercent = 2; int decimalsPercent = 2;
List<TypeCodeDesc> ItemLinkDataTypes = new List<TypeCodeDesc>(); List<TypeCodeDesc> ItemLinkDataTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemLinkData);
ItemLinkDataTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemLinkData);
String dataTypeCostProportion = ItemLinkDataTypes.GetCodeForType(Sbm.ItemLinkData.Requirement_AssocItem_PurchaseCostProportion); String dataTypeCostProportion = ItemLinkDataTypes.GetCodeForType(Sbm.ItemLinkData.Requirement_AssocItem_PurchaseCostProportion);
if (itemLinks == null) if (itemLinks == null)
{ {
@@ -156,7 +156,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmStockLevel(ISbmUserContext_Core userContext, SysId id, SysId idCommodity, SysId idLocation, Sbm.StockLevelType type, Sbm.StockLevelSource source) : base(userContext, id) protected SbmStockLevel(ISbmUserOrganisationContext userContext, SysId id, SysId idCommodity, SysId idLocation, Sbm.StockLevelType type, Sbm.StockLevelSource source) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
CommodityId = idCommodity; CommodityId = idCommodity;
+1 -1
View File
@@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmSysParam(ISbmUserContext_Core userContext, SysId id, Sbm.SysParamCategory category, String name) : base(userContext, id) protected SbmSysParam(ISbmUserOrganisationContext userContext, SysId id, Sbm.SysParamCategory category, String name) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
Category = category; Category = category;
@@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmSystemAccount(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, Sbm.SystemAccountType systemAccountType, SysId interfaceId, SysId associationId) : base(userContext, id) protected SbmSystemAccount(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, Sbm.SystemAccountType systemAccountType, SysId interfaceId, SysId associationId) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -91,7 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmSystemAccountUser(ISbmUserContext_Core userContext, SysId accountId, SysId userId) : base(userContext) protected SbmSystemAccountUser(ISbmUserOrganisationContext userContext, SysId accountId, SysId userId) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
AccountId = accountId; AccountId = accountId;
@@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmSystemUser(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, SysId interfaceId, SysId affiliateId) : base(userContext, id) protected SbmSystemUser(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, SysId interfaceId, SysId affiliateId) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
AffiliateIdOwner = affiliateIdOwner; AffiliateIdOwner = affiliateIdOwner;
@@ -648,7 +648,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmTransaction(ISbmUserContext_Core userContext, SysId id, SysId affiliateIdOwner, SysId associationId, Sbm.TransactionType transactionType) : base(userContext, id) protected SbmTransaction(ISbmUserOrganisationContext userContext, SysId id, SysId affiliateIdOwner, SysId associationId, Sbm.TransactionType transactionType) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
Id = id; Id = id;
@@ -794,10 +794,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Status Categories. // Status Categories.
public static List<TypeCodeDesc> GetTransactionStatusCats(ISbmUserContext_Core userContext, Sbm.TransactionType transactionType) public static List<TypeCodeDesc> GetTransactionStatusCats(ISbmUserOrganisationContext userContext, Sbm.TransactionType transactionType)
{ {
List<TypeCodeDesc> statusCats = new List<TypeCodeDesc>(); List<TypeCodeDesc> statusCats = new List<TypeCodeDesc>();
List<TypeCodeDesc> statusCatsFull = SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.TransactionStatusCat); List<TypeCodeDesc> statusCatsFull = SbmSystem.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat);
switch (transactionType) switch (transactionType)
{ {
// NB Changes here may also need to be made in SapTransaction::GetTaxEffectiveDate() // NB Changes here may also need to be made in SapTransaction::GetTaxEffectiveDate()
@@ -861,7 +861,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
{ {
return GetTaxEffectiveDate(UserContext, TransactionType, Status, Raised, InProgress, Closed); return GetTaxEffectiveDate(UserContext, TransactionType, Status, Raised, InProgress, Closed);
} }
public static DateTime GetTaxEffectiveDate(ISbmUserContext_Core userContext, Sbm.TransactionType transactionType, SaStatus status, DateTime raised, DateTime inProgress, DateTime closed) public static DateTime GetTaxEffectiveDate(ISbmUserOrganisationContext userContext, Sbm.TransactionType transactionType, SaStatus status, DateTime raised, DateTime inProgress, DateTime closed)
{ {
// Original thinking was that the status would have an effect on the tax point. // Original thinking was that the status would have an effect on the tax point.
SbmTransaction.StatusCat transactionStatusCat = GetCategoryForStatus(status); SbmTransaction.StatusCat transactionStatusCat = GetCategoryForStatus(status);
@@ -951,7 +951,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
bool updateRequired = true; bool updateRequired = true;
if (messageConsole != null) if (messageConsole != null)
{ {
String transactionType = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionStatusCat).GetDescForType(TransactionType); String transactionType = SbmSystem.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat).GetDescForType(TransactionType);
if (StringUtil.IsEmpty(transactionType)) transactionType = "Transaction"; if (StringUtil.IsEmpty(transactionType)) transactionType = "Transaction";
String message = String message =
"The earliest 'Required' date against unclosed\nrequirements for this " + transactionType + " is " + "The earliest 'Required' date against unclosed\nrequirements for this " + transactionType + " is " +
@@ -988,7 +988,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
bool completeTransaction = true; bool completeTransaction = true;
if (messageConsole != null) if (messageConsole != null)
{ {
String transactionType = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionStatusCat).GetDescForType(TransactionType); String transactionType = SbmSystem.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat).GetDescForType(TransactionType);
if (StringUtil.IsEmpty(transactionType)) transactionType = "Transaction"; if (StringUtil.IsEmpty(transactionType)) transactionType = "Transaction";
String message = String message =
"All of the requirements against this " + transactionType + "\nhave been completed.\n\nSet the status to 'Completed'?"; "All of the requirements against this " + transactionType + "\nhave been completed.\n\nSet the status to 'Completed'?";
@@ -90,12 +90,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
public SbmTransactionPayment(ISbmUserContext_Core userContext) : base(userContext) public SbmTransactionPayment(ISbmUserOrganisationContext userContext) : base(userContext)
{ {
Status = DefaultStatus; Status = DefaultStatus;
} }
// Conversion from ItemLink. // Conversion from ItemLink.
public SbmTransactionPayment(ISbmUserContext_Core userContext, String archive) : base(userContext) public SbmTransactionPayment(ISbmUserOrganisationContext userContext, String archive) : base(userContext)
{ {
String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None); String[] data = archive.Split(new String[] { delimArchive }, StringSplitOptions.None);
type = (data.Length > 1 ? data[1] : ""); type = (data.Length > 1 ? data[1] : "");
+1 -1
View File
@@ -333,7 +333,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmVehicle(ISbmUserContext_Core userContext, SysId id) : base(userContext, id) protected SbmVehicle(ISbmUserOrganisationContext userContext, SysId id) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
//Database = database; //Database = database;
@@ -236,7 +236,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
public static readonly Byte Flag_DescBriefFixed = 0x01; public static readonly Byte Flag_DescBriefFixed = 0x01;
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmVehicleClass(ISbmUserContext_Core userContext, SysId id) : base(userContext, id) protected SbmVehicleClass(ISbmUserOrganisationContext userContext, SysId id) : base(userContext, id)
{ {
base.SetData(data); base.SetData(data);
Status = DefaultStatus; Status = DefaultStatus;
@@ -185,7 +185,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmVehicleEvent(ISbmUserContext_Core userContext, SysId vehicleId, Sbm.VehicleEventType vehicleEventType) : base(userContext, vehicleId) protected SbmVehicleEvent(ISbmUserOrganisationContext userContext, SysId vehicleId, Sbm.VehicleEventType vehicleEventType) : base(userContext, vehicleId)
{ {
base.SetData(data); base.SetData(data);
VehicleId = vehicleId; VehicleId = vehicleId;
@@ -162,7 +162,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmVehicleFeature(ISbmUserContext_Core userContext, SysId vehicleId, Sbm.VehicleFeatureSource vehicleFeatureSource, Sbm.VehicleFeatureType vehicleFeatureType) : base(userContext) protected SbmVehicleFeature(ISbmUserOrganisationContext userContext, SysId vehicleId, Sbm.VehicleFeatureSource vehicleFeatureSource, Sbm.VehicleFeatureType vehicleFeatureType) : base(userContext)
{ {
base.SetData(data); base.SetData(data);
VehicleId = vehicleId; VehicleId = vehicleId;
@@ -43,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
/// Replace dynamic tags in email message body. /// Replace dynamic tags in email message body.
/// <para></para> /// <para></para>
/// </summary> /// </summary>
public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, ISbmUserContext_Core userContext) public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, ISbmUserOrganisationContext userContext)
{ {
// Replace core tags, eg. main stylesheet. // Replace core tags, eg. main stylesheet.
SaEmailConsole.ReplaceDynamicEmailTags(emailData); SaEmailConsole.ReplaceDynamicEmailTags(emailData);
@@ -0,0 +1,415 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Accounts.QuickBooks.App;
using Sarand.Net.Standard.Accounts.Sage.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{
//=======================================================================
/// <summary>
/// Session Console - Transaction processing options/rules.
/// </summary>
partial class SbmSessionConsole
{
//-------------------------------------------------------------------
// Supported Transaction types.
public virtual bool AllowTransactionType(Sbm.TransactionType type)
{
switch (type)
{
// Transaction types that are allowed.
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.SalesOrder:
//case Sbm.TransactionType.PurchaseOrder:
return InstanceConfig.AllowTransactionType(type, true);
// Proforma types are only allowed if ther counterparts cannot be created.
case Sbm.TransactionType.ProformaPurchaseOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.PurchaseOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.PurchaseOrder));
case Sbm.TransactionType.ProformaSalesOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesOrder));
case Sbm.TransactionType.ProformaSalesInvoice:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesInvoice) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesInvoice));
}
return false;
}
//-------------------------------------------------------------------
// Create Transaction.
public virtual bool CanCreateTransactionLocally(Sbm.TransactionType type)
{
if (!AllowTransactionType(type)) return false;
// Refresh options.
if (dfnSageInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId || dfnQBooksInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId)
{
// Reset the accounts interface configurations.
dfnSageInt.ClearConfig();
dfnSageInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
dfnQBooksInt.ClearConfig();
dfnQBooksInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
// Identify the interfaces.
dfnSageInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.SageLine50);
dfnQBooksInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.QuickBooks);
// Sales and purchase orders/invoices can only be created locally if they are not imported from one of these interfaces.
if (SysId.IsValid(dfnSageInt.InterfaceId))
{
// Interpret interface options.
dfnSageInt.importPurchaseOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.importSalesOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.SalesOrder);
dfnSageInt.importProductInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.importServiceInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.importSalesOrderInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_SalesOrder);
dfnSageInt.exportPurchaseOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.SalesOrder);
dfnSageInt.exportProductInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.exportServiceInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_SalesOrder);
}
if (SysId.IsValid(dfnQBooksInt.InterfaceId))
{
// Interpret interface options.
dfnQBooksInt.importPurchaseOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.importSalesOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.importProductInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.importServiceInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.importSalesOrderInvoice = false;
dfnQBooksInt.exportPurchaseOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.exportSalesOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.exportProductInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.exportServiceInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.bexport_SalesOrderInvoice = false;
}
// Transaction types cannot be created locally if they are either imported from or exported to Sage.
// In the case of exports, it is the 'proforma' equivalent that can be created for export.
createTransaction_PurchaseOrder = true;
createTransaction_SalesQuote = true;
createTransaction_SalesOrder = true;
createTrans_SalesInvoice = true;
if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnSageInt.importPurchaseOrder && !dfnSageInt.exportPurchaseOrder;
if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnSageInt.importSalesOrder && !dfnSageInt.exportSalesOrder;
if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnSageInt.importProductInvoice && !dfnSageInt.exportProductInvoice && !dfnSageInt.importServiceInvoice && !dfnSageInt.exportServiceInvoice && !dfnSageInt.importSalesOrderInvoice && !dfnSageInt.bexport_SalesOrderInvoice;
if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnQBooksInt.importPurchaseOrder && !dfnQBooksInt.exportPurchaseOrder;
if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnQBooksInt.importSalesOrder && !dfnQBooksInt.exportSalesOrder;
if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnQBooksInt.importProductInvoice && !dfnQBooksInt.exportProductInvoice && !dfnQBooksInt.importServiceInvoice && !dfnQBooksInt.exportServiceInvoice && !dfnQBooksInt.importSalesOrderInvoice && !dfnQBooksInt.bexport_SalesOrderInvoice;
// Sales quotes are also imported from Sage Sales Orders.
createTransaction_SalesQuote = createTransaction_SalesOrder;
}
switch (type)
{
case Sbm.TransactionType.SalesQuote:
return createTransaction_SalesQuote;
case Sbm.TransactionType.SalesOrder:
return createTransaction_SalesOrder;
case Sbm.TransactionType.SalesInvoice:
return createTrans_SalesInvoice;
case Sbm.TransactionType.PurchaseOrder:
return createTransaction_PurchaseOrder;
}
return true;
}
//-------------------------------------------------------------------
// Transaction Creation options.
public enum AssignTransRefMethod
{
System, Manual, Option
}
public virtual AssignTransRefMethod TransactionAssignRefMethod(Sbm.TransactionType transTypes)
{
return AssignTransRefMethod.System;
}
public enum AssignTransRefSource
{
ByOwnerType, ByType
}
public virtual AssignTransRefSource TransactionAssignRefSource(Sbm.TransactionType transTypes)
{
return AssignTransRefSource.ByOwnerType;
}
// By default all types of transaction have their own Id sequence.
// Override this method to allow different types of transaction to share Id sequence.
public virtual Sbm.TransactionType GetTransactionTypeForNextId(Sbm.TransactionType transTypes)
{
return transTypes;
}
// NextId key value.
public virtual string GetTransactionNextIdKey(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType)
{
idAssoc = new SysId();
Sbm.TransactionType transTypes = GetTransactionTypeForNextId(eType);
switch (TransactionAssignRefSource(eType))
{
case AssignTransRefSource.ByOwnerType:
// Next Id depends on both the transaction type and owner.
return "TransRef:" + transTypes.ToString() + ":" + AffiliateId_Owner.ToString();
default:
// Next Id only depends on the transaction type.
return "TransRef:" + transTypes.ToString();
}
}
// Set the minimum Id for transactions of the specified type.
public virtual bool SetMinTransactionId(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
{
bool set = false;
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string nextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo set = SbmGlobals.Database.SetMinNextId(nextIdKey, iId, false);
}
return set;
}
// The implementation in this class will generate simple numeric values for the owner
// and global options that can be formatted (eg. to fixed length) by overwridden versions.
public virtual string GetTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
string Ref = "";
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string NextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo long iRefNext = SbmGlobals.Database.GetNextId(NextIdKey, false);
// Ref = FormatTransactionCreateRef(AffiliateId_Owner, idAssoc, transTypes, iRefNext);
}
return Ref;
}
public virtual string FormatTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt)
{
string Ref = "";
if (RefInt > 0)
{
// Retrieve and validate the sequence padding length.
int SeqLen = Math.Max(1, Math.Min(8, GetTransactionRefSeqLength(AffiliateId_Owner, idAssoc, transTypes)));
// Pad the sequence number.
//Ref = String(RefInt, SeqLen);
// Add the reference prefix (max 5 chars)
string prefix = GetTransactionRefPrefix(AffiliateId_Owner, idAssoc, transTypes);
Ref = prefix.Left(5) + Ref;
}
return Ref;
}
public virtual int GetTransactionRefSeqLength(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
return 5;
}
//-------------------------------------------------------------------
/// <summary>Transaction reference prefix by type</summary>
public virtual string GetTransactionRefPrefix(SysId id, SysId idAssoc, Sbm.TransactionType transactionType)
{
return "";
}
//-------------------------------------------------------------------
// Raise Transaction.
public virtual bool CanRaiseTransaction(Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo)
{
if (!AllowTransactionType(typeFrom) || !AllowTransactionType(typeTo)) return false;
if (!CanCreateTransactionLocally(typeTo)) return false;
if (typeFrom == Sbm.TransactionType.Project)
{
// Can raise another project from a project.
switch (typeTo)
{
case Sbm.TransactionType.Project:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesLead)
{
// Can raise sales quote or order from a lead.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesQuote)
{
// Can raise sales lead or order from a sales quote.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesOrder || typeFrom == Sbm.TransactionType.ProformaSalesOrder)
{
// Can raise almost anything from a sales order.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
// Can also raise purchase quote or order from sales order:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesDispatch)
{
// Can raise a sales invoice from a dispatch note.
switch (typeTo)
{
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseQuote)
{
// Can raise a purchase order from purchase quote.
switch (typeTo)
{
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseOrder || typeFrom == Sbm.TransactionType.ProformaPurchaseOrder)
{
// Can raise a sales order or purchase quote from a purchase order.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
return false;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom)
{
// Build the list of transaction types that are allowed to be raised from the specified type.
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
if (transactionTypes_Full.Count == 0) transactionTypes_Full = internals.GetSystemCodes(Sbm.SystemCode.TransactionType);
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//if ((Sbm.TransactionType)typeTo.iType == typeFrom) continue;
if (CanRaiseTransaction(typeFrom, (Sbm.TransactionType)transTypeTo.Type))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo)
{
// Build the list of transaction types that are allowed to be raised to the specified type.
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
if (transactionTypes_Full.Count == 0) transactionTypes_Full = internals.GetSystemCodes(Sbm.SystemCode.TransactionType);
//transTypes_Full.GotoStart();
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//TypeCodeDesc & typeTo = transTypes_Full.Index();
if ((Sbm.TransactionType)transTypeTo.Type == typeTo) continue;
if (CanRaiseTransaction((Sbm.TransactionType)transTypeTo.Type, typeTo))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
// Prepare Requirements Transaction. - Prepare copied list of requirements, eg. when raising from another transaction.
public virtual bool PrepareCopiedRequirements(SbmTransaction transSource, List<SbmRequirement> requireList, Sbm.TransactionType type)
{
type = new Sbm.TransactionType();
//transSource; requireList; type;
return false;
}
//-------------------------------------------------------------------
// Remove Transaction.- By default, not allowed if transaction has requirements.
public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, int requirementCount)
{
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
return requirementCount < 1;
}
//-------------------------------------------------------------------
// Tax Effective Date. - TransTypes that should use the 'In Progress' date as tax point as opposed to the 'Raised' date.
public virtual bool UseInProgressTaxDateAsTaxPoint(Sbm.TransactionType transactionType)
{
switch (transactionType)
{
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseDelivery:
case Sbm.TransactionType.ProformaSalesInvoice:
return false;
}
return true;
}
//-------------------------------------------------------------------
// R e q u i r e m e n t O p t i o n s
//-------------------------------------------------------------------
// Requirement Actions.
public virtual bool SearchCommodityOnCreateRequirement(Sbm.TransactionType transactionType)
{
return false;
}
//-------------------------------------------------------------------
// Requirement Costing.
public virtual SbmRequirementCostingConfig GetRequirementCostingConfig()
{
SbmRequirementCostingConfig cfgRequirementCosting = new SbmRequirementCostingConfig();
return cfgRequirementCosting;
}
//-------------------------------------------------------------------
// Transaction Maintenance Dialogs.
/*
public SapDlgUpdateTransaction GetCreateTransactionDlg (ISbmUserContext userContext, SysId id, Sbm.TransactionType type)
{
return null;
}
public SapDlgUpdateTransaction GetUpdateTransactionDlg (ISbmUserContext userContext, Sbm.TransactionType type, bool readOnly)
{
return null;
}
*/
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -1,4 +1,5 @@
using Sarand.BusinessMgr.Net.Standard.Base.App; using Org.BouncyCastle.Asn1.X509;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus; using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.BusinessMgr.Net.Standard.Base.Procs; using Sarand.BusinessMgr.Net.Standard.Base.Procs;
@@ -12,6 +13,9 @@ using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
using static Sarand.Net.Standard.Base.Core.StringPair;
using static Sarand.Net.Standard.Base.ItemOptions.SaItemOptionDfn;
namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{ {
@@ -19,7 +23,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
/// <summary> /// <summary>
/// Application configuration associated with a specific session. /// Application configuration associated with a specific session.
/// </summary> /// </summary>
public class SbmSessionConsole : SacsDisposable public partial class SbmSessionConsole : SacsDisposable, ISbmOrganisationConfig
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Interface definition. // Interface definition.
@@ -73,6 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
private SbmInternals internals; private SbmInternals internals;
private List<TypeCodeDesc> transactionTypes_Full = new List<TypeCodeDesc>(); private List<TypeCodeDesc> transactionTypes_Full = new List<TypeCodeDesc>();
private SbmInstanceConfig instanceConfig; private SbmInstanceConfig instanceConfig;
private SbmOrganisationConfig organisationConfig;
private AccountsInterfaceDfn dfnSageInt = new AccountsInterfaceDfn(); private AccountsInterfaceDfn dfnSageInt = new AccountsInterfaceDfn();
private AccountsInterfaceDfn dfnQBooksInt = new AccountsInterfaceDfn(); private AccountsInterfaceDfn dfnQBooksInt = new AccountsInterfaceDfn();
private bool createTransaction_PurchaseOrder, createTransaction_SalesQuote, createTransaction_SalesOrder, createTrans_SalesInvoice; private bool createTransaction_PurchaseOrder, createTransaction_SalesQuote, createTransaction_SalesOrder, createTrans_SalesInvoice;
@@ -80,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserContext_Core userContext) protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserOrganisationContext userContext)
{ {
this.SessionConfig = sessionConfig; this.SessionConfig = sessionConfig;
this.AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt); this.AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt);
@@ -98,20 +103,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
public Sbm.SessionConfig SessionConfig { get; } public Sbm.SessionConfig SessionConfig { get; }
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
public SbmVersion AppVersion { get; } public SbmVersion AppVersion { get; }
public SbmVersion ConsoleVersion { get; } public SbmVersion ConsoleVersion { get; }
public SbmInstanceConfig InstanceConfig { get { if (instanceConfig == null) instanceConfig = SbmGlobals.Application.GetInstanceConfig(SessionContext); return instanceConfig; } } public SbmInstanceConfig InstanceConfig { get { if (instanceConfig == null) instanceConfig = SbmGlobals.Application.GetInstanceConfig(SessionContext); return instanceConfig; } }
public SbmOrganisationConfig OrganisationConfig { get { if (organisationConfig == null) organisationConfig = SbmGlobals.Application.GetOrganisationConfig(UserContext); return organisationConfig; } }
private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } } private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// C r e a t e C o n s o l e // C r e a t e C o n s o l e
//------------------------------------------------------------------- //-------------------------------------------------------------------
public static SbmSessionConsole CreateConsole(ISbmUserContext_Core userContext) public static SbmSessionConsole CreateConsole(ISbmUserOrganisationContext userContext)
{ {
SaLogger.Warn($"{SysUtil.Fn} Creating default configuration console."); // Initialise console.
// Default console.
SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt); SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt);
return new SbmSessionConsole(Sbm.SessionConfig.Generic, consoleVersion, userContext); return new SbmSessionConsole(Sbm.SessionConfig.Generic, consoleVersion, userContext);
} }
@@ -120,7 +125,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Utilities. // Utilities.
//------------------------------------------------------------------- //-------------------------------------------------------------------
// A p p l i c a t i o n // Organisation configuration.
//-------------------------------------------------------------------
public String GetOrganisationOption(Sbm.OrganisationOption option, String context)
{
return OrganisationConfig.GetOrganisationOption(option, context);
}
public String GetOrganisationOption(String optionName, String context)
{
return OrganisationConfig.GetOrganisationOption(optionName, context);
}
public String GetOwnerOption_Value(Sbm.OrgOption_Value value)
{
return OrganisationConfig.GetOwnerOption_Value(value);
}
public String GetOwnerOption_Folder(Sbm.OrgOption_Folder folder)
{
return OrganisationConfig.GetOwnerOption_Folder(folder);
}
public bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption option)
{
return OrganisationConfig.GetOwnerOption_AllowOption(option);
}
public String GetOwnerOption_Caption(Sbm.OrgOption_Caption caption, String defaultValue)
{
return OrganisationConfig.GetOwnerOption_Caption(caption, defaultValue);
}
public bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx column)
{
return OrganisationConfig.GetOwnerOption_ShowField(column);
}
public bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn column)
{
return OrganisationConfig.GetOwnerOption_ShowColumn(column);
}
public String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx column, String defautValue)
{
return OrganisationConfig.GetOwnerOption_FieldLabel(column, defautValue);
}
public int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes limit, int defautValue)
{
return OrganisationConfig.GetOwnerOption_Minutes(limit, defautValue);
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays limit, int defautValue)
{
return OrganisationConfig.GetOwnerOption_UpdateLimit(limit, defautValue);
}
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks limit, int defautValue)
{
return OrganisationConfig.GetOwnerOption_UpdateLimit(limit, defautValue);
}
public int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals decimals, int defautValue = 2)
{
return OrganisationConfig.GetOwnerOption_NumericDecimals(decimals, defautValue);
}
public Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityType)
{
return OrganisationConfig.GetOwnerOption_CommodityType(commodityType);
}
public SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation stockLocation)
{
return OrganisationConfig.GetOwnerOption_StockLocation(stockLocation);
}
//-------------------------------------------------------------------
// Application.
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Application Customisation. // Application Customisation.
public virtual string GetApplicationCaption(Sbm.CaptionType captionType) public virtual string GetApplicationCaption(Sbm.CaptionType captionType)
@@ -160,20 +229,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Application. // Application.
case Sbm.ConfigOption.SystemMenu: case Sbm.ConfigOption.SystemMenu:
return InstanceConfig.AllowApplicationOption(option, SacsSystem.DebugMode); return InstanceConfig.AllowApplicationOption(option, SacsSystem.DebugMode);
case Sbm.ConfigOption.AllowConsoleView: // Options allowed by default.
case Sbm.ConfigOption.AllowOrganisationUpdate: case Sbm.ConfigOption.ConsoleView:
case Sbm.ConfigOption.AllowContacts: case Sbm.ConfigOption.OrganisationUpdate:
case Sbm.ConfigOption.AllowProcesses: case Sbm.ConfigOption.Contacts:
case Sbm.ConfigOption.AllowCommodities: case Sbm.ConfigOption.Processes:
case Sbm.ConfigOption.AllowTransactions: case Sbm.ConfigOption.Commodities:
case Sbm.ConfigOption.Transactions:
case Sbm.ConfigOption.DiaryView: case Sbm.ConfigOption.DiaryView:
case Sbm.ConfigOption.AllowRequirementUpdateInline: case Sbm.ConfigOption.RequirementUpdateInline:
return InstanceConfig.AllowApplicationOption(option, true); return InstanceConfig.AllowApplicationOption(option, true);
// Commodities. // Commodities.
case Sbm.ConfigOption.CommodityPartialCodeFilter: case Sbm.ConfigOption.CommodityPartialCodeFilter:
if (InstanceConfig.AllowApplicationOption(option, false)) if (InstanceConfig.AllowApplicationOption(option, false))
return true; return true;
return UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter); return OrganisationConfig.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter);
// Order Pricing. // Order Pricing.
case Sbm.ConfigOption.CustomerPriceSet: case Sbm.ConfigOption.CustomerPriceSet:
case Sbm.ConfigOption.CustomerDiscount: case Sbm.ConfigOption.CustomerDiscount:
@@ -189,9 +259,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
return true; return true;
return Internals.AccountsDfn.IsUsingSageInterface() && Internals.AccountsDfn.IsAssociationTypeManagedByAccounts(Sbm.AssociationType.Supplier) && !Internals.AccountsDfn.UseLocalSupplierPricing(); return Internals.AccountsDfn.IsUsingSageInterface() && Internals.AccountsDfn.IsAssociationTypeManagedByAccounts(Sbm.AssociationType.Supplier) && !Internals.AccountsDfn.UseLocalSupplierPricing();
} }
} default:
// Other options are not allowed by default.
return InstanceConfig.AllowApplicationOption(option, false); return InstanceConfig.AllowApplicationOption(option, false);
} }
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Application events. // Application events.
@@ -334,24 +406,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// I t e m s // I t e m s
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Item Data Interface. // Item Data Interface.
public virtual bool CanUpdateItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType) public virtual bool CanUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
{ {
return false; return false;
} }
public virtual bool DoUpdateItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType) public virtual bool DoUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
{ {
return false; return false;
} }
public virtual bool CanRemoveItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType) public virtual bool CanRemoveItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType)
{ {
return false; return false;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Update Log. // Update Log.
public virtual bool IsColumnChangeLogged(ISbmUserContext_Core userContext, SbmDbDfn.ColumnIdx column) public virtual bool IsColumnChangeLogged(ISbmUserOrganisationContext userContext, SbmDbDfn.ColumnIdx column)
{ {
return false; return false;
} }
@@ -377,27 +449,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{ {
return InstanceConfig.AllowAssociationType(type, true); return InstanceConfig.AllowAssociationType(type, true);
} }
// Supported Transaction types.
public virtual bool AllowTransactionType(Sbm.TransactionType type)
{
switch (type)
{
// Transaction types that are allowed.
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.SalesOrder:
//case Sbm.TransactionType.PurchaseOrder:
return InstanceConfig.AllowTransactionType(type, true);
// Proforma types are only allowed if ther counterparts cannot be created.
case Sbm.TransactionType.ProformaPurchaseOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.PurchaseOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.PurchaseOrder));
case Sbm.TransactionType.ProformaSalesOrder:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesOrder) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesOrder));
case Sbm.TransactionType.ProformaSalesInvoice:
return InstanceConfig.AllowTransactionType(type, AllowTransactionType(Sbm.TransactionType.SalesInvoice) && !CanCreateTransactionLocally(Sbm.TransactionType.SalesInvoice));
}
return false;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// D a t a O p t i o n s // D a t a O p t i o n s
@@ -411,28 +462,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Commodity - specification. // Commodity - specification.
case SbmDbDfn.ColumnIdx.Commodity_Weight: case SbmDbDfn.ColumnIdx.Commodity_Weight:
case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight: case SbmDbDfn.ColumnIdx.Commodity_UomIdWeight:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Weight);
case SbmDbDfn.ColumnIdx.Commodity_Length: case SbmDbDfn.ColumnIdx.Commodity_Length:
case SbmDbDfn.ColumnIdx.Commodity_UomIdLength: case SbmDbDfn.ColumnIdx.Commodity_UomIdLength:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Length);
case SbmDbDfn.ColumnIdx.Commodity_Volume: case SbmDbDfn.ColumnIdx.Commodity_Volume:
case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume: case SbmDbDfn.ColumnIdx.Commodity_UomIdVolume:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Volume);
case SbmDbDfn.ColumnIdx.Commodity_Density: case SbmDbDfn.ColumnIdx.Commodity_Density:
case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity: case SbmDbDfn.ColumnIdx.Commodity_UomIdDensity:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_Density);
case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity: case SbmDbDfn.ColumnIdx.Commodity_BoxQuantity:
case SbmDbDfn.ColumnIdx.Commodity_UomIdBox: case SbmDbDfn.ColumnIdx.Commodity_UomIdBox:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity);
case SbmDbDfn.ColumnIdx.Commodity_TimeProd: case SbmDbDfn.ColumnIdx.Commodity_TimeProd:
case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd: case SbmDbDfn.ColumnIdx.Commodity_UomIdTimeProd:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_TimeProd);
case SbmDbDfn.ColumnIdx.Commodity_MaterialCost: case SbmDbDfn.ColumnIdx.Commodity_MaterialCost:
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial: case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_MaterialCost);
case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost: case SbmDbDfn.ColumnIdx.Commodity_ExWorksCost:
case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks: case SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost);
case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj: case SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01:
@@ -447,9 +498,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth10:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth11:
case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12:
return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual); return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual);
default: default:
return UserContext.GetOwnerOption_ShowField(column); return OrganisationConfig.GetOwnerOption_ShowField(column);
} }
} }
@@ -460,388 +511,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
string Caption = ""; string Caption = "";
if (column != SbmDbDfn.ColumnIdx.Unknown) if (column != SbmDbDfn.ColumnIdx.Unknown)
{ {
Caption = UserContext.GetOwnerOption_FieldLabel(column, Default); Caption = OrganisationConfig.GetOwnerOption_FieldLabel(column, Default);
} }
if (Caption.IsEmpty()) Caption = Default; if (Caption.IsEmpty()) Caption = Default;
return Caption; return Caption;
} }
//------------------------------------------------------------------- // To do - move to InstanceConfig.
// T r a n s a c t i o n O p t i o n s
//-------------------------------------------------------------------
// Job Tracking Options. // Job Tracking Options.
public virtual string GetDefaultQuoteDescIntro() public virtual string GetDefaultQuoteDescIntro()
{ {
return ""; return "";
} }
//-------------------------------------------------------------------
// Transaction Maintenance Dialogs.
/*
public SapDlgUpdateTransaction GetCreateTransactionDlg (ISbmUserContext userContext, SysId id, Sbm.TransactionType type)
{
return null;
}
public SapDlgUpdateTransaction GetUpdateTransactionDlg (ISbmUserContext userContext, Sbm.TransactionType type, bool readOnly)
{
return null;
}
*/
//-------------------------------------------------------------------
// Create Transaction.
public virtual bool CanCreateTransactionLocally(Sbm.TransactionType type)
{
if (!AllowTransactionType(type)) return false;
// Refresh options.
if (dfnSageInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId || dfnQBooksInt.AffiliateId_Owner != UserContext.OrganisationAffiliateId)
{
// Reset the accounts interface configurations.
dfnSageInt.ClearConfig();
dfnSageInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
dfnQBooksInt.ClearConfig();
dfnQBooksInt.AffiliateId_Owner = UserContext.OrganisationAffiliateId;
// Identify the interfaces.
dfnSageInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.SageLine50);
dfnQBooksInt.InterfaceId = Internals.AccountsDfn.GetAccountInterfaceId(Sbm.InterfaceType_Accounts.QuickBooks);
// Sales and purchase orders/invoices can only be created locally if they are not imported from one of these interfaces.
if (SysId.IsValid(dfnSageInt.InterfaceId))
{
// Interpret interface options.
dfnSageInt.importPurchaseOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.importSalesOrder = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.SalesOrder);
dfnSageInt.importProductInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.importServiceInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.importSalesOrderInvoice = Internals.AccountsDfn.GetSageImportOption(Sage.ItemType.Invoice_SalesOrder);
dfnSageInt.exportPurchaseOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.PurchaseOrder);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.SalesOrder);
dfnSageInt.exportProductInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Product);
dfnSageInt.exportServiceInvoice = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_Service);
dfnSageInt.exportSalesOrder = Internals.AccountsDfn.GetSageExportOption(Sage.ItemType.Invoice_SalesOrder);
}
if (SysId.IsValid(dfnQBooksInt.InterfaceId))
{
// Interpret interface options.
dfnQBooksInt.importPurchaseOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.importSalesOrder = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.importProductInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.importServiceInvoice = Internals.AccountsDfn.GetQuickBooksImportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.importSalesOrderInvoice = false;
dfnQBooksInt.exportPurchaseOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.PurchaseOrder);
dfnQBooksInt.exportSalesOrder = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.SalesOrder);
dfnQBooksInt.exportProductInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Product);
dfnQBooksInt.exportServiceInvoice = Internals.AccountsDfn.GetQuickBooksExportOption(Qbk.EntityType.Invoice_Service);
dfnQBooksInt.bexport_SalesOrderInvoice = false;
}
// Transaction types cannot be created locally if they are either imported from or exported to Sage.
// In the case of exports, it is the 'proforma' equivalent that can be created for export.
createTransaction_PurchaseOrder = true;
createTransaction_SalesQuote = true;
createTransaction_SalesOrder = true;
createTrans_SalesInvoice = true;
if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnSageInt.importPurchaseOrder && !dfnSageInt.exportPurchaseOrder;
if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnSageInt.importSalesOrder && !dfnSageInt.exportSalesOrder;
if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnSageInt.importProductInvoice && !dfnSageInt.exportProductInvoice && !dfnSageInt.importServiceInvoice && !dfnSageInt.exportServiceInvoice && !dfnSageInt.importSalesOrderInvoice && !dfnSageInt.bexport_SalesOrderInvoice;
if (createTransaction_PurchaseOrder) createTransaction_PurchaseOrder = !dfnQBooksInt.importPurchaseOrder && !dfnQBooksInt.exportPurchaseOrder;
if (createTransaction_SalesOrder) createTransaction_SalesOrder = !dfnQBooksInt.importSalesOrder && !dfnQBooksInt.exportSalesOrder;
if (createTrans_SalesInvoice) createTrans_SalesInvoice = !dfnQBooksInt.importProductInvoice && !dfnQBooksInt.exportProductInvoice && !dfnQBooksInt.importServiceInvoice && !dfnQBooksInt.exportServiceInvoice && !dfnQBooksInt.importSalesOrderInvoice && !dfnQBooksInt.bexport_SalesOrderInvoice;
// Sales quotes are also imported from Sage Sales Orders.
createTransaction_SalesQuote = createTransaction_SalesOrder;
}
switch (type)
{
case Sbm.TransactionType.SalesQuote:
return createTransaction_SalesQuote;
case Sbm.TransactionType.SalesOrder:
return createTransaction_SalesOrder;
case Sbm.TransactionType.SalesInvoice:
return createTrans_SalesInvoice;
case Sbm.TransactionType.PurchaseOrder:
return createTransaction_PurchaseOrder;
}
return true;
}
//-------------------------------------------------------------------
// Transaction Creation options.
public enum AssignTransRefMethod
{
System, Manual, Option
}
public virtual AssignTransRefMethod TransactionAssignRefMethod(Sbm.TransactionType transTypes)
{
return AssignTransRefMethod.System;
}
public enum AssignTransRefSource
{
ByOwnerType, ByType
}
public virtual AssignTransRefSource TransactionAssignRefSource(Sbm.TransactionType transTypes)
{
return AssignTransRefSource.ByOwnerType;
}
// By default all types of transaction have their own Id sequence.
// Override this method to allow different types of transaction to share Id sequence.
public virtual Sbm.TransactionType GetTransactionTypeForNextId(Sbm.TransactionType transTypes)
{
return transTypes;
}
// NextId key value.
public virtual string GetTransactionNextIdKey(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType)
{
idAssoc = new SysId();
Sbm.TransactionType transTypes = GetTransactionTypeForNextId(eType);
switch (TransactionAssignRefSource(eType))
{
case AssignTransRefSource.ByOwnerType:
// Next Id depends on both the transaction type and owner.
return "TransRef:" + transTypes.ToString() + ":" + AffiliateId_Owner.ToString();
default:
// Next Id only depends on the transaction type.
return "TransRef:" + transTypes.ToString();
}
}
// Set the minimum Id for transactions of the specified type.
public virtual bool SetMinTransactionId(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
{
bool set = false;
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string nextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo set = SbmGlobals.Database.SetMinNextId(nextIdKey, iId, false);
}
return set;
}
// The implementation in this class will generate simple numeric values for the owner
// and global options that can be formatted (eg. to fixed length) by overwridden versions.
public virtual string GetTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
string Ref = "";
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
{
string NextIdKey = GetTransactionNextIdKey(AffiliateId_Owner, idAssoc, transTypes);
// ToDo long iRefNext = SbmGlobals.Database.GetNextId(NextIdKey, false);
// Ref = FormatTransactionCreateRef(AffiliateId_Owner, idAssoc, transTypes, iRefNext);
}
return Ref;
}
public virtual string FormatTransactionCreateRef
(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt)
{
string Ref = "";
if (RefInt > 0)
{
// Retrieve and validate the sequence padding length.
int SeqLen = Math.Max(1, Math.Min(8, GetTransactionRefSeqLength(AffiliateId_Owner, idAssoc, transTypes)));
// Pad the sequence number.
//Ref = String(RefInt, SeqLen);
// Add the reference prefix (max 5 chars)
string prefix = GetTransactionRefPrefix(AffiliateId_Owner, idAssoc, transTypes);
Ref = prefix.Left(5) + Ref;
}
return Ref;
}
public virtual int GetTransactionRefSeqLength(SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
{
return 5;
}
//-------------------------------------------------------------------
/// <summary>Transaction reference prefix by type</summary>
public virtual string GetTransactionRefPrefix(SysId id, SysId idAssoc, Sbm.TransactionType transactionType)
{
return "";
}
//-------------------------------------------------------------------
// Raise Transaction.
public virtual bool CanRaiseTransaction(Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo)
{
if (!AllowTransactionType(typeFrom) || !AllowTransactionType(typeTo)) return false;
if (!CanCreateTransactionLocally(typeTo)) return false;
if (typeFrom == Sbm.TransactionType.Project)
{
// Can raise another project from a project.
switch (typeTo)
{
case Sbm.TransactionType.Project:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesLead)
{
// Can raise sales quote or order from a lead.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesQuote)
{
// Can raise sales lead or order from a sales quote.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesOrder || typeFrom == Sbm.TransactionType.ProformaSalesOrder)
{
// Can raise almost anything from a sales order.
switch (typeTo)
{
case Sbm.TransactionType.SalesLead:
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
// Can also raise purchase quote or order from sales order:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.SalesDispatch)
{
// Can raise a sales invoice from a dispatch note.
switch (typeTo)
{
case Sbm.TransactionType.ProformaSalesInvoice:
case Sbm.TransactionType.SalesInvoice:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseQuote)
{
// Can raise a purchase order from purchase quote.
switch (typeTo)
{
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
else if (typeFrom == Sbm.TransactionType.PurchaseOrder || typeFrom == Sbm.TransactionType.ProformaPurchaseOrder)
{
// Can raise a sales order or purchase quote from a purchase order.
switch (typeTo)
{
case Sbm.TransactionType.SalesQuote:
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesOrder:
case Sbm.TransactionType.PurchaseQuote:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseOrder:
return CanCreateTransactionLocally(typeTo);
}
}
return false;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom)
{
// Build the list of transaction types that are allowed to be raised from the specified type.
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
if (transactionTypes_Full.Count == 0) transactionTypes_Full = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType);
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//if ((Sbm.TransactionType)typeTo.iType == typeFrom) continue;
if (CanRaiseTransaction(typeFrom, (Sbm.TransactionType)transTypeTo.Type))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo)
{
// Build the list of transaction types that are allowed to be raised to the specified type.
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
if (transactionTypes_Full.Count == 0) transactionTypes_Full = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType);
//transTypes_Full.GotoStart();
foreach (TypeCodeDesc transTypeTo in transactionTypes_Full)
{
//TypeCodeDesc & typeTo = transTypes_Full.Index();
if ((Sbm.TransactionType)transTypeTo.Type == typeTo) continue;
if (CanRaiseTransaction((Sbm.TransactionType)transTypeTo.Type, typeTo))
transTypes.Add(transTypeTo);
}
return transTypes;
}
//-------------------------------------------------------------------
// Prepare Requirements Transaction. - Prepare copied list of requirements, eg. when raising from another transaction.
public virtual bool PrepareCopiedRequirements(SbmTransaction transSource, List<SbmRequirement> requireList, Sbm.TransactionType type)
{
type = new Sbm.TransactionType();
//transSource; requireList; type;
return false;
}
//-------------------------------------------------------------------
// Remove Transaction.- By default, not allowed if transaction has requirements.
public virtual bool CanRemoveTransactionWithRequirements(SbmTransaction transaction, int requirementCount)
{
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
return requirementCount < 1;
}
//-------------------------------------------------------------------
// Tax Effective Date. - TransTypes that should use the 'In Progress' date as tax point as opposed to the 'Raised' date.
public virtual bool UseInProgressTaxDateAsTaxPoint(Sbm.TransactionType transactionType)
{
switch (transactionType)
{
case Sbm.TransactionType.ProformaSalesOrder:
case Sbm.TransactionType.SalesDispatch:
case Sbm.TransactionType.ProformaPurchaseOrder:
case Sbm.TransactionType.PurchaseDelivery:
case Sbm.TransactionType.ProformaSalesInvoice:
return false;
}
return true;
}
//-------------------------------------------------------------------
// R e q u i r e m e n t O p t i o n s
//-------------------------------------------------------------------
// Requirement Actions.
public virtual bool SearchCommodityOnCreateRequirement(Sbm.TransactionType transactionType)
{
return false;
}
//-------------------------------------------------------------------
// Requirement Costing.
public virtual SbmRequirementCostingConfig GetRequirementCostingConfig()
{
SbmRequirementCostingConfig cfgRequirementCosting = new SbmRequirementCostingConfig();
return cfgRequirementCosting;
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// C o m m o d i t y O p t i o n s // C o m m o d i t y O p t i o n s
//------------------------------------------------------------------- //-------------------------------------------------------------------
@@ -967,9 +649,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
{ {
case SaInterfaceCategory.Website: case SaInterfaceCategory.Website:
case SaInterfaceCategory.File: case SaInterfaceCategory.File:
return true; return InstanceConfig.AllowInterfaceCategory(interfaceCategory, true);
} }
return false; return InstanceConfig.AllowInterfaceCategory(interfaceCategory, false);
} }
public virtual bool AllowInterface(SaInterfaceCategory interfaceCategory, short interfaceType) public virtual bool AllowInterface(SaInterfaceCategory interfaceCategory, short interfaceType)
@@ -1005,7 +687,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
// Sbm.InterfaceType_System.Hpi - Only allowed by derived console. // Sbm.InterfaceType_System.Hpi - Only allowed by derived console.
break; break;
case SaInterfaceCategory.File: case SaInterfaceCategory.File:
if (AllowOption(Sbm.ConfigOption.AllowTransactions)) if (AllowOption(Sbm.ConfigOption.Transactions))
{ {
if (interfaceType == (short)Sbm.InterfaceType_File.TransactionImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.TransactionImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.TransactionExport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.TransactionExport) return true;
@@ -1015,19 +697,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesInvoice) return AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice); if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_SalesInvoice) return AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice) || AllowTransactionType(Sbm.TransactionType.SalesInvoice);
if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_PurchaseOrder) return AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder) || AllowTransactionType(Sbm.TransactionType.PurchaseOrder); if (interfaceType == (short)Sbm.InterfaceType_File.TransToWord_PurchaseOrder) return AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder) || AllowTransactionType(Sbm.TransactionType.PurchaseOrder);
} }
if (AllowOption(Sbm.ConfigOption.AllowContacts)) if (AllowOption(Sbm.ConfigOption.Contacts))
{ {
if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateExport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AffiliateExport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.AssociationImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AssociationImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.AssociationExport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AssociationExport) return true;
} }
if (AllowOption(Sbm.ConfigOption.AllowCommodities)) if (AllowOption(Sbm.ConfigOption.Commodities))
{ {
if (interfaceType == (short)Sbm.InterfaceType_File.CommodityImport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.CommodityImport) return true;
if (interfaceType == (short)Sbm.InterfaceType_File.CommodityExport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.CommodityExport) return true;
} }
if (interfaceType == (short)Sbm.InterfaceType_File.VehicleImport) return AllowOption(Sbm.ConfigOption.AllowVehicles); if (interfaceType == (short)Sbm.InterfaceType_File.VehicleImport) return AllowOption(Sbm.ConfigOption.Vehicles);
if (interfaceType == (short)Sbm.InterfaceType_File.LeasewayInvoice) if (interfaceType == (short)Sbm.InterfaceType_File.LeasewayInvoice)
//return SbmGlobals.Application.GetPropertyValue("Interface", "LeasewayInvoice").EqualsCI("Allow"); //return SbmGlobals.Application.GetPropertyValue("Interface", "LeasewayInvoice").EqualsCI("Allow");
return false; return false;
@@ -0,0 +1,56 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Base.Core
{
//=======================================================================
/// <summary>
/// Defines a range of application options/rules specific to a BusinessMgr instance.
/// <para>- Web application retrieves this information from the Item Params belonging to the Instance defined in the Control database.</para>
/// <para>- Legacy desktop application implements a named 'Console' (each in a separate library and loaded at runtime) for each specific instance.</para>
/// </summary>
public interface ISbmInstanceConfig
{
//-------------------------------------------------------------------
// Application options.
bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse);
//-------------------------------------------------------------------
// Contacts.
/// <summary>
/// Supported affiliate types.
/// </summary>
bool AllowAffiliateType(Sbm.AffiliateType type, bool defaultResponse);
/// <summary>
/// Supported Association types.
/// </summary>
bool AllowAssociationType(Sbm.AssociationType type, bool defaultResponse);
//-------------------------------------------------------------------
// Transactions.
/// <summary>
/// Supported Transaction types.
/// </summary>
bool AllowTransactionType(Sbm.TransactionType type, bool defaultResponse);
//-------------------------------------------------------------------
// Interfaces.
/// <summary>
/// Whether the Interface Category is allowed.
/// </summary>
bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse);
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,37 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
namespace Sarand.BusinessMgr.Net.Standard.Base.Core
{
//=======================================================================
/// <summary>
/// Organisation configuration options - as defined by Item Options.
/// </summary>
public interface ISbmOrganisationConfig
{
//-------------------------------------------------------------------
string GetOwnerOption_Value(OrgOption_Value value);
string GetOwnerOption_Folder(OrgOption_Folder folder);
bool GetOwnerOption_AllowOption(OrgOption_AllowOption option);
string GetOwnerOption_Caption(OrgOption_Caption caption, string defaultValue);
bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx column);
bool GetOwnerOption_ShowColumn(OrgOption_ShowColumn column);
string GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx eCol, string defautValue);
int GetOwnerOption_Minutes(OrgOption_Minutes eLimit, int defautValue);
int GetOwnerOption_UpdateLimit(OrgOption_PeriodDays eLimit, int defautValue);
int GetOwnerOption_UpdateLimit(OrgOption_PeriodWeeks eLimit, int defautValue);
int GetOwnerOption_NumericDecimals(OrgOption_NumericDecimals eNumDecimals, int defautValue = 2);
CommodityType GetOwnerOption_CommodityType(OrgOption_CommodityType commodityTypeContext);
SysId GetOwnerOption_StockLocation(OrgOption_StockLocation stockLocation);
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,37 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.Core
{
//=======================================================================
/// <summary>
/// Basic Organisation properties associated with a session.
/// </summary>
public interface ISbmOrganisationContext
{
//-------------------------------------------------------------------
// Organisation properties.
/// <summary>Organisation Affiliate Id.</summary>
SysId OrganisationAffiliateId { get; }
/// <summary>Organisation Affiliate Type.</summary>
Sbm.AffiliateType OrganisationAffiliateType { get; }
/// <summary>Organisation 'Internal' Association Id.</summary>
SysId OrganisationAssociationId { get; }
/// <summary>Organisation display name.</summary>
String OrganisationDisplayName { get; }
/// <summary>Organisation Interface context - to qualify interfaces belonging to the organisation.</summary>
String OrganisationInterfaceContext { get; }
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -8,6 +8,9 @@ using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Base.Core namespace Sarand.BusinessMgr.Net.Standard.Base.Core
{ {
//======================================================================= //=======================================================================
/// <summary>
/// Basic User properties associated with a session.
/// </summary>
public interface ISbmUserContext public interface ISbmUserContext
{ {
//------------------------------------------------------------------- //-------------------------------------------------------------------
@@ -1,67 +0,0 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.Core
{
//=======================================================================
public interface ISbmUserContext_Core : ISbmUserContext
{
//-------------------------------------------------------------------
/// <summary>Session Context - Identifies database connections etc.</summary>
SbmSessionContext SessionContext { get; }
//-------------------------------------------------------------------
// User properties.
/// <summary>User Security Item Id.</summary>
SysId UserSecurityItemId { get; }
/// <summary>User Affiliate Id.</summary>
SysId UserAffiliateId { get; }
//-------------------------------------------------------------------
/// <summary>Security profile - what the user is allowed to do based on security roles and groups.</summary>
ISbmSecurityProfile_Core SecurityProfile_Core { get; }
//-------------------------------------------------------------------
// Organisation properties.
/// <summary>Organisation Affiliate Id.</summary>
SysId OrganisationAffiliateId { get; }
/// <summary>Organisation Affiliate Type.</summary>
Sbm.AffiliateType OrganisationAffiliateType { get; }
/// <summary>Organisation 'Internal' Association Id.</summary>
SysId OrganisationAssociationId { get; }
/// <summary>Organisation display name.</summary>
String OrganisationDisplayName { get; }
/// <summary>Organisation Interface context - to qualify interfaces belonging to the organisation.</summary>
String OrganisationInterfaceContext { get; }
//-------------------------------------------------------------------
// Organisation configuration.
String GetOrganisationOption(Sbm.OrganisationOption option, String context);
String GetOrganisationOption(String optionName, String context);
String GetOwnerOption_Value(Sbm.OrgOption_Value eCol);
String GetOwnerOption_Folder(Sbm.OrgOption_Folder eCol);
bool GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption eCol);
String GetOwnerOption_Caption(Sbm.OrgOption_Caption eCol, String defaultValue);
bool GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx eCol);
bool GetOwnerOption_ShowColumn(Sbm.OrgOption_ShowColumn eCol);
String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx eCol, String defautValue);
int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes eLimit, int defautValue);
int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays eLimit, int defautValue);
int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks eLimit, int defautValue);
int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals eNumDecimals, int defautValue = 2);
Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityTypeContext);
SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation eLoc);
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,34 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Dbas;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.BusinessMgr.Net.Standard.Base.Core
{
//=======================================================================
/// <summary>
/// Basic User and Organisation properties associated with a session.
/// </summary>
public interface ISbmUserOrganisationContext : ISbmUserContext, ISbmOrganisationContext
{
//-------------------------------------------------------------------
/// <summary>Session Context - Identifies database connections etc.</summary>
SbmSessionContext SessionContext { get; }
//-------------------------------------------------------------------
// User properties.
/// <summary>User Security Item Id.</summary>
SysId UserSecurityItemId { get; }
/// <summary>User Affiliate Id.</summary>
SysId UserAffiliateId { get; }
//-------------------------------------------------------------------
/// <summary>Security profile - what the user is allowed to do based on security roles and groups.</summary>
ISbmSecurityProfile_Core SecurityProfile_Core { get; }
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -35,7 +35,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAccountMgr(ISbmUserContext_Core userContext) : protected SbmAccountMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmAccountMgr(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
@@ -17,8 +17,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
// A d d r e s s e s // A d d r e s s e s
//******************************************************************* //*******************************************************************
// Utilities. // Utilities.
//public override SbmAddress CloneAddress(SbmAddress addressSource, bool copyId) //public override SbmAddress CloneAddress(SbmAddress addressSource, bool copyId, DbUpdateInfo dbUpdateInfo)
public abstract bool VerifyAsPrimaryAddress(SbmAddress addressPrimary); public abstract bool VerifyAsPrimaryAddress(SbmAddress addressPrimary, DbUpdateInfo dbUpdateInfo);
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Retrieve individual addresses. // Retrieve individual addresses.
@@ -201,11 +201,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
case Sbm.OrganisationOption.NumericDecimals: case Sbm.OrganisationOption.NumericDecimals:
return true; return true;
case Sbm.OrganisationOption.CommodityType: case Sbm.OrganisationOption.CommodityType:
return AllowConfigOption(Sbm.ConfigOption.AllowCommodities); return AllowConfigOption(Sbm.ConfigOption.Commodities);
case Sbm.OrganisationOption.CommodityFilterDefaultStatusCat: case Sbm.OrganisationOption.CommodityFilterDefaultStatusCat:
return AllowConfigOption(Sbm.ConfigOption.AllowCommodities) && orgOptData.Values_CommodityStatusCat.Count > 0; return AllowConfigOption(Sbm.ConfigOption.Commodities) && orgOptData.Values_CommodityStatusCat.Count > 0;
case Sbm.OrganisationOption.CommodityFilterInitialStockCat: case Sbm.OrganisationOption.CommodityFilterInitialStockCat:
return AllowConfigOption(Sbm.ConfigOption.AllowCommodities) && orgOptData.Values_CommodityStockCat.Count > 0; return AllowConfigOption(Sbm.ConfigOption.Commodities) && orgOptData.Values_CommodityStockCat.Count > 0;
case Sbm.OrganisationOption.StatusCaption_Container: case Sbm.OrganisationOption.StatusCaption_Container:
return StockControlConfig.AllowStockContainers(); return StockControlConfig.AllowStockContainers();
case Sbm.OrganisationOption.SalesLocation: case Sbm.OrganisationOption.SalesLocation:
@@ -218,40 +218,38 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
private OrganisationOptionData InitOrganisationOptionData() private OrganisationOptionData InitOrganisationOptionData()
{ {
OrganisationOptionData orgOptData = new OrganisationOptionData(); OrganisationOptionData orgOptData = new OrganisationOptionData();
using (SbmSessionConsole sessionConsole = SbmGlobals.Application.CreateSessionConsole(UserContext))
using (SbmAccountsDfn accounts = new SbmAccountsDfn(UserContext))
{
// Option types. // Option types.
orgOptData.associationOptionTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssociationOption)); orgOptData.associationOptionTypes.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.AssociationOption));
// Yes/No. // Yes/No.
orgOptData.Values_YesNo.Add(orgOptData.Value_Yes, "Yes"); orgOptData.Values_YesNo.Add(orgOptData.Value_Yes, "Yes");
orgOptData.Values_YesNo.Add(orgOptData.Value_No, "No"); orgOptData.Values_YesNo.Add(orgOptData.Value_No, "No");
// Organisation configuration. // Organisation configuration.
bool bAllowContacts = (AllowConfigOption(Sbm.ConfigOption.AllowContacts)); bool bAllowContacts = (AllowConfigOption(Sbm.ConfigOption.Contacts));
bool bAllowCustomers = (AllowAssociationType(Sbm.AssociationType.Customer)); bool bAllowCustomers = (AllowAssociationType(Sbm.AssociationType.Customer));
bool bAllowStockists = (AllowAssociationType(Sbm.AssociationType.Stockist)); bool bAllowStockists = (AllowAssociationType(Sbm.AssociationType.Stockist));
bool bAllowFinanceAgencies = (AllowAssociationType(Sbm.AssociationType.FinanceAgency)); bool bAllowFinanceAgencies = (AllowAssociationType(Sbm.AssociationType.FinanceAgency));
bool bAllowCommodities = (AllowConfigOption(Sbm.ConfigOption.AllowCommodities)); bool bAllowCommodities = (AllowConfigOption(Sbm.ConfigOption.Commodities));
bool bAllowVehicles = (AllowConfigOption(Sbm.ConfigOption.AllowVehicles)); bool bAllowVehicles = (AllowConfigOption(Sbm.ConfigOption.Vehicles));
bool bAllowAssets = (AllowConfigOption(Sbm.ConfigOption.AllowAssets)); bool bAllowAssets = (AllowConfigOption(Sbm.ConfigOption.Assets));
bool bAllowTransactions = (AllowConfigOption(Sbm.ConfigOption.AllowTransactions)); bool bAllowTransactions = (AllowConfigOption(Sbm.ConfigOption.Transactions));
bool bAllowSalesOrders = ((AllowTransactionType(Sbm.TransactionType.SalesOrder) || AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder))); bool bAllowSalesOrders = ((AllowTransactionType(Sbm.TransactionType.SalesOrder) || AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)));
bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch)); bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch));
bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice))); bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice)));
bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder))); bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)));
bool bAllowInterfaces = (sessionConsole.AllowInterfaces()); bool bAllowInterfaces = (SessionConsole.AllowInterfaces());
bool bAllowInterfaces_File = (bAllowInterfaces && sessionConsole.AllowInterfaceCategory(SaInterfaceCategory.File)); bool bAllowInterfaces_File = (bAllowInterfaces && SessionConsole.AllowInterfaceCategory(SaInterfaceCategory.File));
// Values: // Values:
List<TypeCodeDesc> orgOptionValues = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Value); List<TypeCodeDesc> orgOptionValues = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Value);
if (bAllowTransactions) if (bAllowTransactions)
{ {
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter));
if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion)) if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion))
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText));
if (sessionConsole.GetRequirementCostingConfig().AllowRequirementCosting(Sbm.TransactionType.SalesOrder)) if (SessionConsole.GetRequirementCostingConfig().AllowRequirementCosting(Sbm.TransactionType.SalesOrder))
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CostLabourRateDefault)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CostLabourRateDefault));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice));
if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes)) if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes))
@@ -263,14 +261,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailSubject)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailSubject));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailBody)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailBody));
} }
if (accounts.IsUsingSageInterface()) if (AccountsDfn.IsUsingSageInterface())
{ {
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultSalesCarriageNominal)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultSalesCarriageNominal));
orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal)); orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal));
} }
// Folders: // Folders:
List<TypeCodeDesc> lOrgOptionFolder = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Folder); List<TypeCodeDesc> lOrgOptionFolder = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Folder);
if (bAllowCommodities) if (bAllowCommodities)
{ {
orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityImage)); orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityImage));
@@ -278,7 +276,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
} }
// Allow option contexts: // Allow option contexts:
List<TypeCodeDesc> lAllowOption = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_AllowOption); List<TypeCodeDesc> lAllowOption = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_AllowOption);
if (bAllowContacts) if (bAllowContacts)
{ {
orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.UpdateAssociationCode)); orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.UpdateAssociationCode));
@@ -341,11 +339,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
} }
// Caption contexts: // Caption contexts:
orgOptData.Contexts_Caption.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Caption)); orgOptData.Contexts_Caption.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Caption));
// Show field contexts. // Show field contexts.
// NB This list must be kept up to date with equivalent in 'SapphireConsole::DisplayAttribute': // NB This list must be kept up to date with equivalent in 'SapphireConsole::DisplayAttribute':
List<TypeCodeDesc> lShowField = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowField); List<TypeCodeDesc> lShowField = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_ShowField);
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget))
orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)); orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget));
if (ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn)) if (ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn))
@@ -376,7 +374,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
} }
// Show column contexts: // Show column contexts:
List<TypeCodeDesc> lShowColumn = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowColumn); List<TypeCodeDesc> lShowColumn = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_ShowColumn);
if (bAllowSalesOrders) if (bAllowSalesOrders)
{ {
if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget))
@@ -405,7 +403,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice)); orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice));
if (bAllowSalesInvoices) if (bAllowSalesInvoices)
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Transaction_ContactArea)); orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Transaction_ContactArea));
if (bAllowSalesInvoices && accounts.IsTransactionTypeManagedByAccounts(Sbm.TransactionType.SalesInvoice)) if (bAllowSalesInvoices && AccountsDfn.IsTransactionTypeManagedByAccounts(Sbm.TransactionType.SalesInvoice))
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef)); orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef));
if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl()) if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl())
{ {
@@ -426,7 +424,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation)); orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation));
// Field label contexts: // Field label contexts:
List<TypeCodeDesc> lFieldLabel = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_FieldLabel); List<TypeCodeDesc> lFieldLabel = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_FieldLabel);
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef)); 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_Dimensions));
orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)); orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode));
@@ -466,7 +464,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
} }
// Commodity status filter. // Commodity status filter.
List<TypeCodeDesc> lCmdStatusCat = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityStatusCat); List<TypeCodeDesc> lCmdStatusCat = Internals.GetSystemCodes(Sbm.SystemCode.CommodityStatusCat);
orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Any)); orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Any));
orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Current)); orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Current));
@@ -476,12 +474,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
// Container status caption. // Container status caption.
if (CommodityMgr.ContainerDatabaseIsValid && StockControlConfig.AllowStockContainers()) if (CommodityMgr.ContainerDatabaseIsValid && StockControlConfig.AllowStockContainers())
orgOptData.Contexts_ContainerStatus.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ContainerStatusCaption)); orgOptData.Contexts_ContainerStatus.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_ContainerStatusCaption));
// Generic options: // Generic options:
orgOptData.Contexts_Minutes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Minutes)); orgOptData.Contexts_Minutes.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Minutes));
orgOptData.Contexts_PeriodDays.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodDays)); orgOptData.Contexts_PeriodDays.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_PeriodDays));
orgOptData.Contexts_PeriodWeeks.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodWeeks)); orgOptData.Contexts_PeriodWeeks.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_PeriodWeeks));
// Minutes. // Minutes.
for (int iMins = 0; iMins <= 30; iMins++) for (int iMins = 0; iMins <= 30; iMins++)
@@ -535,7 +533,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
orgOptData.Values_PeriodWeeks.Add("30", "30 weeks"); orgOptData.Values_PeriodWeeks.Add("30", "30 weeks");
// Numeric Decimals: // Numeric Decimals:
orgOptData.Contexts_NumericDecimals.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_NumericDecimals)); orgOptData.Contexts_NumericDecimals.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_NumericDecimals));
orgOptData.Values_Decimals_0To2.Add("0", "None"); orgOptData.Values_Decimals_0To2.Add("0", "None");
orgOptData.Values_Decimals_0To2.Add("1", "1 places"); orgOptData.Values_Decimals_0To2.Add("1", "1 places");
orgOptData.Values_Decimals_0To2.Add("2", "2 places"); orgOptData.Values_Decimals_0To2.Add("2", "2 places");
@@ -546,17 +544,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
orgOptData.Values_Decimals_0To4.Add("4", "4 places"); orgOptData.Values_Decimals_0To4.Add("4", "4 places");
// Commodity types. // Commodity types.
orgOptData.Contexts_CommodityType.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType)); orgOptData.Contexts_CommodityType.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.CommodityType));
orgOptData.Values_CommodityTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType)); orgOptData.Values_CommodityTypes.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.CommodityType));
// Sales locations. // Sales locations.
orgOptData.Contexts_SalesLocation.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_StockLocation)); orgOptData.Contexts_SalesLocation.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_StockLocation));
SbmLocation.Params prmLocation = new SbmLocation.Params(); SbmLocation.Params prmLocation = new SbmLocation.Params();
prmLocation.RestrictToSalesStock = true; prmLocation.RestrictToSalesStock = true;
prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly; prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly;
foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation)) foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation))
orgOptData.Values_SalesLocation.Add(SysId.ToString(location.Id), location.Name); orgOptData.Values_SalesLocation.Add(SysId.ToString(location.Id), location.Name);
}
return orgOptData; return orgOptData;
} }
+5 -1
View File
@@ -13,7 +13,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmAssetMgr(ISbmUserContext_Core userContext) : protected SbmAssetMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmAssetMgr(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
@@ -32,7 +32,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmCommodityMgr(ISbmUserContext_Core userContext) : protected SbmCommodityMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmCommodityMgr(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
@@ -275,7 +275,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
String path = ""; String path = "";
if (!StringUtil.IsEmpty(commodityCode)) if (!StringUtil.IsEmpty(commodityCode))
{ {
String folder = UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityImage); String folder = SessionConsole.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityImage);
path = GetImagePath(folder, commodityCode); path = GetImagePath(folder, commodityCode);
} }
return path; return path;
@@ -287,7 +287,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
String path = ""; String path = "";
if (!StringUtil.IsEmpty(commodityCode)) if (!StringUtil.IsEmpty(commodityCode))
{ {
String folder = UserContext.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityBarcodeImage); String folder = SessionConsole.GetOwnerOption_Folder(Sbm.OrgOption_Folder.CommodityBarcodeImage);
path = GetImagePath(folder, commodityCode); path = GetImagePath(folder, commodityCode);
} }
return path; return path;
+97 -68
View File
@@ -23,25 +23,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//======================================================================= //=======================================================================
public abstract class SbmCoreMgr : SbmItemMgr public abstract class SbmCoreMgr : SbmItemMgr
{ {
//-------------------------------------------------------------------
// System code cache.
/// <summary>Central repository for system codes used by manager.</summary>
private class SystemCodeCache
{
public SystemCodeCache(ISbmUserContext_Core userContext)
{
this.userContext = userContext;
}
private readonly ISbmUserContext_Core userContext;
private Dictionary<Sbm.SystemCode, List<TypeCodeDesc>> systemCodes = new Dictionary<Sbm.SystemCode, List<TypeCodeDesc>>();
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode)
{
if (!systemCodes.ContainsKey(systemCode))
systemCodes[systemCode] = SbmSystem.GetCodesOfType(userContext, systemCode);
return new List<TypeCodeDesc>(systemCodes.GetValue(systemCode, new List<TypeCodeDesc>()));
}
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Code type cache. // Code type cache.
public class CodeTypeCache public class CodeTypeCache
@@ -90,14 +71,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Data members. // Data members.
private SbmInternals internals; private class Members
private readonly SystemCodeCache systemCodeCache; {
private readonly List<TypeCodeDesc> currencyCodes; // Externally supplied Internals - disposed elsewhere.
private List<SaCurrency> currencies; public SbmInternals internalsSupplied;
private List<SaLanguage> languages; // Internally constructed Internals - disposed here.
private List<SaRegion> regions; public SbmInternals internals;
private List<SaTaxCode> taxCodes; // Numeric control values.
private List<SaUnitMeasure> unitsOfMeasure; public bool numericControlValuesInitialised = false;
public int weightDecimals;
public int lengthDecimals;
public int volumeDecimals;
public int densityDecimals;
public int boxQuantityDecimals;
public int orderQuantityDecimals;
// Reference data.
public List<TypeCodeDesc> currencyCodes;
public List<SaCurrency> currencies;
public List<SaLanguage> languages;
public List<SaRegion> regions;
public List<SaTaxCode> taxCodes;
public List<SaUnitMeasure> unitsOfMeasure;
}
private readonly Members mbr = new Members();
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Static initialisation. // Static initialisation.
@@ -107,30 +103,50 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmCoreMgr(ISbmUserContext_Core userContext) protected SbmCoreMgr(SbmInternals internals)
{
if (internals == null)
throw new NotSupportedException("SbmItemMgr Internals must be supplied");
mbr.internalsSupplied = internals;
UserContext = internals.UserContext;
Initialise();
}
protected SbmCoreMgr(ISbmUserOrganisationContext userContext)
{ {
if (userContext == null) if (userContext == null)
throw new NotSupportedException("SbmItemMgr User context must be supplied"); throw new NotSupportedException("SbmItemMgr User context must be supplied");
UserContext = userContext; mbr.internalsSupplied = null;
systemCodeCache = new SystemCodeCache(userContext); this.UserContext = userContext;
// Numeric formatting values. Initialise();
WeightDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityWeight);
LengthDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityLength);
VolumeDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityVolume);
DensityDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityDensity);
BoxQuantityDecimals = 0;
// Reference data.
currencyCodes = SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.CurrencyCode);
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing) if (disposing)
{ {
if (internals != null) internals.Dispose(); if (mbr.internals != null) mbr.internals.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
//-------------------------------------------------------------------
// Initialisation.
private void Initialise()
{
}
private void InitialiseNumericControlValues()
{
if (mbr.numericControlValuesInitialised) return;
mbr.numericControlValuesInitialised = true;
// Numeric formatting values.
mbr.weightDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityWeight);
mbr.lengthDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityLength);
mbr.volumeDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityVolume);
mbr.densityDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityDensity);
mbr.boxQuantityDecimals = 0;
mbr.orderQuantityDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity);
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Async initialisation. // Async initialisation.
public async void InitialiseCodeTypesAsync() public async void InitialiseCodeTypesAsync()
@@ -151,26 +167,31 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
protected List<TypeCodeDesc> ItemTypes { get { return GetCodesOfType(Sbm.SystemCode.ItemType); } } protected List<TypeCodeDesc> ItemTypes { get { return GetCodesOfType(Sbm.SystemCode.ItemType); } }
protected List<TypeCodeDesc> InterfaceOptionCodes { get { return GetCodesOfType(Sbm.SystemCode.InterfaceOption); } } protected List<TypeCodeDesc> InterfaceOptionCodes { get { return GetCodesOfType(Sbm.SystemCode.InterfaceOption); } }
// Numeric control values. // Numeric control values.
protected int WeightDecimals { get; set; } = 0; protected int WeightDecimals { get { InitialiseNumericControlValues(); return mbr.weightDecimals; } }
protected int LengthDecimals { get; set; } = 0; protected int LengthDecimals { get { InitialiseNumericControlValues(); return mbr.lengthDecimals; } }
protected int VolumeDecimals { get; set; } = 0; protected int VolumeDecimals { get { InitialiseNumericControlValues(); return mbr.volumeDecimals; } }
protected int DensityDecimals { get; set; } = 0; protected int DensityDecimals { get { InitialiseNumericControlValues(); return mbr.densityDecimals; } }
protected int BoxQuantityDecimals { get; set; } = 0; protected int BoxQuantityDecimals { get { InitialiseNumericControlValues(); return mbr.boxQuantityDecimals; } }
protected int OrderQuantityDecimals { get; set; } = 0; protected int OrderQuantityDecimals { get { InitialiseNumericControlValues(); return mbr.orderQuantityDecimals; } }
// Session. // Internals.
protected ISbmUserContext_Core UserContext { get; }
protected SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
protected SbmInternals Internals protected SbmInternals Internals
{ {
get get
{ {
if (internals == null) internals = new SbmInternals(UserContext); if (mbr.internalsSupplied != null) return mbr.internalsSupplied;
return internals; if (mbr.internals == null) mbr.internals = new SbmInternals(UserContext);
return mbr.internals;
} }
} }
// Session.
protected ISbmUserOrganisationContext UserContext { get; }
protected SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
public SysId AffiliateId_Owner { get { return UserContext.OrganisationAffiliateId; } } public SysId AffiliateId_Owner { get { return UserContext.OrganisationAffiliateId; } }
protected SbmAccountsDfn AccountsDfn { get { return Internals.AccountsDfn; } } protected SbmAccountsDfn AccountsDfn { get { return Internals.AccountsDfn; } }
protected DbUpdateInfo DbUpdateInfo { get { return Internals.DbUpdateInfo; } } protected DbUpdateInfo DbUpdateInfo { get { return Internals.DbUpdateInfo; } }
// User security profile.
public bool UserCanViewCommoditySalesFinancials() { return UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); }
public bool UserCanViewCommoditySupplyFinancials() { return UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); }
// Managers. // Managers.
protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } } protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } } protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } }
@@ -192,7 +213,15 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
// Currencies. // Currencies.
protected List<TypeCodeDesc> CurrencyCodes { get { return new List<TypeCodeDesc>(currencyCodes); } } protected List<TypeCodeDesc> CurrencyCodes
{
get
{
if (mbr.currencyCodes == null)
mbr.currencyCodes = SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.CurrencyCode);
return new List<TypeCodeDesc>(mbr.currencyCodes);
}
}
protected List<SaCurrency> GetCurrencies() protected List<SaCurrency> GetCurrencies()
{ {
return Internals.GetCurrencies(); return Internals.GetCurrencies();
@@ -215,7 +244,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
// Utilities. // Utilities.
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode)
{ {
return systemCodeCache.GetCodesOfType(systemCode); return Internals.GetSystemCodes(systemCode);
} }
// Database utilities. // Database utilities.
public bool TableExists(SbmDbDfn.TableIdx tableIdx) public bool TableExists(SbmDbDfn.TableIdx tableIdx)
@@ -240,7 +269,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Configuration console utilities. // Session console utilities.
public bool AllowConfigOption(Sbm.ConfigOption configOption) public bool AllowConfigOption(Sbm.ConfigOption configOption)
{ {
return SessionConsole.AllowOption(configOption); return SessionConsole.AllowOption(configOption);
@@ -320,71 +349,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
// Currencies. // Currencies.
private void PopulateCurrencies() private void PopulateCurrencies()
{ {
if (currencies != null) return; if (mbr.currencies != null) return;
SaCurrency.Params prmCurrency = new SaCurrency.Params(); SaCurrency.Params prmCurrency = new SaCurrency.Params();
prmCurrency.StatusCat = SaCurrency.StatusCat.Any; prmCurrency.StatusCat = SaCurrency.StatusCat.Any;
currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency); mbr.currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency);
} }
public SaCurrency GetDefaultCurrency() public SaCurrency GetDefaultCurrency()
{ {
PopulateCurrencies(); PopulateCurrencies();
String currencyCode = CurrencyCodes.GetCodeForType(SaCurrencyCode.Sterling); String currencyCode = CurrencyCodes.GetCodeForType(SaCurrencyCode.Sterling);
return currencies.Find(item => item.Code.EqualsCI(currencyCode)); return mbr.currencies.Find(item => item.Code.EqualsCI(currencyCode));
} }
public SaCurrency GetCurrency(SysId currencyId) public SaCurrency GetCurrency(SysId currencyId)
{ {
PopulateCurrencies(); PopulateCurrencies();
return currencies.Find(item => item.Id.Equals(currencyId)); return mbr.currencies.Find(item => item.Id.Equals(currencyId));
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Regions. // Regions.
private void PopulateRegions() private void PopulateRegions()
{ {
if (regions != null) return; if (mbr.regions != null) return;
SaRegion.Params prmRegion = new SaRegion.Params(); SaRegion.Params prmRegion = new SaRegion.Params();
regions = ReferenceDataConsole.GetRegionList(prmRegion); mbr.regions = ReferenceDataConsole.GetRegionList(prmRegion);
} }
public SaRegion FindRegionById(SysId regionId) public SaRegion FindRegionById(SysId regionId)
{ {
PopulateRegions(); PopulateRegions();
return regions.FindById(regionId); return mbr.regions.FindById(regionId);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Tax codes. // Tax codes.
private void PopulateTaxCodes() private void PopulateTaxCodes()
{ {
if (taxCodes != null) return; if (mbr.taxCodes != null) return;
SaTaxCode.Params prmTaxCode = new SaTaxCode.Params(); SaTaxCode.Params prmTaxCode = new SaTaxCode.Params();
taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode); mbr.taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode);
} }
public SaTaxCode FindTaxCodeById(SysId taxCodeId) public SaTaxCode FindTaxCodeById(SysId taxCodeId)
{ {
PopulateTaxCodes(); PopulateTaxCodes();
return taxCodes.Find(item => item.Id.Equals(taxCodeId)); return mbr.taxCodes.Find(item => item.Id.Equals(taxCodeId));
} }
public SaTaxCode FindTaxCodeEffectiveOn(String taxCode, DateTime effectiveOn) public SaTaxCode FindTaxCodeEffectiveOn(String taxCode, DateTime effectiveOn)
{ {
PopulateTaxCodes(); PopulateTaxCodes();
return taxCodes.FindByCodeEffectiveOn(taxCode, effectiveOn); return mbr.taxCodes.FindByCodeEffectiveOn(taxCode, effectiveOn);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Units of measure. // Units of measure.
private void PopulateUnitsOfMeasure() private void PopulateUnitsOfMeasure()
{ {
if (taxCodes != null) return; if (mbr.unitsOfMeasure != null) return;
SaUnitMeasure.Params prmUnitOfMeasure = new SaUnitMeasure.Params(); SaUnitMeasure.Params prmUnitOfMeasure = new SaUnitMeasure.Params();
prmUnitOfMeasure.StatusCat = SaUnitMeasure.StatusCat.Any; prmUnitOfMeasure.StatusCat = SaUnitMeasure.StatusCat.Any;
unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitOfMeasure); mbr.unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitOfMeasure);
} }
public SaUnitMeasure FindUnitOfMeasureById(SysId uomId) public SaUnitMeasure FindUnitOfMeasureById(SysId uomId)
{ {
PopulateUnitsOfMeasure(); PopulateUnitsOfMeasure();
return unitsOfMeasure.FindById(uomId); return mbr.unitsOfMeasure.FindById(uomId);
} }
public List<SaUnitMeasure> FindUnitsOfMeasureByCategory(SaUomCategory uomCategory) public List<SaUnitMeasure> FindUnitsOfMeasureByCategory(SaUomCategory uomCategory)
{ {
PopulateUnitsOfMeasure(); PopulateUnitsOfMeasure();
return unitsOfMeasure.FindAll(item => item.Category == uomCategory); return mbr.unitsOfMeasure.FindAll(item => item.Category == uomCategory);
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
@@ -16,6 +16,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
static SbmDataItemMgr() static SbmDataItemMgr()
{ {
} }
//-------------------------------------------------------------------
// Construction.
protected SbmDataItemMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmDataItemMgr(ISbmUserOrganisationContext userContext) :
base(userContext)
{
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing) if (disposing)
@@ -24,13 +35,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
base.Dispose(disposing); base.Dispose(disposing);
} }
//-------------------------------------------------------------------
// Construction.
protected SbmDataItemMgr(ISbmUserContext_Core userContext) :
base(userContext)
{
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Utilities. // Utilities.
+5 -1
View File
@@ -20,7 +20,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmPriceMgr(ISbmUserContext_Core userContext) : protected SbmPriceMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmPriceMgr(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
@@ -19,7 +19,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmProcessMgr(ISbmUserContext_Core userContext) : protected SbmProcessMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmProcessMgr(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
+11 -7
View File
@@ -16,6 +16,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
static SbmStockMgr() static SbmStockMgr()
{ {
} }
//-------------------------------------------------------------------
// Construction.
protected SbmStockMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmStockMgr(ISbmUserOrganisationContext userContext) :
base(userContext)
{
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing) if (disposing)
@@ -24,13 +35,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
base.Dispose(disposing); base.Dispose(disposing);
} }
//-------------------------------------------------------------------
// Construction.
protected SbmStockMgr(ISbmUserContext_Core userContext) :
base(userContext)
{
}
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
// Code lists. // Code lists.
@@ -16,12 +16,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//******************************************************************* //*******************************************************************
// L o c a t i o n s // L o c a t i o n s
//******************************************************************* //*******************************************************************
//-------------------------------------------------------------------
// Utilities. // Utilities.
public SysId GetDefaultSalesStockLocation() public SysId GetDefaultSalesStockLocation()
{ {
ClearErrorState(); ClearErrorState();
SysId salesLocationId = UserContext.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.SalesOrderDefault); SysId salesLocationId = SessionConsole.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.SalesOrderDefault);
if (SysId.IsValid(salesLocationId)) if (SysId.IsValid(salesLocationId))
{ {
// Check that this location is valid for sales stock. // Check that this location is valid for sales stock.
@@ -36,8 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
if (!SysId.IsValid(salesLocationId)) if (!SysId.IsValid(salesLocationId))
{ {
// Use another location manager to ensure that this one is not interferred with. // Use another location manager to ensure that this one is not interferred with.
SbmStockMgr stockMgr = SbmGlobals.System.CreateStockMgr(UserContext); if (StockMgr != null)
if (stockMgr != null)
{ {
// Identify the first created sales location: // Identify the first created sales location:
SbmLocation.Params prmLocation = new SbmLocation.Params(); SbmLocation.Params prmLocation = new SbmLocation.Params();
@@ -45,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
prmLocation.RestrictToSalesStock = true; prmLocation.RestrictToSalesStock = true;
prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly; prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly;
foreach (SbmLocation location in stockMgr.GetLocationList(prmLocation)) foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation))
{ {
if (location == null) break; if (location == null) break;
if (location.SalesStock /*&& location.GetStatusType() == SaStatus.Active*/) if (location.SalesStock /*&& location.GetStatusType() == SaStatus.Active*/)
@@ -61,7 +59,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
public SysId GetDefaultPurchaseStockLocation() public SysId GetDefaultPurchaseStockLocation()
{ {
ClearErrorState(); ClearErrorState();
SysId purchaseLocationId = UserContext.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.PurchaseOrderDefault); SysId purchaseLocationId = SessionConsole.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.PurchaseOrderDefault);
if (SysId.IsValid(purchaseLocationId)) if (SysId.IsValid(purchaseLocationId))
{ {
purchaseLocationId = GetDefaultSalesStockLocation(); purchaseLocationId = GetDefaultSalesStockLocation();
@@ -32,7 +32,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Construction. // Construction.
protected SbmTransactionMgr(ISbmUserContext_Core userContext) : protected SbmTransactionMgr(SbmInternals internals) :
base(internals)
{
}
protected SbmTransactionMgr(ISbmUserOrganisationContext userContext) :
base(userContext) base(userContext)
{ {
} }
@@ -313,7 +313,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
{ {
// Alternative text - only populated if promotion description is blank. // Alternative text - only populated if promotion description is blank.
if (StringUtil.IsEmpty(promotionDesc)) if (StringUtil.IsEmpty(promotionDesc))
value = new DataValue(UserContext.GetOwnerOption_Value(Sbm.OrgOption_Value.AlternativePromotionText)); value = new DataValue(SessionConsole.GetOwnerOption_Value(Sbm.OrgOption_Value.AlternativePromotionText));
else value = new DataValue(""); else value = new DataValue("");
} }
} }
@@ -27,8 +27,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
public abstract decimal GetTransCostLabourRateHour(SysId transactionId); public abstract decimal GetTransCostLabourRateHour(SysId transactionId);
public abstract bool DeliveryFinancialsAreAvailable(); public abstract bool DeliveryFinancialsAreAvailable();
public abstract bool ChangeTransactionsAssociation(SbmTransaction transaction, SysId assocId); public abstract bool ChangeTransactionsAssociation(SbmTransaction transaction, SysId assocId);
public abstract bool RefreshAssociatedData(SbmTransaction transaction, List<SbmRequirement.Data> requirements = null); public abstract bool RefreshAssociatedData(SbmTransaction transaction, List<SbmRequirement.Data> requirements, DbUpdateInfo dbUpdateInfo);
public abstract bool RefreshAssociatedTransactions(SbmTransaction transaction, List<SbmRequirement.Data> requirements = null); public abstract bool RefreshAssociatedTransactions(SbmTransaction transaction, List<SbmRequirement.Data> requirements, DbUpdateInfo dbUpdateInfo);
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Has transactions. // Has transactions.
@@ -26,11 +26,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Procs
// Configuration. // Configuration.
public new class Config : SaReport_Base.Config public new class Config : SaReport_Base.Config
{ {
protected Config(ISbmUserContext_Core userContext) protected Config(ISbmUserOrganisationContext userContext)
{ {
UserContext = userContext; UserContext = userContext;
} }
public ISbmUserContext_Core UserContext { get; } public ISbmUserOrganisationContext UserContext { get; }
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
@@ -37,7 +37,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Properties. // Properties.
public ISbmUserContext_Core UserContext { get { return config.Internals.UserContext; } } public ISbmUserOrganisationContext UserContext { get { return config.Internals.UserContext; } }
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Internal utilities. // Internal utilities.
@@ -0,0 +1,112 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.ItemOptions;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
{
//=======================================================================
/// <summary>
/// Practically persistant/static data stored in instance database, eg. Owner configuration options.
/// </summary>
public class SbmInstanceDataCache_Dbas : SbmInstanceDataCache
{
//-------------------------------------------------------------------
// Definitions.
private class ItemOptionData
{
public ItemOptionData(ItemId itemId)
{
ItemId = itemId;
}
// Irem Id - options' owning item.
public ItemId ItemId { get; private set; } = new ItemId();
public List<SaItemOption> ItemOptions { get; } = new List<SaItemOption>();
public DateTime LastRefreshed { get; set; } = DateTime.Now;
}
private class ItemOptionsCacheData
{
public ItemOptionsCacheData(ItemId itemIdRef)
{
ItemIdRef = itemIdRef;
}
// Reference Id - Owner Organisation Affiliate Id.
public ItemId ItemIdRef { get; private set; } = new ItemId();
// Item option identified by their owning item.
public Dictionary<ItemId, ItemOptionData> ItemOptions { get; } = new Dictionary<ItemId, ItemOptionData>();
}
//-------------------------------------------------------------------
// Data members.
private SbmInternals internals = null;
// Instance Item Options - keyed on Owner Affiliate Id.
private readonly Dictionary<ItemId, ItemOptionsCacheData> itemOptionCaches = new Dictionary<ItemId, ItemOptionsCacheData>();
//-------------------------------------------------------------------
// Construction.
public SbmInstanceDataCache_Dbas(SbmSessionContext sessionContext)
{
this.SessionContext = sessionContext;
}
protected override void Dispose(bool disposing)
{
if (internals != null) internals.Dispose(); internals = null;
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
public SbmSessionContext SessionContext { get; }
private SbmInternals Internals { get { if (internals == null) { internals = new SbmInternals(SessionContext); }; return internals; } }
//-------------------------------------------------------------------
// Retrieve Item Options for Owner Organisation configuration.
public override List<SaItemOption> GetOwnerOptions(ISbmUserOrganisationContext userContext)
{
List<SaItemOption> ownerOptions = new List<SaItemOption>();
if (!SysId.IsValid(userContext.OrganisationAffiliateId) || !SysId.IsValid(userContext.OrganisationAssociationId))
return ownerOptions;
ItemId affiliateItemId_Owner = new ItemId((short)Sbm.ItemType.Affiliate, userContext.OrganisationAffiliateId);
ItemId associationItemId_Internal = new ItemId((short)Sbm.ItemType.Association, userContext.OrganisationAssociationId);
lock (itemOptionCaches)
{
// Retrieve the Owner Organisation item options from the cache.
ItemOptionsCacheData itemOptionsCache = itemOptionCaches.GetValueOrDefault(affiliateItemId_Owner);
if (itemOptionsCache == null)
{
// Add new entry in the cache for this Owner Organisation.
itemOptionsCache = new ItemOptionsCacheData(affiliateItemId_Owner);
itemOptionCaches[affiliateItemId_Owner] = itemOptionsCache;
}
// Retieve the Internal Association's item options from the cache.
ItemOptionData ownerItemOptions = itemOptionsCache.ItemOptions.GetValueOrDefault(associationItemId_Internal);
if (ownerItemOptions == null || (DateTime.Now - ownerItemOptions.LastRefreshed).TotalMinutes > 30)
{
// Initialise the cache for this item's options.
ownerItemOptions = new ItemOptionData(associationItemId_Internal);
itemOptionsCache.ItemOptions[associationItemId_Internal] = ownerItemOptions;
// Populate options for this item.
ownerItemOptions.ItemOptions.AddRange(Internals.ItemOptionConsole.GetItemOptionsForItem(associationItemId_Internal));
SaLogger.Debug($"{SysUtil.Fn} AffilIdOwner: {userContext.OrganisationAffiliateId}. AssocIdInternal: {userContext.OrganisationAssociationId}. Item options populated: {ownerItemOptions.ItemOptions.Count}.");
}
ownerOptions = new List<SaItemOption>(ownerItemOptions.ItemOptions);
}
return ownerOptions;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,37 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
{
//=======================================================================
public class SbmOrganisationConfig_Dbas : SbmOrganisationConfig
{
//-------------------------------------------------------------------
// Data members.
private readonly ISbmUserOrganisationContext userContext;
private readonly SbmInstanceDataCache instanceDataCache;
//-------------------------------------------------------------------
// Construction.
public SbmOrganisationConfig_Dbas(ISbmUserOrganisationContext userContext, SbmInstanceDataCache instanceDataCache) : base()
{
this.userContext = userContext;
this.instanceDataCache = instanceDataCache;
}
protected override void Dispose(bool disposing) { }
//-------------------------------------------------------------------
// Properties.
protected override ISbmUserOrganisationContext UserContext { get { return userContext; } }
protected override SbmInstanceDataCache InstanceDataCache { get { return instanceDataCache; } }
//-------------------------------------------------------------------
}
//=======================================================================
}

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