From 61ecd59794fb589c4e24be61ebcef077892d11ad Mon Sep 17 00:00:00 2001 From: Andy Howard Date: Thu, 16 Jan 2025 13:19:58 +0000 Subject: [PATCH] Session Console and Internals. --- .../Procs/Consoles/SbmProcessConsole.cs | 14 +- .../Procs/Interfaces/SbmInterfaceProcess.cs | 2 +- .../SbmInterfaceProcess_Commodity_Export.cs | 20 +- .../Procs/Procs/SbmProcess_Base.cs | 15 +- .../Procs/SbmProcess_Commodity_Export.cs | 10 +- SaBusMgrCoreProcs/Procs/Reports/SbmReport.cs | 2 +- SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs | 28 +- .../Web/App/SbmInstanceConfig_Control.cs | 257 +-- .../Web/App/SbmInstanceConfig_Core.cs | 55 +- SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs | 21 +- SaBusMgrCoreWeb/Web/App/SbmUserContext_Web.cs | 3 +- .../Web/Consoles/SbmCodeTypeConsole_Web.cs | 2 +- .../Web/Consoles/SbmItemOptionConsole_Web.cs | 46 + .../Web/Consoles/SbmSecurityConsole_Web.cs | 2 +- .../Web/Consoles/SbmUpdateLogConsole_Web.cs | 2 +- .../Web/Controllers/SbmController_Base.cs | 4 +- SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs | 4 +- SaBusMgrStandardBase/Base/App/Sbm.cs | 126 +- SaBusMgrStandardBase/Base/App/SbmAppConfig.cs | 190 +- .../Base/App/SbmApplication.cs | 26 +- .../Base/App/SbmConsoleViewDfn.cs | 2 +- .../Base/App/SbmInstanceConfig.cs | 24 +- .../Base/App/SbmInstanceDataCache.cs | 32 + SaBusMgrStandardBase/Base/App/SbmInternals.cs | 360 ++-- .../Base/App/SbmOrganisationConfig.cs | 181 ++ .../Base/App/SbmSecurityProfile.cs | 58 +- .../Base/App/SbmSysParamCache.cs | 4 +- .../Base/App/SbmSystem-CodeTypes.cs | 108 +- .../Base/App/SbmSystem-Statics.cs | 1570 ++++++++++------- SaBusMgrStandardBase/Base/App/SbmSystem.cs | 433 +---- .../Base/App/SbmUserContext.cs | 193 +- .../Base/Bus/Control/SbmcItemParam.cs | 2 + .../Base/Bus/SbmAccountsDfn-QuickBooks.cs | 4 +- .../Base/Bus/SbmAccountsDfn-Sage.cs | 6 +- .../Base/Bus/SbmAccountsDfn.cs | 6 +- SaBusMgrStandardBase/Base/Bus/SbmAddress.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmAsset.cs | 2 +- .../Base/Bus/SbmAssetCategory.cs | 2 +- .../Base/Bus/SbmAssetProcess.cs | 2 +- .../Base/Bus/SbmAssociation.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs | 6 +- .../Base/Bus/SbmCommodityCustomer.cs | 2 +- .../Base/Bus/SbmCommoditySupplier.cs | 2 +- .../Base/Bus/SbmConstituent.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmContainer.cs | 2 +- .../Base/Bus/SbmContainerItem.cs | 2 +- .../Base/Bus/SbmCostEstimate.cs | 6 +- .../Base/Bus/SbmHierarchyItem.cs | 6 +- SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs | 4 +- .../Base/Bus/SbmItemProcess.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmLocation.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmMovement.cs | 2 +- .../Base/Bus/SbmPortfolioItem.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmPrice.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmProcess.cs | 2 +- .../Base/Bus/SbmRequirement.cs | 2 +- .../Base/Bus/SbmRequirementCosts.cs | 7 +- .../Base/Bus/SbmStockLevel.cs | 2 +- SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs | 2 +- .../Base/Bus/SbmSystemAccount.cs | 2 +- .../Base/Bus/SbmSystemAccountUser.cs | 2 +- .../Base/Bus/SbmSystemUser.cs | 2 +- .../Base/Bus/SbmTransaction.cs | 12 +- .../Base/Bus/SbmTransactionPayment.cs | 4 +- SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs | 2 +- .../Base/Bus/SbmVehicleClass.cs | 2 +- .../Base/Bus/SbmVehicleEvent.cs | 2 +- .../Base/Bus/SbmVehicleFeature.cs | 2 +- .../Base/Consoles/SbmEmailConsole.cs | 2 +- .../SbmSessionConsole-Transactions.cs | 415 +++++ .../Base/Consoles/SbmSessionConsole.cs | 540 ++---- .../Base/Core/ISbmInstanceConfig.cs | 56 + .../Base/Core/ISbmOrganisationConfig.cs | 37 + .../Base/Core/ISbmOrganisationContext.cs | 37 + .../Base/Core/ISbmUserContext.cs | 3 + .../Base/Core/ISbmUserContext_Core.cs | 67 - .../Base/Core/ISbmUserOrganisationContext.cs | 34 + .../Base/Mgr/SbmAccountMgr.cs | 6 +- .../Base/Mgr/SbmAccountMgr_Address.cs | 4 +- .../Base/Mgr/SbmAccountMgr_Organisation.cs | 677 ++++--- SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr.cs | 6 +- .../Base/Mgr/SbmCommodityMgr.cs | 6 +- .../Mgr/SbmCommodityMgr_Commodity-Utils.cs | 4 +- SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs | 169 +- .../Base/Mgr/SbmDataItemMgr.cs | 18 +- SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs | 10 +- .../Base/Mgr/SbmProcessMgr.cs | 6 +- SaBusMgrStandardBase/Base/Mgr/SbmStockMgr.cs | 18 +- .../Base/Mgr/SbmStockMgr_Location.cs | 10 +- .../Base/Mgr/SbmTransactionMgr.cs | 6 +- .../Base/Mgr/SbmTransactionMgr_Requirement.cs | 2 +- .../Base/Mgr/SbmTransactionMgr_Transaction.cs | 4 +- .../Base/Procs/SbmReport_Base.cs | 4 +- .../Base/UpdateLog/SbmUpdateLogItemMonitor.cs | 2 +- .../Dbas/App/SbmInstanceDataCache_Dbas.cs | 112 ++ .../Dbas/App/SbmOrganisationConfig_Dbas.cs | 37 + .../Dbas/App/SbmSystem_Dbas.cs | 48 +- .../Dbas/Bus/SbmProcess_Dbas.cs | 2 +- .../Dbas/Bus/SbmTransaction_Dbas.cs | 9 +- .../Dbas/Consoles/SbmCodeTypeConsole_Dbas.cs | 4 +- .../Dbas/Consoles/SbmDiaryConsole_Dbas.cs | 4 +- .../Dbas/Consoles/SbmInterfaceConsole_Dbas.cs | 16 +- .../Dbas/Consoles/SbmItemDataConsole_Dbas.cs | 4 +- .../Dbas/Consoles/SbmItemDocConsole_Dbas.cs | 4 +- .../Consoles/SbmItemOptionConsole_Dbas.cs | 4 +- .../Consoles/SbmReferenceDataConsole_Dbas.cs | 4 +- .../Dbas/Consoles/SbmSecurityConsole_Dbas.cs | 31 +- .../Dbas/Consoles/SbmUpdateLogConsole_Dbas.cs | 4 +- .../Mgr/Control/SbmcItemMgr_Dbas-ItemParam.cs | 23 +- .../Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs | 34 +- .../Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs | 42 +- .../Mgr/SbmAccountMgr_Dbas-Association.cs | 116 +- .../Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs | 22 +- .../Mgr/SbmAccountMgr_Dbas-SystemAccount.cs | 28 +- .../SbmAccountMgr_Dbas-SystemAccountUser.cs | 28 +- .../Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs | 30 +- .../Dbas/Mgr/SbmAccountMgr_Dbas.cs | 29 +- .../Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs | 24 +- .../Mgr/SbmAssetMgr_Dbas-AssetCategory.cs | 37 +- .../Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs | 22 +- .../Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs | 36 +- .../Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs | 36 +- .../Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs | 22 +- .../Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs | 34 +- .../Dbas/Mgr/SbmAssetMgr_Dbas.cs | 43 +- .../SbmCommodityMgr_Dbas-Commodity-Utils.cs | 10 +- .../Mgr/SbmCommodityMgr_Dbas-Commodity.cs | 118 +- .../SbmCommodityMgr_Dbas-CommodityCustomer.cs | 40 +- .../SbmCommodityMgr_Dbas-CommoditySupplier.cs | 28 +- .../Mgr/SbmCommodityMgr_Dbas-Container.cs | 32 +- .../Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs | 31 +- .../Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs | 34 +- .../Dbas/Mgr/SbmCommodityMgr_Dbas.cs | 38 +- .../Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs | 24 +- .../Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs | 4 +- .../Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs | 24 +- .../Dbas/Mgr/SbmDataItemMgr_Dbas.cs | 37 +- .../Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs | 20 +- .../Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs | 26 +- .../Dbas/Mgr/SbmPriceMgr_Dbas.cs | 29 +- .../Mgr/SbmProcessMgr_Dbas-ItemProcess.cs | 8 +- .../Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs | 28 +- .../Dbas/Mgr/SbmProcessMgr_Dbas.cs | 33 +- .../Dbas/Mgr/SbmStockMgr_Dbas-Location.cs | 22 +- .../Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs | 50 +- .../Dbas/Mgr/SbmStockMgr_Dbas.cs | 41 +- .../Mgr/SbmTransactionMgr_Dbas-Constituent.cs | 52 +- .../Mgr/SbmTransactionMgr_Dbas-Requirement.cs | 102 +- .../Mgr/SbmTransactionMgr_Dbas-Transaction.cs | 112 +- .../Dbas/Mgr/SbmTransactionMgr_Dbas.cs | 39 +- .../SbmUpdateLogItemMonitor_Address.cs | 4 +- .../SbmUpdateLogItemMonitor_Affiliate.cs | 2 +- .../SbmUpdateLogItemMonitor_AssetCategory.cs | 4 +- .../SbmUpdateLogItemMonitor_Association.cs | 4 +- .../SbmUpdateLogItemMonitor_Commodity.cs | 2 +- .../SbmUpdateLogItemMonitor_Constituent.cs | 2 +- .../SbmUpdateLogItemMonitor_Container.cs | 4 +- .../SbmUpdateLogItemMonitor_ContainerItem.cs | 11 +- .../SbmUpdateLogItemMonitor_ItemBatch.cs | 2 +- .../SbmUpdateLogItemMonitor_ItemLink.cs | 2 +- .../SbmUpdateLogItemMonitor_Location.cs | 2 +- .../SbmUpdateLogItemMonitor_Movement.cs | 5 +- .../SbmUpdateLogItemMonitor_PortfolioItem.cs | 2 +- .../SbmUpdateLogItemMonitor_Process.cs | 4 +- .../SbmUpdateLogItemMonitor_Requirement.cs | 2 +- .../SbmUpdateLogItemMonitor_SysParam.cs | 2 +- .../SbmUpdateLogItemMonitor_Transaction.cs | 2 +- .../SbmUpdateLogItemMonitor_VehicleClass.cs | 6 +- .../SbmUpdateLogItemMonitor_VehicleEvent.cs | 2 +- .../SbmUpdateLogItemMonitor_VehicleFeature.cs | 4 +- .../Control/App/SbmApplication_Control.cs | 30 +- .../Control/App/SbmUserContext_Control.cs | 2 +- .../Controllers/Param/ParamController-Ajax.cs | 16 +- .../Controllers/SbmController_Control.cs | 2 +- .../Control/Models/SbmModel_Control.cs | 2 +- .../Portal/App/SbmApplication_Portal.cs | 53 +- .../Portal/App/SbmSessionData_Portal.cs | 2 +- .../SbmReferenceDataConsole_Portal.cs | 2 +- .../Controllers/SbmController_Portal.cs | 31 +- .../Security/SecurityController-Ajax.cs | 74 +- .../Security/SecurityController.cs | 7 +- .../Commodities/Model_Commodity-Config.cs | 2 +- .../Portal/Models/SbmModel_Portal.cs | 106 +- 187 files changed, 4681 insertions(+), 3647 deletions(-) create mode 100644 SaBusMgrCoreWeb/Web/Consoles/SbmItemOptionConsole_Web.cs create mode 100644 SaBusMgrStandardBase/Base/App/SbmInstanceDataCache.cs create mode 100644 SaBusMgrStandardBase/Base/App/SbmOrganisationConfig.cs create mode 100644 SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole-Transactions.cs create mode 100644 SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs create mode 100644 SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs create mode 100644 SaBusMgrStandardBase/Base/Core/ISbmOrganisationContext.cs delete mode 100644 SaBusMgrStandardBase/Base/Core/ISbmUserContext_Core.cs create mode 100644 SaBusMgrStandardBase/Base/Core/ISbmUserOrganisationContext.cs create mode 100644 SaBusMgrStandardDbas/Dbas/App/SbmInstanceDataCache_Dbas.cs create mode 100644 SaBusMgrStandardDbas/Dbas/App/SbmOrganisationConfig_Dbas.cs diff --git a/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs b/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs index 9e3f7bf..18ee28e 100644 --- a/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs +++ b/SaBusMgrCoreProcs/Procs/Consoles/SbmProcessConsole.cs @@ -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 //------------------------------------------------------------------- - public static List GetInterfaceItemOptionDfns(ISbmUserContext_Core userContext, SaInterfaceCategory interfaceCategory, short interfaceType) + public static List GetInterfaceItemOptionDfns(ISbmUserOrganisationContext userContext, SaInterfaceCategory interfaceCategory, short interfaceType) { 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 //------------------------------------------------------------------- - public static List GetProcessingOptions(ISbmUserContext_Core userContext, SaInterface interfaceObj) + public static List GetProcessingOptions(ISbmUserOrganisationContext userContext, SaInterface interfaceObj) { if (interfaceObj == null || !SysId.IsValid(interfaceObj.Id)) return new List(); List 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 //------------------------------------------------------------------- - 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; 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 //------------------------------------------------------------------- - 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; 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 //------------------------------------------------------------------- // 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. @@ -186,11 +186,11 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles //------------------------------------------------------------------- // 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); } - 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.Params prmInterface = new SaInterface.Params(); diff --git a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess.cs b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess.cs index 67bc893..527e82b 100644 --- a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess.cs +++ b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess.cs @@ -30,7 +30,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces } 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; } diff --git a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs index 67a96df..b185689 100644 --- a/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs +++ b/SaBusMgrCoreProcs/Procs/Interfaces/SbmInterfaceProcess_Commodity_Export.cs @@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces // Configuration. public new class Config : SbmInterfaceProcess.Config { - public Config(ISbmUserContext_Core userContext) : base(userContext) + public Config(ISbmUserOrganisationContext userContext) : base(userContext) { ItemType = Sbm.ItemType.Commodity; ProcessType = ProcessType.ExportData; @@ -120,7 +120,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces public SbmInterfaceProcess_Commodity_Export(Config config) : base(config) { this.config = config; - interfaceOptions = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceOption); + interfaceOptions = Internals.GetSystemCodes(Sbm.SystemCode.InterfaceOption); } protected override void Dispose(bool disposing) { @@ -677,7 +677,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces for (int i = 1; i <= kiMaxDataColumn; i++) 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) { optionValues_Column = new List(); @@ -707,7 +707,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces } AddColumnValue(SbmCommodity.Column.Location, "Cmd_Location", "Location"); 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.Weight, "Cmd_Weight", "Weight"); //AddColumnValue(SbmCommodity.Column.WeightUomId, "Cmd_WeightUomId", "Weight","UOM Id"); @@ -847,7 +847,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces // Stock take: AddColumnValue(SbmCommodity.Column.StockTake_Date, "Cmd_StockTake_Date", "Stock take date (derived)"); // 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_Jan, "Cmd_SalesProj_Jan", "Sales proj - Jan"); @@ -1011,7 +1011,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces // Portfolio items: AddColumnValue(SbmCommodity.Column.PortfolioItem_Count, "Cmd_Portfolio_ItemCount", "Portfolio item count"); // 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.BarcodeImage, "Cmd_BarcodeImage", "Barcode image"); @@ -1038,7 +1038,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces switch (SbmDbDfn.GetTableForColumn(eDbCol)) { case SbmDbDfn.TableIdx.PortfolioItem: - allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.AllowPortfolios); + allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.Portfolios); if (allowColumn) allowColumn = CommodityMgr.PortfolioDatabaseIsValid; break; @@ -1049,7 +1049,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces break; case SbmDbDfn.TableIdx.Transaction: case SbmDbDfn.TableIdx.Requirement: - allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.AllowTransactions); + allowColumn = SessionConsole.AllowOption(Sbm.ConfigOption.Transactions); break; } @@ -1072,7 +1072,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces Export_Commodities, } /// Configure processing options. - public static List GetProcessingOptions(ISbmUserContext_Core userContext, SaInterface interfaceObj) + public static List GetProcessingOptions(ISbmUserOrganisationContext userContext, SaInterface interfaceObj) { List optionGroups = new List(); @@ -1087,7 +1087,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces //------------------------------------------------------------------- /// Process interface using selected options. - 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) { diff --git a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs index 7346eac..0d20872 100644 --- a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs +++ b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Base.cs @@ -25,8 +25,8 @@ using Sarand.BusinessMgr.Net.Standard.Base.Consoles; namespace Sarand.BusinessMgr.Net.Core.Procs.Procs { - //======================================================================= - public abstract partial class SbmProcess_Base : SaProcess + //======================================================================= + public abstract partial class SbmProcess_Base : SaProcess { //------------------------------------------------------------------- // Configuration. @@ -40,11 +40,16 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs } 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; } - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } /// Specific type of data item being handled. public Sbm.ItemType ItemType { get; set; } = Sbm.ItemType.Unknown; /// Format to import/export data. @@ -106,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs } } // Context. - public ISbmUserContext_Core UserContext { get { return config.UserContext; } } + public ISbmUserOrganisationContext UserContext { get { return config.UserContext; } } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } protected SbmInternals Internals { diff --git a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs index 94e49d3..e4ce225 100644 --- a/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs +++ b/SaBusMgrCoreProcs/Procs/Procs/SbmProcess_Commodity_Export.cs @@ -24,7 +24,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs // Configuration. public new class Config : SbmProcess_Base.Config { - public Config(ISbmUserContext_Core userContext) : base(userContext) + public Config(ISbmUserOrganisationContext userContext) : base(userContext) { ItemType = Sbm.ItemType.Commodity; DataFormat = DataFormatType.Excel; @@ -330,7 +330,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs displayColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.DescBrief, "Description", 240)); if (CommodityMgr.CodeTypeHasCodes(Sbm.ApplCodeType.CommodityCategory)) 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)); 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.RetailPrice)); 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)); - 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)); 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_Due_Imminently)); // 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++) displayColumns.Add(CommodityMgr.GetCommodityColumnDfn((SbmCommodity.Column)(SbmCommodity.Column.SalesProj_Jan + monthIdx))); diff --git a/SaBusMgrCoreProcs/Procs/Reports/SbmReport.cs b/SaBusMgrCoreProcs/Procs/Reports/SbmReport.cs index 9f03a51..bcec9d6 100644 --- a/SaBusMgrCoreProcs/Procs/Reports/SbmReport.cs +++ b/SaBusMgrCoreProcs/Procs/Reports/SbmReport.cs @@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Reports // Configuration. public new class Config : SbmReport_Base.Config { - protected Config(ISbmUserContext_Core userContext) : + protected Config(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs b/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs index e07c56d..33a0a3f 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmApplication_Web.cs @@ -24,8 +24,8 @@ using System.Text; namespace Sarand.BusinessMgr.Net.Core.Web.App { - //======================================================================= - public abstract class SbmApplication_Web : SbmApplication + //======================================================================= + public abstract class SbmApplication_Web : SbmApplication { //------------------------------------------------------------------- // Data members. @@ -98,39 +98,39 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App //------------------------------------------------------------------- // Create consoles. - public override SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext) + public override SbmSessionConsole CreateSessionConsole(ISbmUserOrganisationContext userContext) { return SbmSessionConsole.CreateConsole(userContext); } - public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext) + public override SaDiaryConsole CreateDiaryConsole(ISbmUserOrganisationContext userContext) { return null; } - public override SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext) + public override SaSecurityConsole CreateSecurityConsole(ISbmUserOrganisationContext userContext) { return new SbmSecurityConsole_Web(userContext); } - public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext_Core userContext) + public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserOrganisationContext userContext) { return new SbmCodeTypeConsole_Web(userContext); } - public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext) + public override SaItemDataConsole CreateItemDataConsole(ISbmUserOrganisationContext userContext) { return null; } - public override SaItemDocConsole CreateItemDocConsole(ISbmUserContext_Core userContext) + public override SaItemDocConsole CreateItemDocConsole(ISbmUserOrganisationContext userContext) { 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; } - public override SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext_Core userContext) - { - return null; - } - public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext_Core userContext) + public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserOrganisationContext userContext) { return new SbmUpdateLogConsole_Web(userContext); } diff --git a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs index 6682d4c..320a3ff 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Control.cs @@ -7,7 +7,9 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; +using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Core.Web.App { @@ -16,10 +18,17 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { //------------------------------------------------------------------- // Definitions. - protected const String ParamContext_Config = "Config"; - protected const String ParamContext_ConfigPrefix = "Config-"; - protected const String ApplicationOptionValue_Allow = "Allow"; - protected const String ApplicationOptionValue_Disallow = "Disallow"; + protected const String ParamContext_OptionAllowed = "OptionAllowed"; + protected const String ParamContext_AffiliateTypeAllowed = "AffiliateTypeAllowed"; + protected const String ParamContext_AssociationTypeAllowed = "AssociationTypeAllowed"; + 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. @@ -39,17 +48,10 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App // Owner/Instance configuration parameters. public enum ConfigParamType { - // Affiliate types. - AllowedAffiliateTypes, - DisallowedAffiliateTypes, - // Association types. - AllowedAssociationTypes, - DisallowedAssociationTypes, - // Transaction types. - AllowedTransactionTypes, - DisallowedTransactionTypes, - // Application options. - ApplicationOption, + AffiliateTypeAllowed, + AssociationTypeAllowed, + TransactionTypeAllowed, + ApplicationOptionAllowed, } public class ConfigParamData { @@ -60,52 +62,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App 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() { ApplicationOptionValue_Allow, ApplicationOptionValue_Disallow }); - return configParamData; - } - //------------------------------------------------------------------- // Populate Repository Configuration parameters. private void PopulateControlParams() @@ -138,74 +94,93 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App } private void PopulateControlParam(SbmcItemParam itemParam) { - // Affiliate types. - if (IsConfigParamOfType(ConfigParamType.AllowedAffiliateTypes, itemParam)) - AffiliateTypes_Allowed.UnionWith(EnumUtil.ParseEnums(Regex.Split(itemParam.Value, "[\\s,;\\-]+"))); - else if (IsConfigParamOfType(ConfigParamType.DisallowedAffiliateTypes, itemParam)) - AffiliateTypes_Disallowed.UnionWith(EnumUtil.ParseEnums(Regex.Split(itemParam.Value, "[\\s,;\\-]+"))); - // Association types. - else if (IsConfigParamOfType(ConfigParamType.AllowedAssociationTypes, itemParam)) - AssociationTypes_Allowed.UnionWith(EnumUtil.ParseEnums(Regex.Split(itemParam.Value, "[\\s,;\\-]+"))); - else if (IsConfigParamOfType(ConfigParamType.DisallowedAssociationTypes, itemParam)) - AssociationTypes_Disallowed.UnionWith(EnumUtil.ParseEnums(Regex.Split(itemParam.Value, "[\\s,;\\-]+"))); - // Transaction types. - else if (IsConfigParamOfType(ConfigParamType.AllowedTransactionTypes, itemParam)) - TransactionTypes_Allowed.UnionWith(EnumUtil.ParseEnums(Regex.Split(itemParam.Value, "[\\s,;\\-]+"))); - else if (IsConfigParamOfType(ConfigParamType.DisallowedTransactionTypes, itemParam)) - TransactionTypes_Disallowed.UnionWith(EnumUtil.ParseEnums(Regex.Split(itemParam.Value, "[\\s,;\\-]+"))); - // Application options. - else if (IsConfigParamOfType(ConfigParamType.ApplicationOption, itemParam)) + if (itemParam.Context.EqualsCI(ParamContext_OptionAllowed)) { + // Application options. Sbm.ConfigOption option = EnumUtil.ParseEnum(itemParam.Name, Sbm.ConfigOption.Unknown); if (option != Sbm.ConfigOption.Unknown) { - if (itemParam.Value.EqualsCI(ApplicationOptionValue_Allow)) + if (StringUtil.ToBool(itemParam.Value)) ApplicationOptions_Allowed.Add(option); - else if (itemParam.Value.EqualsCI(ApplicationOptionValue_Disallow)) - ApplicationOptions_Disallowed.Add(option); else - SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option value: {itemParam.Value}. Option: {option}."); + ApplicationOptions_Disallowed.Add(option); } - else - SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option: {itemParam.Name}."); + 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 + 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 + 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. - //------------------------------------------------------------------- - - // Supported affiliate types. - private readonly HashSet AffiliateTypes_Allowed = new HashSet(); - private readonly HashSet AffiliateTypes_Disallowed = new HashSet(); - 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 AssociationTypes_Allowed = new HashSet(); - private readonly HashSet AssociationTypes_Disallowed = new HashSet(); - 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 TransactionTypes_Allowed = new HashSet(); - private readonly HashSet TransactionTypes_Disallowed = new HashSet(); - 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; - } - + // Configuration rules. //------------------------------------------------------------------- + // Application options. // Supported application options. private readonly HashSet ApplicationOptions_Allowed = new HashSet(); @@ -217,6 +192,54 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App return defaultResponse; } + //------------------------------------------------------------------- + // Contacts. + + // Supported Affiliate types. + private readonly HashSet AffiliateTypes_Allowed = new HashSet(); + private readonly HashSet AffiliateTypes_Disallowed = new HashSet(); + 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 AssociationTypes_Allowed = new HashSet(); + private readonly HashSet AssociationTypes_Disallowed = new HashSet(); + 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 TransactionTypes_Allowed = new HashSet(); + private readonly HashSet TransactionTypes_Disallowed = new HashSet(); + 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 InterfaceCategories_Allowed = new HashSet(); + private readonly HashSet InterfaceCategories_Disallowed = new HashSet(); + /// + /// Whether the Interface Category is allowed. + /// + public override bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse) + { + if (InterfaceCategories_Allowed.Contains(interfaceCategory)) return false; + if (InterfaceCategories_Disallowed.Contains(interfaceCategory)) return true; + return defaultResponse; + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs index d1bc856..9e1fb79 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmInstanceConfig_Core.cs @@ -39,28 +39,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App private SbmSessionContext_Web SessionContext { get; } //------------------------------------------------------------------- - // Allowed data component types. - //------------------------------------------------------------------- - - // 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; - } - + // Configuration rules. //------------------------------------------------------------------- + // Application options. // Supported application options. public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse) @@ -68,6 +49,38 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App 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; + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs b/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs index bb3e13f..ef41f4c 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmLocaliser.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Localization; 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.Core; using Sarand.Net.Standard.Base.Utils; @@ -140,11 +142,11 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App public List GetCodesOfType(Sbm.SystemCode codeType) { if (!codes.ContainsKey(codeType)) - codes.Add(codeType, SbmSystem.GetCodesOfType(null, codeType)); + codes.Add(codeType, SbmSystem.GetSystemCodes(codeType)); return codes.GetValueOrDefault(codeType, new List()); } } - private CodeCache codes = new CodeCache(); + private readonly CodeCache systemCodes = new CodeCache(); // Status. public String GetStatusCaption(SaStatus status) @@ -158,7 +160,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { if ((int)affiliateType < 1) return ""; // ToDo Affiliate Type localisation. - List affiliateTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AffiliateType); + List affiliateTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.AffiliateType); return affiliateTypeCodes.GetDescForType(affiliateType, affiliateTypeCodes.GetCodeForType(affiliateType)); } @@ -167,7 +169,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { if ((int)associationType < 1) return ""; // ToDo Association Type localisation. - List associationTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssociationType); + List associationTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.AssociationType); return associationTypeCodes.GetDescForType(associationType, associationTypeCodes.GetCodeForType(associationType)); } @@ -176,10 +178,19 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App { if ((int)assetType < 1) return ""; // ToDo Asset Type localisation. - List assetTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssetType); + List assetTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.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 transactionTypeCodes = systemCodes.GetCodesOfType(Sbm.SystemCode.TransactionType); + return transactionTypeCodes.GetDescForType(transactionType, transactionTypeCodes.GetCodeForType(transactionType)); + } + // To be completed. //------------------------------------------------------------------- diff --git a/SaBusMgrCoreWeb/Web/App/SbmUserContext_Web.cs b/SaBusMgrCoreWeb/Web/App/SbmUserContext_Web.cs index 2c28873..ae2119a 100644 --- a/SaBusMgrCoreWeb/Web/App/SbmUserContext_Web.cs +++ b/SaBusMgrCoreWeb/Web/App/SbmUserContext_Web.cs @@ -1,5 +1,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.App; 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.Security; using System; @@ -9,7 +10,7 @@ using System.Text; namespace Sarand.BusinessMgr.Net.Core.Web.App { //======================================================================= - public class SbmUserContext_Web : SbmUserContext + public class SbmUserContext_Web : SbmUserContext_Dbas { //------------------------------------------------------------------- // Data members. diff --git a/SaBusMgrCoreWeb/Web/Consoles/SbmCodeTypeConsole_Web.cs b/SaBusMgrCoreWeb/Web/Consoles/SbmCodeTypeConsole_Web.cs index dfc621b..1d887ee 100644 --- a/SaBusMgrCoreWeb/Web/Consoles/SbmCodeTypeConsole_Web.cs +++ b/SaBusMgrCoreWeb/Web/Consoles/SbmCodeTypeConsole_Web.cs @@ -14,7 +14,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles { //------------------------------------------------------------------- // Construction. - public SbmCodeTypeConsole_Web(ISbmUserContext_Core userContext) : base(userContext) + public SbmCodeTypeConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrCoreWeb/Web/Consoles/SbmItemOptionConsole_Web.cs b/SaBusMgrCoreWeb/Web/Consoles/SbmItemOptionConsole_Web.cs new file mode 100644 index 0000000..0e22281 --- /dev/null +++ b/SaBusMgrCoreWeb/Web/Consoles/SbmItemOptionConsole_Web.cs @@ -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. + + /// + /// 'Show Item Options' dialog only for desktop and mobile applications. + /// + protected override ShowItemOptionsDialogFunction ShowItemOptionsDialogFn => throw new NotImplementedException(); + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrCoreWeb/Web/Consoles/SbmSecurityConsole_Web.cs b/SaBusMgrCoreWeb/Web/Consoles/SbmSecurityConsole_Web.cs index 51c6a78..247d0bc 100644 --- a/SaBusMgrCoreWeb/Web/Consoles/SbmSecurityConsole_Web.cs +++ b/SaBusMgrCoreWeb/Web/Consoles/SbmSecurityConsole_Web.cs @@ -17,7 +17,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles //------------------------------------------------------------------- // Construction. - public SbmSecurityConsole_Web(ISbmUserContext_Core userContext) : base(userContext) + public SbmSecurityConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext) { } protected override void Dispose(bool disposing) diff --git a/SaBusMgrCoreWeb/Web/Consoles/SbmUpdateLogConsole_Web.cs b/SaBusMgrCoreWeb/Web/Consoles/SbmUpdateLogConsole_Web.cs index 5ecf8f2..6931fb9 100644 --- a/SaBusMgrCoreWeb/Web/Consoles/SbmUpdateLogConsole_Web.cs +++ b/SaBusMgrCoreWeb/Web/Consoles/SbmUpdateLogConsole_Web.cs @@ -16,7 +16,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles //------------------------------------------------------------------- // Construction. - public SbmUpdateLogConsole_Web(ISbmUserContext_Core userContext) : base(userContext) + public SbmUpdateLogConsole_Web(ISbmUserOrganisationContext userContext) : base(userContext) { } protected override void Dispose(bool disposing) diff --git a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs b/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs index e98e271..a46f055 100644 --- a/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs +++ b/SaBusMgrCoreWeb/Web/Controllers/SbmController_Base.cs @@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } } public App.SbmAppConfig AppConfig { get { return App.AppConfig; } } public abstract SbmSessionContext SessionContext { get; } - public abstract ISbmUserContext_Core UserContext_Core { get; } + public abstract ISbmUserOrganisationContext UserContext_Core { get; } // Business components. 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; } } @@ -98,7 +98,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers public SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } public SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } // System codes. - public List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); } + public List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); } // Email. public SaEmailConfig EmailConfig { get { return Internals.EmailConfig; } } public SbmEmailConsole EmailConsole { get { return Internals.EmailConsole; } } diff --git a/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs b/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs index 775b243..76031f1 100644 --- a/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs +++ b/SaBusMgrCoreWeb/Web/Models/SbmModel_Base.cs @@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models public SbmSessionData SessionData { get { return SessionData_Web; } } public SbmSessionData_Web SessionData_Web { get; set; } 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 SbmLocaliser Localiser { get; } // Request properties. @@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } } protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } // System codes. - protected List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); } + protected List GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetSystemCodes(systemCode); } //------------------------------------------------------------------- // Security. diff --git a/SaBusMgrStandardBase/Base/App/Sbm.cs b/SaBusMgrStandardBase/Base/App/Sbm.cs index 33060d6..faabef4 100644 --- a/SaBusMgrStandardBase/Base/App/Sbm.cs +++ b/SaBusMgrStandardBase/Base/App/Sbm.cs @@ -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.Dbas; using System; @@ -324,20 +325,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App /// Display dialog bar. DialogBar = 11, // Core application modules. - AllowConsoleView = 20, /* Default: True */ - AllowOrganisationUpdate, /* Default: True */ - AllowContacts, /* Default: True */ - AllowProcesses, /* Default: True */ - AllowAssets, - AllowVehicles, - AllowComputerHardware, - AllowCommodities, /* Default: True */ - AllowCommodityAssociations, - AllowPortfolios, - AllowPriceSets, - AllowTransactions, /* Default: True */ - AllowItemDocuments, - AllowFinancialsAccessControl, + ConsoleView = 20, /* Default: True */ + OrganisationUpdate, /* Default: True */ + Contacts, /* Default: True */ + ComputerHardware, + Commodities, /* Default: True */ + CommodityAssociations, + Processes, /* Default: True */ + Assets, + Vehicles, + Portfolios, + PriceSets, + Transactions, /* Default: True */ + ItemDocuments, + FinancialsAccessControl, //--------------------------------------------------------------- // Navigation (view) options. DiaryView = 60, /* Default: True */ @@ -346,7 +347,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App AnyTransactionView, Jobs = 70, TimeRecording, - AllowTasks, + Tasks, //--------------------------------------------------------------- // Associations. AssocMaxTransAmount = 100, @@ -366,21 +367,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App TransactionUpperRefExt, ShowSiteAddrOnTransView, ShowTransRefInDropdown, - AllowRaiseOrderWithQuoteRef, + RaiseOrderWithQuoteRef, TransactionEstimatedAmount, TransactionPayments, TransactionDeliveryCosts, TransactionSplitTimes, - AllowFixedSalesQuoteToWordExport, + FixedSalesQuoteToWordExport, //--------------------------------------------------------------- // Requirements. - AllowPurchasingPlanning = 220, - AllowProductionControl, - AllowDeliveryPlanning, + PurchasingPlanning = 220, + ProductionControl, + DeliveryPlanning, /// For quicker addition of items to order (all with quantity=0). - AllowOrderSelectCommodities, + OrderSelectCommodities, /// Direct update from main view (default: true). - AllowRequirementUpdateInline, + RequirementUpdateInline, /// Using cost and labour codes (unit and job). EstimateSalesQuotesByCosts, /// To derive processes for commodities from quote cost estimates. @@ -738,13 +739,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App ItemDataType, // Contacts. AffiliateType, - AssociationType, - AssociationStatusCat, AddressType, + AssociationType, SystemAccountType, // Transactions. TransactionType, - /// Ref. SbmTransaction.StatusCat TransactionStatusCat, RequirementType, TaskCodeType, @@ -753,19 +752,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App ConstituentStatusCat, // Miscellaneous. ItemLinkData, + SysParamCategory, // Commodities. CommodityType, CommodityStatusCat, PortfolioItemType, - LocationCategory, - LocationFilter, ContainerCategory, ContainerType, // Stock. + LocationCategory, + LocationFilter, MovementType, StockLevelType, StockLevelSource, - SysParamCategory, // Processes. ProcessCategory, ProcessType, @@ -782,8 +781,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App VehicleTransType, FuelType, OdometerUnits, + // Reference. RegionType, - // Unit of measure. UnitMeasureCategory, UnitMeasureType, FinancialType, @@ -1138,6 +1137,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Asset_Sale, Asset_Rental, } + //------------------------------------------------------------------- public enum OrgOption_Caption { @@ -1174,6 +1174,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App MenuOpt_ProformaPurchaseInvoices, 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 { @@ -1633,6 +1698,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Personal = -2, // Task management only. NotInternal = -1, Any = 0, + Unknown = Any, // NB Do not change the positive values, as tied to the database. Internal = 1, Customer = 2, diff --git a/SaBusMgrStandardBase/Base/App/SbmAppConfig.cs b/SaBusMgrStandardBase/Base/App/SbmAppConfig.cs index 75cc212..e85fb3d 100644 --- a/SaBusMgrStandardBase/Base/App/SbmAppConfig.cs +++ b/SaBusMgrStandardBase/Base/App/SbmAppConfig.cs @@ -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 //------------------------------------------------------------------- // 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) { //----------------------------------------------------------- @@ -32,210 +32,210 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App case Sbm.View.Main: return true; case Sbm.View.Console: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowConsoleView)) return false; - if (!sessionConfig.GetConsoleViewDfn().HasContent()) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.ConsoleView)) return false; + if (!sessionConsole.GetConsoleViewDfn().HasContent()) return false; return true; case Sbm.View.Diary: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.DiaryView)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.DiaryView)) return false; return true; //----------------------------------------------------------- // Contacts. case Sbm.View.Contacts_Affiliates: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; return true; case Sbm.View.Contacts_ContactGroups: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; return true; case Sbm.View.Contacts_Associations: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AnyAssociationView)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.AnyAssociationView)) return false; return true; case Sbm.View.Contacts_Associations_Customer: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; return true; case Sbm.View.Contacts_Associations_Supplier: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; return true; case Sbm.View.Contacts_Associations_Associate: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Associate)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Associate)) return false; return true; case Sbm.View.Contacts_Associations_Stockist: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Stockist)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Stockist)) return false; return true; case Sbm.View.Contacts_Associations_FinanceAgency: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.FinanceAgency)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.FinanceAgency)) return false; return true; case Sbm.View.Contacts_Associations_Member: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Member)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Member)) return false; return true; case Sbm.View.Contacts_Associations_Contractor: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Contractor)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Contractor)) return false; return true; //----------------------------------------------------------- // Commodities. case Sbm.View.Commodities: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false; return true; case Sbm.View.Commodity_Locations: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false; return true; case Sbm.View.Commodity_Containers: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false; return true; case Sbm.View.Commodity_Portfolio: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false; return true; case Sbm.View.Commodity_SalesBudget: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) return false; return true; 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; return true; //----------------------------------------------------------- // Assets. case Sbm.View.AssetCategories: case Sbm.View.Assets: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Assets)) return false; return true; case Sbm.View.VehicleClasses: case Sbm.View.Vehicles: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) return false; - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Assets)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles)) return false; return true; //----------------------------------------------------------- // Transactions. case Sbm.View.Transactions: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AnyTransactionView)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.AnyTransactionView)) return false; return true; case Sbm.View.Transactions_Project: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.Project)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.Project)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.Project)) return false; return true; case Sbm.View.Transactions_PurchaseQuote: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseQuote)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseQuote)) return false; return true; case Sbm.View.Transactions_ProformaPurchaseOrder: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseOrder)) return false; return true; case Sbm.View.Transactions_PurchaseOrder: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseOrder)) return false; return true; case Sbm.View.Transactions_PurchaseSO: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseSO)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseSO)) return false; return true; case Sbm.View.Transactions_PurchaseDelivery: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseDelivery)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseDelivery)) return false; return true; case Sbm.View.Transactions_ProformaPurchaseInvoice: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaPurchaseInvoice)) return false; return true; case Sbm.View.Transactions_PurchaseInvoice: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Supplier)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.PurchaseInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.PurchaseInvoice)) return false; return true; case Sbm.View.Transactions_SalesLead: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesLead)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesLead)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesLead)) return false; return true; case Sbm.View.Transactions_SalesQuote: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesQuote)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesQuote)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesQuote)) return false; return true; case Sbm.View.Transactions_ProformaSalesOrder: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.ProformaSalesOrder)) return false; return true; case Sbm.View.Transactions_SalesOrder: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesOrder)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesOrder)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesOrder)) return false; return true; case Sbm.View.Transactions_SalesPO: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesPO)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesPO)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesPO)) return false; return true; case Sbm.View.Transactions_SalesDispatch: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesDispatch)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesDispatch)) return false; return true; case Sbm.View.Transactions_ProformaSalesInvoice: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false; return true; case Sbm.View.Transactions_SalesInvoice: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowAssociationType(Sbm.AssociationType.Customer)) return false; - if (!sessionConfig.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowAssociationType(Sbm.AssociationType.Customer)) return false; + if (!sessionConsole.AllowTransactionType(Sbm.TransactionType.SalesInvoice)) return false; if (!securityProfile.UserCanAccessTransactionsOfType(Sbm.TransactionType.SalesInvoice)) return false; return true; //----------------------------------------------------------- // Planning. case Sbm.View.Transactions_PurchasingPlanning: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowPurchasingPlanning)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.PurchasingPlanning)) return false; return true; case Sbm.View.Transactions_ProductionControl: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowProductionControl)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.ProductionControl)) return false; return true; case Sbm.View.Transactions_DeliveryPlanning: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions)) return false; - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowDeliveryPlanning)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.DeliveryPlanning)) return false; return true; //----------------------------------------------------------- // Other. case Sbm.View.SystemAccounts: case Sbm.View.SystemUsers: - if (!sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts)) return false; + if (!sessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) return false; // 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; // 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.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 //------------------------------------------------------------------- - 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. return false; } - Sbm.View view = GetViewForMenuOption(sessionConfig.UserContext.SessionContext, menuOption); + Sbm.View view = GetViewForMenuOption(sessionConsole.UserContext.SessionContext, menuOption); if (view != Sbm.View.Unknown) // View options. - return IsViewApplicable(sessionConfig, GetViewForMenuOption(sessionConfig.UserContext.SessionContext, menuOption)); + return IsViewApplicable(sessionConsole, GetViewForMenuOption(sessionConsole.UserContext.SessionContext, menuOption)); // Non-view options. switch (menuOption) @@ -296,7 +296,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //----------------------------------------------------------- // Actions. 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()}"); diff --git a/SaBusMgrStandardBase/Base/App/SbmApplication.cs b/SaBusMgrStandardBase/Base/App/SbmApplication.cs index b076830..d674750 100644 --- a/SaBusMgrStandardBase/Base/App/SbmApplication.cs +++ b/SaBusMgrStandardBase/Base/App/SbmApplication.cs @@ -58,8 +58,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { return GetBusMgrDatabase(sessionContext).CreateDbInfo(); } - // Instance configuration. + // Instance and Organisation profiles. public abstract SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext); + public abstract SbmInstanceDataCache GetInstanceDataCache(SbmSessionContext sessionContext); + public abstract SbmOrganisationConfig GetOrganisationConfig(ISbmUserOrganisationContext userContext); // Database utilities. public IDatabaseInfo CreateDbInfo(ISacsDatabase db) { @@ -84,17 +86,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Create consoles. - public abstract SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext); - public abstract SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext); - public abstract SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext); - public abstract SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext_Core userContext); - public abstract SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext); - public abstract SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext); - public abstract SaItemDocConsole CreateItemDocConsole(ISbmUserContext_Core userContext); - public abstract SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext_Core userContext); - public abstract SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext_Core userContext); - public abstract SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext_Core userContext); - public abstract SbmEmailConsole CreateEmailConsole(ISbmUserContext_Core userContext); + public abstract SbmSessionConsole CreateSessionConsole(ISbmUserOrganisationContext userContext); + public abstract SaDiaryConsole CreateDiaryConsole(ISbmUserOrganisationContext userContext); + public abstract SaSecurityConsole CreateSecurityConsole(ISbmUserOrganisationContext userContext); + public abstract SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserOrganisationContext userContext); + public abstract SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserOrganisationContext userContext); + public abstract SaItemDataConsole CreateItemDataConsole(ISbmUserOrganisationContext userContext); + public abstract SaItemDocConsole CreateItemDocConsole(ISbmUserOrganisationContext userContext); + public abstract SaItemOptionConsole CreateItemOptionConsole(ISbmUserOrganisationContext userContext); + public abstract SaInterfaceConsole CreateInterfaceConsole(ISbmUserOrganisationContext userContext); + public abstract SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserOrganisationContext userContext); + public abstract SbmEmailConsole CreateEmailConsole(ISbmUserOrganisationContext userContext); //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/App/SbmConsoleViewDfn.cs b/SaBusMgrStandardBase/Base/App/SbmConsoleViewDfn.cs index 5bbf8fd..7851695 100644 --- a/SaBusMgrStandardBase/Base/App/SbmConsoleViewDfn.cs +++ b/SaBusMgrStandardBase/Base/App/SbmConsoleViewDfn.cs @@ -101,7 +101,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public virtual String LinkSuffix { get { return ""; } } //--------------------------------------------------------------- // Utilities. - public virtual bool Refresh(ISbmUserContext_Core userContext) + public virtual bool Refresh(ISbmUserOrganisationContext userContext) { ItemCount = 0; switch (LinkType) diff --git a/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs b/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs index 8113836..eaf6f82 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInstanceConfig.cs @@ -1,6 +1,7 @@ using Org.BouncyCastle.Math.EC; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; @@ -13,25 +14,42 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { //======================================================================= /// - /// Application configuration associated with an instance. + /// Application and Owner configuration associated with an instance. /// - public abstract class SbmInstanceConfig + public abstract class SbmInstanceConfig : ISbmInstanceConfig { + //------------------------------------------------------------------- + // Construction. + protected SbmInstanceConfig() { } + //------------------------------------------------------------------- // Application options. public abstract bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse); //------------------------------------------------------------------- - // Allowed data component types. + // Contacts. // Supported affiliate types. public abstract bool AllowAffiliateType(Sbm.AffiliateType type, bool defaultResponse); + // Supported Association types. public abstract bool AllowAssociationType(Sbm.AssociationType type, bool defaultResponse); + + //------------------------------------------------------------------- + // Transactions. + // Supported Transaction types. public abstract bool AllowTransactionType(Sbm.TransactionType type, bool defaultResponse); + //------------------------------------------------------------------- + // Interfaces. + + /// + /// Whether the Interface Category is allowed. + /// + public abstract bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse); + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/App/SbmInstanceDataCache.cs b/SaBusMgrStandardBase/Base/App/SbmInstanceDataCache.cs new file mode 100644 index 0000000..4869c44 --- /dev/null +++ b/SaBusMgrStandardBase/Base/App/SbmInstanceDataCache.cs @@ -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 +{ + //======================================================================= + /// + /// Practically persistant/static data stored in instance database, eg. Owner configuration options. + /// + public abstract class SbmInstanceDataCache : SacsDisposable + { + //------------------------------------------------------------------- + // Construction. + public SbmInstanceDataCache() { } + protected override void Dispose(bool disposing) + { + } + + //------------------------------------------------------------------- + // Retrieve Item Options for Owner Organisation configuration. + public abstract List GetOwnerOptions(ISbmUserOrganisationContext userContext); + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/App/SbmInternals.cs b/SaBusMgrStandardBase/Base/App/SbmInternals.cs index c25d2dd..b5ded4a 100644 --- a/SaBusMgrStandardBase/Base/App/SbmInternals.cs +++ b/SaBusMgrStandardBase/Base/App/SbmInternals.cs @@ -20,37 +20,58 @@ using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; using System.Linq; +using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.App { //======================================================================= - public class SbmInternals : SacsDisposable + public class SbmInternals : SacsDisposable, ISbmOrganisationConfig { + //------------------------------------------------------------------- + // Definitions. + + /// + /// Internal User Context for read-only database access when this class is used outside of user specific sessions. + /// - data caches etc. + /// + private class SbmUserContext_Internal : SbmUserContext + { + public SbmUserContext_Internal(SbmSessionContext sessionContext) : base(sessionContext) { } + } + //------------------------------------------------------------------- // Data members. private readonly SbmSystem system = SbmGlobals.System; private SbmAccountsDfn accountsDfn; // Managers. - private SbmAccountMgr accountMgr; - private SbmAssetMgr assetMgr; - private SbmCommodityMgr commodityMgr; - private SbmPriceMgr priceMgr; - private SbmTransactionMgr transactionMgr; - private SbmStockMgr stockMgr; - private SbmProcessMgr processMgr; - private SbmDataItemMgr dataItemMgr; + private class Managers + { + public SbmAccountMgr accountMgr; + public SbmAssetMgr assetMgr; + public SbmCommodityMgr commodityMgr; + public SbmPriceMgr priceMgr; + public SbmTransactionMgr transactionMgr; + public SbmStockMgr stockMgr; + public SbmProcessMgr processMgr; + public SbmDataItemMgr dataItemMgr; + } + private readonly Managers mgr = new Managers(); // Consoles. - private SbmSessionConsole sessionConsole; - private SaDiaryConsole diaryConsole; - private SaSecurityConsole securityConsole; - private SaCodeTypeConsole codeTypeConsole; - private SaReferenceDataConsole referenceDataConsole; - private SaUpdateLogConsole updateLogConsole; - private SaInterfaceConsole interfaceConsole; - private SaItemDocConsole itemDocConsole; - private SaItemOptionConsole itemOptionConsole; - private SaItemDataConsole itemDataConsole; - public SbmEmailConsole emailConsole; + private class Consoles + { + public SbmSessionConsole sessionConsole; + public SaDiaryConsole diaryConsole; + public SaSecurityConsole securityConsole; + public SaCodeTypeConsole codeTypeConsole; + public SaReferenceDataConsole referenceDataConsole; + public SaUpdateLogConsole updateLogConsole; + public SaInterfaceConsole interfaceConsole; + public SaItemDocConsole itemDocConsole; + public SaItemOptionConsole itemOptionConsole; + public SaItemDataConsole itemDataConsole; + public SbmEmailConsole emailConsole; + } + private readonly Consoles con = new Consoles(); // Configurations. private SbmStockControlConfig stockControlConfig; private SbmRequirementCostingConfig requirementCostingConfig; @@ -61,46 +82,53 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Construction. - public SbmInternals(ISbmUserContext_Core userContext) + public SbmInternals(SbmSessionContext sessionContext) + { + UserContext = new SbmUserContext_Internal(sessionContext); + ReadOnly = true; + } + public SbmInternals(ISbmUserOrganisationContext userContext) { UserContext = userContext; + ReadOnly = false; } protected override void Dispose(bool disposing) { if (disposing) { // Managers. - if (accountMgr != null) accountMgr.Dispose(); - if (assetMgr != null) assetMgr.Dispose(); - if (commodityMgr != null) commodityMgr.Dispose(); - if (priceMgr != null) priceMgr.Dispose(); - if (transactionMgr != null) transactionMgr.Dispose(); - if (stockMgr != null) stockMgr.Dispose(); - if (processMgr != null) processMgr.Dispose(); - if (dataItemMgr != null) dataItemMgr.Dispose(); + if (mgr.accountMgr != null) mgr.accountMgr.Dispose(); + if (mgr.assetMgr != null) mgr.assetMgr.Dispose(); + if (mgr.commodityMgr != null) mgr.commodityMgr.Dispose(); + if (mgr.priceMgr != null) mgr.priceMgr.Dispose(); + if (mgr.transactionMgr != null) mgr.transactionMgr.Dispose(); + if (mgr.stockMgr != null) mgr.stockMgr.Dispose(); + if (mgr.processMgr != null) mgr.processMgr.Dispose(); + if (mgr.dataItemMgr != null) mgr.dataItemMgr.Dispose(); // Reference data. if (currencies != null) currencies.ClearAndDispose(); if (taxCodes != null) taxCodes.ClearAndDispose(); if (unitsOfMeasure != null) unitsOfMeasure.ClearAndDispose(); // Consoles. - if (sessionConsole != null) sessionConsole.Dispose(); - if (diaryConsole != null) diaryConsole.Dispose(); - if (securityConsole != null) securityConsole.Dispose(); - if (codeTypeConsole != null) codeTypeConsole.Dispose(); - if (referenceDataConsole != null) referenceDataConsole.Dispose(); - if (updateLogConsole != null) updateLogConsole.Dispose(); - if (interfaceConsole != null) interfaceConsole.Dispose(); - if (itemDocConsole != null) itemDocConsole.Dispose(); - if (itemOptionConsole != null) itemOptionConsole.Dispose(); - if (itemDataConsole != null) itemDataConsole.Dispose(); - if (itemDataConsole != null) itemDataConsole.Dispose(); + if (con.sessionConsole != null) con.sessionConsole.Dispose(); + if (con.diaryConsole != null) con.diaryConsole.Dispose(); + if (con.securityConsole != null) con.securityConsole.Dispose(); + if (con.codeTypeConsole != null) con.codeTypeConsole.Dispose(); + if (con.referenceDataConsole != null) con.referenceDataConsole.Dispose(); + if (con.updateLogConsole != null) con.updateLogConsole.Dispose(); + if (con.interfaceConsole != null) con.interfaceConsole.Dispose(); + if (con.itemDocConsole != null) con.itemDocConsole.Dispose(); + if (con.itemOptionConsole != null) con.itemOptionConsole.Dispose(); + if (con.itemDataConsole != null) con.itemDataConsole.Dispose(); + if (con.itemDataConsole != null) con.itemDataConsole.Dispose(); } } //------------------------------------------------------------------- // Session properties. 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 ISbmSecurityProfile_Core SecurityProfile { get { return UserContext.SecurityProfile_Core; } } 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. private Dictionary> systemCodeCache = new Dictionary>(); - public List GetCodesOfType(Sbm.SystemCode systemCode) + public List GetSystemCodes(Sbm.SystemCode systemCode) { if (!systemCodeCache.ContainsKey(systemCode)) - systemCodeCache.Add(systemCode, SbmSystem.GetCodesOfType(UserContext, systemCode)); + { + List codes = new List(); + 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(systemCodeCache.GetValueOrDefault(systemCode, new List())); } - public List AffiliateTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AffiliateType); } } - public List AssociationTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AssociationType); } } - public List CommodityTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.CommodityType); } } - public List AssetTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AssetType); } } - public List TransactionTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.TransactionType); } } + // Selection of specific system code types. + public List AffiliateTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AffiliateType); } } + public List AssociationTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AssociationType); } } + public List CommodityTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.CommodityType); } } + public List AssetTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.AssetType); } } + public List TransactionTypeCodes { get { return GetSystemCodes(Sbm.SystemCode.TransactionType); } } //------------------------------------------------------------------- // Code types. @@ -143,72 +229,72 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { get { - if (accountMgr == null) - accountMgr = system.CreateAccountMgr(UserContext); - return accountMgr; + if (mgr.accountMgr == null) + mgr.accountMgr = system.CreateAccountMgr(this); + return mgr.accountMgr; } } public SbmAssetMgr AssetMgr { get { - if (assetMgr == null) - assetMgr = system.CreateAssetMgr(UserContext); - return assetMgr; + if (mgr.assetMgr == null) + mgr.assetMgr = system.CreateAssetMgr(this); + return mgr.assetMgr; } } public SbmCommodityMgr CommodityMgr { get { - if (commodityMgr == null) - commodityMgr = system.CreateCommodityMgr(UserContext); - return commodityMgr; + if (mgr.commodityMgr == null) + mgr.commodityMgr = system.CreateCommodityMgr(this); + return mgr.commodityMgr; } } public SbmPriceMgr PriceMgr { get { - if (priceMgr == null) - priceMgr = system.CreatePriceMgr(UserContext); - return priceMgr; + if (mgr.priceMgr == null) + mgr.priceMgr = system.CreatePriceMgr(this); + return mgr.priceMgr; } } public SbmTransactionMgr TransactionMgr { get { - if (transactionMgr == null) - transactionMgr = system.CreateTransactionMgr(UserContext); - return transactionMgr; + if (mgr.transactionMgr == null) + mgr.transactionMgr = system.CreateTransactionMgr(this); + return mgr.transactionMgr; } } public SbmStockMgr StockMgr { get { - if (stockMgr == null) - stockMgr = system.CreateStockMgr(UserContext); - return stockMgr; + if (mgr.stockMgr == null) + mgr.stockMgr = system.CreateStockMgr(this); + return mgr.stockMgr; } } public SbmProcessMgr ProcessMgr { get { - if (processMgr == null) - processMgr = system.CreateProcessMgr(UserContext); - return processMgr; + if (mgr.processMgr == null) + mgr.processMgr = system.CreateProcessMgr(this); + return mgr.processMgr; } } public SbmDataItemMgr DataItemMgr { get { - if (dataItemMgr == null) - dataItemMgr = SbmGlobals.System.CreateDataItemMgr(UserContext); - return dataItemMgr; + if (mgr.dataItemMgr == null) + mgr.dataItemMgr = SbmGlobals.System.CreateDataItemMgr(this); + return mgr.dataItemMgr; } } @@ -218,90 +304,90 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { get { - if (sessionConsole == null) - sessionConsole = Application.CreateSessionConsole(UserContext); - return sessionConsole; + if (con.sessionConsole == null) + con.sessionConsole = Application.CreateSessionConsole(UserContext); + return con.sessionConsole; } } public SaDiaryConsole DiaryConsole { get { - if (diaryConsole == null) - diaryConsole = Application.CreateDiaryConsole(UserContext); - return DiaryConsole; + if (con.diaryConsole == null) + con.diaryConsole = Application.CreateDiaryConsole(UserContext); + return con.diaryConsole; } } public SaSecurityConsole SecurityConsole { get { - if (securityConsole == null) - securityConsole = Application.CreateSecurityConsole(UserContext); - return securityConsole; + if (con.securityConsole == null) + con.securityConsole = Application.CreateSecurityConsole(UserContext); + return con.securityConsole; } } public SaCodeTypeConsole CodeTypeConsole { get { - if (codeTypeConsole == null) - codeTypeConsole = Application.CreateCodeTypeConsole(UserContext); - return codeTypeConsole; + if (con.codeTypeConsole == null) + con.codeTypeConsole = Application.CreateCodeTypeConsole(UserContext); + return con.codeTypeConsole; } } public SaReferenceDataConsole ReferenceDataConsole { get { - if (referenceDataConsole == null) - referenceDataConsole = Application.CreateReferenceDataConsole(UserContext); - return referenceDataConsole; + if (con.referenceDataConsole == null) + con.referenceDataConsole = Application.CreateReferenceDataConsole(UserContext); + return con.referenceDataConsole; } } public SaUpdateLogConsole UpdateLogConsole { get { - if (updateLogConsole == null) - updateLogConsole = Application.CreateUpdateLogConsole(UserContext); - return updateLogConsole; + if (con.updateLogConsole == null) + con.updateLogConsole = Application.CreateUpdateLogConsole(UserContext); + return con.updateLogConsole; } } public SaInterfaceConsole InterfaceConsole { get { - if (interfaceConsole == null) - interfaceConsole = Application.CreateInterfaceConsole(UserContext); - return interfaceConsole; + if (con.interfaceConsole == null) + con.interfaceConsole = Application.CreateInterfaceConsole(UserContext); + return con.interfaceConsole; } } public SaItemDocConsole ItemDocConsole { get { - if (itemDocConsole == null) - itemDocConsole = Application.CreateItemDocConsole(UserContext); - return itemDocConsole; + if (con.itemDocConsole == null) + con.itemDocConsole = Application.CreateItemDocConsole(UserContext); + return con.itemDocConsole; } } public SaItemOptionConsole ItemOptionConsole { get { - if (itemOptionConsole == null) - itemOptionConsole = Application.CreateItemOptionConsole(UserContext); - return itemOptionConsole; + if (con.itemOptionConsole == null) + con.itemOptionConsole = Application.CreateItemOptionConsole(UserContext); + return con.itemOptionConsole; } } public SaItemDataConsole ItemDataConsole { get { - if (itemDataConsole == null) - itemDataConsole = Application.CreateItemDataConsole(UserContext); - return itemDataConsole; + if (con.itemDataConsole == null) + con.itemDataConsole = Application.CreateItemDataConsole(UserContext); + return con.itemDataConsole; } } @@ -312,9 +398,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App { get { - if (emailConsole == null) - emailConsole = Application.CreateEmailConsole(UserContext); - return emailConsole; + if (con.emailConsole == null) + con.emailConsole = Application.CreateEmailConsole(UserContext); + return con.emailConsole; } } @@ -438,6 +524,70 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App 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); + } + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaBusMgrStandardBase/Base/App/SbmOrganisationConfig.cs b/SaBusMgrStandardBase/Base/App/SbmOrganisationConfig.cs new file mode 100644 index 0000000..2a92b78 --- /dev/null +++ b/SaBusMgrStandardBase/Base/App/SbmOrganisationConfig.cs @@ -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 assocOptions; + private List contextValues; + private List contextFolders; + private List contextAllowOptions; + private List contextCaptions; + private List contextShowColumns; + private List contextShowFields; + private List contextFieldLabels; + private List contextMinutes; + private List contextPeriodDays; + private List contextPeriodWeeks; + private List contextNumericDecimals; + private List contextCommodityTypes; + private List commodityTypes; + private List 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; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs b/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs index 55b47e1..c5baea3 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSecurityProfile.cs @@ -27,7 +27,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Construction. [JsonConstructor] private SbmSecurityProfile() { } - public SbmSecurityProfile(ISbmUserContext_Core userContext, bool includeHostSecurityProfile) + public SbmSecurityProfile(ISbmUserOrganisationContext userContext, bool includeHostSecurityProfile) { this.UserContext = userContext; this.includeHostSecurityProfile = includeHostSecurityProfile; @@ -41,7 +41,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Properties. [JsonIgnore] - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } //------------------------------------------------------------------- // Refresh profile. @@ -76,14 +76,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App this.hostSecurityProfile = hostSecurityProfile; RefreshProfileSettings(sessionConsole); } - private void RefreshProfileSettings(SbmSessionConsole sessionConfig) + private void RefreshProfileSettings(SbmSessionConsole sessionConsole) { - RefreshAdminProfile(sessionConfig); - RefreshManageProfile(sessionConfig); - RefreshFinancialProfile(sessionConfig); - RefreshContactsProfile(sessionConfig); - RefreshTransactionProfile(sessionConfig); - RefreshItemTypeProfile(sessionConfig); + RefreshAdminProfile(sessionConsole); + RefreshManageProfile(sessionConsole); + RefreshFinancialProfile(sessionConsole); + RefreshContactsProfile(sessionConsole); + RefreshTransactionProfile(sessionConsole); + RefreshItemTypeProfile(sessionConsole); // ToDo Commodities. } private void ClearProfile() @@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public bool CanManageInterfaces { get; internal set; } = false; } public AdminProfile Admin { get; internal set; } - private void RefreshAdminProfile(SbmSessionConsole sessionConfig) + private void RefreshAdminProfile(SbmSessionConsole sessionConsole) { Admin.CanManageSecurity = UserHasSecurityRight(Sbm.SecurityRight.Security_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 ManageProfile Manage { get; internal set; } - private void RefreshManageProfile(SbmSessionConsole sessionConfig) + private void RefreshManageProfile(SbmSessionConsole sessionConsole) { Manage.CanManageTasks = UserHasSecurityRight(Sbm.SecurityRight.TaskManager); Manage.CanManageTimesheets = UserHasSecurityRight(Sbm.SecurityRight.TimesheetManager); @@ -172,7 +172,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public bool FinancialsAccessControl { 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.UpdateFinancials = UserHasSecurityRight(Sbm.SecurityRight.Financial_Update); @@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App Financial.ViewCommoditySalesFinancials = UserCanAccessFinancialViewOfType(Sbm.FinancialType.CommoditySales); Financial.UpdateCommoditySalesFinancials = UserCanAccessFinancialUpdateOfType(Sbm.FinancialType.CommoditySales); // 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) @@ -245,7 +245,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public ContactsProfile Contacts { get; internal set; } public bool UserCanCreateContacts() { return Contacts.Create; } public bool UserCanUpdateContacts() { return Contacts.Update; } - private void RefreshContactsProfile(SbmSessionConsole sessionConfig) + private void RefreshContactsProfile(SbmSessionConsole sessionConsole) { Contacts.Update = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update)); 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; } - private void RefreshTransactionProfile(SbmSessionConsole sessionConfig) + private void RefreshTransactionProfile(SbmSessionConsole sessionConsole) { Transaction.Update = (UserHasSecurityRight(Sbm.SecurityRight.Transaction_Update)); 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 ItemTypesProfile ItemType { get; } = new ItemTypesProfile(); - private void RefreshItemTypeProfile(SbmSessionConsole sessionConfig) + private void RefreshItemTypeProfile(SbmSessionConsole sessionConsole) { - ItemType.Processes = sessionConfig.AllowOption(Sbm.ConfigOption.AllowProcesses); - ItemType.Contacts = sessionConfig.AllowOption(Sbm.ConfigOption.AllowContacts); - ItemType.Commodities = sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities); - ItemType.Portfolios = sessionConfig.AllowOption(Sbm.ConfigOption.AllowPortfolios); - ItemType.PriceSets = sessionConfig.AllowOption(Sbm.ConfigOption.AllowPriceSets); - ItemType.CommodityCustomers = sessionConfig.AllowOption(Sbm.ConfigOption.CommodityCustomers); - ItemType.CommoditySuppliers = sessionConfig.AllowOption(Sbm.ConfigOption.CommoditySuppliers); - ItemType.Transactions = sessionConfig.AllowOption(Sbm.ConfigOption.AllowTransactions); - ItemType.Assets = sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets); - ItemType.Vehicles = sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles); - ItemType.StockLocations = sessionConfig.GetStockControlConfig().AllowStockLocations(); - ItemType.StockContainers = sessionConfig.GetStockControlConfig().AllowStockContainers(); - ItemType.StockControl = sessionConfig.GetStockControlConfig().AllowStockControl(); + ItemType.Processes = sessionConsole.AllowOption(Sbm.ConfigOption.Processes); + ItemType.Contacts = sessionConsole.AllowOption(Sbm.ConfigOption.Contacts); + ItemType.Commodities = sessionConsole.AllowOption(Sbm.ConfigOption.Commodities); + ItemType.Portfolios = sessionConsole.AllowOption(Sbm.ConfigOption.Portfolios); + ItemType.PriceSets = sessionConsole.AllowOption(Sbm.ConfigOption.PriceSets); + ItemType.CommodityCustomers = sessionConsole.AllowOption(Sbm.ConfigOption.CommodityCustomers); + ItemType.CommoditySuppliers = sessionConsole.AllowOption(Sbm.ConfigOption.CommoditySuppliers); + ItemType.Transactions = sessionConsole.AllowOption(Sbm.ConfigOption.Transactions); + ItemType.Assets = sessionConsole.AllowOption(Sbm.ConfigOption.Assets); + ItemType.Vehicles = sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles); + ItemType.StockLocations = sessionConsole.GetStockControlConfig().AllowStockLocations(); + ItemType.StockContainers = sessionConsole.GetStockControlConfig().AllowStockContainers(); + ItemType.StockControl = sessionConsole.GetStockControlConfig().AllowStockControl(); } public bool ItemTypeIsAllowed(Sbm.ItemType itemType) diff --git a/SaBusMgrStandardBase/Base/App/SbmSysParamCache.cs b/SaBusMgrStandardBase/Base/App/SbmSysParamCache.cs index 8702619..c29fdc6 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSysParamCache.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSysParamCache.cs @@ -49,7 +49,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Construction. - public SbmSysParamCache(ISbmUserContext_Core userContext, SysId affiliateIdUser) + public SbmSysParamCache(ISbmUserOrganisationContext userContext, SysId affiliateIdUser) { this.UserContext = userContext; this.AffiliateIdUser = affiliateIdUser; @@ -64,7 +64,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } public SysId AffiliateIdUser { get; } public bool Modified { get; private set; } diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs b/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs index fd1e5cd..7a4ae82 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem-CodeTypes.cs @@ -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 //------------------------------------------------------------------- - 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 //--------------------------------------------------------------- - if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowCommodities)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) { // Commodity category. SaCodeTypeDfn codeTypeCommodityCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.CommodityCategory), 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityCategory); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityCategory)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityCategory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityCategory)); // Commodity range. 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); // 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; SaCodeTypeDfn codeTypeCommodityMaterial = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityMaterial), commodityMaterialLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityMaterial); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityMaterial.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityMaterial)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityMaterial.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityMaterial)); // 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; SaCodeTypeDfn codeTypeCommodityFinish = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityFinish), commodityFinishLabel, 12); codeTypeConsole.RegisterCodeType(codeTypeCommodityFinish); - codeTypeConsole.RegisterCodesOfType(codeTypeCommodityFinish.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityFinish)); + codeTypeConsole.RegisterCodesOfType(codeTypeCommodityFinish.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CommodityFinish)); // 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; SaCodeTypeDfn codeTypeCommodityPromotion = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CommodityPromotion), commodityPromotionLabel, 12); 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 //--------------------------------------------------------------- - if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowProcesses)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Processes)) { // Process type. SaCodeTypeDfn codeTypeProcessType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ProcessType), codeTypes.GetDescForType(Sbm.ApplCodeType.ProcessType), 12); 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 //--------------------------------------------------------------- - if (sessionConfig != null) + if (sessionConsole != null) { // Refer type. SaCodeTypeDfn codeTypeReferType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.ReferType), codeTypes.GetDescForType(Sbm.ApplCodeType.ReferType), 12); codeTypeReferType.AllowSequence = true; 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 //--------------------------------------------------------------- - if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowTasks)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Tasks)) { // Task category. SaCodeTypeDfn codeTypeTaskCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.TaskCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.TaskCategory), 12); codeTypeTaskCategory.AllowSequence = true; 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 //--------------------------------------------------------------- - if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowAssets)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Assets)) { // Asset sell category. SaCodeTypeDfn codeTypeAssetSellCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.AssetSellCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.AssetSellCategory), 8); 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 //--------------------------------------------------------------- - if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowVehicles)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.Vehicles)) { // Vehicle category. SaCodeTypeDfn codeTypeVehicleCategory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleCategory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleCategory), 8); codeTypeConsole.RegisterCodeType(codeTypeVehicleCategory); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleCategory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleCategory)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleCategory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleCategory)); // Vehicle make. SaCodeTypeDfn codeTypeVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleMake), 8); codeTypeConsole.RegisterCodeType(codeTypeVehicleMake); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleMake.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleMake)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleMake.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleMake)); // Vehicle service history. SaCodeTypeDfn codeTypeVehicleServiceHistory = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleServiceHistory), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleServiceHistory), 12); codeTypeConsole.RegisterCodeType(codeTypeVehicleServiceHistory); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleServiceHistory.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleServiceHistory)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleServiceHistory.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleServiceHistory)); // Vehicle insurance. SaCodeTypeDfn codeTypeVehicleInsurance = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.VehicleInsurance), codeTypes.GetDescForType(Sbm.ApplCodeType.VehicleInsurance), 3); codeTypeConsole.RegisterCodeType(codeTypeVehicleInsurance); - codeTypeConsole.RegisterCodesOfType(codeTypeVehicleInsurance.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleInsurance)); + codeTypeConsole.RegisterCodesOfType(codeTypeVehicleInsurance.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.VehicleInsurance)); // Vehicle tacho. 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 //--------------------------------------------------------------- - 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. SaCodeTypeDfn codeTypeHpiVehicleMake = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleMake), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleMake), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleMake); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleMake.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleMake)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleMake.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleMake)); // HPI vehicle model. SaCodeTypeDfn codeTypeHpiVehicleModel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleModel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleModel), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleModel); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleModel.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleModel)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleModel.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleModel)); // HPI vehicle colour. SaCodeTypeDfn codeTypeHpiVehicleColour = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleColour), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleColour), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleColour); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleColour.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleColour)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleColour.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleColour)); // HPI vehicle fuel. SaCodeTypeDfn codeTypeHpiVehicleFuel = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleFuel), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleFuel), 12); codeTypeConsole.RegisterCodeType(codeTypeHpiVehicleFuel); - codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleFuel.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleFuel)); + codeTypeConsole.RegisterCodesOfType(codeTypeHpiVehicleFuel.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.HpiVehicleFuel)); // HPI vehicle transmission. SaCodeTypeDfn codeTypeHpiVehicleTrans = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.HpiVehicleTrans), codeTypes.GetDescForType(Sbm.ApplCodeType.HpiVehicleTrans), 12); 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 //--------------------------------------------------------------- - if (sessionConfig != null) + if (sessionConsole != null) { // 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"); codeTypeConsole.RegisterCodeType(codeTypeAccountManager); // 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"); codeTypeConsole.RegisterCodeType(codeTypeAccountHandler); // 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"); codeTypeConsole.RegisterCodeType(codeTypeAccountType); // 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); codeTypeConsole.RegisterCodeType(codeTypeAccountRating); // 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); codeTypeContactTitle.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeContactTitle); - codeTypeConsole.RegisterCodesOfType(codeTypeContactTitle.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.ContactTitle)); + codeTypeConsole.RegisterCodesOfType(codeTypeContactTitle.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.ContactTitle)); // 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"); codeTypeConsole.RegisterCodeType(codeTypeContactArea); // 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); codeTypeConsole.RegisterCodeType(codeTypeContactHandler); // 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); codeTypeConsole.RegisterCodeType(codeTypeContactMethod); // 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); 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 //--------------------------------------------------------------- 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. 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")); #endif codeTypeConsole.RegisterCodeType(codeTypeCostPerUnit); - codeTypeConsole.RegisterCodesOfType(codeTypeCostPerUnit.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerUnit)); + codeTypeConsole.RegisterCodesOfType(codeTypeCostPerUnit.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.CostPerUnit)); // Cost per job. SaCodeTypeDfn codeTypeCostPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.CostPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.CostPerJob), 12); codeTypeCostPerJob.AllowSequence = true; codeTypeCostPerJob.FlagDefinitions.Add(estimateDefaultFlag); 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. SaCodeTypeDfn codeTypeLabourPerUnit = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerUnit), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerUnit), 12); codeTypeLabourPerUnit.AllowSequence = true; codeTypeLabourPerUnit.FlagDefinitions.Add(estimateDefaultFlag); 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. SaCodeTypeDfn codeTypeLabourPerJob = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.LabourPerJob), codeTypes.GetDescForType(Sbm.ApplCodeType.LabourPerJob), 12); codeTypeLabourPerJob.AllowSequence = true; codeTypeLabourPerJob.FlagDefinitions.Add(estimateDefaultFlag); 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 //--------------------------------------------------------------- - 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. SaCodeTypeDfn codeTypeDeliveryStatus = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryStatus), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryStatus), 3); codeTypeDeliveryStatus.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryStatus); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryStatus.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryStatus)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryStatus.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryStatus)); // Delivery type. SaCodeTypeDfn codeTypeDeliveryType = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryType), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryType), 12); codeTypeDeliveryType.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryType); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryType.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryType)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryType.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryType)); // Delivery method. SaCodeTypeDfn codeTypeDeliveryMethod = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryMethod), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryMethod), 12); codeTypeDeliveryMethod.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryMethod); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryMethod.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryMethod)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryMethod.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryMethod)); // Delivery courier. SaCodeTypeDfn codeTypeDeliveryCourier = new SaCodeTypeDfn(codeTypes.GetCodeForType(Sbm.ApplCodeType.DeliveryCourier), codeTypes.GetDescForType(Sbm.ApplCodeType.DeliveryCourier), 12); codeTypeDeliveryCourier.AllowSequence = true; codeTypeConsole.RegisterCodeType(codeTypeDeliveryCourier); - codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryCourier.Code, sessionConfig.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryCourier)); + codeTypeConsole.RegisterCodesOfType(codeTypeDeliveryCourier.Code, sessionConsole.GetDefaultCodesOfType(Sbm.ApplCodeType.DeliveryCourier)); // Delivery book-in. 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); codeTypeStockPicker.AllowSequence = true; 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 //--------------------------------------------------------------- - if (sessionConfig != null && sessionConfig.AllowOption(Sbm.ConfigOption.AllowItemDocuments)) + if (sessionConsole != null && sessionConsole.AllowOption(Sbm.ConfigOption.ItemDocuments)) { // PDF document types. 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.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Pdf_WebPublish, "WebPublish", "Publish to Web")); 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. 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.FlagDefinitions.Add(new FlagDfn((Byte)Sbm.ApplCodeFlag.DocType_Image_WebPublish, "WebPublish", "Publish to Web")); 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)); } //--------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs index 62b2950..f4d508f 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem-Statics.cs @@ -1,8 +1,10 @@ using Sarand.BusinessMgr.Net.Standard.Base.Bus; +using Sarand.BusinessMgr.Net.Standard.Base.Mgr; using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.ReferenceData; using System.Collections.Generic; +using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; namespace Sarand.BusinessMgr.Net.Standard.Base.App { @@ -15,94 +17,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // SBM System - Static initialisation. //------------------------------------------------------------------- - // Code type lists. + // System code types. + private static Dictionary> systemCodes = new Dictionary>(); + // Code types. private static List codeTypes = new List(); - private static List itemTypes = new List(); - // Contacts. - private static List affiliateTypes = new List(); - private static List associationTypes = new List(); - // Transactions. - private static List transactionStatusCats = new List(); - private static List requirementTypes = new List(); - private static List requirementStatusCats = new List(); - private static List taskCodeTypes = new List(); - private static List constituentTypes = new List(); - private static List constituentStatusCats = new List(); - // Miscellaneous. - private static List itemLinkDatas = new List(); - // Commodities. - private static List portfolioItemTypes = new List(); - private static List locationCategories = new List(); - private static List locationFilters = new List(); - private static List containerCategories = new List(); - private static List containerTypes = new List(); - private static List commodityStatusCats = new List(); - private static List movementTypes = new List(); - private static List stockLevelTypes = new List(); - private static List stockLevelSources = new List(); - private static List addressTypes = new List(); - private static List sysParamCategories = new List(); - private static List processTypes = new List(); // _Commodity - private static List paymentTypes = new List(); - private static List assetIncomeTypes = new List(); - private static List assetTypes = new List(); - private static List vehicleTypes = new List(); - private static List vehicleEventTypes = new List(); - private static List vVehicleFeatureSources = new List(); - private static List vehicleFeatureTypes = new List(); - private static List vehicleOptionTypes = new List(); - private static List vehicleTransTypes = new List(); - private static List fuelTypes = new List(); - private static List odometerUnits = new List(); - private static List discountTypes = new List(); - private static List discountMarkups = new List(); - private static List regionTypes = new List(); - private static List unitMeasureCategories = new List(); - private static List unitMeasureTypes = new List(); - private static List priceTypes = new List(); - private static List priceCalcMethods = new List(); - private static List priceRounderMethods = new List(); - private static List priceRounderDirections = new List(); - private static List systemAccountTypes = new List(); - private static List itemStatuses = new List(); - private static List eventStatuses = new List(); - // Application configuration. - private static List associationTabs = new List(); - // Interface definitions. - private static List interfaceTypes_Website = new List(); - private static List interfaceTypes_Accounts = new List(); - private static List interfaceTypes_System = new List(); - private static List interfaceTypes_File = new List(); - private static List interfaceDataTypes = new List(); - // Associated data. - // Types of data associated via SaItemData objects. - private static List itemDataTypes = new List(); - // Organisation configuration options. - private static List orgOption_Values = new List(); - private static List orgOption_Folders = new List(); - private static List OrgOption_Minutes = new List(); - private static List orgOption_AllowOptions = new List(); - private static List orgOption_ShowFields = new List(); - private static List orgOption_FieldLabels = new List(); - private static List orgOption_TransactionCreationStatuses = new List(); - private static List orgOption_ContainerStatusCaptions = new List(); - private static List orgOption_NumericDecimals = new List(); - private static List orgOption_CommodityTypes = new List(); - private static List orgOption_StockLocations = new List(); - private static List orgOption_TaxCodeColumns = new List(); // Equivalent code = new List(); eg. Sage and other system interfaces. - private static List orgOption_SystemUserRights = new List(); - // Configuration options. - private static List systemUserOptions = new List(); - private static List associationOptions = new List(); - // Interface options. - private static List interfaceOptions = new List(); - private static List interfaceOption_WebFlags = new List(); - private static List interfaceOption_WebUploadDatas = new List(); - private static List interfaceOption_WebUploadMethods = new List(); - private static List interfaceOption_WebDownloadDatas = new List(); - private static List interfaceOption_WebDownloadMethods = new List(); - private static List fileInterface_RowColValues = new List(); // Generic file interface options. - private static List fileInterface_Modes = new List(); //------------------------------------------------------------------- // Static initialisation. @@ -180,605 +98,1033 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //--------------------------------------------------------------- // I t e m T y p e //--------------------------------------------------------------- - // ItemType. - itemTypes.Add(Sbm.ItemType.SecItem, "SecItm", "Securty Item"); - itemTypes.Add(Sbm.ItemType.Currency, "Currency", "Currency"); - itemTypes.Add(Sbm.ItemType.Language, "Language", "Language"); - itemTypes.Add(Sbm.ItemType.Region, "Region", "Region"); - itemTypes.Add(Sbm.ItemType.TaxCode, "TaxCode", " Tax Code"); - itemTypes.Add(Sbm.ItemType.UnitMeasure, "UOM", "Unit of Measure"); - itemTypes.Add(Sbm.ItemType.Process, "Process", "Process"); - itemTypes.Add(Sbm.ItemType.Affiliate, "Affiliate", "Affiliate"); - itemTypes.Add(Sbm.ItemType.Address, "Address", "Address"); - itemTypes.Add(Sbm.ItemType.Commodity, "Commodity", "Commodity"); - itemTypes.Add(Sbm.ItemType.PortfolioItem, "PortfolioItem", "Portfolio Item"); - itemTypes.Add(Sbm.ItemType.Location, "Location", "Location"); - itemTypes.Add(Sbm.ItemType.Container, "Container", "Container"); - itemTypes.Add(Sbm.ItemType.ContainerItem, "ContainerItem", "Container Item"); - itemTypes.Add(Sbm.ItemType.Movement, "Movement", "Movement"); - itemTypes.Add(Sbm.ItemType.StockLevel, "StockLevel", "Stock Level"); - itemTypes.Add(Sbm.ItemType.Association, "Association", "Association"); - itemTypes.Add(Sbm.ItemType.Transaction, "Transaction", "Transaction"); - itemTypes.Add(Sbm.ItemType.Requirement, "Requirement", "Requirement"); - itemTypes.Add(Sbm.ItemType.Constituent, "Constituent", "Constituent"); - itemTypes.Add(Sbm.ItemType.SystemAccount, "SystemAccount", "System Account"); - itemTypes.Add(Sbm.ItemType.SystemUser, "SystemUser", "System User"); - itemTypes.Add(Sbm.ItemType.SystemAccountUser, "SystemAccountUser", "System Account User"); - itemTypes.Add(Sbm.ItemType.AssetCategory, "AssetCategory", "Asset Category"); - itemTypes.Add(Sbm.ItemType.Asset, "Asset", "Asset"); - itemTypes.Add(Sbm.ItemType.VehicleClass, "VehicleClass", "Vehicle Class"); - itemTypes.Add(Sbm.ItemType.Vehicle, "Vehicle", "Vehicle"); - itemTypes.Add(Sbm.ItemType.VehicleEvent, "VehicleEvent", "Vehicle Event"); - itemTypes.Add(Sbm.ItemType.VehicleFeature, "VehicleFeature", "Vehicle Feature"); - itemTypes.Add(Sbm.ItemType.CommodityProcess, "CommodityProcess", "Commodity Process"); - itemTypes.Add(Sbm.ItemType.RequirementProcess, "RequirementProcess", "Requirement Process"); - itemTypes.Add(Sbm.ItemType.AssetCategoryProcess, "AssetCatProcess", "Asset Category Process"); - itemTypes.Add(Sbm.ItemType.AssetProcess, "AssetProcess", "Asset Process"); - itemTypes.Add(Sbm.ItemType.Interface, "Interface", "Interface"); + systemCodes[Sbm.SystemCode.ItemType] = new List() + { + new TypeCodeDesc((int)Sbm.ItemType.SecItem, "SecItm", "Securty Item"), + new TypeCodeDesc((int)Sbm.ItemType.Currency, "Currency", "Currency"), + new TypeCodeDesc((int)Sbm.ItemType.Language, "Language", "Language"), + new TypeCodeDesc((int)Sbm.ItemType.Region, "Region", "Region"), + new TypeCodeDesc((int)Sbm.ItemType.TaxCode, "TaxCode", " Tax Code"), + new TypeCodeDesc((int)Sbm.ItemType.UnitMeasure, "UOM", "Unit of Measure"), + new TypeCodeDesc((int)Sbm.ItemType.Process, "Process", "Process"), + new TypeCodeDesc((int)Sbm.ItemType.Affiliate, "Affiliate", "Affiliate"), + new TypeCodeDesc((int)Sbm.ItemType.Address, "Address", "Address"), + new TypeCodeDesc((int)Sbm.ItemType.Commodity, "Commodity", "Commodity"), + new TypeCodeDesc((int)Sbm.ItemType.PortfolioItem, "PortfolioItem", "Portfolio Item"), + new TypeCodeDesc((int)Sbm.ItemType.Location, "Location", "Location"), + new TypeCodeDesc((int)Sbm.ItemType.Container, "Container", "Container"), + new TypeCodeDesc((int)Sbm.ItemType.ContainerItem, "ContainerItem", "Container Item"), + new TypeCodeDesc((int)Sbm.ItemType.Movement, "Movement", "Movement"), + new TypeCodeDesc((int)Sbm.ItemType.StockLevel, "StockLevel", "Stock Level"), + new TypeCodeDesc((int)Sbm.ItemType.Association, "Association", "Association"), + new TypeCodeDesc((int)Sbm.ItemType.Transaction, "Transaction", "Transaction"), + new TypeCodeDesc((int)Sbm.ItemType.Requirement, "Requirement", "Requirement"), + new TypeCodeDesc((int)Sbm.ItemType.Constituent, "Constituent", "Constituent"), + new TypeCodeDesc((int)Sbm.ItemType.SystemAccount, "SystemAccount", "System Account"), + new TypeCodeDesc((int)Sbm.ItemType.SystemUser, "SystemUser", "System User"), + new TypeCodeDesc((int)Sbm.ItemType.SystemAccountUser, "SystemAccountUser", "System Account User"), + new TypeCodeDesc((int)Sbm.ItemType.AssetCategory, "AssetCategory", "Asset Category"), + new TypeCodeDesc((int)Sbm.ItemType.Asset, "Asset", "Asset"), + new TypeCodeDesc((int)Sbm.ItemType.VehicleClass, "VehicleClass", "Vehicle Class"), + new TypeCodeDesc((int)Sbm.ItemType.Vehicle, "Vehicle", "Vehicle"), + new TypeCodeDesc((int)Sbm.ItemType.VehicleEvent, "VehicleEvent", "Vehicle Event"), + new TypeCodeDesc((int)Sbm.ItemType.VehicleFeature, "VehicleFeature", "Vehicle Feature"), + new TypeCodeDesc((int)Sbm.ItemType.CommodityProcess, "CommodityProcess", "Commodity Process"), + new TypeCodeDesc((int)Sbm.ItemType.RequirementProcess, "RequirementProcess", "Requirement Process"), + new TypeCodeDesc((int)Sbm.ItemType.AssetCategoryProcess, "AssetCatProcess", "Asset Category Process"), + new TypeCodeDesc((int)Sbm.ItemType.AssetProcess, "AssetProcess", "Asset Process"), + new TypeCodeDesc((int)Sbm.ItemType.Interface, "Interface", "Interface") + }; //--------------------------------------------------------------- - // Accounts. - //--------------------------------------------------------------- + // Contacts. + // Affiliate Type. - affiliateTypes.Add(Sbm.AffiliateType.Individual, "IND", "Individual"); - affiliateTypes.Add(Sbm.AffiliateType.Commercial, "COM", "Commercial"); - affiliateTypes.Add(Sbm.AffiliateType.Society, "SOC", "Society"); - affiliateTypes.Add(Sbm.AffiliateType.Academic, "ACA", "Academic"); - affiliateTypes.Add(Sbm.AffiliateType.PublicSector, "PUB", "Public Sector"); - affiliateTypes.Add(Sbm.AffiliateType.Charity, "CHA", "Charity"); - affiliateTypes.Add(Sbm.AffiliateType.ContactGroup, "GRP", "Contact Group"); + systemCodes[Sbm.SystemCode.AffiliateType] = new List() + { + new TypeCodeDesc((int)Sbm.AffiliateType.Individual, "IND", "Individual"), + new TypeCodeDesc((int)Sbm.AffiliateType.Commercial, "COM", "Commercial"), + new TypeCodeDesc((int)Sbm.AffiliateType.Society, "SOC", "Society"), + new TypeCodeDesc((int)Sbm.AffiliateType.Academic, "ACA", "Academic"), + new TypeCodeDesc((int)Sbm.AffiliateType.PublicSector, "PUB", "Public Sector"), + new TypeCodeDesc((int)Sbm.AffiliateType.Charity, "CHA", "Charity"), + new TypeCodeDesc((int)Sbm.AffiliateType.ContactGroup, "GRP", "Contact Group") + }; + + // Address Type. + systemCodes[Sbm.SystemCode.AddressType] = new List() + { + new TypeCodeDesc((int)Sbm.AddressType.Office, "OFF", "Office"), + new TypeCodeDesc((int)Sbm.AddressType.Registered, "REG", "Registered"), + new TypeCodeDesc((int)Sbm.AddressType.Home, "HOM", "Home"), + new TypeCodeDesc((int)Sbm.AddressType.Billing, "BIL", "Billing"), + new TypeCodeDesc((int)Sbm.AddressType.Delivery, "DEL", "Delivery") + }; + // Association Type. - associationTypes.Add(Sbm.AssociationType.Internal, "INT", "Internal"); - associationTypes.Add(Sbm.AssociationType.Customer, "CUS", "Customer"); - associationTypes.Add(Sbm.AssociationType.Supplier, "SUP", "Supplier"); - associationTypes.Add(Sbm.AssociationType.Associate, "ASS", "Associate"); - associationTypes.Add(Sbm.AssociationType.Member, "MEM", "Member"); - associationTypes.Add(Sbm.AssociationType.Contractor, "CON", "Contractor"); - associationTypes.Add(Sbm.AssociationType.Stockist, "STK", "Stockist"); - associationTypes.Add(Sbm.AssociationType.FinanceAgency, "FIN", "Finance agency"); + systemCodes[Sbm.SystemCode.AssociationType] = new List() + { + new TypeCodeDesc((int)Sbm.AssociationType.Internal, "INT", "Internal"), + new TypeCodeDesc((int)Sbm.AssociationType.Customer, "CUS", "Customer"), + new TypeCodeDesc((int)Sbm.AssociationType.Supplier, "SUP", "Supplier"), + new TypeCodeDesc((int)Sbm.AssociationType.Associate, "ASS", "Associate"), + new TypeCodeDesc((int)Sbm.AssociationType.Member, "MEM", "Member"), + new TypeCodeDesc((int)Sbm.AssociationType.Contractor, "CON", "Contractor"), + new TypeCodeDesc((int)Sbm.AssociationType.Stockist, "STK", "Stockist"), + new TypeCodeDesc((int)Sbm.AssociationType.FinanceAgency, "FIN", "Finance agency") + }; + + // System Account Type. + systemCodes[Sbm.SystemCode.SystemAccountType] = new List() + { + new TypeCodeDesc((int)Sbm.SystemAccountType.Customer, "CUST", "Customer") + }; //--------------------------------------------------------------- // Transactions. - //--------------------------------------------------------------- + + // Transaction types. + systemCodes[Sbm.SystemCode.TransactionType] = new List() + { + new TypeCodeDesc((int) Sbm.TransactionType.Project, "PRO", "Project"), + new TypeCodeDesc((int)Sbm.TransactionType.SalesLead, "SLD", "Sales Lead"), + new TypeCodeDesc((int)Sbm.TransactionType.SalesQuote, "SQT", "Sales Quote"), + new TypeCodeDesc((int)Sbm.TransactionType.SalesPO, "SPO", "Sales Purchase Order"), + new TypeCodeDesc((int)Sbm.TransactionType.ProformaSalesOrder, "SAP", "Proforma Sales Order"), + new TypeCodeDesc((int)Sbm.TransactionType.SalesOrder, "SAL", "Sales Order"), + new TypeCodeDesc((int)Sbm.TransactionType.SalesDispatch, "SDP", "Sales Dispatch"), + new TypeCodeDesc((int)Sbm.TransactionType.ProformaSalesInvoice, "PSI", "Proforma Sales Invoice"), + new TypeCodeDesc((int)Sbm.TransactionType.SalesInvoice, "SAI", "Sales Invoice"), + new TypeCodeDesc((int)Sbm.TransactionType.PurchaseQuote, "PQT", "Purchase Quote"), + new TypeCodeDesc((int)Sbm.TransactionType.PurchaseSO, "PSO", "Purchase Sales Order"), + new TypeCodeDesc((int)Sbm.TransactionType.ProformaPurchaseOrder, "PUP", "Proforma Purchase Order"), + new TypeCodeDesc((int)Sbm.TransactionType.PurchaseOrder, "PUR", "Purchase Order"), + new TypeCodeDesc((int)Sbm.TransactionType.PurchaseDelivery, "PDL", "Purchase Delivery"), + new TypeCodeDesc((int)Sbm.TransactionType.ProformaPurchaseInvoice, "PPI", "Proforma Purchase Invoice"), + new TypeCodeDesc((int)Sbm.TransactionType.PurchaseInvoice, "PUI", "Purchase Invoice"), + }; + // Transaction StatusCat. - transactionStatusCats.Add(SbmTransaction.StatusCat.Pending, "PEN", "Pending"); - transactionStatusCats.Add(SbmTransaction.StatusCat.Open, "OPE", "Open"); - transactionStatusCats.Add(SbmTransaction.StatusCat.Closed, "CLO", "Closed"); + systemCodes[Sbm.SystemCode.TransactionStatusCat] = new List() + { + new TypeCodeDesc((int)SbmTransaction.StatusCat.Pending, "PEN", "Pending"), + new TypeCodeDesc((int)SbmTransaction.StatusCat.Open, "OPE", "Open"), + new TypeCodeDesc((int)SbmTransaction.StatusCat.Closed, "CLO", "Closed"), + }; + // Requirement Type. - requirementTypes.Add(Sbm.RequirementType.Detail, "DET", "Detail"); - requirementTypes.Add(Sbm.RequirementType.Job, "JOB", "Job"); + systemCodes[Sbm.SystemCode.RequirementType] = new List() + { + new TypeCodeDesc((int)Sbm.RequirementType.Detail, "DET", "Detail"), + new TypeCodeDesc((int)Sbm.RequirementType.Job, "JOB", "Job"), + }; + // TaskCodeType. - taskCodeTypes.Add(Sbm.TaskCodeType.Project, "PRO", "Project code"); - taskCodeTypes.Add(Sbm.TaskCodeType.Job, "JOB", "Job number"); + systemCodes[Sbm.SystemCode.TaskCodeType] = new List() + { + new TypeCodeDesc((int)Sbm.TaskCodeType.Project, "PRO", "Project code"), + new TypeCodeDesc((int)Sbm.TaskCodeType.Job, "JOB", "Job number"), + }; + // Requirement StatusCat. - requirementStatusCats.Add(SbmRequirement.StatusCat.Open, "OPE", "Open"); - requirementStatusCats.Add(SbmRequirement.StatusCat.Closed, "CLO", "Closed"); + systemCodes[Sbm.SystemCode.RequirementStatusCat] = new List() + { + new TypeCodeDesc((int)SbmRequirement.StatusCat.Open, "OPE", "Open"), + new TypeCodeDesc((int)SbmRequirement.StatusCat.Closed, "CLO", "Closed"), + }; + // ConstituentType. - constituentTypes.Add(Sbm.ConstituentType.TimeRecord, "TIM", "Time record"); - constituentTypes.Add(Sbm.ConstituentType.Event, "EVT", "Event"); - constituentTypes.Add(Sbm.ConstituentType.Task, "TSK", "Task"); - constituentTypes.Add(Sbm.ConstituentType.Response, "RSP", "Response"); - constituentTypes.Add(Sbm.ConstituentType.Consumable, "CON", "Consumable"); - constituentTypes.Add(Sbm.ConstituentType.Expense, "EXP", "Expense"); + systemCodes[Sbm.SystemCode.ConstituentType] = new List() + { + new TypeCodeDesc((int)Sbm.ConstituentType.TimeRecord, "TIM", "Time record"), + new TypeCodeDesc((int)Sbm.ConstituentType.Event, "EVT", "Event"), + new TypeCodeDesc((int)Sbm.ConstituentType.Task, "TSK", "Task"), + new TypeCodeDesc((int)Sbm.ConstituentType.Response, "RSP", "Response"), + new TypeCodeDesc((int)Sbm.ConstituentType.Consumable, "CON", "Consumable"), + new TypeCodeDesc((int)Sbm.ConstituentType.Expense, "EXP", "Expense"), + }; + // Constituent StatusCat. - constituentStatusCats.Add(SbmConstituent.StatusCat.Open, "OPE", "Open"); - constituentStatusCats.Add(SbmConstituent.StatusCat.Closed, "CLO", "Closed"); - + systemCodes[Sbm.SystemCode.ConstituentStatusCat] = new List() + { + new TypeCodeDesc((int)SbmConstituent.StatusCat.Open, "OPE", "Open"), + new TypeCodeDesc((int)SbmConstituent.StatusCat.Closed, "CLO", "Closed"), + }; + //--------------------------------------------------------------- + // Miscellaneous. // ItemLinkData. - itemLinkDatas.Add(Sbm.ItemLinkData.Requirement_AssocItem_PurchaseCostProportion, "PurchaseCostProportion", "Purchase cost proportion"); - // PortfolioItemType. - portfolioItemTypes.Add(Sbm.PortfolioItemType.Portfolio, "PORT", "Portfolio"); - portfolioItemTypes.Add(Sbm.PortfolioItemType.Category, "CAT", "Category"); - portfolioItemTypes.Add(Sbm.PortfolioItemType.Commodity, "COMM", "Commodity"); - // LocationCategory. - locationCategories.Add(Sbm.LocationCategory.Stock, "STOCK", "Stock"); - // LocationFilter. - locationFilters.Add(Sbm.LocationFilter.Sales, "SALESLOC", "Sales locations"); - locationFilters.Add(Sbm.LocationFilter.Calc, "CALCLOC", "Calculated locations"); - locationFilters.Add(Sbm.LocationFilter.All, "ALLLOC", "All locations"); - // ContainerCategory. - containerCategories.Add(Sbm.ContainerCategory.Stock, "STOCK", "Stock"); - // ContainerType. - containerTypes.Add(Sbm.ContainerType.Vehicle, "VEHICLE", "Vehicle"); - containerTypes.Add(Sbm.ContainerType.Truck, "TRUCK", "Truck"); - containerTypes.Add(Sbm.ContainerType.Train, "TRAIN", "Train"); - containerTypes.Add(Sbm.ContainerType.Ship, "SHIP", "Ship"); - containerTypes.Add(Sbm.ContainerType.Container, "CONTAINER", "Container"); - containerTypes.Add(Sbm.ContainerType.Wagon, "WAGON", "Wagon"); - containerTypes.Add(Sbm.ContainerType.Pallet, "PALLET", "Pallet"); - // CommodityStatusCat. - Any' value is included in list to support organisation item options and commodity panel filter. - commodityStatusCats.Add(SbmCommodity.StatusCat.Any, "ANY", ""); - commodityStatusCats.Add(SbmCommodity.StatusCat.Current, "CUR", "Current"); - // MovementType. - movementTypes.Add(Sbm.MovementType.StockTransfer, "STKTRA", "Stock transfer"); - movementTypes.Add(Sbm.MovementType.SalesAllocation, "SALALL", "Sales allocation"); - movementTypes.Add(Sbm.MovementType.PurchaseAllocation, "PURALL", "Purchase allocation"); - // StockLevelType. - stockLevelTypes.Add(Sbm.StockLevelType.CurrentLevel, "CUR", "Current level"); - stockLevelTypes.Add(Sbm.StockLevelType.StockTake, "STK", "Stock take"); - //StockLevelType.Add(Sbm.StockLevelType.Adjustment, "ADJ", "Adjustment"); - // StockLevelSource. - stockLevelSources.Add(Sbm.StockLevelSource.Manual, "MAN", "Manual"); - stockLevelSources.Add(Sbm.StockLevelSource.System, "SYS", "System"); - stockLevelSources.Add(Sbm.StockLevelSource.Sage, "SAG", "Sage"); - // AddressType. - addressTypes.Add(Sbm.AddressType.Office, "OFF", "Office"); - addressTypes.Add(Sbm.AddressType.Registered, "REG", "Registered"); - addressTypes.Add(Sbm.AddressType.Home, "HOM", "Home"); - addressTypes.Add(Sbm.AddressType.Billing, "BIL", "Billing"); - addressTypes.Add(Sbm.AddressType.Delivery, "DEL", "Delivery"); - // SysParamCategory. - sysParamCategories.Add(Sbm.SysParamCategory.Security, "SEC", "Security parameter"); - sysParamCategories.Add(Sbm.SysParamCategory.UserParam, "USP", "User session parameter"); - // ProcessType. - processTypes.Add(Sbm.ProcessType.Preparation, "PREP", "Preparation"); - processTypes.Add(Sbm.ProcessType.Production, "PROD", "Production"); - processTypes.Add(Sbm.ProcessType.Finishing, "FNSH", "Finishing"); - processTypes.Add(Sbm.ProcessType.External, "EXTL", "External"); - // PaymentType. - paymentTypes.Add(Sbm.PaymentType.Finance, "FINANCE", "Finance"); - paymentTypes.Add(Sbm.PaymentType.Cash, "CASH", "Cash"); - paymentTypes.Add(Sbm.PaymentType.Cheque, "CHEQUE", "Cheque"); - paymentTypes.Add(Sbm.PaymentType.DebitCard, "DEBIT", "Debit card"); - paymentTypes.Add(Sbm.PaymentType.CreditCard, "CREDIT", "Credit card"); - // AssetIncomeType. - assetIncomeTypes.Add(Sbm.AssetIncomeType.Sale, "SALE", "Sale"); - assetIncomeTypes.Add(Sbm.AssetIncomeType.Rental, "RENTAL", "Rental"); - // AssetType. - assetTypes.Add(Sbm.AssetType.General, "GEN", "General"); - assetTypes.Add(Sbm.AssetType.Furniture, "FUR", "Furniture"); - assetTypes.Add(Sbm.AssetType.Vehicle, "VEH", "Vehicle"); - assetTypes.Add(Sbm.AssetType.ComputerHardware, "CHW", "Computer hardware"); - // VehicleType. - vehicleTypes.Add(Sbm.VehicleType.Car, "CAR", "Car"); - vehicleTypes.Add(Sbm.VehicleType.Minibus, "MINIBUS", "Minibus"); - vehicleTypes.Add(Sbm.VehicleType.Van, "VAN", "Van"); - vehicleTypes.Add(Sbm.VehicleType.Truck, "TRUCK", "Truck"); - vehicleTypes.Add(Sbm.VehicleType.Coach, "COACH", "Coach"); - // VehicleEventType. - vehicleEventTypes.Add(Sbm.VehicleEventType.Odometer, "ODO", "Odometer"); - vehicleEventTypes.Add(Sbm.VehicleEventType.Service, "SRV", "Service"); - vehicleEventTypes.Add(Sbm.VehicleEventType.Incident, "INC", "Incident"); - vehicleEventTypes.Add(Sbm.VehicleEventType.Repair, "REP", "Repair"); - vehicleEventTypes.Add(Sbm.VehicleEventType.Comment, "CMT", "Comment"); - // VehicleFeatureSource. - vVehicleFeatureSources.Add(Sbm.VehicleFeatureSource.Manual, "MAN", "Manual"); - vVehicleFeatureSources.Add(Sbm.VehicleFeatureSource.HPI, "HPI", "HPI"); - vVehicleFeatureSources.Add(Sbm.VehicleFeatureSource.CAP, "CAP", "CAP"); - vVehicleFeatureSources.Add(Sbm.VehicleFeatureSource.DVLA, "DVLA", "DVLA"); - vVehicleFeatureSources.Add(Sbm.VehicleFeatureSource.SMMT, "SMMT", "SMMT"); - // VehicleFeatureType. - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Make, "MAKE", "Make"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Model, "MODEL", "Model"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Derivative, "DERIV", "Derivative"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Body, "BODY", "Body"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.DoorPlan, "DOORPLAN", "Door plan"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Trim, "TRIM", "Trim"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Colour, "COLOUR", "Colour"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.PreviousColour, "PREVCOL", "Previous Colour"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.LastPrevColour, "LASTPREVCOL", "Last Previous Colour"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.OriginalColour, "ORIGCOL", "Original Colour"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Fuel, "FUEL", "Fuel"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Transmission, "TRANS", "Transmission"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.TransDetail, "TRANSDET", "Transmission - Detail"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.WheelPlan, "WHEELPLAN", "Wheel plan"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Technical, "TECHNICAL", "Technical"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.Equipment, "EQUIPMENT", "Equipment"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.OptionalExtra, "OPTEXT", "Optional extra"); - vehicleFeatureTypes.Add(Sbm.VehicleFeatureType.SelectedOption, "OPTSEL", "Selected option"); - // VehicleOptionType. - vehicleOptionTypes.Add(Sbm.VehicleOptionType.Trim, "TRIM", "Trim"); - vehicleOptionTypes.Add(Sbm.VehicleOptionType.Ventilation, "VENTILATION", "Ventilation"); - vehicleOptionTypes.Add(Sbm.VehicleOptionType.Wheels, "WHEELS", "Wheels"); - vehicleOptionTypes.Add(Sbm.VehicleOptionType.PaintFinish, "PAINTFINISH", "Paint finish"); - vehicleOptionTypes.Add(Sbm.VehicleOptionType.Packs, "PACKS", "Packs"); - // VehicleTransType. - vehicleTransTypes.Add(Sbm.VehicleTransType.Manual, "MANUAL", "Manual"); - vehicleTransTypes.Add(Sbm.VehicleTransType.Automatic, "AUTO", "Automatic"); - // FuelType. - fuelTypes.Add(Sbm.VehicleFuelType.Petrol, "PETROL", "Petrol"); - fuelTypes.Add(Sbm.VehicleFuelType.Diesel, "DIESEL", "Diesel"); - fuelTypes.Add(Sbm.VehicleFuelType.Lpg, "LPG", "LPG"); - fuelTypes.Add(Sbm.VehicleFuelType.Electric, "ELEC", "Electric"); - fuelTypes.Add(Sbm.VehicleFuelType.Hybrid, "HYBRID", "Hybrid"); - // OdometerUnits. - odometerUnits.Add(Sbm.VehicleOdometerUnits.Mile, "MILE", "Miles"); - odometerUnits.Add(Sbm.VehicleOdometerUnits.Kilometre, "KM", "Kilometres"); - // DiscountType. - discountTypes.Add(Sbm.DiscountType.NoDiscount, "NoDisc", "No Discount"); - discountTypes.Add(Sbm.DiscountType.ValueDiscount, "ValDisc", "Value discount"); - discountTypes.Add(Sbm.DiscountType.QtyDiscountA, "QtyDiscA", "Quantity discount A"); - discountTypes.Add(Sbm.DiscountType.QtyDiscountB, "QtyDiscB", "Quantity discount B"); - discountTypes.Add(Sbm.DiscountType.QtyDiscountC, "QtyDiscC", "Quantity discount C"); - discountTypes.Add(Sbm.DiscountType.QtyDiscountD, "QtyDiscD", "Quantity discount D"); - discountTypes.Add(Sbm.DiscountType.QtyDiscountE, "QtyDiscE", "Quantity discount E"); - // DiscountMarkup. - discountMarkups.Add(Sbm.DiscountMarkup.Discount, "DISC", "Discount"); - discountMarkups.Add(Sbm.DiscountMarkup.Markup, "MARK", "Markup"); - // RegionType. - regionTypes.Add(SaRegionType.Continent, "CON", "Continent"); - regionTypes.Add(SaRegionType.Country, "COU", "Country"); - regionTypes.Add(SaRegionType.Province, "PRO", "Province"); - regionTypes.Add(SaRegionType.Town, "TWN", "Town"); - // UnitMeasureCategory. - unitMeasureCategories.Add(SaUomCategory.Time, "TIM", "Time"); - unitMeasureCategories.Add(SaUomCategory.Pack, "PCK", "Pack"); - unitMeasureCategories.Add(SaUomCategory.Weight, "WEI", "Weight"); - unitMeasureCategories.Add(SaUomCategory.Length, "LEN", "Length"); - unitMeasureCategories.Add(SaUomCategory.Area, "ARE", "Area"); - unitMeasureCategories.Add(SaUomCategory.Volume, "VOL", "Volume"); - unitMeasureCategories.Add(SaUomCategory.Density, "DEN", "Density"); - unitMeasureCategories.Add(SaUomCategory.Box, "BOX", "Box (container)"); - // UnitMeasureType. - unitMeasureTypes.Add(SaUomType.Time_Second, "SEC", "Second"); - unitMeasureTypes.Add(SaUomType.Time_Minute, "MIN", "Minute"); - unitMeasureTypes.Add(SaUomType.Time_Hour, "HR", "Hour"); - unitMeasureTypes.Add(SaUomType.Time_Day, "DAY", "Day"); - unitMeasureTypes.Add(SaUomType.Time_WorkingDay, "WDAY", "Working day"); - unitMeasureTypes.Add(SaUomType.Time_Week, "WK", "Week"); - unitMeasureTypes.Add(SaUomType.Time_WorkingWeek, "WWK", "Working week"); - unitMeasureTypes.Add(SaUomType.Time_Fortnight, "FNT", "Fortnight"); - unitMeasureTypes.Add(SaUomType.Time_Month, "MTH", "Month"); - unitMeasureTypes.Add(SaUomType.Time_Quarter, "QTR", "Quarter"); - unitMeasureTypes.Add(SaUomType.Time_Year, "YR", "Year"); - unitMeasureTypes.Add(SaUomType.Pack_Each, "EACH", "Each"); - unitMeasureTypes.Add(SaUomType.Pack_Set, "SET", "Set"); - unitMeasureTypes.Add(SaUomType.Weight_Gram, "GRM", "Gram"); - unitMeasureTypes.Add(SaUomType.Weight_Kilogram, "KG", "Kilogram"); - unitMeasureTypes.Add(SaUomType.Weight_Tonne, "TON", "Tonne"); - unitMeasureTypes.Add(SaUomType.Length_Metre, "METRE", "Metre"); - unitMeasureTypes.Add(SaUomType.Length_Kilometre, "KMET", "Kilometre"); - unitMeasureTypes.Add(SaUomType.Length_SquareMetre, "SQMET", "Square metre"); - unitMeasureTypes.Add(SaUomType.Length_Hectare, "HECT", "Hectare"); - unitMeasureTypes.Add(SaUomType.Length_Acre, "ACRE", "Acre"); - unitMeasureTypes.Add(SaUomType.Volume_Litre, "LITRE", "Litre"); - unitMeasureTypes.Add(SaUomType.Volume_CubicMetre, "CUBMET", "Cubic metre"); - unitMeasureTypes.Add(SaUomType.Density_KilogramsPerCubicMetre, "KPCMET", "Kg/m3"); - unitMeasureTypes.Add(SaUomType.Density_GramsPerCubicCentimeter, "GPCCMET", "g/cm3"); - unitMeasureTypes.Add(SaUomType.Box_Box, "BOX", "Box"); - unitMeasureTypes.Add(SaUomType.Box_Carton, "CARTON", "Carton"); - unitMeasureTypes.Add(SaUomType.Box_Pallet, "PALLET", "Pallet"); - // PriceType. - priceTypes.Add(Sbm.PriceType.Customer, "P", "Customer"); - priceTypes.Add(Sbm.PriceType.Supplier, "U", "Supplier"); - priceTypes.Add(Sbm.PriceType.Special, "S", "Special"); - // PriceCalcMethod. - priceCalcMethods.Add(Sbm.PriceCalcMethod.Fixed, "Fixed", "Fixed"); - priceCalcMethods.Add(Sbm.PriceCalcMethod.Standard, "Standard", "Standard"); - priceCalcMethods.Add(Sbm.PriceCalcMethod.DecreasePercent, "DecreasePercent", "Decrease Percent"); - priceCalcMethods.Add(Sbm.PriceCalcMethod.DecreaseValue, "DecreaseValue", "Decrease Value"); - priceCalcMethods.Add(Sbm.PriceCalcMethod.MarkupCost, "MarkupCost", "Markup Cost"); - priceCalcMethods.Add(Sbm.PriceCalcMethod.MarkupValue, "MarkupValue", "Markup Value"); - priceCalcMethods.Add(Sbm.PriceCalcMethod.MarkupSales, "MarkupSales", "Markup Sales"); + systemCodes[Sbm.SystemCode.ItemLinkData] = new List() + { + new TypeCodeDesc((int)Sbm.ItemLinkData.Requirement_AssocItem_PurchaseCostProportion, "PurchaseCostProportion", "Purchase cost proportion") + }; + + // Sys Param Category. + systemCodes[Sbm.SystemCode.SysParamCategory] = new List() + { + new TypeCodeDesc((int)Sbm.StockLevelSource.Manual, "MAN", "Manual"), + new TypeCodeDesc((int)Sbm.SysParamCategory.Security, "SEC", "Security parameter"), + new TypeCodeDesc((int)Sbm.SysParamCategory.UserParam, "USP", "User session parameter") + }; + + //--------------------------------------------------------------- + // Commodities. + + // Commodity Type. + systemCodes[Sbm.SystemCode.CommodityType] = new List() + { + new TypeCodeDesc((int)Sbm.CommodityType.Stock, "STK", "Stock"), + new TypeCodeDesc((int)Sbm.CommodityType.NonStock, "NST", "Non-stock"), + new TypeCodeDesc((int)Sbm.CommodityType.Service, "SRV", "Service"), + new TypeCodeDesc((int)Sbm.CommodityType.Asset, "AST", "Asset") + }; + + // Commodity Status Cat. - Any' value is included in list to support organisation item options and commodity panel filter. + systemCodes[Sbm.SystemCode.CommodityStatusCat] = new List() + { + new TypeCodeDesc((int)SbmCommodity.StatusCat.Any, "ANY", ""), + new TypeCodeDesc((int)SbmCommodity.StatusCat.Current, "CUR", "Current") + }; + + // Portfolio Item Type. + systemCodes[Sbm.SystemCode.PortfolioItemType] = new List() + { + new TypeCodeDesc((int)Sbm.PortfolioItemType.Portfolio, "PORT", "Portfolio"), + new TypeCodeDesc((int)Sbm.PortfolioItemType.Category, "CAT", "Category"), + new TypeCodeDesc((int)Sbm.PortfolioItemType.Commodity, "COMM", "Commodity") + }; + + // Container Category. + systemCodes[Sbm.SystemCode.ContainerCategory] = new List() + { + new TypeCodeDesc((int)Sbm.ContainerCategory.Stock, "STOCK", "Stock") + }; + + // Container Type. + systemCodes[Sbm.SystemCode.ContainerType] = new List() + { + new TypeCodeDesc((int)Sbm.ContainerType.Vehicle, "VEHICLE", "Vehicle"), + new TypeCodeDesc((int)Sbm.ContainerType.Truck, "TRUCK", "Truck"), + new TypeCodeDesc((int)Sbm.ContainerType.Train, "TRAIN", "Train"), + new TypeCodeDesc((int)Sbm.ContainerType.Ship, "SHIP", "Ship"), + new TypeCodeDesc((int)Sbm.ContainerType.Container, "CONTAINER", "Container"), + new TypeCodeDesc((int)Sbm.ContainerType.Wagon, "WAGON", "Wagon"), + new TypeCodeDesc((int)Sbm.ContainerType.Pallet, "PALLET", "Pallet") + }; + + //--------------------------------------------------------------- + // Stock. + + // Location Category. + systemCodes[Sbm.SystemCode.LocationCategory] = new List() + { + new TypeCodeDesc((int)Sbm.LocationCategory.Stock, "STOCK", "Stock") + }; + + // Location Filter. + systemCodes[Sbm.SystemCode.LocationFilter] = new List() + { + new TypeCodeDesc((int)Sbm.LocationFilter.Sales, "SALESLOC", "Sales locations"), + new TypeCodeDesc((int)Sbm.LocationFilter.Calc, "CALCLOC", "Calculated locations"), + new TypeCodeDesc((int)Sbm.LocationFilter.All, "ALLLOC", "All locations") + }; + + // Movement Type. + systemCodes[Sbm.SystemCode.MovementType] = new List() + { + new TypeCodeDesc((int)Sbm.MovementType.StockTransfer, "STKTRA", "Stock transfer"), + new TypeCodeDesc((int)Sbm.MovementType.SalesAllocation, "SALALL", "Sales allocation"), + new TypeCodeDesc((int)Sbm.MovementType.PurchaseAllocation, "PURALL", "Purchase allocation") + }; + + // Stock Level Type. + systemCodes[Sbm.SystemCode.StockLevelType] = new List() + { + new TypeCodeDesc((int)Sbm.StockLevelType.CurrentLevel, "CUR", "Current level"), + new TypeCodeDesc((int)Sbm.StockLevelType.StockTake, "STK", "Stock take"), + //new TypeCodeDesc((int)Sbm.StockLevelType.Adjustment, "ADJ", "Adjustment") + }; + + // Stock Level Source. + systemCodes[Sbm.SystemCode.StockLevelSource] = new List() + { + new TypeCodeDesc((int)Sbm.StockLevelSource.Manual, "MAN", "Manual"), + new TypeCodeDesc((int)Sbm.StockLevelSource.System, "SYS", "System"), + new TypeCodeDesc((int)Sbm.StockLevelSource.Sage, "SAG", "Sage") + }; + + //--------------------------------------------------------------- + // Processes. + + // Process Category. + systemCodes[Sbm.SystemCode.ProcessCategory] = new List() + { + new TypeCodeDesc((int)Sbm.ProcessCategory.Commodity, "CMD", "Commodity"), + new TypeCodeDesc((int)Sbm.ProcessCategory.Asset, "ASSET", "Asset") + }; + + // Process Type. + systemCodes[Sbm.SystemCode.ProcessType] = new List() + { + new TypeCodeDesc((int)Sbm.ProcessType.Preparation, "PREP", "Preparation"), + new TypeCodeDesc((int)Sbm.ProcessType.Production, "PROD", "Production"), + new TypeCodeDesc((int)Sbm.ProcessType.Finishing, "FNSH", "Finishing"), + new TypeCodeDesc((int)Sbm.ProcessType.External, "EXTL", "External") + }; + + // Payment Type. + systemCodes[Sbm.SystemCode.PaymentType] = new List() + { + new TypeCodeDesc((int)Sbm.PaymentType.Finance, "FINANCE", "Finance"), + new TypeCodeDesc((int)Sbm.PaymentType.Cash, "CASH", "Cash"), + new TypeCodeDesc((int)Sbm.PaymentType.Cheque, "CHEQUE", "Cheque"), + new TypeCodeDesc((int)Sbm.PaymentType.DebitCard, "DEBIT", "Debit card"), + new TypeCodeDesc((int)Sbm.PaymentType.CreditCard, "CREDIT", "Credit card") + }; + + //--------------------------------------------------------------- + // Assets. + + // Asset Type. + systemCodes[Sbm.SystemCode.AssetType] = new List() + { + new TypeCodeDesc((int)Sbm.AssetType.General, "GEN", "General"), + new TypeCodeDesc((int)Sbm.AssetType.Furniture, "FUR", "Furniture"), + new TypeCodeDesc((int)Sbm.AssetType.Vehicle, "VEH", "Vehicle"), + new TypeCodeDesc((int)Sbm.AssetType.ComputerHardware, "CHW", "Computer hardware") + }; + + // Asset Income Type. + systemCodes[Sbm.SystemCode.AssetIncomeType] = new List() + { + new TypeCodeDesc((int)Sbm.AssetIncomeType.Sale, "SALE", "Sale"), + new TypeCodeDesc((int)Sbm.AssetIncomeType.Rental, "RENTAL", "Rental") + }; + + //--------------------------------------------------------------- + // Vehicles. + + // Vehicle Type. + systemCodes[Sbm.SystemCode.VehicleType] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleType.Car, "CAR", "Car"), + new TypeCodeDesc((int)Sbm.VehicleType.Minibus, "MINIBUS", "Minibus"), + new TypeCodeDesc((int)Sbm.VehicleType.Van, "VAN", "Van"), + new TypeCodeDesc((int)Sbm.VehicleType.Truck, "TRUCK", "Truck"), + new TypeCodeDesc((int)Sbm.VehicleType.Coach, "COACH", "Coach") + }; + + // Vehicle Event Type. + systemCodes[Sbm.SystemCode.VehicleEventType] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleEventType.Odometer, "ODO", "Odometer"), + new TypeCodeDesc((int)Sbm.VehicleEventType.Service, "SRV", "Service"), + new TypeCodeDesc((int)Sbm.VehicleEventType.Incident, "INC", "Incident"), + new TypeCodeDesc((int)Sbm.VehicleEventType.Repair, "REP", "Repair"), + new TypeCodeDesc((int)Sbm.VehicleEventType.Comment, "CMT", "Comment") + }; + + // Vehicle Feature Source. + systemCodes[Sbm.SystemCode.VehicleFeatureSource] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleFeatureSource.Manual, "MAN", "Manual"), + new TypeCodeDesc((int)Sbm.VehicleFeatureSource.HPI, "HPI", "HPI"), + new TypeCodeDesc((int)Sbm.VehicleFeatureSource.CAP, "CAP", "CAP"), + new TypeCodeDesc((int)Sbm.VehicleFeatureSource.DVLA, "DVLA", "DVLA"), + new TypeCodeDesc((int)Sbm.VehicleFeatureSource.SMMT, "SMMT", "SMMT") + }; + + // Vehicle Feature Type. + systemCodes[Sbm.SystemCode.VehicleFeatureType] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Make, "MAKE", "Make"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Model, "MODEL", "Model"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Derivative, "DERIV", "Derivative"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Body, "BODY", "Body"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.DoorPlan, "DOORPLAN", "Door plan"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Trim, "TRIM", "Trim"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Colour, "COLOUR", "Colour"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.PreviousColour, "PREVCOL", "Previous Colour"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.LastPrevColour, "LASTPREVCOL", "Last Previous Colour"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.OriginalColour, "ORIGCOL", "Original Colour"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Fuel, "FUEL", "Fuel"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Transmission, "TRANS", "Transmission"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.TransDetail, "TRANSDET", "Transmission - Detail"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.WheelPlan, "WHEELPLAN", "Wheel plan"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Technical, "TECHNICAL", "Technical"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.Equipment, "EQUIPMENT", "Equipment"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.OptionalExtra, "OPTEXT", "Optional extra"), + new TypeCodeDesc((int)Sbm.VehicleFeatureType.SelectedOption, "OPTSEL", "Selected option") + }; + + // Vehicle Option Type. + systemCodes[Sbm.SystemCode.VehicleOptionType] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleOptionType.Trim, "TRIM", "Trim"), + new TypeCodeDesc((int)Sbm.VehicleOptionType.Ventilation, "VENTILATION", "Ventilation"), + new TypeCodeDesc((int)Sbm.VehicleOptionType.Wheels, "WHEELS", "Wheels"), + new TypeCodeDesc((int)Sbm.VehicleOptionType.PaintFinish, "PAINTFINISH", "Paint finish"), + new TypeCodeDesc((int)Sbm.VehicleOptionType.Packs, "PACKS", "Packs") + }; + + // Vehicle Trans Type. + systemCodes[Sbm.SystemCode.VehicleTransType] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleTransType.Manual, "MANUAL", "Manual"), + new TypeCodeDesc((int)Sbm.VehicleTransType.Automatic, "AUTO", "Automatic") + }; + + // Fuel Type. + systemCodes[Sbm.SystemCode.FuelType] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleFuelType.Petrol, "PETROL", "Petrol"), + new TypeCodeDesc((int)Sbm.VehicleFuelType.Diesel, "DIESEL", "Diesel"), + new TypeCodeDesc((int)Sbm.VehicleFuelType.Lpg, "LPG", "LPG"), + new TypeCodeDesc((int)Sbm.VehicleFuelType.Electric, "ELEC", "Electric"), + new TypeCodeDesc((int)Sbm.VehicleFuelType.Hybrid, "HYBRID", "Hybrid") + }; + + // Odometer Units. + systemCodes[Sbm.SystemCode.OdometerUnits] = new List() + { + new TypeCodeDesc((int)Sbm.VehicleOdometerUnits.Mile, "MILE", "Miles"), + new TypeCodeDesc((int)Sbm.VehicleOdometerUnits.Kilometre, "KM", "Kilometres") + }; + + // Discount Type. + systemCodes[Sbm.SystemCode.DiscountType] = new List() + { + new TypeCodeDesc((int)Sbm.DiscountType.NoDiscount, "NoDisc", "No Discount"), + new TypeCodeDesc((int)Sbm.DiscountType.ValueDiscount, "ValDisc", "Value discount"), + new TypeCodeDesc((int)Sbm.DiscountType.QtyDiscountA, "QtyDiscA", "Quantity discount A"), + new TypeCodeDesc((int)Sbm.DiscountType.QtyDiscountB, "QtyDiscB", "Quantity discount B"), + new TypeCodeDesc((int)Sbm.DiscountType.QtyDiscountC, "QtyDiscC", "Quantity discount C"), + new TypeCodeDesc((int)Sbm.DiscountType.QtyDiscountD, "QtyDiscD", "Quantity discount D"), + new TypeCodeDesc((int)Sbm.DiscountType.QtyDiscountE, "QtyDiscE", "Quantity discount E") + }; + + // Discount Markup. + systemCodes[Sbm.SystemCode.DiscountMarkup] = new List() + { + new TypeCodeDesc((int)Sbm.DiscountMarkup.Discount, "DISC", "Discount"), + new TypeCodeDesc((int)Sbm.DiscountMarkup.Markup, "MARK", "Markup") + }; + + //--------------------------------------------------------------- + // Reference. + + // Region Type. + systemCodes[Sbm.SystemCode.RegionType] = new List() + { + new TypeCodeDesc((int)SaRegionType.Continent, "CON", "Continent"), + new TypeCodeDesc((int)SaRegionType.Country, "COU", "Country"), + new TypeCodeDesc((int)SaRegionType.Province, "PRO", "Province"), + new TypeCodeDesc((int)SaRegionType.Town, "TWN", "Town") + }; + + // Unit Measure Category. + systemCodes[Sbm.SystemCode.UnitMeasureCategory] = new List() + { + new TypeCodeDesc((int)SaUomCategory.Time, "TIM", "Time"), + new TypeCodeDesc((int)SaUomCategory.Pack, "PCK", "Pack"), + new TypeCodeDesc((int)SaUomCategory.Weight, "WEI", "Weight"), + new TypeCodeDesc((int)SaUomCategory.Length, "LEN", "Length"), + new TypeCodeDesc((int)SaUomCategory.Area, "ARE", "Area"), + new TypeCodeDesc((int)SaUomCategory.Volume, "VOL", "Volume"), + new TypeCodeDesc((int)SaUomCategory.Density, "DEN", "Density"), + new TypeCodeDesc((int)SaUomCategory.Box, "BOX", "Box (container)") + }; + + // Unit Measure Type. + systemCodes[Sbm.SystemCode.UnitMeasureType] = new List() + { + new TypeCodeDesc((int)SaUomType.Time_Second, "SEC", "Second"), + new TypeCodeDesc((int)SaUomType.Time_Minute, "MIN", "Minute"), + new TypeCodeDesc((int)SaUomType.Time_Hour, "HR", "Hour"), + new TypeCodeDesc((int)SaUomType.Time_Day, "DAY", "Day"), + new TypeCodeDesc((int)SaUomType.Time_WorkingDay, "WDAY", "Working day"), + new TypeCodeDesc((int)SaUomType.Time_Week, "WK", "Week"), + new TypeCodeDesc((int)SaUomType.Time_WorkingWeek, "WWK", "Working week"), + new TypeCodeDesc((int)SaUomType.Time_Fortnight, "FNT", "Fortnight"), + new TypeCodeDesc((int)SaUomType.Time_Month, "MTH", "Month"), + new TypeCodeDesc((int)SaUomType.Time_Quarter, "QTR", "Quarter"), + new TypeCodeDesc((int)SaUomType.Time_Year, "YR", "Year"), + new TypeCodeDesc((int)SaUomType.Pack_Each, "EACH", "Each"), + new TypeCodeDesc((int)SaUomType.Pack_Set, "SET", "Set"), + new TypeCodeDesc((int)SaUomType.Weight_Gram, "GRM", "Gram"), + new TypeCodeDesc((int)SaUomType.Weight_Kilogram, "KG", "Kilogram"), + new TypeCodeDesc((int)SaUomType.Weight_Tonne, "TON", "Tonne"), + new TypeCodeDesc((int)SaUomType.Length_Metre, "METRE", "Metre"), + new TypeCodeDesc((int)SaUomType.Length_Kilometre, "KMET", "Kilometre"), + new TypeCodeDesc((int)SaUomType.Length_SquareMetre, "SQMET", "Square metre"), + new TypeCodeDesc((int)SaUomType.Length_Hectare, "HECT", "Hectare"), + new TypeCodeDesc((int)SaUomType.Length_Acre, "ACRE", "Acre"), + new TypeCodeDesc((int)SaUomType.Volume_Litre, "LITRE", "Litre"), + new TypeCodeDesc((int)SaUomType.Volume_CubicMetre, "CUBMET", "Cubic metre"), + new TypeCodeDesc((int)SaUomType.Density_KilogramsPerCubicMetre, "KPCMET", "Kg/m3"), + new TypeCodeDesc((int)SaUomType.Density_GramsPerCubicCentimeter, "GPCCMET", "g/cm3"), + new TypeCodeDesc((int)SaUomType.Box_Box, "BOX", "Box"), + new TypeCodeDesc((int)SaUomType.Box_Carton, "CARTON", "Carton"), + new TypeCodeDesc((int)SaUomType.Box_Pallet, "PALLET", "Pallet") + }; + + // Financial Type. + systemCodes[Sbm.SystemCode.FinancialType] = new List() + { + new TypeCodeDesc((int)Sbm.FinancialType.CommoditySupply, "CmdSup", "Commodity supply"), + new TypeCodeDesc((int)Sbm.FinancialType.CommoditySales, "CmdSal", "Commodity sales") + }; + + //--------------------------------------------------------------- + // Pricing. + + // Price Type. + systemCodes[Sbm.SystemCode.PriceType] = new List() + { + new TypeCodeDesc((int)Sbm.PriceType.Customer, "P", "Customer"), + new TypeCodeDesc((int)Sbm.PriceType.Supplier, "U", "Supplier"), + new TypeCodeDesc((int)Sbm.PriceType.Special, "S", "Special") + }; + + // Price Calc Method. + systemCodes[Sbm.SystemCode.PriceCalcMethod] = new List() + { + new TypeCodeDesc((int)Sbm.PriceCalcMethod.Fixed, "Fixed", "Fixed"), + new TypeCodeDesc((int)Sbm.PriceCalcMethod.Standard, "Standard", "Standard"), + new TypeCodeDesc((int)Sbm.PriceCalcMethod.DecreasePercent, "DecreasePercent", "Decrease Percent"), + new TypeCodeDesc((int)Sbm.PriceCalcMethod.DecreaseValue, "DecreaseValue", "Decrease Value"), + new TypeCodeDesc((int)Sbm.PriceCalcMethod.MarkupCost, "MarkupCost", "Markup Cost"), + new TypeCodeDesc((int)Sbm.PriceCalcMethod.MarkupValue, "MarkupValue", "Markup Value"), + new TypeCodeDesc((int)Sbm.PriceCalcMethod.MarkupSales, "MarkupSales", "Markup Sales") + }; + // PriceRounderMethod. - //PriceRounderMethod.Add(XXX, "", ""); + //PriceRounderMethod.Add(XXX, "", ""), // PriceRounderDirection. - //PriceRounderDirection.Add(XXX, "", ""); - // SystemAccountType. - systemAccountTypes.Add(Sbm.SystemAccountType.Customer, "CUST", "Customer"); + //PriceRounderDirection.Add(XXX, "", ""), + // ItemStatus. // EventStatus. //--------------------------------------------------------------- // Application configuration. - // AssociationTab. - associationTabs.Add(Sbm.AssociationTab.Details, "Details", "Details"); - associationTabs.Add(Sbm.AssociationTab.Order, "Order", "Order"); - associationTabs.Add(Sbm.AssociationTab.ClientOrder, "ClientOrder", "Client order"); - associationTabs.Add(Sbm.AssociationTab.Member, "Member", "Member"); - associationTabs.Add(Sbm.AssociationTab.Time, "Time", "Time"); - associationTabs.Add(Sbm.AssociationTab.Task, "Task", "Task"); - associationTabs.Add(Sbm.AssociationTab.Doc, "Doc", "Doc"); + + // Association Tab. + systemCodes[Sbm.SystemCode.AssociationTab] = new List() + { + new TypeCodeDesc((int)Sbm.AssociationTab.Details, "Details", "Details"), + new TypeCodeDesc((int)Sbm.AssociationTab.Order, "Order", "Order"), + new TypeCodeDesc((int)Sbm.AssociationTab.ClientOrder, "ClientOrder", "Client order"), + new TypeCodeDesc((int)Sbm.AssociationTab.Member, "Member", "Member"), + new TypeCodeDesc((int)Sbm.AssociationTab.Time, "Time", "Time"), + new TypeCodeDesc((int)Sbm.AssociationTab.Task, "Task", "Task"), + new TypeCodeDesc((int)Sbm.AssociationTab.Doc, "Doc", "Doc") + }; //--------------------------------------------------------------- // Interfaces. + // Interface types - Website. - interfaceTypes_Website.Add(Sbm.InterfaceType_Website.WebStore, "WebStore", "WebStore"); - interfaceTypes_Website.Add(Sbm.InterfaceType_Website.JoomlaVirtueMart, "JoomlaVM", "Joomla VirtueMart"); - interfaceTypes_Website.Add(Sbm.InterfaceType_Website.MiMoWeb, "MiMoWeb", "MiMo Website"); + systemCodes[Sbm.SystemCode.InterfaceType_Website] = new List() + { + new TypeCodeDesc((int)Sbm.InterfaceType_Website.WebStore, "WebStore", "WebStore"), + new TypeCodeDesc((int)Sbm.InterfaceType_Website.JoomlaVirtueMart, "JoomlaVM", "Joomla VirtueMart"), + new TypeCodeDesc((int)Sbm.InterfaceType_Website.MiMoWeb, "MiMoWeb", "MiMo Website") + }; // Interface types - Accounts. - interfaceTypes_Accounts.Add(Sbm.InterfaceType_Accounts.SageLine50, "SageLine50", "Sage Line 50"); - interfaceTypes_Accounts.Add(Sbm.InterfaceType_Accounts.QuickBooks, "QBooks", "QuickBooks"); + systemCodes[Sbm.SystemCode.InterfaceType_Accounts] = new List() + { + new TypeCodeDesc((int)Sbm.InterfaceType_Accounts.SageLine50, "SageLine50", "Sage Line 50"), + new TypeCodeDesc((int)Sbm.InterfaceType_Accounts.QuickBooks, "QBooks", "QuickBooks") + }; // Interface types - System. - interfaceTypes_System.Add(Sbm.InterfaceType_System.MSOutlook, "MSOutlook", "MS Outlook"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.PostcodeAnywhere, "POSTCODEANYWHERE", "Postcode Anywhere"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Capi, "CAPI", "Capi"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Bac, "BAC", "BAC"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Pvh, "PVH", "Practical Van Hire"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Cap, "CAP", "CAP"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Hpi, "HPI", "HPI"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Anchor_OrderFulfilment, "ANCORDFIL", "Ancor Order Fulfilment"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos, "CULORDSSHEET-ARGOS", "Cadix Order Spreadsheet - Argos"); - interfaceTypes_System.Add(Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase, "CULORDSSHEET-HOMEBASE", "Cadix Order Spreadsheet - Homebase"); + systemCodes[Sbm.SystemCode.InterfaceType_System] = new List() + { + new TypeCodeDesc((int)Sbm.InterfaceType_System.MSOutlook, "MSOutlook", "MS Outlook"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.PostcodeAnywhere, "POSTCODEANYWHERE", "Postcode Anywhere"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Capi, "CAPI", "Capi"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Bac, "BAC", "BAC"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Pvh, "PVH", "Practical Van Hire"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Cap, "CAP", "CAP"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Hpi, "HPI", "HPI"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Anchor_OrderFulfilment, "ANCORDFIL", "Ancor Order Fulfilment"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Argos, "CULORDSSHEET-ARGOS", "Cadix Order Spreadsheet - Argos"), + new TypeCodeDesc((int)Sbm.InterfaceType_System.Cadix_OrderSpreadsheet_Homebase, "CULORDSSHEET-HOMEBASE", "Cadix Order Spreadsheet - Homebase") + }; // Interface types - File. - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransactionImport, "SalesOrderImport", "Transaction import"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransactionExport, "SalesOrderExport", "Transaction export"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransToWord_SalesQuote, "SalQutToWord", "Sales Quote to Word"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransToWord_SalesOrder, "SalOrdToWord", "Sales Order to Word"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransToWord_SalesDispatch, "SalDisToWord", "Sales Dispatch to Word"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransToWord_SalesInvoice, "SalInvToWord", "Sales Invoice to Word"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.TransToWord_PurchaseOrder, "PurOrdToWord", "Purchase Order to Word"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.AssociationImport, "AssociationImport", "Association import"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.AssociationExport, "AssociationExport", "Association export"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.CommodityImport, "CommodityImport", "Commodity import"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.CommodityExport, "CommodityExport", "Commodity export"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.VehicleImport, "VehicleImport", "Vehicle import"); - interfaceTypes_File.Add(Sbm.InterfaceType_File.LeasewayInvoice, "LWI", "Leaseway Invoice"); + systemCodes[Sbm.SystemCode.InterfaceType_File] = new List() + { + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransactionImport, "SalesOrderImport", "Transaction import"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransactionExport, "SalesOrderExport", "Transaction export"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransToWord_SalesQuote, "SalQutToWord", "Sales Quote to Word"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransToWord_SalesOrder, "SalOrdToWord", "Sales Order to Word"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransToWord_SalesDispatch, "SalDisToWord", "Sales Dispatch to Word"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransToWord_SalesInvoice, "SalInvToWord", "Sales Invoice to Word"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.TransToWord_PurchaseOrder, "PurOrdToWord", "Purchase Order to Word"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.AssociationImport, "AssociationImport", "Association import"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.AssociationExport, "AssociationExport", "Association export"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.CommodityImport, "CommodityImport", "Commodity import"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.CommodityExport, "CommodityExport", "Commodity export"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.VehicleImport, "VehicleImport", "Vehicle import"), + new TypeCodeDesc((int)Sbm.InterfaceType_File.LeasewayInvoice, "LWI", "Leaseway Invoice") + }; // InterfaceDataType. - interfaceDataTypes.Add(Sbm.InterfaceDataType.Contact, "CONTACT", "Contact"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Association, "ASSOCIATION", "Association"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Customer, "CUST", "Customer"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Supplier, "SUPP", "Supplier"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Associate, "ASSOCIATE", "Associate"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Contractor, "CONTRACT", "Contractor"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.AssetCategory, "ASSETCAT", "Asset Category"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Asset, "ASSET", "Assest"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.VehicleClass, "VEHCLA", "Vehicle Class"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Vehicle, "VEH", "Vehicle"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Commodity, "CMD", "Commodity"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.PriceSet, "PRICESET", "Price Set"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.PortfolioItem, "PORTITEM", "Portfolio Item"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.CommodityCustomer, "CMDCUST", "Commodity Customer"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.CommoditySupplier, "CMDSUPP", "Commodity Supplier"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Location, "LOCAT", "Location"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Container, "CONTAIN", "Container"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.StockTake, "STOCKTAKE", "Stock Take"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Transaction, "TRANS", "Transaction"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.SalesQuote, "TSQ", "Sales Quote"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.ProformaSalesOrder, "TPSO", "Proforma Sales Order"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.SalesOrder, "TSO", "Sales Order"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.SalesDispatch, "TSD", "Sales Dispatch"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.ProformaSalesInvoice, "TPSI", "Proforma Sales Invoice"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.SalesInvoice, "TSI", "Sales Invoice"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.PurchaseQuote, "TPQ", "Purchase Quote"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.ProformaPurchaseOrder, "TPPO", "Proforma Purchase Order"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.PurchaseOrder, "TPO", "Purchase Order"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.ConstituentTime, "CONSTTIME", "Constituent Time"); - interfaceDataTypes.Add(Sbm.InterfaceDataType.Pricing, "PRICING", "Pricing"); + systemCodes[Sbm.SystemCode.InterfaceDataType] = new List() + { + new TypeCodeDesc((int)Sbm.InterfaceDataType.Contact, "CONTACT", "Contact"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Association, "ASSOCIATION", "Association"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Customer, "CUST", "Customer"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Supplier, "SUPP", "Supplier"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Associate, "ASSOCIATE", "Associate"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Contractor, "CONTRACT", "Contractor"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.AssetCategory, "ASSETCAT", "Asset Category"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Asset, "ASSET", "Assest"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.VehicleClass, "VEHCLA", "Vehicle Class"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Vehicle, "VEH", "Vehicle"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Commodity, "CMD", "Commodity"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.PriceSet, "PRICESET", "Price Set"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.PortfolioItem, "PORTITEM", "Portfolio Item"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.CommodityCustomer, "CMDCUST", "Commodity Customer"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.CommoditySupplier, "CMDSUPP", "Commodity Supplier"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Location, "LOCAT", "Location"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Container, "CONTAIN", "Container"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.StockTake, "STOCKTAKE", "Stock Take"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Transaction, "TRANS", "Transaction"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.SalesQuote, "TSQ", "Sales Quote"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.ProformaSalesOrder, "TPSO", "Proforma Sales Order"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.SalesOrder, "TSO", "Sales Order"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.SalesDispatch, "TSD", "Sales Dispatch"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.ProformaSalesInvoice, "TPSI", "Proforma Sales Invoice"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.SalesInvoice, "TSI", "Sales Invoice"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.PurchaseQuote, "TPQ", "Purchase Quote"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.ProformaPurchaseOrder, "TPPO", "Proforma Purchase Order"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.PurchaseOrder, "TPO", "Purchase Order"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.ConstituentTime, "CONSTTIME", "Constituent Time"), + new TypeCodeDesc((int)Sbm.InterfaceDataType.Pricing, "PRICING", "Pricing") + }; //--------------------------------------------------------------- // Associated data. - // ItemDataType. - itemDataTypes.Add(Sbm.ItemDataType.Vehicle_HpiResponse, "HPI", "HPI response"); - itemDataTypes.Add(Sbm.ItemDataType.Transaction_VehicleFilter, "VehicleFilter", "Vehicle filter"); - itemDataTypes.Add(Sbm.ItemDataType.Transaction_ExchangeVehicle, "ExchangeVehicle", "Exchange vehicle"); - itemDataTypes.Add(Sbm.ItemDataType.Transaction_Finance, "Finance", "Finance"); - itemDataTypes.Add(Sbm.ItemDataType.Transaction_Payments, "Payments", "Payments"); - itemDataTypes.Add(Sbm.ItemDataType.Process_FixedCost_Unit, "ProcFixedCostUnit", "Fixed cost per unit"); - itemDataTypes.Add(Sbm.ItemDataType.Process_FixedCost_Job, "ProcFixedCostJob", "Fixed cost per job"); - itemDataTypes.Add(Sbm.ItemDataType.Process_LabourCost_Unit, "ProcLabourCostUnit", "Labour cost per unit"); - itemDataTypes.Add(Sbm.ItemDataType.Process_LabourCost_Job, "ProcLabourCostJob", "Labour cost per job"); + + // Item Data Type. + systemCodes[Sbm.SystemCode.ItemDataType] = new List() + { + new TypeCodeDesc((int)Sbm.ItemDataType.Vehicle_HpiResponse, "HPI", "HPI response"), + new TypeCodeDesc((int)Sbm.ItemDataType.Transaction_VehicleFilter, "VehicleFilter", "Vehicle filter"), + new TypeCodeDesc((int)Sbm.ItemDataType.Transaction_ExchangeVehicle, "ExchangeVehicle", "Exchange vehicle"), + new TypeCodeDesc((int)Sbm.ItemDataType.Transaction_Finance, "Finance", "Finance"), + new TypeCodeDesc((int)Sbm.ItemDataType.Transaction_Payments, "Payments", "Payments"), + new TypeCodeDesc((int)Sbm.ItemDataType.Process_FixedCost_Unit, "ProcFixedCostUnit", "Fixed cost per unit"), + new TypeCodeDesc((int)Sbm.ItemDataType.Process_FixedCost_Job, "ProcFixedCostJob", "Fixed cost per job"), + new TypeCodeDesc((int)Sbm.ItemDataType.Process_LabourCost_Unit, "ProcLabourCostUnit", "Labour cost per unit"), + new TypeCodeDesc((int)Sbm.ItemDataType.Process_LabourCost_Job, "ProcLabourCostJob", "Labour cost per job") + }; //--------------------------------------------------------------- // Organisation configuration. - // OrgOption_Value. - orgOption_Values.Add(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter, "MaxTransEmptyFilter", "Maximum transactions queried for empty filter"); - orgOption_Values.Add(Sbm.OrgOption_Value.AlternativePromotionText, "AltPromotionText", "To be used when no promotion specified"); - orgOption_Values.Add(Sbm.OrgOption_Value.CostLabourRateDefault, "CostLbrRateDefault", "Cost - labour rate per hour (default)", "Currency value with decimals"); - orgOption_Values.Add(Sbm.OrgOption_Value.DefaultSalesCarriageNominal, "DfltSalCarrNom", "Default Sales carriage nominal"); - orgOption_Values.Add(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal, "DfltPurCarrNom", "Default Purchase carriage nominal"); - orgOption_Values.Add(Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice, "CmdAllowNegPrice", "Commodities allowed negative price", "Comma separated list."); - orgOption_Values.Add(Sbm.OrgOption_Value.TransTimeChunk1Caption, "TransTimeSplitCaption1", "Transaction time split caption 1"); - orgOption_Values.Add(Sbm.OrgOption_Value.TransTimeChunk2Caption, "TransTimeSplitCaption2", "Transaction time split caption 2"); - orgOption_Values.Add(Sbm.OrgOption_Value.EmailSubject, "EmailSubject", "Email subject"); - orgOption_Values.Add(Sbm.OrgOption_Value.EmailBody, "EmailBody", "Email body"); - // OrgOption_Folder. - orgOption_Folders.Add(Sbm.OrgOption_Folder.CommodityImage, "CmdImage", "Commodity image"); - orgOption_Folders.Add(Sbm.OrgOption_Folder.CommodityBarcodeImage, "CmdBarcodeImage", "Commodity barcode image"); - // OrgOption_AllowOption. - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.UpdateAssociationCode, "UpdAssocCode", "Update association code"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.CustomerAccountDetails, "CustAccntDet", "Customer account details"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.StockistAssociations, "StockistAssociations", "Stockist associations"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.FinanceAgencyAssociations, "FinanceAssociations", "Finance agency associations"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Commodity_SalesBudget, "CommoditySalesBudget", "Commodity sales budget"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter, "CommodityPartialCodeFilter", "Commodity partial code filter", "As opposed to 'starting' with."); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Commodity_EditHistoryItem, "CommodityEditHistoryItem", "Commodity - edit history items", "Where updates allowed"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.ImminentStock, "ImminStock", "Imminent stock", "Includes overdue and up to specified number of weeks of due stock"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.ManageContainerMovemements, "ManageContMovmt", "Manage container movements"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock, "AwaitContImmin", "Include planned container movements in imminent stock"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.TransactionFilter_AnyStatus, "TransFltStatAny", "Transaction filter - 'Any' status"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRef, "TransFltRetainRef", "Transaction filter - retain reference", "Between views"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRefExt, "TransFltRetainRefExt", "Transaction filter - retain external reference", "Between views"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.TransactionExport_FixedContent, "TransExpFixedContent", "Transaction exports - fixed content", ""); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Order_BillingAddress, "OrdBillingAddr", "Order billing address - populated from account"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.SalesOrder_OnHold, "SalOrdOnHold", "Sales order - On Hold status"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.SalesOrder_ReplacementOrders, "SalOrdReplacement", "Sales order - Replacement orders"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails, "SalOrdDispatchDet", "Sales order - Dispatch details"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.SalesOrder_PartialInvoice, "SalOrdPartialInv", "Sales order - Partial invoice"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.SalesOrder_RaiseInvoiceOnCompletion, "SalOrdRaiseInvOnCompl", "Sales order - Raise invoice on completion"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Transaction_RetainCurrentViewOnRaise, "TransRetainCurrViewOnRaise", "Transactions - retain current view on 'Raise'"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems, "PurItmAssocSalItm", "Purchase order item associated sales items", "Link purchase items to the sales items that are being supplied"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription, "OrderItemModCmdDesc", "Order item - modify commodity description", ""); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails, "OrderItemShowCmdDet", "Order item - show commodity details", ""); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails, "OrderItemShowStkDet", "Order item - show Stock details", ""); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Asset_Sale, "AssetSale", "Asset Sale"); - orgOption_AllowOptions.Add(Sbm.OrgOption_AllowOption.Asset_Rental, "AssetRental", "Asset rental"); - // OrgOption_ShowField. - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Association_AnnualSalesTarget, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget, null, false), "Association: Annual sales target"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Address_LastVisitOn, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_LastVisitOn, null, false), "Address: Last visit date"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_DrawingIssue, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue, null, false), "Commodity: Issue"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_DrawingNo, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_DrawingNo, null, false), "Commodity: Drawing no"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_Department, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Department, null, false), "Commodity: Department"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_CatalogRef, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CatalogRef, null, false), "Commodity: Catalog ref"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_Volume, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Volume, null, false), "Commodity: Volume"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_Density, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Density, null, false), "Commodity: Density"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_BoxQuantity, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, null, false), "Commodity: Box quantity"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_ICNTariffCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode, null, false), "Commodity: ICN Tarrif"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_PlaceOfOrigin, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin, null, false), "Commodity: Place of origin"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_MaterialCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, null, false), "Commodity: Material cost"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_ExWorksCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost, null, false), "Commodity: Ex-works cost"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_RetailPricePlanned, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned, null, false), "Commodity: Planned RRP"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.Commodity_CarriageCostIndicative, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative, null, false), "Commodity: Carriage cost (ind)"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.StockLevel_Bay1, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay1, null, false), "Stock Level: Bay 1"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.StockLevel_Bay2, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay2, null, false), "Stock Level: Bay 2"); - orgOption_ShowFields.Add(Sbm.OrgOption_ShowField.StockLevel_Bay3, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay3, null, false), "Stock Level: Bay 3"); - // OrgOption_FieldLabel. - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_CatalogRef, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CatalogRef, null, false), "Commodity: Catalog reference"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_Dimensions, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Dimensions, null, false), "Commodity: Dimensions"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_ICNTariffCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode, null, false), "Commodity: ICN tariff"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_CostPrice, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CostPrice, null, false), "Commodity: Cost price"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_PlaceOfOrigin, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin, null, false), "Commodity: Place of origin"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_MaterialCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, null, false), "Commodity: Material cost"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_CurrencyIdMaterial, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial, null, false), "Commodity: Material currency"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_ExWorksCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost, null, false), "Commodity: Ex-works cost"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_CurrencyIdExWorks, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks, null, false), "Commodity: Ex-works currency"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_SpecSummary, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_SpecSummary, null, false), "Commodity: Specification"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_MaterialCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, null, false), "Commodity: Material"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_FinishCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_FinishCode, null, false), "Commodity: Finish"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_DescDetail, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_DescDetail, null, false), "Commodity: Detail description"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Commodity_RetailPricePlanned, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned, null, false), "Commodity: Planned RRP"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Affiliate_Abbrev, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Abbrev, null, false), "Contact: Abbreviation"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Affiliate_Nature, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Nature, null, false), "Contact: Nature"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_Location, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Location, null, false), "Association: Location"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_AccountManagerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, null, false), "Association: Account manager"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_AccountHandlerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, null, false), "Association: Account handler"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_AccountTypeCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountTypeCode, null, false), "Association: Account type"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_AccountRatingCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountRatingCode, null, false), "Association: Account rating"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_ContactAreaCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, null, false), "Association: Contact area"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_ContactHandlerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, null, false), "Association: Contact handler"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_ContactMethodCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactMethodCode, null, false), "Association: Contact method"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Association_ContactCallCycleCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, null, false), "Association: Contact call cycle"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Transaction_Ref, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Ref, null, false), "Transaction: Reference"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.Transaction_RefExt, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_RefExt, null, false), "Transaction: External ref"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.StockLevel_Bay1, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay1, null, false), "Stock Level: Bay 1"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.StockLevel_Bay2, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay2, null, false), "Stock Level: Bay 2"); - orgOption_FieldLabels.Add(Sbm.OrgOption_FieldLabel.StockLevel_Bay3, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay3, null, false), "Stock Level: Bay 3"); - // OrgOption_TransactionCreationStatus. - orgOption_TransactionCreationStatuses.Add(Sbm.OrgOption_TransCreateStatus.ProformaSalesOrder, "ProFromaSalOrd", "Proforma SO creation status", "Default: 'Preparation'"); - orgOption_TransactionCreationStatuses.Add(Sbm.OrgOption_TransCreateStatus.SalesOrder, "SalesOrder", "SO creation status", "Default. 'In progress'"); - // OrgOption_ContainerStatusCaption. - orgOption_ContainerStatusCaptions.Add(Sbm.OrgOption_StatusContainer.Provisional, SacsSystem.GetStatusCode(SaStatus.Provisional), "Provisional"); - orgOption_ContainerStatusCaptions.Add(Sbm.OrgOption_StatusContainer.Awaiting, SacsSystem.GetStatusCode(SaStatus.Awaiting), "Awaiting"); - orgOption_ContainerStatusCaptions.Add(Sbm.OrgOption_StatusContainer.Active, SacsSystem.GetStatusCode(SaStatus.Active), "Active"); - orgOption_ContainerStatusCaptions.Add(Sbm.OrgOption_StatusContainer.Actioned, SacsSystem.GetStatusCode(SaStatus.Actioned), "Actioned"); - orgOption_ContainerStatusCaptions.Add(Sbm.OrgOption_StatusContainer.Cancelled, SacsSystem.GetStatusCode(SaStatus.Cancelled), "Cancelled"); - // OrgOption_Minutes. - OrgOption_Minutes.Add(Sbm.OrgOption_Minutes.AutoSaveTransaction, "MinsAutoSaveTrans", "Auto save transactions (minutes)", ""); - // OrgOption_NumericDecimals. - orgOption_NumericDecimals.Add(Sbm.OrgOption_NumericDecimals.OrderQuantity, "OrdQty", "Order quantity"); - orgOption_NumericDecimals.Add(Sbm.OrgOption_NumericDecimals.CommodityWeight, "CmdWeight", "Commodity weight"); - orgOption_NumericDecimals.Add(Sbm.OrgOption_NumericDecimals.CommodityLength, "CmdLength", "Commodity length"); - orgOption_NumericDecimals.Add(Sbm.OrgOption_NumericDecimals.CommodityVolume, "CmdVolume", "Commodity volume"); - orgOption_NumericDecimals.Add(Sbm.OrgOption_NumericDecimals.CommodityDensity, "CmdDensity", "Commodity density"); - // OrgOption_CommodityType. - orgOption_CommodityTypes.Add(Sbm.OrgOption_CommodityType.CommodityCreationDefault, "CmdCreateDflt", "Commodity creation default"); - // OrgOption_StockLocation. - orgOption_StockLocations.Add(Sbm.OrgOption_StockLocation.SalesOrderDefault, "SalOrdDflt", "Sales order default"); - orgOption_StockLocations.Add(Sbm.OrgOption_StockLocation.PurchaseOrderDefault, "PurOrdDflt", "Purchase order default"); - orgOption_StockLocations.Add(Sbm.OrgOption_StockLocation.TransactionFilterDefault, "TransFltrDflt", "Transaction filter default - replaces 'blank' selection"); + + // Organisation Option - Value. + systemCodes[Sbm.SystemCode.OrgOption_Value] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter, "MaxTransEmptyFilter", "Maximum transactions queried for empty filter"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.AlternativePromotionText, "AltPromotionText", "To be used when no promotion specified"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.CostLabourRateDefault, "CostLbrRateDefault", "Cost - labour rate per hour (default)", "Currency value with decimals"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.DefaultSalesCarriageNominal, "DfltSalCarrNom", "Default Sales carriage nominal"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal, "DfltPurCarrNom", "Default Purchase carriage nominal"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.CommoditiesAllowedNegativePrice, "CmdAllowNegPrice", "Commodities allowed negative price", "Comma separated list."), + new TypeCodeDesc((int)Sbm.OrgOption_Value.TransTimeChunk1Caption, "TransTimeSplitCaption1", "Transaction time split caption 1"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.TransTimeChunk2Caption, "TransTimeSplitCaption2", "Transaction time split caption 2"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.EmailSubject, "EmailSubject", "Email subject"), + new TypeCodeDesc((int)Sbm.OrgOption_Value.EmailBody, "EmailBody", "Email body") + }; + + // Organisation Option - Folder. + systemCodes[Sbm.SystemCode.OrgOption_Folder] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_Folder.CommodityImage, "CmdImage", "Commodity image"), + new TypeCodeDesc((int)Sbm.OrgOption_Folder.CommodityBarcodeImage, "CmdBarcodeImage", "Commodity barcode image") + }; + + // Organisation Option - Allow Option. + systemCodes[Sbm.SystemCode.OrgOption_AllowOption] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.UpdateAssociationCode, "UpdAssocCode", "Update association code"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.CustomerAccountDetails, "CustAccntDet", "Customer account details"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.StockistAssociations, "StockistAssociations", "Stockist associations"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.FinanceAgencyAssociations, "FinanceAssociations", "Finance agency associations"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Commodity_SalesBudget, "CommoditySalesBudget", "Commodity sales budget"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter, "CommodityPartialCodeFilter", "Commodity partial code filter", "As opposed to 'starting' with."), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Commodity_EditHistoryItem, "CommodityEditHistoryItem", "Commodity - edit history items", "Where updates allowed"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.ImminentStock, "ImminStock", "Imminent stock", "Includes overdue and up to specified number of weeks of due stock"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.ManageContainerMovemements, "ManageContMovmt", "Manage container movements"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock, "AwaitContImmin", "Include planned container movements in imminent stock"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.TransactionFilter_AnyStatus, "TransFltStatAny", "Transaction filter - 'Any' status"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.TransactionFilter_RetainRef, "TransFltRetainRef", "Transaction filter - retain reference", "Between views"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.TransactionFilter_RetainRefExt, "TransFltRetainRefExt", "Transaction filter - retain external reference", "Between views"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.TransactionExport_FixedContent, "TransExpFixedContent", "Transaction exports - fixed content", ""), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Order_BillingAddress, "OrdBillingAddr", "Order billing address - populated from account"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.SalesOrder_OnHold, "SalOrdOnHold", "Sales order - On Hold status"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.SalesOrder_ReplacementOrders, "SalOrdReplacement", "Sales order - Replacement orders"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails, "SalOrdDispatchDet", "Sales order - Dispatch details"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.SalesOrder_PartialInvoice, "SalOrdPartialInv", "Sales order - Partial invoice"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.SalesOrder_RaiseInvoiceOnCompletion, "SalOrdRaiseInvOnCompl", "Sales order - Raise invoice on completion"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Transaction_RetainCurrentViewOnRaise, "TransRetainCurrViewOnRaise", "Transactions - retain current view on 'Raise'"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems, "PurItmAssocSalItm", "Purchase order item associated sales items", "Link purchase items to the sales items that are being supplied"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription, "OrderItemModCmdDesc", "Order item - modify commodity description", ""), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails, "OrderItemShowCmdDet", "Order item - show commodity details", ""), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails, "OrderItemShowStkDet", "Order item - show Stock details", ""), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Sale, "AssetSale", "Asset Sale"), + new TypeCodeDesc((int)Sbm.OrgOption_AllowOption.Asset_Rental, "AssetRental", "Asset rental") + }; + + // Organisation Option - Caption + systemCodes[Sbm.SystemCode.OrgOption_Caption] = new List() + { + // Transaction type captions. + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_Project, "Project", "Transaction type - Project"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_SalesLead, "SalLead", "Transaction type - Sales Lead"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_SalesQuote, "SalQuote", "Transaction type - Sales quote"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_SalesPO, "SalPO", "Transaction type - Sales PO"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_ProformaSalesOrder, "SalPfOrder", "Transaction type - sales proforma order"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_SalesOrder, "SalOrder", "Transaction type - sales order"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_SalesDispatch, "SalDispatch", "Transaction type - Sales dispatch"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_ProformaSalesInvoice, "SalPfInvoice", "Transaction type - Proforma sales invoice"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_SalesInvoice, "SalInvoice", "Transaction type - Sales invoice"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_PurchaseQuote, "PurQuote", "Transaction type - Purchase quote"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_PurchaseSO, "PurSO", "Transaction type - Purchase SO"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_ProformaPurchaseOrder, "PurPfOrder", "Transaction type - Purchase proforma order"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_PurchaseOrder, "PurOrder", "Transaction type - Purchase order"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_PurchaseDelivery, "PurDelivery", "Transaction type - Purchase Delivery"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_ProformaPurchaseInvoice, "PurPfInvoice", "Transaction type - Proforma Purchase invoice"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.TransType_PurchaseInvoice, "PurInvoice", "Transaction type - Purchase invoice"), + // Menu option captions: + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_Projects, "MnuOptProject", "Caption - Projects menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_SalesLeads, "MnuOptSalLead", "Caption - Sales leads menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_SalesPOs, "MnuOptSalPO", "Caption - Sales POs menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_SalesQuotes, "MnuOptSalQuote", "Caption - Sales quotes menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_ProformaSalesOrders, "MnuOptSalPfOrder", "Caption - Proforma sales orders menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_SalesOrders, "MnuOptSalOrder", "Caption - Sales orders menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_SalesDispatches, "MnuOptSalDispatch", "Caption - Sales dispatches menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_ProformaSalesInvoices, "MnuOptSalPfInvoice", "Caption - Proforma sales invoices menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_SalesInvoices, "MnuOptSalInvoice", "Caption - Sales invoices menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_PurchaseQuotes, "MnuOptPurQuote", "Caption - Purchase quotes menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_PurchaseSOs, "MnuOptPurSO", "Caption - Purchase SOs menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseOrders, "MnuOptPurPfOrder", "Caption - Proforma purchase orders menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_PurchaseOrders, "MnuOptPurOrder", "Caption - Purchase orders menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_PurchaseDeliveries, "MnuOptPurDelivery", "Caption - Purchase Deliveries menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_ProformaPurchaseInvoices, "MnuOptPurPfInvoice", "Caption - Proforma purchase invoices menu option"), + new TypeCodeDesc((int)Sbm.OrgOption_Caption.MenuOpt_PurchaseInvoices, "MnuOptPurInvoice", "Caption - Purchase invoices menu option") + }; + + // Organisation Option - Show Column. + systemCodes[Sbm.SystemCode.OrgOption_ShowColumn] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget, "Association:AnnualSalesTarget", "Association: Annual sales target"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised, "Association:Trans:LastSaleRaised", "Association: Last SO raised"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open, "Association:Trans:SalesValue:Open", "Association: SO value: Open"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd, "Association:Trans:SalesValue:Cytd", "Association: SO value: YTD"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy, "Association:Trans:SalesValue:Lcy", "Association: SO value: LCY"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Association_Group, "Association:Group", "Association: Group"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Commodity_CatalogRef, "Commodity:CatalogRef", "Commodity: Catalog reference"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Commodity_Weight, "Commodity:Weight", "Commodity: Weight"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Commodity_PackQtySale, "Commodity:PackQtySale", "Commodity: Pack qty - sale"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Commodity_StockAllocated, "Commodity:StockAllocated", "Commodity: Allocated stock"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales, "Commodity:StockLevelSales", "Commodity: Stock level (Sales)"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Commodity_StockAvailable, "Commodity:StockAvailable", "Commodity: Available stock"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Order_AllocationInd, "Order:AllocationInd", "Order: Allocation indicator"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier, "SalesOrder:DeliveryCourier", "Order: Delivery courier"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice, "SalesOrder:HasInvoice", "Order: Has invoice flag"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Transaction_ContactArea, "Transaction:ContactArea", "Transaction: Contact area"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef, "Accounts:InvoiceRef", "Accounts: Invoice reference"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd, "OrderItem:AllocationInd", "Order item: Allocation indicator"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current, "OrderItem:StockCurrent", "Order item: Stock current"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available, "OrderItem:StockAvailable", "Order item: Stock available"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation, "OrderItem:StockBySalesLocation", "Order item: Stock by sales location"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched, "SalesOrderItem:QuantityDispatched", "Sales order item: qty dispatched"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced, "SalesOrderItem:QuantityInvoiced", "Sales order item: qty invoiced"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess, "SalesOrderItem:NextProcess", "Sales order item: Next process"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation, "Vehicle:KeyLocation", "Vehicle: Key location") + }; + + // Organisation Option - Show Field. + systemCodes[Sbm.SystemCode.OrgOption_ShowField] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Association_AnnualSalesTarget, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget, null, false), "Association: Annual sales target"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Address_LastVisitOn, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_LastVisitOn, null, false), "Address: Last visit date"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_DrawingIssue, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue, null, false), "Commodity: Issue"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_DrawingNo, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_DrawingNo, null, false), "Commodity: Drawing no"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_Department, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Department, null, false), "Commodity: Department"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_CatalogRef, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CatalogRef, null, false), "Commodity: Catalog ref"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_Volume, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Volume, null, false), "Commodity: Volume"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_Density, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Density, null, false), "Commodity: Density"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_BoxQuantity, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity, null, false), "Commodity: Box quantity"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_ICNTariffCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode, null, false), "Commodity: ICN Tarrif"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_PlaceOfOrigin, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin, null, false), "Commodity: Place of origin"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_MaterialCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, null, false), "Commodity: Material cost"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_ExWorksCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost, null, false), "Commodity: Ex-works cost"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_RetailPricePlanned, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned, null, false), "Commodity: Planned RRP"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.Commodity_CarriageCostIndicative, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative, null, false), "Commodity: Carriage cost (ind)"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.StockLevel_Bay1, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay1, null, false), "Stock Level: Bay 1"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.StockLevel_Bay2, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay2, null, false), "Stock Level: Bay 2"), + new TypeCodeDesc((int)Sbm.OrgOption_ShowField.StockLevel_Bay3, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay3, null, false), "Stock Level: Bay 3") + }; + + // Organisation Option - Field Label. + systemCodes[Sbm.SystemCode.OrgOption_FieldLabel] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_CatalogRef, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CatalogRef, null, false), "Commodity: Catalog reference"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_Dimensions, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Dimensions, null, false), "Commodity: Dimensions"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_ICNTariffCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode, null, false), "Commodity: ICN tariff"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_CostPrice, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CostPrice, null, false), "Commodity: Cost price"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_PlaceOfOrigin, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin, null, false), "Commodity: Place of origin"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_MaterialCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MaterialCost, null, false), "Commodity: Material cost"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_CurrencyIdMaterial, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial, null, false), "Commodity: Material currency"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_ExWorksCost, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost, null, false), "Commodity: Ex-works cost"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_CurrencyIdExWorks, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks, null, false), "Commodity: Ex-works currency"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_SpecSummary, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_SpecSummary, null, false), "Commodity: Specification"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_MaterialCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_MaterialCode, null, false), "Commodity: Material"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_FinishCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_FinishCode, null, false), "Commodity: Finish"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_DescDetail, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_DescDetail, null, false), "Commodity: Detail description"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Commodity_RetailPricePlanned, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned, null, false), "Commodity: Planned RRP"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Affiliate_Abbrev, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Abbrev, null, false), "Contact: Abbreviation"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Affiliate_Nature, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Nature, null, false), "Contact: Nature"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_Location, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Location, null, false), "Association: Location"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_AccountManagerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountManagerCode, null, false), "Association: Account manager"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_AccountHandlerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode, null, false), "Association: Account handler"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_AccountTypeCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountTypeCode, null, false), "Association: Account type"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_AccountRatingCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AccountRatingCode, null, false), "Association: Account rating"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_ContactAreaCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, null, false), "Association: Contact area"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_ContactHandlerCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode, null, false), "Association: Contact handler"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_ContactMethodCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactMethodCode, null, false), "Association: Contact method"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Association_ContactCallCycleCode, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode, null, false), "Association: Contact call cycle"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Transaction_Ref, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Ref, null, false), "Transaction: Reference"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.Transaction_RefExt, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_RefExt, null, false), "Transaction: External ref"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.StockLevel_Bay1, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay1, null, false), "Stock Level: Bay 1"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.StockLevel_Bay2, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay2, null, false), "Stock Level: Bay 2"), + new TypeCodeDesc((int)Sbm.OrgOption_FieldLabel.StockLevel_Bay3, SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Bay3, null, false), "Stock Level: Bay 3") + }; + + // Organisation Option - Transaction Creation Status. + systemCodes[Sbm.SystemCode.OrgOption_TransactionCreationStatus] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_TransCreateStatus.ProformaSalesOrder, "ProFromaSalOrd", "Proforma SO creation status", "Default: 'Preparation'"), + new TypeCodeDesc((int)Sbm.OrgOption_TransCreateStatus.SalesOrder, "SalesOrder", "SO creation status", "Default. 'In progress'") + }; + + // Organisation Option - Container Status Caption. + systemCodes[Sbm.SystemCode.OrgOption_ContainerStatusCaption] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_StatusContainer.Provisional, SacsSystem.GetStatusCode(SaStatus.Provisional), "Provisional"), + new TypeCodeDesc((int)Sbm.OrgOption_StatusContainer.Awaiting, SacsSystem.GetStatusCode(SaStatus.Awaiting), "Awaiting"), + new TypeCodeDesc((int)Sbm.OrgOption_StatusContainer.Active, SacsSystem.GetStatusCode(SaStatus.Active), "Active"), + new TypeCodeDesc((int)Sbm.OrgOption_StatusContainer.Actioned, SacsSystem.GetStatusCode(SaStatus.Actioned), "Actioned"), + new TypeCodeDesc((int)Sbm.OrgOption_StatusContainer.Cancelled, SacsSystem.GetStatusCode(SaStatus.Cancelled), "Cancelled") + }; + + // Organisation Option - Minutes. + systemCodes[Sbm.SystemCode.OrgOption_Minutes] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_Minutes.AutoSaveTransaction, "MinsAutoSaveTrans", "Auto save transactions (minutes)", "") + }; + + // Organisation Option - Period Days. + systemCodes[Sbm.SystemCode.OrgOption_PeriodDays] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_PeriodDays.TransactionDatesInFuture, "TransDatesInFut", "Days in future that transaction dates can be set", ""), + new TypeCodeDesc((int)Sbm.OrgOption_PeriodDays.UpdateClosedTransaction, "UpdClosedTrans", "Grace period (days) for updating closed transactions", "Period after transaction closure during which updates are allowed (0-30 days)"), + new TypeCodeDesc((int)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)"), + new TypeCodeDesc((int)Sbm.OrgOption_PeriodDays.UpdateStockLevelsInPast, "UpdStkLvlInPast", "Update stock levels in past") + }; + + // Organisation Option - Period Weeks. + systemCodes[Sbm.SystemCode.OrgOption_PeriodWeeks] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_PeriodWeeks.Timesheets, "Timesheets", "Weeks of timesheets to list (default 8)"), + new TypeCodeDesc((int)Sbm.OrgOption_PeriodWeeks.UpdateTimeRecords_Control, "UpdTimeRecsCtrl", "Weeks in past for admin user to update time records (default 2)"), + new TypeCodeDesc((int)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)") + }; + + // Organisation Option - Numeric Decimals. + systemCodes[Sbm.SystemCode.OrgOption_NumericDecimals] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_NumericDecimals.OrderQuantity, "OrdQty", "Order quantity"), + new TypeCodeDesc((int)Sbm.OrgOption_NumericDecimals.CommodityWeight, "CmdWeight", "Commodity weight"), + new TypeCodeDesc((int)Sbm.OrgOption_NumericDecimals.CommodityLength, "CmdLength", "Commodity length"), + new TypeCodeDesc((int)Sbm.OrgOption_NumericDecimals.CommodityVolume, "CmdVolume", "Commodity volume"), + new TypeCodeDesc((int)Sbm.OrgOption_NumericDecimals.CommodityDensity, "CmdDensity", "Commodity density") + }; + + // Organisation Option - Commodity Type. + systemCodes[Sbm.SystemCode.OrgOption_CommodityType] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_CommodityType.CommodityCreationDefault, "CmdCreateDflt", "Commodity creation default") + }; + + // Organisation Option - Stock Location. + systemCodes[Sbm.SystemCode.OrgOption_StockLocation] = new List() + { + new TypeCodeDesc((int)Sbm.OrgOption_StockLocation.SalesOrderDefault, "SalOrdDflt", "Sales order default"), + new TypeCodeDesc((int)Sbm.OrgOption_StockLocation.PurchaseOrderDefault, "PurOrdDflt", "Purchase order default"), + new TypeCodeDesc((int)Sbm.OrgOption_StockLocation.TransactionFilterDefault, "TransFltrDflt", "Transaction filter default - replaces 'blank' selection") + }; //--------------------------------------------------------------- // Association organisation options. + // AssociationOrgOption. - associationOptions.Add(Sbm.OrganisationOption.Value, "Value", "Value"); - associationOptions.Add(Sbm.OrganisationOption.Folder, "Folder", "Folder"); - associationOptions.Add(Sbm.OrganisationOption.AllowOption, "AllowOpt", "Allow option"); - associationOptions.Add(Sbm.OrganisationOption.Caption, "Caption", "Caption"); - associationOptions.Add(Sbm.OrganisationOption.ShowColumn, "ShowCol", "Show column"); - associationOptions.Add(Sbm.OrganisationOption.ShowField, "ShowFld", "Show field"); - associationOptions.Add(Sbm.OrganisationOption.FieldLabel, "FldLbl", "Field caption"); - associationOptions.Add(Sbm.OrganisationOption.Minutes, "PeriodMins", "Period - minutes"); - associationOptions.Add(Sbm.OrganisationOption.PeriodDays, "PeriodDays", "Period - days"); - associationOptions.Add(Sbm.OrganisationOption.PeriodWeeks, "PeriodWeeks", "Period - weeks"); - associationOptions.Add(Sbm.OrganisationOption.NumericDecimals, "NumDec", "Numeric decimals"); - associationOptions.Add(Sbm.OrganisationOption.CommodityType, "CmdType", "Commodity type"); - associationOptions.Add(Sbm.OrganisationOption.CommodityFilterDefaultStatusCat, "CmdFltStacDflt", "Commodity filter default status"); - associationOptions.Add(Sbm.OrganisationOption.CommodityFilterInitialStockCat, "CmdFltStkCatInit", "Commodity filter initial category"); - associationOptions.Add(Sbm.OrganisationOption.StatusCaption_Container, "CntStatCaption", "Status caption - Container"); - associationOptions.Add(Sbm.OrganisationOption.SalesLocation, "SalesLoc", "Sales location"); + systemCodes[Sbm.SystemCode.AssociationOption] = new List() + { + new TypeCodeDesc((int)Sbm.OrganisationOption.Value, "Value", "Value"), + new TypeCodeDesc((int)Sbm.OrganisationOption.Folder, "Folder", "Folder"), + new TypeCodeDesc((int)Sbm.OrganisationOption.AllowOption, "AllowOpt", "Allow option"), + new TypeCodeDesc((int)Sbm.OrganisationOption.Caption, "Caption", "Caption"), + new TypeCodeDesc((int)Sbm.OrganisationOption.ShowColumn, "ShowCol", "Show column"), + new TypeCodeDesc((int)Sbm.OrganisationOption.ShowField, "ShowFld", "Show field"), + new TypeCodeDesc((int)Sbm.OrganisationOption.FieldLabel, "FldLbl", "Field caption"), + new TypeCodeDesc((int)Sbm.OrganisationOption.Minutes, "PeriodMins", "Period - minutes"), + new TypeCodeDesc((int)Sbm.OrganisationOption.PeriodDays, "PeriodDays", "Period - days"), + new TypeCodeDesc((int)Sbm.OrganisationOption.PeriodWeeks, "PeriodWeeks", "Period - weeks"), + new TypeCodeDesc((int)Sbm.OrganisationOption.NumericDecimals, "NumDec", "Numeric decimals"), + new TypeCodeDesc((int)Sbm.OrganisationOption.CommodityType, "CmdType", "Commodity type"), + new TypeCodeDesc((int)Sbm.OrganisationOption.CommodityFilterDefaultStatusCat, "CmdFltStacDflt", "Commodity filter default status"), + new TypeCodeDesc((int)Sbm.OrganisationOption.CommodityFilterInitialStockCat, "CmdFltStkCatInit", "Commodity filter initial category"), + new TypeCodeDesc((int)Sbm.OrganisationOption.StatusCaption_Container, "CntStatCaption", "Status caption - Container"), + new TypeCodeDesc((int)Sbm.OrganisationOption.SalesLocation, "SalesLoc", "Sales location") + }; //--------------------------------------------------------------- // System User options. + // SystemUserOption. - systemUserOptions.Add(Sbm.SystemUserOption.Right, "SecRight", "Security Right"); + systemCodes[Sbm.SystemCode.SystemUserOption] = new List() + { + new TypeCodeDesc((int)Sbm.SystemUserOption.Right, "SecRight", "Security Right") + }; //--------------------------------------------------------------- // Interface options. + // InterfaceOption. - interfaceOptions.Add(Sbm.InterfaceOption.Value, "Value", "Value"); - interfaceOptions.Add(Sbm.InterfaceOption.Flag, "Flag", "Flag"); - interfaceOptions.Add(Sbm.InterfaceOption.Hidden, "Hidden", "Hidden"); - interfaceOptions.Add(Sbm.InterfaceOption.Mode, "Mode", "Mode"); - interfaceOptions.Add(Sbm.InterfaceOption.ReadOnly, "ReadOnly", "ReadOnly"); - interfaceOptions.Add(Sbm.InterfaceOption.HostPc, "HostPC", "Host PC"); - interfaceOptions.Add(Sbm.InterfaceOption.Folder, "Folder", "Folder"); - interfaceOptions.Add(Sbm.InterfaceOption.UnitMeasure, "UOM", "Unit of measure"); - interfaceOptions.Add(Sbm.InterfaceOption.TaxCodeColumn, "TaxCodeCol", "Equivalent tax code column", "To convert tax codes between systems."); - interfaceOptions.Add(Sbm.InterfaceOption.Portfolio, "Portfolio", "Portfolio"); - interfaceOptions.Add(Sbm.InterfaceOption.PriceSet, "PriceSet", "Price Set", ""); - interfaceOptions.Add(Sbm.InterfaceOption.TransactionCreationStatus, "TransCreateStat", "Transaction creation status"); - interfaceOptions.Add(Sbm.InterfaceOption.BackgroundColour, "BackgroundColour", "Background colour"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_UrlHome, "UrlHome", "Website home URL"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_UrlCgiBin, "UrlCgiBin", "Website cgi-bin URL"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_FtpHost, "FtpHost", "FTP host server"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_FtpUser, "FtpUser", "FTP user"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_FtpPword, "FtpPword", "FTP password"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_FtpPathWebHome, "FtpPathWebHome", "Web home folder"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_FtpPathWebCgiBin, "FtpPathWebCgiBin", "Web cgi-bin folder"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_FtpPathWebDataRoot, "FtpPathWebDataRoot", "WebData folder"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_ServerPathWebDataRoot, "ServerPathWebDataRoot", "Server WebData path"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_Upload_PerlShebang, "PerlSheBang", "Perl SheBang"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_Upload_Data, "UploadData", "Upload data"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_Upload_Method, "UploadMethod", "Upload method"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_Download_Data, "DownloadData", "Download data"); - interfaceOptions.Add(Sbm.InterfaceOption.WebStore_Download_Method, "DownloadMethod", "Download method"); - interfaceOptions.Add(Sbm.InterfaceOption.File_RecordType, "FileRecType", "Record type"); - interfaceOptions.Add(Sbm.InterfaceOption.File_ItemLocation, "FileItemLoc", "Data item location"); - interfaceOptions.Add(Sbm.InterfaceOption.File_ItemRow, "FileItemRow", "Item row"); - interfaceOptions.Add(Sbm.InterfaceOption.File_ItemColumn, "FileItemCol", "Item column"); - interfaceOptions.Add(Sbm.InterfaceOption.File_ColumnWidth, "FileItemColWidth", "Column width"); - interfaceOptions.Add(Sbm.InterfaceOption.File_ColumnCaption, "FileItemColCaption", "Column caption"); + systemCodes[Sbm.SystemCode.InterfaceOption] = new List() + { + new TypeCodeDesc((int)Sbm.InterfaceOption.Value, "Value", "Value"), + new TypeCodeDesc((int)Sbm.InterfaceOption.Flag, "Flag", "Flag"), + new TypeCodeDesc((int)Sbm.InterfaceOption.Hidden, "Hidden", "Hidden"), + new TypeCodeDesc((int)Sbm.InterfaceOption.Mode, "Mode", "Mode"), + new TypeCodeDesc((int)Sbm.InterfaceOption.ReadOnly, "ReadOnly", "ReadOnly"), + new TypeCodeDesc((int)Sbm.InterfaceOption.HostPc, "HostPC", "Host PC"), + new TypeCodeDesc((int)Sbm.InterfaceOption.Folder, "Folder", "Folder"), + new TypeCodeDesc((int)Sbm.InterfaceOption.UnitMeasure, "UOM", "Unit of measure"), + new TypeCodeDesc((int)Sbm.InterfaceOption.TaxCodeColumn, "TaxCodeCol", "Equivalent tax code column", "To convert tax codes between systems."), + new TypeCodeDesc((int)Sbm.InterfaceOption.Portfolio, "Portfolio", "Portfolio"), + new TypeCodeDesc((int)Sbm.InterfaceOption.PriceSet, "PriceSet", "Price Set", ""), + new TypeCodeDesc((int)Sbm.InterfaceOption.TransactionCreationStatus, "TransCreateStat", "Transaction creation status"), + new TypeCodeDesc((int)Sbm.InterfaceOption.BackgroundColour, "BackgroundColour", "Background colour"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_UrlHome, "UrlHome", "Website home URL"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_UrlCgiBin, "UrlCgiBin", "Website cgi-bin URL"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_FtpHost, "FtpHost", "FTP host server"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_FtpUser, "FtpUser", "FTP user"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_FtpPword, "FtpPword", "FTP password"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_FtpPathWebHome, "FtpPathWebHome", "Web home folder"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_FtpPathWebCgiBin, "FtpPathWebCgiBin", "Web cgi-bin folder"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_FtpPathWebDataRoot, "FtpPathWebDataRoot", "WebData folder"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_ServerPathWebDataRoot, "ServerPathWebDataRoot", "Server WebData path"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_Upload_PerlShebang, "PerlSheBang", "Perl SheBang"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_Upload_Data, "UploadData", "Upload data"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_Upload_Method, "UploadMethod", "Upload method"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_Download_Data, "DownloadData", "Download data"), + new TypeCodeDesc((int)Sbm.InterfaceOption.WebStore_Download_Method, "DownloadMethod", "Download method"), + new TypeCodeDesc((int)Sbm.InterfaceOption.File_RecordType, "FileRecType", "Record type"), + new TypeCodeDesc((int)Sbm.InterfaceOption.File_ItemLocation, "FileItemLoc", "Data item location"), + new TypeCodeDesc((int)Sbm.InterfaceOption.File_ItemRow, "FileItemRow", "Item row"), + new TypeCodeDesc((int)Sbm.InterfaceOption.File_ItemColumn, "FileItemCol", "Item column"), + new TypeCodeDesc((int)Sbm.InterfaceOption.File_ColumnWidth, "FileItemColWidth", "Column width"), + new TypeCodeDesc((int)Sbm.InterfaceOption.File_ColumnCaption, "FileItemColCaption", "Column caption") + }; //--------------------------------------------------------------- // Generic item options. + // OrgOption_TaxCodeColumn. // eg. for Sage and other system interfaces. - orgOption_TaxCodeColumns.Add(SaTaxCodeColumn.Code, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_Code), "Code"); - orgOption_TaxCodeColumns.Add(SaTaxCodeColumn.CodeAlt1, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1), "Alternative code 1"); - orgOption_TaxCodeColumns.Add(SaTaxCodeColumn.CodeAlt2, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt2), "Alternative code 2"); + systemCodes[Sbm.SystemCode.OrgOption_TaxCodeColumn] = new List() + { + new TypeCodeDesc((int)SaTaxCodeColumn.Code, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_Code), "Code"), + new TypeCodeDesc((int)SaTaxCodeColumn.CodeAlt1, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt1), "Alternative code 1"), + new TypeCodeDesc((int)SaTaxCodeColumn.CodeAlt2, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.TaxCode_CodeAlt2), "Alternative code 2") + }; //--------------------------------------------------------------- // Website interface configuration. + // InterfaceOption_WebFlag. - interfaceOption_WebFlags.Add(Sbm.SystemInterface_Website_Flag.IncludeImminentStock, "IncImminStock", "Include imminent stock in current level"); - interfaceOption_WebFlags.Add(Sbm.SystemInterface_Website_Flag.AllowZeroOrderItemAmount, "AllowZeroOrdItmAmt", "Allow zero order item amount"); + systemCodes[Sbm.SystemCode.InterfaceOption_WebFlag] = new List() + { + new TypeCodeDesc((int)Sbm.SystemInterface_Website_Flag.IncludeImminentStock, "IncImminStock", "Include imminent stock in current level"), + new TypeCodeDesc((int)Sbm.SystemInterface_Website_Flag.AllowZeroOrderItemAmount, "AllowZeroOrdItmAmt", "Allow zero order item amount") + }; + // InterfaceOption_WebUploadData. - interfaceOption_WebUploadDatas.Add(Sbm.WebUploadData.Portfolio, "Portfolio", "Portfolio"); - interfaceOption_WebUploadDatas.Add(Sbm.WebUploadData.StockLevels, "StockLevels", "Stock Levels"); - interfaceOption_WebUploadDatas.Add(Sbm.WebUploadData.Accounts, "Accounts", "Accounts"); - interfaceOption_WebUploadDatas.Add(Sbm.WebUploadData.SalesProfile, "SalesProfile", "Sales Profile"); + systemCodes[Sbm.SystemCode.InterfaceOption_WebUploadData] = new List() + { + new TypeCodeDesc((int)Sbm.WebUploadData.Portfolio, "Portfolio", "Portfolio"), + new TypeCodeDesc((int)Sbm.WebUploadData.StockLevels, "StockLevels", "Stock Levels"), + new TypeCodeDesc((int)Sbm.WebUploadData.Accounts, "Accounts", "Accounts"), + new TypeCodeDesc((int)Sbm.WebUploadData.SalesProfile, "SalesProfile", "Sales Profile") + }; + //InterfaceOption_WebUploadMethod. - interfaceOption_WebUploadMethods.Add(Sbm.WebUploadMethod.None, "None", "None"); - interfaceOption_WebUploadMethods.Add(Sbm.WebUploadMethod.Ftp, "FTP", "FTP"); - interfaceOption_WebUploadMethods.Add(Sbm.WebUploadMethod.Webstore, "SWS", "Webstore"); + systemCodes[Sbm.SystemCode.InterfaceOption_WebUploadMethod] = new List() + { + new TypeCodeDesc((int)Sbm.WebUploadMethod.None, "None", "None"), + new TypeCodeDesc((int)Sbm.WebUploadMethod.Ftp, "FTP", "FTP"), + new TypeCodeDesc((int)Sbm.WebUploadMethod.Webstore, "SWS", "Webstore") + }; + // InterfaceOption_WebDownloadData. - interfaceOption_WebDownloadDatas.Add(Sbm.WebDownloadData.Orders, "Orders", "Orders"); + systemCodes[Sbm.SystemCode.InterfaceOption_WebDownloadData] = new List() + { + new TypeCodeDesc((int)Sbm.WebDownloadData.Orders, "Orders", "Orders") + }; + //InterfaceOption_WebDownloadMethod. - interfaceOption_WebDownloadMethods.Add(Sbm.WebDownloadMethod.None, "None", "None"); - interfaceOption_WebDownloadMethods.Add(Sbm.WebDownloadMethod.Ftp, "FTP", "FTP"); - interfaceOption_WebDownloadMethods.Add(Sbm.WebDownloadMethod.Webstore, "SWS", "Webstore"); + systemCodes[Sbm.SystemCode.InterfaceOption_WebDownloadMethod] = new List() + { + new TypeCodeDesc((int)Sbm.WebDownloadMethod.None, "None", "None"), + new TypeCodeDesc((int)Sbm.WebDownloadMethod.Ftp, "FTP", "FTP"), + new TypeCodeDesc((int)Sbm.WebDownloadMethod.Webstore, "SWS", "Webstore") + }; //--------------------------------------------------------------- // Generic File Interface options. + // File Interface - Row Column values. - fileInterface_RowColValues.Add(Sbm.FileInterface_RowColValue.Row, "Row", "Row"); - fileInterface_RowColValues.Add(Sbm.FileInterface_RowColValue.Col, "Col", "Column"); - fileInterface_RowColValues.Add(Sbm.FileInterface_RowColValue.Value, "Val", "Value"); + systemCodes[Sbm.SystemCode.FileInterface_RowColValue] = new List() + { + new TypeCodeDesc((int)Sbm.FileInterface_RowColValue.Row, "Row", "Row"), + new TypeCodeDesc((int)Sbm.FileInterface_RowColValue.Col, "Col", "Column"), + new TypeCodeDesc((int)Sbm.FileInterface_RowColValue.Value, "Val", "Value") + }; // File Interface - Mode. - fileInterface_Modes.Add(Sbm.FileInterface_Mode.Csv, "CSV", "Comma separated file (csv)", ""); - fileInterface_Modes.Add(Sbm.FileInterface_Mode.MsExcel, "MSExcel", "MS Excel workbook", ""); + systemCodes[Sbm.SystemCode.FileInterface_Mode] = new List() + { + new TypeCodeDesc((int)Sbm.FileInterface_Mode.Csv, "CSV", "Comma separated file (csv)", ""), + new TypeCodeDesc((int)Sbm.FileInterface_Mode.MsExcel, "MSExcel", "MS Excel workbook", "") + }; //--------------------------------------------------------------- // System User configuration. - orgOption_SystemUserRights.Add(Sbm.SystemUserRight.AllAccounts, "AllAccounts", "All accounts"); - orgOption_SystemUserRights.Add(Sbm.SystemUserRight.Admin, "Admin", "Admin"); - orgOption_SystemUserRights.Add(Sbm.SystemUserRight.Test, "Test", "Test"); + systemCodes[Sbm.SystemCode.OrgOption_SystemUserRight] = new List() + { + new TypeCodeDesc((int)Sbm.SystemUserRight.AllAccounts, "AllAccounts", "All accounts"), + new TypeCodeDesc((int)Sbm.SystemUserRight.Admin, "Admin", "Admin"), + new TypeCodeDesc((int)Sbm.SystemUserRight.Test, "Test", "Test") + }; //--------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/App/SbmSystem.cs b/SaBusMgrStandardBase/Base/App/SbmSystem.cs index 803a121..e80aec0 100644 --- a/SaBusMgrStandardBase/Base/App/SbmSystem.cs +++ b/SaBusMgrStandardBase/Base/App/SbmSystem.cs @@ -7,6 +7,7 @@ using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.App { @@ -77,423 +78,33 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App //------------------------------------------------------------------- // 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 GetSystemCodes(Sbm.SystemCode systemCode) { - // In case user context not specified, eg. Security Console initialising list of transaction types before user logged in. - if (userContext != null) - return userContext.GetOwnerOption_Caption(orgOption_Caption, defaultValue); - return defaultValue; - } - public static List 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(itemTypes); - case Sbm.SystemCode.AffiliateType: - return new List(affiliateTypes); - case Sbm.SystemCode.AssociationType: - return new List(associationTypes); - case Sbm.SystemCode.TransactionType: - // Transaction types. - return new List() - { - 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(transactionStatusCats); - case Sbm.SystemCode.RequirementType: - return new List(requirementTypes); - case Sbm.SystemCode.TaskCodeType: - return new List(taskCodeTypes); - case Sbm.SystemCode.RequirementStatusCat: - return new List(requirementStatusCats); - case Sbm.SystemCode.ConstituentType: - return new List(constituentTypes); - case Sbm.SystemCode.ConstituentStatusCat: - return new List(constituentStatusCats); - case Sbm.SystemCode.ItemLinkData: - return new List(itemLinkDatas); - case Sbm.SystemCode.PortfolioItemType: - return new List(portfolioItemTypes); - case Sbm.SystemCode.LocationCategory: - return new List(locationCategories); - case Sbm.SystemCode.LocationFilter: - return new List(locationFilters); - case Sbm.SystemCode.ContainerCategory: - return new List(containerCategories); - case Sbm.SystemCode.ContainerType: - return new List(containerTypes); - case Sbm.SystemCode.CommodityType: - { - // CommodityType. - List CommodityType = new List(); - 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(commodityStatusCats); - case Sbm.SystemCode.MovementType: - return new List(movementTypes); - case Sbm.SystemCode.StockLevelType: - return new List(stockLevelTypes); - case Sbm.SystemCode.StockLevelSource: - return new List(stockLevelSources); - case Sbm.SystemCode.AddressType: - return new List(addressTypes); - case Sbm.SystemCode.SysParamCategory: - return new List(sysParamCategories); - case Sbm.SystemCode.ProcessCategory: - { - List ProcessCategory = new List(); - 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(processTypes); - case Sbm.SystemCode.PaymentType: - return new List(paymentTypes); - case Sbm.SystemCode.AssetIncomeType: - return new List(assetIncomeTypes); - case Sbm.SystemCode.AssetType: - return new List(assetTypes); - case Sbm.SystemCode.VehicleType: - return new List(vehicleTypes); - case Sbm.SystemCode.VehicleEventType: - return new List(vehicleEventTypes); - case Sbm.SystemCode.VehicleFeatureSource: - return new List(vVehicleFeatureSources); - case Sbm.SystemCode.VehicleFeatureType: - return new List(vehicleFeatureTypes); - case Sbm.SystemCode.VehicleOptionType: - return new List(vehicleOptionTypes); - case Sbm.SystemCode.VehicleTransType: - return new List(vehicleTransTypes); - case Sbm.SystemCode.FuelType: - return new List(fuelTypes); - case Sbm.SystemCode.OdometerUnits: - return new List(odometerUnits); - case Sbm.SystemCode.DiscountType: - return new List(discountTypes); - case Sbm.SystemCode.DiscountMarkup: - return new List(discountMarkups); - case Sbm.SystemCode.RegionType: - return new List(regionTypes); - case Sbm.SystemCode.UnitMeasureCategory: - return new List(unitMeasureCategories); - case Sbm.SystemCode.UnitMeasureType: - return new List(unitMeasureTypes); - case Sbm.SystemCode.FinancialType: - { - List FinancialType = new List(); - 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(priceTypes); - case Sbm.SystemCode.PriceCalcMethod: - return new List(priceCalcMethods); - case Sbm.SystemCode.PriceRounderMethod: - return new List(priceRounderMethods); - case Sbm.SystemCode.PriceRounderDirection: - return new List(priceRounderDirections); - case Sbm.SystemCode.SystemAccountType: - return new List(systemAccountTypes); - case Sbm.SystemCode.ItemStatus: - return new List(itemStatuses); - case Sbm.SystemCode.EventStatus: - return new List(eventStatuses); - case Sbm.SystemCode.AssociationTab: - return new List(associationTabs); - case Sbm.SystemCode.InterfaceType_Website: - { - // Interface types - Website. - // Duplicate static list and remove unsupported options. - List codes = new List(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(codes); - } - case Sbm.SystemCode.InterfaceType_Accounts: - { - // Interface Type - Accounts. - // Duplicate static list and remove unsupported options. - List codes = new List(interfaceTypes_Accounts); - return new List(codes); - } - case Sbm.SystemCode.InterfaceType_System: - { - // Interface Type - System. - // Duplicate static list and remove unsupported options. - List codes = new List(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(codes); - } - case Sbm.SystemCode.InterfaceType_File: - { - // Interface Type - File. - // Duplicate static list and remove unsupported options. - List codes = new List(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(codes); - } - case Sbm.SystemCode.InterfaceDataType: - return new List(interfaceDataTypes); - case Sbm.SystemCode.ItemDataType: - return new List(itemDataTypes); - case Sbm.SystemCode.OrgOption_Value: - return new List(orgOption_Values); - case Sbm.SystemCode.OrgOption_Folder: - return new List(orgOption_Folders); - case Sbm.SystemCode.OrgOption_Minutes: - return new List(OrgOption_Minutes); - case Sbm.SystemCode.OrgOption_PeriodDays: - { - List OrgOption_PeriodDays = new List(); - - 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 OrgOption_PeriodWeeks = new List(); - 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(orgOption_AllowOptions); - case Sbm.SystemCode.OrgOption_Caption: - { - List OrgOption_Caption = new List(); - 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 OrgOption_ShowColumn = new List(); - 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(orgOption_ShowFields); - case Sbm.SystemCode.OrgOption_FieldLabel: - return new List(orgOption_FieldLabels); - case Sbm.SystemCode.OrgOption_TransactionCreationStatus: - return new List(orgOption_TransactionCreationStatuses); - case Sbm.SystemCode.OrgOption_ContainerStatusCaption: - return new List(orgOption_ContainerStatusCaptions); - case Sbm.SystemCode.OrgOption_NumericDecimals: - return new List(orgOption_NumericDecimals); - case Sbm.SystemCode.OrgOption_CommodityType: - return new List(orgOption_CommodityTypes); - case Sbm.SystemCode.OrgOption_StockLocation: - return new List(orgOption_StockLocations); - case Sbm.SystemCode.OrgOption_TaxCodeColumn: - return new List(orgOption_TaxCodeColumns); - case Sbm.SystemCode.OrgOption_SystemUserRight: - return new List(orgOption_SystemUserRights); - case Sbm.SystemCode.SystemUserOption: - return new List(systemUserOptions); - case Sbm.SystemCode.AssociationOption: - return new List(associationOptions); - case Sbm.SystemCode.InterfaceOption: - return new List(interfaceOptions); - case Sbm.SystemCode.InterfaceOption_WebFlag: - return new List(interfaceOption_WebFlags); - case Sbm.SystemCode.InterfaceOption_WebUploadData: - return new List(interfaceOption_WebUploadDatas); - case Sbm.SystemCode.InterfaceOption_WebUploadMethod: - return new List(interfaceOption_WebUploadMethods); - case Sbm.SystemCode.InterfaceOption_WebDownloadData: - return new List(interfaceOption_WebDownloadDatas); - case Sbm.SystemCode.InterfaceOption_WebDownloadMethod: - return new List(interfaceOption_WebDownloadMethods); - case Sbm.SystemCode.FileInterface_RowColValue: - return new List(fileInterface_RowColValues); - case Sbm.SystemCode.FileInterface_Mode: - return new List(fileInterface_Modes); - } - } - return null; + List codes = systemCodes.GetValueOrDefault(systemCode); + if (codes == null) + SaLogger.Warn($"{SysUtil.Fn} Unrecognised system code type: {systemCode}."); + return codes; } //------------------------------------------------------------------- // D a t a M a n a g e r s //------------------------------------------------------------------- - public abstract SbmAccountMgr CreateAccountMgr(ISbmUserContext_Core userContext); - public abstract SbmAssetMgr CreateAssetMgr(ISbmUserContext_Core userContext); - public abstract SbmCommodityMgr CreateCommodityMgr(ISbmUserContext_Core userContext); - public abstract SbmPriceMgr CreatePriceMgr(ISbmUserContext_Core userContext); - public abstract SbmDataItemMgr CreateDataItemMgr(ISbmUserContext_Core userContext); - public abstract SbmProcessMgr CreateProcessMgr(ISbmUserContext_Core userContext); - public abstract SbmStockMgr CreateStockMgr(ISbmUserContext_Core userContext); - public abstract SbmTransactionMgr CreateTransactionMgr(ISbmUserContext_Core userContext); + public abstract SbmAccountMgr CreateAccountMgr(SbmInternals internals); + public abstract SbmAccountMgr CreateAccountMgr(ISbmUserOrganisationContext userContext); + public abstract SbmAssetMgr CreateAssetMgr(SbmInternals internals); + public abstract SbmAssetMgr CreateAssetMgr(ISbmUserOrganisationContext userContext); + public abstract SbmCommodityMgr CreateCommodityMgr(SbmInternals internals); + public abstract SbmCommodityMgr CreateCommodityMgr(ISbmUserOrganisationContext userContext); + public abstract SbmPriceMgr CreatePriceMgr(SbmInternals internals); + 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. public abstract SbmcAccountMgr CreateControlAccountMgr(); public abstract SbmcInstanceMgr CreateControlInstanceMgr(); diff --git a/SaBusMgrStandardBase/Base/App/SbmUserContext.cs b/SaBusMgrStandardBase/Base/App/SbmUserContext.cs index 26c6e63..d8c7a95 100644 --- a/SaBusMgrStandardBase/Base/App/SbmUserContext.cs +++ b/SaBusMgrStandardBase/Base/App/SbmUserContext.cs @@ -14,7 +14,7 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.App { //======================================================================= - public class SbmUserContext : ISbmUserContext_Core + public class SbmUserContext : ISbmUserOrganisationContext { //------------------------------------------------------------------- // Definitions. @@ -69,8 +69,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public class OrganisationData { internal OrganisationData() { } - // Organisation options. - internal readonly SaItemOption.Cache configOptionsCache = new SaItemOption.Cache(); /// Organisation Affiliate Id. public SysId AffiliateId { get; protected set; } = new SysId(); /// Organisation Affiliate Type. @@ -81,8 +79,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App public String InterfaceContext { get; protected set; } = ""; /// Organisation 'Internal' Association Id. public SysId AssociationId { get; protected set; } = new SysId(); - /// Organisation configuration options - public List ConfigOptions { get { return new List(configOptionsCache.ItemOptions); } } } private class OrganisationData_Internal : OrganisationData { @@ -93,7 +89,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App AffiliateType = Sbm.AffiliateType.Unknown; DisplayName = ""; InterfaceContext = ""; - configOptionsCache.Clear(); } internal void Refresh(SbmAffiliate affiliateOrganisation, SbmAssociation associationInternal, String interfaceContext) { @@ -109,21 +104,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Data members. private readonly UserData_Internal userData = new UserData_Internal(); private readonly OrganisationData_Internal organisationData; - private List assocOptions; - private List contextValues; - private List contextFolders; - private List contextAllowOptions; - private List contextCaptions; - private List contextShowColumns; - private List contextShowFields; - private List contextFieldLabels; - private List contextMinutes; - private List contextPeriodDays; - private List contextPeriodWeeks; - private List contextNumericDecimals; - private List contextCommodityTypes; - private List commodityTypes; - private List contextSalesLocations; //------------------------------------------------------------------- // Construction. @@ -170,138 +150,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App private SbmSecurityProfile securityProfile { get; set; } 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. protected void SetUserData(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List supervisedOwners) @@ -319,44 +167,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App // Interface context for selected organisation. String interfaceContext = SbmAccountMgr.GetInterfaceContext(affiliateIdOrganisation); - SbmAffiliate affiliateOrganisation = null; - SbmAssociation associationInternal = null; if (SysId.IsValid(affiliateIdOrganisation)) { using (SbmAccountMgr accountMgr = SbmGlobals.System.CreateAccountMgr(this)) - { - // Affiliate. - affiliateOrganisation = accountMgr.GetAffiliateById(affiliateIdOrganisation); - // 'Internal' association. - associationInternal = accountMgr.GetAssociationByOwnerTypeTarget(affiliateIdOrganisation, Sbm.AssociationType.Internal, affiliateIdOrganisation); - } - } + // Affiliate. + using (SbmAffiliate affiliateOrganisation = accountMgr.GetAffiliateById(affiliateIdOrganisation)) + // 'Internal' association. + using (SbmAssociation associationInternal = accountMgr.GetAssociationByOwnerTypeTarget(affiliateIdOrganisation, Sbm.AssociationType.Internal, affiliateIdOrganisation)) - if (affiliateOrganisation != null && associationInternal != null) - { - // Refresh the organisation properties. - 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)) + if (affiliateOrganisation != null && associationInternal != null) { - 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}."); - } + // Refresh the organisation properties. + organisationData.Refresh(affiliateOrganisation, associationInternal, interfaceContext); } - } + else ClearOrganisationData(); } - else ClearOrganisationData(); - if (affiliateOrganisation != null) affiliateOrganisation.Dispose(); affiliateOrganisation = null; - if (associationInternal != null) associationInternal.Dispose(); associationInternal = null; } protected void ClearOrganisationData() { diff --git a/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs b/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs index 979da98..b350c99 100644 --- a/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs +++ b/SaBusMgrStandardBase/Base/Bus/Control/SbmcItemParam.cs @@ -240,6 +240,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus.Control public HashSet ItemIdsIncluded { get; } = new HashSet(); /// Generic search value - name, contact, email, phone etc. public String Search { get; set; } + public String Context { get; set; } + public String Name { get; set; } public String NotesPartial { get; set; } /// Contact status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-QuickBooks.cs b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-QuickBooks.cs index 262eee7..556796f 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-QuickBooks.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-QuickBooks.cs @@ -155,7 +155,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } private class QBooksParams { - public QBooksParams(ISbmUserContext_Core userContext) + public QBooksParams(ISbmUserOrganisationContext userContext) { } // QuickBooks interface definitions. @@ -324,7 +324,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus itemOption.DisplayOptions.Group = OptionGroup_Data; itemOption.Name = sageStatics.InterfaceOptions.GetCodeForType(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); interfaceItemOptionDfns.Add(itemOption); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-Sage.cs b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-Sage.cs index d215b60..1e5fa65 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-Sage.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn-Sage.cs @@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus } private class SageParams { - public SageParams(ISbmUserContext_Core userContext, SbmInternals internals) + public SageParams(ISbmUserOrganisationContext userContext, SbmInternals internals) { UserContext = userContext; 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"); } //--------------------------------------------------------------- - private ISbmUserContext_Core UserContext { get; } + private ISbmUserOrganisationContext UserContext { get; } private readonly SbmInternals internals; // Sage interface definitions. 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.Name = sageStatics.InterfaceOptions.GetCodeForType(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); interfaceItemOptionDfns.Add(itemOption); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs index 6f87c0b..13ca9e2 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAccountsDfn.cs @@ -63,13 +63,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Construction. - public SbmAccountsDfn(ISbmUserContext_Core userContext) + public SbmAccountsDfn(ISbmUserOrganisationContext userContext) { UserContext = userContext; internals = new SbmInternals(userContext); sageParams = new SageParams(userContext, internals); qbkParams = new QBooksParams(userContext); - interfaceOptions = SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.InterfaceOption); + interfaceOptions = internals.GetSystemCodes(Sbm.SystemCode.InterfaceOption); Reset(); } protected override void Dispose(bool disposing) @@ -83,7 +83,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } protected SaInterfaceConsole InterfaceConsole { get { return internals.InterfaceConsole; } } protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs b/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs index c5b6285..e899b9a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAddress.cs @@ -356,7 +356,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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.SetData(data); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs index 9e0103a..98d87b8 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAffiliate.cs @@ -340,7 +340,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateType = affiliateType; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs b/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs index 36d416b..4e7ae37 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAsset.cs @@ -376,7 +376,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); Id = id; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs index f864ce9..cbd88fc 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssetCategory.cs @@ -215,7 +215,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus private readonly Data data = new Data(); //------------------------------------------------------------------- // 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); AffIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs index caebb33..c008032 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssetProcess.cs @@ -122,7 +122,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus private readonly Data data = new Data(); //------------------------------------------------------------------- // 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); Id = id; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs b/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs index 40790df..51c6d8e 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmAssociation.cs @@ -504,7 +504,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs index 60cfcd1..8da103c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommodity.cs @@ -1086,7 +1086,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; @@ -1858,7 +1858,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus /// Commodity status. public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; // Utilities. - public List GetDisplayValues(ISbmUserContext_Core userContext) + public List GetDisplayValues(ISbmUserOrganisationContext userContext) { SbmAccountMgr accountMgr = null; List lValue = new List(); @@ -1868,7 +1868,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus if (IdsIncluded.Count > 0) lValue.Add("Included commodities", IdsIncluded.Count.ToString()); if (IdsExcluded.Count > 0) lValue.Add("Excluded commodities", IdsExcluded.Count.ToString()); // 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"); if (StockItemsOnly) lValue.Add("Stock items only", "True"); // Commodity code. diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs index 214445e..3d26408 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommodityCustomer.cs @@ -125,7 +125,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); CommodityId = commodityId; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs b/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs index ed70b12..bc3fa39 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCommoditySupplier.cs @@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); CommodityId = commodityId; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs b/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs index 0814d6b..3882a0d 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmConstituent.cs @@ -395,7 +395,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); Id = id; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs b/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs index ccde9bb..878d8ac 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmContainer.cs @@ -156,7 +156,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs index 05ad8d4..ade9287 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmContainerItem.cs @@ -159,7 +159,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); ContainerId = containerId; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs b/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs index 9b09881..35da021 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmCostEstimate.cs @@ -134,13 +134,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Construction. - public SbmCostEstimate(ISbmUserContext_Core userContext, Sbm.CostEstimateCategory costEstimateCategory) : base(userContext) + public SbmCostEstimate(ISbmUserOrganisationContext userContext, Sbm.CostEstimateCategory costEstimateCategory) : base(userContext) { CostEstimateCategory = costEstimateCategory; Status = DefaultStatus; } // 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); 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 values, ISbmUserContext_Core userContext, SbmInternals internals, SbmCommodity commodity, decimal quantity) + public static void SetCommodityCosts(this List values, ISbmUserOrganisationContext userContext, SbmInternals internals, SbmCommodity commodity, decimal quantity) { // Retrieve costs from commodity and remove unwanted costs (for other quantities). List costEstimatesCommodity = internals.CommodityMgr.GetCommodityCostEstimates(commodity); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmHierarchyItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmHierarchyItem.cs index 6a3de25..a288eb7 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmHierarchyItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmHierarchyItem.cs @@ -9,18 +9,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus { //------------------------------------------------------------------- // Construction. - protected SbmHierarchyItem(ISbmUserContext_Core userContext) : base() + protected SbmHierarchyItem(ISbmUserOrganisationContext userContext) : base() { UserContext = userContext; } - protected SbmHierarchyItem(ISbmUserContext_Core userContext, SysId id) : base(id) + protected SbmHierarchyItem(ISbmUserOrganisationContext userContext, SysId id) : base(id) { UserContext = userContext; } //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs index 06a15d0..b080e6a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemBatch.cs @@ -118,7 +118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs index efc6d48..db702d3 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemLink.cs @@ -152,7 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); ItemLinkType = itemLinkType; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs index ed512ee..9937063 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemPrice.cs @@ -92,12 +92,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Construction. - public SbmItemPrice(ISbmUserContext_Core userContext) : base(userContext) + public SbmItemPrice(ISbmUserOrganisationContext userContext) : base(userContext) { Status = DefaultStatus; } // 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); type = (data.Length > 1 ? data[1] : ""); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs index 04b3a52..ad0f639 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmItemProcess.cs @@ -185,7 +185,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); ItemType = itemType; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs b/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs index 466d068..9f0542c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmLocation.cs @@ -113,7 +113,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs b/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs index d3cd1bb..2b1117a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmMovement.cs @@ -171,7 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static readonly Byte Flag_DiaryEntry = 0x01; //------------------------------------------------------------------- // 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); ItemType = itemType; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs b/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs index 2540f31..4913da4 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPortfolioItem.cs @@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs b/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs index f3d8aea..06999e2 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPrice.cs @@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); PriceSetId = priceSetId; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs b/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs index 6ee401a..0ecf2d8 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmPriceSet.cs @@ -121,7 +121,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs b/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs index e90cc03..c6a338e 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmProcess.cs @@ -129,7 +129,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs b/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs index 42dc143..2491934 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmRequirement.cs @@ -702,7 +702,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmRequirementCosts.cs b/SaBusMgrStandardBase/Base/Bus/SbmRequirementCosts.cs index 1f62162..7279ee2 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmRequirementCosts.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmRequirementCosts.cs @@ -140,14 +140,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Construction. - public SbmRequirementCosts(ISbmUserContext_Core userContext) + public SbmRequirementCosts(ISbmUserOrganisationContext userContext) { UserContext = userContext; } //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } //------------------------------------------------------------------- // Calculation. @@ -279,8 +279,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus PurchaseCostsPopulated = true; int decimalsPercent = 2; - List ItemLinkDataTypes = new List(); - ItemLinkDataTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemLinkData); + List ItemLinkDataTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemLinkData); String dataTypeCostProportion = ItemLinkDataTypes.GetCodeForType(Sbm.ItemLinkData.Requirement_AssocItem_PurchaseCostProportion); if (itemLinks == null) { diff --git a/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs b/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs index 8edaf92..7bd918c 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmStockLevel.cs @@ -156,7 +156,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); CommodityId = idCommodity; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs b/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs index 0347293..e6e9c29 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSysParam.cs @@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); Category = category; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs index 18f673a..12b8c67 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccount.cs @@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs index 80425db..5925a23 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemAccountUser.cs @@ -91,7 +91,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AccountId = accountId; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs b/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs index 526b835..7c4637d 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmSystemUser.cs @@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); AffiliateIdOwner = affiliateIdOwner; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs b/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs index 0c94a39..c7fd66a 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmTransaction.cs @@ -648,7 +648,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); Id = id; @@ -794,10 +794,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Status Categories. - public static List GetTransactionStatusCats(ISbmUserContext_Core userContext, Sbm.TransactionType transactionType) + public static List GetTransactionStatusCats(ISbmUserOrganisationContext userContext, Sbm.TransactionType transactionType) { List statusCats = new List(); - List statusCatsFull = SbmSystem.GetCodesOfType(userContext, Sbm.SystemCode.TransactionStatusCat); + List statusCatsFull = SbmSystem.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat); switch (transactionType) { // 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); } - 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. SbmTransaction.StatusCat transactionStatusCat = GetCategoryForStatus(status); @@ -951,7 +951,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus bool updateRequired = true; 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"; String message = "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; 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"; String message = "All of the requirements against this " + transactionType + "\nhave been completed.\n\nSet the status to 'Completed'?"; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs b/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs index 1142be1..7c37778 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmTransactionPayment.cs @@ -90,12 +90,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Construction. - public SbmTransactionPayment(ISbmUserContext_Core userContext) : base(userContext) + public SbmTransactionPayment(ISbmUserOrganisationContext userContext) : base(userContext) { Status = DefaultStatus; } // 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); type = (data.Length > 1 ? data[1] : ""); diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs index 987e65f..d10b771 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicle.cs @@ -333,7 +333,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // Construction. - protected SbmVehicle(ISbmUserContext_Core userContext, SysId id) : base(userContext, id) + protected SbmVehicle(ISbmUserOrganisationContext userContext, SysId id) : base(userContext, id) { base.SetData(data); //Database = database; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs index 102674c..d74d818 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleClass.cs @@ -236,7 +236,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus public static readonly Byte Flag_DescBriefFixed = 0x01; //------------------------------------------------------------------- // Construction. - protected SbmVehicleClass(ISbmUserContext_Core userContext, SysId id) : base(userContext, id) + protected SbmVehicleClass(ISbmUserOrganisationContext userContext, SysId id) : base(userContext, id) { base.SetData(data); Status = DefaultStatus; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs index beb95dc..1efca21 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleEvent.cs @@ -185,7 +185,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); VehicleId = vehicleId; diff --git a/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs b/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs index 16a6ed0..233e404 100644 --- a/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs +++ b/SaBusMgrStandardBase/Base/Bus/SbmVehicleFeature.cs @@ -162,7 +162,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Bus //------------------------------------------------------------------- // 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); VehicleId = vehicleId; diff --git a/SaBusMgrStandardBase/Base/Consoles/SbmEmailConsole.cs b/SaBusMgrStandardBase/Base/Consoles/SbmEmailConsole.cs index 5087415..fb9735f 100644 --- a/SaBusMgrStandardBase/Base/Consoles/SbmEmailConsole.cs +++ b/SaBusMgrStandardBase/Base/Consoles/SbmEmailConsole.cs @@ -43,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles /// Replace dynamic tags in email message body. /// /// - public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, ISbmUserContext_Core userContext) + public void ReplaceDynamicEmailBodyTags(SaEmailData emailData, ISbmUserOrganisationContext userContext) { // Replace core tags, eg. main stylesheet. SaEmailConsole.ReplaceDynamicEmailTags(emailData); diff --git a/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole-Transactions.cs b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole-Transactions.cs new file mode 100644 index 0000000..7394e3c --- /dev/null +++ b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole-Transactions.cs @@ -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 +{ + //======================================================================= + /// + /// Session Console - Transaction processing options/rules. + /// + 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; + } + + //------------------------------------------------------------------- + /// Transaction reference prefix by type + 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 GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom) + { + // Build the list of transaction types that are allowed to be raised from the specified type. + List transTypes = new List(); + 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 GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo) + { + // Build the list of transaction types that are allowed to be raised to the specified type. + List transTypes = new List(); + 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 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; + } + */ + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs index f3f7827..138fa02 100644 --- a/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs +++ b/SaBusMgrStandardBase/Base/Consoles/SbmSessionConsole.cs @@ -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.Core; using Sarand.BusinessMgr.Net.Standard.Base.Procs; @@ -12,6 +13,9 @@ using Sarand.Net.Standard.Base.ItemOptions; using Sarand.Net.Standard.Base.Utils; using System; using System.Collections.Generic; +using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm; +using static Sarand.Net.Standard.Base.Core.StringPair; +using static Sarand.Net.Standard.Base.ItemOptions.SaItemOptionDfn; namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { @@ -19,7 +23,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles /// /// Application configuration associated with a specific session. /// - public class SbmSessionConsole : SacsDisposable + public partial class SbmSessionConsole : SacsDisposable, ISbmOrganisationConfig { //------------------------------------------------------------------- // Interface definition. @@ -73,6 +77,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles private SbmInternals internals; private List transactionTypes_Full = new List(); private SbmInstanceConfig instanceConfig; + private SbmOrganisationConfig organisationConfig; private AccountsInterfaceDfn dfnSageInt = new AccountsInterfaceDfn(); private AccountsInterfaceDfn dfnQBooksInt = new AccountsInterfaceDfn(); private bool createTransaction_PurchaseOrder, createTransaction_SalesQuote, createTransaction_SalesOrder, createTrans_SalesInvoice; @@ -80,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Construction. - protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserContext_Core userContext) + protected SbmSessionConsole(Sbm.SessionConfig sessionConfig, SbmVersion consoleVersion, ISbmUserOrganisationContext userContext) { this.SessionConfig = sessionConfig; this.AppVersion = new SbmVersion("BusinessMgr", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt); @@ -98,20 +103,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles //------------------------------------------------------------------- // Properties. public Sbm.SessionConfig SessionConfig { get; } - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } public SbmVersion AppVersion { get; } public SbmVersion ConsoleVersion { get; } 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; } } //------------------------------------------------------------------- // 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."); - // Default console. + // Initialise console. SbmVersion consoleVersion = new SbmVersion("Standard", Sbm.Version.GetFullVersion(), SacsSystem.AssemblyBuildAt); return new SbmSessionConsole(Sbm.SessionConfig.Generic, consoleVersion, userContext); } @@ -120,7 +125,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // 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. public virtual string GetApplicationCaption(Sbm.CaptionType captionType) @@ -160,20 +229,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // Application. case Sbm.ConfigOption.SystemMenu: return InstanceConfig.AllowApplicationOption(option, SacsSystem.DebugMode); - case Sbm.ConfigOption.AllowConsoleView: - case Sbm.ConfigOption.AllowOrganisationUpdate: - case Sbm.ConfigOption.AllowContacts: - case Sbm.ConfigOption.AllowProcesses: - case Sbm.ConfigOption.AllowCommodities: - case Sbm.ConfigOption.AllowTransactions: + // Options allowed by default. + case Sbm.ConfigOption.ConsoleView: + case Sbm.ConfigOption.OrganisationUpdate: + case Sbm.ConfigOption.Contacts: + case Sbm.ConfigOption.Processes: + case Sbm.ConfigOption.Commodities: + case Sbm.ConfigOption.Transactions: case Sbm.ConfigOption.DiaryView: - case Sbm.ConfigOption.AllowRequirementUpdateInline: + case Sbm.ConfigOption.RequirementUpdateInline: return InstanceConfig.AllowApplicationOption(option, true); // Commodities. case Sbm.ConfigOption.CommodityPartialCodeFilter: if (InstanceConfig.AllowApplicationOption(option, false)) return true; - return UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter); + return OrganisationConfig.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter); // Order Pricing. case Sbm.ConfigOption.CustomerPriceSet: case Sbm.ConfigOption.CustomerDiscount: @@ -189,8 +259,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles return true; 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); } //------------------------------------------------------------------- @@ -334,24 +406,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // I t e m s //------------------------------------------------------------------- // Item Data Interface. - public virtual bool CanUpdateItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType) + public virtual bool CanUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType) { return false; } - public virtual bool DoUpdateItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType) + public virtual bool DoUpdateItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType) { return false; } - public virtual bool CanRemoveItemData(ISbmUserContext_Core userContext, Sbm.ItemDataType itemDataType) + public virtual bool CanRemoveItemData(ISbmUserOrganisationContext userContext, Sbm.ItemDataType itemDataType) { return false; } //------------------------------------------------------------------- // Update Log. - public virtual bool IsColumnChangeLogged(ISbmUserContext_Core userContext, SbmDbDfn.ColumnIdx column) + public virtual bool IsColumnChangeLogged(ISbmUserOrganisationContext userContext, SbmDbDfn.ColumnIdx column) { return false; } @@ -377,27 +449,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { 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 @@ -411,28 +462,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // Commodity - specification. case SbmDbDfn.ColumnIdx.Commodity_Weight: 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_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_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_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_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_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_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_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_SalesProjMonthlyProp: 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_SalesProjMonth11: case SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12: - return UserContext.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual); + return OrganisationConfig.GetOwnerOption_ShowField(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual); default: - return UserContext.GetOwnerOption_ShowField(column); + return OrganisationConfig.GetOwnerOption_ShowField(column); } } @@ -460,388 +511,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles string Caption = ""; if (column != SbmDbDfn.ColumnIdx.Unknown) { - Caption = UserContext.GetOwnerOption_FieldLabel(column, Default); + Caption = OrganisationConfig.GetOwnerOption_FieldLabel(column, Default); } if (Caption.IsEmpty()) Caption = Default; return Caption; } - //------------------------------------------------------------------- - // T r a n s a c t i o n O p t i o n s - //------------------------------------------------------------------- + // To do - move to InstanceConfig. // Job Tracking Options. public virtual string GetDefaultQuoteDescIntro() { 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; - } - - //------------------------------------------------------------------- - /// Transaction reference prefix by type - 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 GetTransactionTypesForRaiseFrom(Sbm.TransactionType typeFrom) - { - // Build the list of transaction types that are allowed to be raised from the specified type. - List transTypes = new List(); - 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 GetTransactionTypesForRaiseTo(Sbm.TransactionType typeTo) - { - // Build the list of transaction types that are allowed to be raised to the specified type. - List transTypes = new List(); - 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 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 //------------------------------------------------------------------- @@ -967,9 +649,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles { case SaInterfaceCategory.Website: 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) @@ -1005,7 +687,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles // Sbm.InterfaceType_System.Hpi - Only allowed by derived console. break; 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.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_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.AffiliateExport) return true; if (interfaceType == (short)Sbm.InterfaceType_File.AssociationImport) 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.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) //return SbmGlobals.Application.GetPropertyValue("Interface", "LeasewayInvoice").EqualsCI("Allow"); return false; diff --git a/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs b/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs new file mode 100644 index 0000000..b253c3a --- /dev/null +++ b/SaBusMgrStandardBase/Base/Core/ISbmInstanceConfig.cs @@ -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 +{ + //======================================================================= + /// + /// Defines a range of application options/rules specific to a BusinessMgr instance. + /// - Web application retrieves this information from the Item Params belonging to the Instance defined in the Control database. + /// - Legacy desktop application implements a named 'Console' (each in a separate library and loaded at runtime) for each specific instance. + /// + public interface ISbmInstanceConfig + { + //------------------------------------------------------------------- + // Application options. + + bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse); + + //------------------------------------------------------------------- + // Contacts. + + /// + /// Supported affiliate types. + /// + bool AllowAffiliateType(Sbm.AffiliateType type, bool defaultResponse); + + /// + /// Supported Association types. + /// + bool AllowAssociationType(Sbm.AssociationType type, bool defaultResponse); + + //------------------------------------------------------------------- + // Transactions. + + /// + /// Supported Transaction types. + /// + bool AllowTransactionType(Sbm.TransactionType type, bool defaultResponse); + + //------------------------------------------------------------------- + // Interfaces. + + /// + /// Whether the Interface Category is allowed. + /// + bool AllowInterfaceCategory(SaInterfaceCategory interfaceCategory, bool defaultResponse); + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs b/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs new file mode 100644 index 0000000..e869ded --- /dev/null +++ b/SaBusMgrStandardBase/Base/Core/ISbmOrganisationConfig.cs @@ -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 +{ + //======================================================================= + /// + /// Organisation configuration options - as defined by Item Options. + /// + 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); + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/Core/ISbmOrganisationContext.cs b/SaBusMgrStandardBase/Base/Core/ISbmOrganisationContext.cs new file mode 100644 index 0000000..363dee6 --- /dev/null +++ b/SaBusMgrStandardBase/Base/Core/ISbmOrganisationContext.cs @@ -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 +{ + //======================================================================= + /// + /// Basic Organisation properties associated with a session. + /// + public interface ISbmOrganisationContext + { + //------------------------------------------------------------------- + // Organisation properties. + + /// Organisation Affiliate Id. + SysId OrganisationAffiliateId { get; } + + /// Organisation Affiliate Type. + Sbm.AffiliateType OrganisationAffiliateType { get; } + + /// Organisation 'Internal' Association Id. + SysId OrganisationAssociationId { get; } + + /// Organisation display name. + String OrganisationDisplayName { get; } + + /// Organisation Interface context - to qualify interfaces belonging to the organisation. + String OrganisationInterfaceContext { get; } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/Core/ISbmUserContext.cs b/SaBusMgrStandardBase/Base/Core/ISbmUserContext.cs index 8b2ac71..3db2857 100644 --- a/SaBusMgrStandardBase/Base/Core/ISbmUserContext.cs +++ b/SaBusMgrStandardBase/Base/Core/ISbmUserContext.cs @@ -8,6 +8,9 @@ using System.Threading.Tasks; namespace Sarand.BusinessMgr.Net.Standard.Base.Core { //======================================================================= + /// + /// Basic User properties associated with a session. + /// public interface ISbmUserContext { //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Core/ISbmUserContext_Core.cs b/SaBusMgrStandardBase/Base/Core/ISbmUserContext_Core.cs deleted file mode 100644 index 0db5377..0000000 --- a/SaBusMgrStandardBase/Base/Core/ISbmUserContext_Core.cs +++ /dev/null @@ -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 - { - //------------------------------------------------------------------- - /// Session Context - Identifies database connections etc. - SbmSessionContext SessionContext { get; } - - //------------------------------------------------------------------- - // User properties. - /// User Security Item Id. - SysId UserSecurityItemId { get; } - /// User Affiliate Id. - SysId UserAffiliateId { get; } - - //------------------------------------------------------------------- - /// Security profile - what the user is allowed to do based on security roles and groups. - ISbmSecurityProfile_Core SecurityProfile_Core { get; } - - //------------------------------------------------------------------- - // Organisation properties. - - /// Organisation Affiliate Id. - SysId OrganisationAffiliateId { get; } - - /// Organisation Affiliate Type. - Sbm.AffiliateType OrganisationAffiliateType { get; } - - /// Organisation 'Internal' Association Id. - SysId OrganisationAssociationId { get; } - - /// Organisation display name. - String OrganisationDisplayName { get; } - - /// Organisation Interface context - to qualify interfaces belonging to the organisation. - 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); - - //------------------------------------------------------------------- - } - //======================================================================= -} diff --git a/SaBusMgrStandardBase/Base/Core/ISbmUserOrganisationContext.cs b/SaBusMgrStandardBase/Base/Core/ISbmUserOrganisationContext.cs new file mode 100644 index 0000000..7f6aae2 --- /dev/null +++ b/SaBusMgrStandardBase/Base/Core/ISbmUserOrganisationContext.cs @@ -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 +{ + //======================================================================= + /// + /// Basic User and Organisation properties associated with a session. + /// + public interface ISbmUserOrganisationContext : ISbmUserContext, ISbmOrganisationContext + { + //------------------------------------------------------------------- + /// Session Context - Identifies database connections etc. + SbmSessionContext SessionContext { get; } + + //------------------------------------------------------------------- + // User properties. + /// User Security Item Id. + SysId UserSecurityItemId { get; } + /// User Affiliate Id. + SysId UserAffiliateId { get; } + + //------------------------------------------------------------------- + /// Security profile - what the user is allowed to do based on security roles and groups. + ISbmSecurityProfile_Core SecurityProfile_Core { get; } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr.cs index 8e4fb8b..2c3bf2a 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr.cs @@ -35,7 +35,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Construction. - protected SbmAccountMgr(ISbmUserContext_Core userContext) : + protected SbmAccountMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmAccountMgr(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs index 2b57e4d..70c76e0 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Address.cs @@ -17,8 +17,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr // A d d r e s s e s //******************************************************************* // Utilities. - //public override SbmAddress CloneAddress(SbmAddress addressSource, bool copyId) - public abstract bool VerifyAsPrimaryAddress(SbmAddress addressPrimary); + //public override SbmAddress CloneAddress(SbmAddress addressSource, bool copyId, DbUpdateInfo dbUpdateInfo) + public abstract bool VerifyAsPrimaryAddress(SbmAddress addressPrimary, DbUpdateInfo dbUpdateInfo); //------------------------------------------------------------------- // Retrieve individual addresses. diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs index a03bf93..6f2c4b8 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAccountMgr_Organisation.cs @@ -9,8 +9,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - public partial class SbmAccountMgr + //======================================================================= + public partial class SbmAccountMgr { //******************************************************************* // O r g a n i s a t i o n @@ -201,11 +201,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr case Sbm.OrganisationOption.NumericDecimals: return true; case Sbm.OrganisationOption.CommodityType: - return AllowConfigOption(Sbm.ConfigOption.AllowCommodities); + return AllowConfigOption(Sbm.ConfigOption.Commodities); 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: - 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: return StockControlConfig.AllowStockContainers(); case Sbm.OrganisationOption.SalesLocation: @@ -218,345 +218,342 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr private OrganisationOptionData InitOrganisationOptionData() { OrganisationOptionData orgOptData = new OrganisationOptionData(); - using (SbmSessionConsole sessionConsole = SbmGlobals.Application.CreateSessionConsole(UserContext)) - using (SbmAccountsDfn accounts = new SbmAccountsDfn(UserContext)) + + // Option types. + orgOptData.associationOptionTypes.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.AssociationOption)); + + // Yes/No. + orgOptData.Values_YesNo.Add(orgOptData.Value_Yes, "Yes"); + orgOptData.Values_YesNo.Add(orgOptData.Value_No, "No"); + + // Organisation configuration. + bool bAllowContacts = (AllowConfigOption(Sbm.ConfigOption.Contacts)); + bool bAllowCustomers = (AllowAssociationType(Sbm.AssociationType.Customer)); + bool bAllowStockists = (AllowAssociationType(Sbm.AssociationType.Stockist)); + bool bAllowFinanceAgencies = (AllowAssociationType(Sbm.AssociationType.FinanceAgency)); + bool bAllowCommodities = (AllowConfigOption(Sbm.ConfigOption.Commodities)); + bool bAllowVehicles = (AllowConfigOption(Sbm.ConfigOption.Vehicles)); + bool bAllowAssets = (AllowConfigOption(Sbm.ConfigOption.Assets)); + bool bAllowTransactions = (AllowConfigOption(Sbm.ConfigOption.Transactions)); + bool bAllowSalesOrders = ((AllowTransactionType(Sbm.TransactionType.SalesOrder) || AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder))); + bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch)); + bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice))); + bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder))); + bool bAllowInterfaces = (SessionConsole.AllowInterfaces()); + bool bAllowInterfaces_File = (bAllowInterfaces && SessionConsole.AllowInterfaceCategory(SaInterfaceCategory.File)); + + // Values: + List orgOptionValues = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Value); + if (bAllowTransactions) { - // Option types. - orgOptData.associationOptionTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssociationOption)); - - // Yes/No. - orgOptData.Values_YesNo.Add(orgOptData.Value_Yes, "Yes"); - orgOptData.Values_YesNo.Add(orgOptData.Value_No, "No"); - - // Organisation configuration. - bool bAllowContacts = (AllowConfigOption(Sbm.ConfigOption.AllowContacts)); - bool bAllowCustomers = (AllowAssociationType(Sbm.AssociationType.Customer)); - bool bAllowStockists = (AllowAssociationType(Sbm.AssociationType.Stockist)); - bool bAllowFinanceAgencies = (AllowAssociationType(Sbm.AssociationType.FinanceAgency)); - bool bAllowCommodities = (AllowConfigOption(Sbm.ConfigOption.AllowCommodities)); - bool bAllowVehicles = (AllowConfigOption(Sbm.ConfigOption.AllowVehicles)); - bool bAllowAssets = (AllowConfigOption(Sbm.ConfigOption.AllowAssets)); - bool bAllowTransactions = (AllowConfigOption(Sbm.ConfigOption.AllowTransactions)); - bool bAllowSalesOrders = ((AllowTransactionType(Sbm.TransactionType.SalesOrder) || AllowTransactionType(Sbm.TransactionType.ProformaSalesOrder))); - bool bAllowSalesDispatches = (AllowTransactionType(Sbm.TransactionType.SalesDispatch)); - bool bAllowSalesInvoices = ((AllowTransactionType(Sbm.TransactionType.SalesInvoice) || AllowTransactionType(Sbm.TransactionType.ProformaSalesInvoice))); - bool bAllowPurchaseOrders = ((AllowTransactionType(Sbm.TransactionType.PurchaseOrder) || AllowTransactionType(Sbm.TransactionType.ProformaPurchaseOrder))); - bool bAllowInterfaces = (sessionConsole.AllowInterfaces()); - bool bAllowInterfaces_File = (bAllowInterfaces && sessionConsole.AllowInterfaceCategory(SaInterfaceCategory.File)); - - // Values: - List orgOptionValues = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Value); - if (bAllowTransactions) + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter)); + if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion)) + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText)); + if (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.CommoditiesAllowedNegativePrice)); + if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes)) { - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter)); - if (CodeTypeHasCodes(Sbm.ApplCodeType.CommodityPromotion)) - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.AlternativePromotionText)); - if (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.CommoditiesAllowedNegativePrice)); - if (AllowConfigOption(Sbm.ConfigOption.TransactionSplitTimes)) - { - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk1Caption)); - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk2Caption)); - } - // Default Email content. - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailSubject)); - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailBody)); + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk1Caption)); + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.TransTimeChunk2Caption)); } - if (accounts.IsUsingSageInterface()) - { - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultSalesCarriageNominal)); - orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal)); - } - - // Folders: - List lOrgOptionFolder = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Folder); - if (bAllowCommodities) - { - orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityImage)); - orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityBarcodeImage)); - } - - // Allow option contexts: - List lAllowOption = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_AllowOption); - if (bAllowContacts) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.UpdateAssociationCode)); - if (bAllowCustomers) - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.CustomerAccountDetails)); - if (bAllowStockists) - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.StockistAssociations)); - if (bAllowFinanceAgencies) - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.FinanceAgencyAssociations)); - } - if (bAllowCommodities) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_SalesBudget)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter)); - if (bAllowTransactions) - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_EditHistoryItem)); - } - if (bAllowTransactions) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_AnyStatus)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRef)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRefExt)); - if (bAllowInterfaces_File) - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionExport_FixedContent)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Order_BillingAddress)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails)); - if (StockControlConfig.AllowStockControl()) - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Transaction_RetainCurrentViewOnRaise)); - } - if (bAllowSalesOrders) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_OnHold)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_ReplacementOrders)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails)); - if (bAllowSalesInvoices) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_PartialInvoice)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_RaiseInvoiceOnCompletion)); - } - } - if (bAllowSalesOrders && bAllowPurchaseOrders) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems)); - } - if (StockControlConfig.AllowStockControl()) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ImminentStock)); - if (StockControlConfig.AllowStockContainers()) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ManageContainerMovemements)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock)); - } - } - if (bAllowAssets) - { - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Sale)); - orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Rental)); - } - - // Caption contexts: - orgOptData.Contexts_Caption.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Caption)); - - // Show field contexts. - // NB This list must be kept up to date with equivalent in 'SapphireConsole::DisplayAttribute': - List lShowField = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowField); - if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Address_LastVisitOn)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingNo)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Department)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Volume)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Density)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_MaterialCost)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative)) - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative)); - if (StockControlConfig.AllowStockControl()) - { - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2)); - orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3)); - } - - // Show column contexts: - List lShowColumn = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ShowColumn); - if (bAllowSalesOrders) - { - if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy)); - } - if (ColumnExists(SbmDbDfn.ColumnIdx.Association_Group)) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Group)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_Weight)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale)); - if (StockControlConfig.AllowStockControl()) - { - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable)); - } - if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl()) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Order_AllocationInd)); - if (bAllowSalesOrders && CodeTypeHasCodes(Sbm.ApplCodeType.DeliveryCourier)) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier)); - if (bAllowSalesOrders || bAllowSalesInvoices) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice)); - if (bAllowSalesInvoices) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Transaction_ContactArea)); - if (bAllowSalesInvoices && accounts.IsTransactionTypeManagedByAccounts(Sbm.TransactionType.SalesInvoice)) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef)); - if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl()) - { - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available)); - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation)); - } - if (bAllowSalesDispatches) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched)); - if (bAllowSalesInvoices) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced)); - // Check for processes: - if (ProcessMgr.HasProcesses(Sbm.ProcessCategory.Commodity)) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess)); - // Check for vehicles: - if (bAllowVehicles) - orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation)); - - // Field label contexts: - List lFieldLabel = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_FieldLabel); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Dimensions)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CostPrice)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)) - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)) - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks)) - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_SpecSummary)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_FinishCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DescDetail)); - if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)) - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Abbrev)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Nature)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_Location)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountManagerCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountTypeCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountRatingCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactAreaCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactMethodCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_Ref)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_RefExt)); - if (StockControlConfig.AllowStockControl()) - { - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2)); - orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3)); - } - - // Commodity status filter. - List lCmdStatusCat = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityStatusCat); - orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Any)); - orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Current)); - - // Commodity Stock Category filter. - List commodityCategories = GetCodeDescsForCodeType(Sbm.ApplCodeType.CommodityCategory, true); - orgOptData.Values_CommodityStockCat.AddRange(commodityCategories); - - // Container status caption. - if (CommodityMgr.ContainerDatabaseIsValid && StockControlConfig.AllowStockContainers()) - orgOptData.Contexts_ContainerStatus.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_ContainerStatusCaption)); - - // Generic options: - orgOptData.Contexts_Minutes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_Minutes)); - orgOptData.Contexts_PeriodDays.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodDays)); - orgOptData.Contexts_PeriodWeeks.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_PeriodWeeks)); - - // Minutes. - for (int iMins = 0; iMins <= 30; iMins++) - orgOptData.Values_Minutes.Add(iMins.ToString(), iMins.ToString() + " min" + (iMins == 1 ? "" : "s")); - - // Period - days. - orgOptData.Values_PeriodDays.Add("1", "1 day"); - orgOptData.Values_PeriodDays.Add("2", "2 days"); - orgOptData.Values_PeriodDays.Add("3", "3 days"); - orgOptData.Values_PeriodDays.Add("7", "1 week"); - orgOptData.Values_PeriodDays.Add("14", "2 weeks"); - orgOptData.Values_PeriodDays.Add("21", "3 weeks"); - orgOptData.Values_PeriodDays.Add("30", "30 days"); - orgOptData.Values_PeriodDays.Add("60", "60 days"); - orgOptData.Values_PeriodDays.Add("90", "90 days"); - orgOptData.Values_PeriodDays.Add("120", "120 days"); - orgOptData.Values_PeriodDays.Add("150", "150 days"); - orgOptData.Values_PeriodDays.Add("300", "300 days"); - - // Period - weeks. - orgOptData.Values_PeriodWeeks.Add("0", "0 weeks"); - orgOptData.Values_PeriodWeeks.Add("1", "1 week"); - orgOptData.Values_PeriodWeeks.Add("2", "2 weeks"); - orgOptData.Values_PeriodWeeks.Add("3", "3 weeks"); - orgOptData.Values_PeriodWeeks.Add("4", "4 weeks"); - orgOptData.Values_PeriodWeeks.Add("5", "5 weeks"); - orgOptData.Values_PeriodWeeks.Add("6", "6 weeks"); - orgOptData.Values_PeriodWeeks.Add("7", "7 weeks"); - orgOptData.Values_PeriodWeeks.Add("8", "8 weeks"); - orgOptData.Values_PeriodWeeks.Add("9", "9 weeks"); - orgOptData.Values_PeriodWeeks.Add("10", "10 weeks"); - orgOptData.Values_PeriodWeeks.Add("11", "11 weeks"); - orgOptData.Values_PeriodWeeks.Add("12", "12 weeks"); - orgOptData.Values_PeriodWeeks.Add("13", "13 weeks"); - orgOptData.Values_PeriodWeeks.Add("14", "14 weeks"); - orgOptData.Values_PeriodWeeks.Add("15", "15 weeks"); - orgOptData.Values_PeriodWeeks.Add("16", "16 weeks"); - orgOptData.Values_PeriodWeeks.Add("17", "17 weeks"); - orgOptData.Values_PeriodWeeks.Add("18", "18 weeks"); - orgOptData.Values_PeriodWeeks.Add("19", "19 weeks"); - orgOptData.Values_PeriodWeeks.Add("20", "20 weeks"); - orgOptData.Values_PeriodWeeks.Add("21", "21 weeks"); - orgOptData.Values_PeriodWeeks.Add("22", "22 weeks"); - orgOptData.Values_PeriodWeeks.Add("23", "23 weeks"); - orgOptData.Values_PeriodWeeks.Add("24", "24 weeks"); - orgOptData.Values_PeriodWeeks.Add("25", "25 weeks"); - orgOptData.Values_PeriodWeeks.Add("26", "26 weeks"); - orgOptData.Values_PeriodWeeks.Add("27", "27 weeks"); - orgOptData.Values_PeriodWeeks.Add("28", "28 weeks"); - orgOptData.Values_PeriodWeeks.Add("29", "29 weeks"); - orgOptData.Values_PeriodWeeks.Add("30", "30 weeks"); - - // Numeric Decimals: - orgOptData.Contexts_NumericDecimals.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_NumericDecimals)); - orgOptData.Values_Decimals_0To2.Add("0", "None"); - orgOptData.Values_Decimals_0To2.Add("1", "1 places"); - orgOptData.Values_Decimals_0To2.Add("2", "2 places"); - orgOptData.Values_Decimals_0To4.Add("0", "None"); - orgOptData.Values_Decimals_0To4.Add("1", "1 places"); - orgOptData.Values_Decimals_0To4.Add("2", "2 places"); - orgOptData.Values_Decimals_0To4.Add("3", "3 places"); - orgOptData.Values_Decimals_0To4.Add("4", "4 places"); - - // Commodity types. - orgOptData.Contexts_CommodityType.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType)); - orgOptData.Values_CommodityTypes.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType)); - - // Sales locations. - orgOptData.Contexts_SalesLocation.AddRange(SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OrgOption_StockLocation)); - SbmLocation.Params prmLocation = new SbmLocation.Params(); - prmLocation.RestrictToSalesStock = true; - prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly; - foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation)) - orgOptData.Values_SalesLocation.Add(SysId.ToString(location.Id), location.Name); + // Default Email content. + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailSubject)); + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.EmailBody)); } + if (AccountsDfn.IsUsingSageInterface()) + { + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultSalesCarriageNominal)); + orgOptData.Contexts_Value.Add(orgOptionValues.GetCodeDescForType(Sbm.OrgOption_Value.DefaultPurchaseCarriageNominal)); + } + + // Folders: + List lOrgOptionFolder = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Folder); + if (bAllowCommodities) + { + orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityImage)); + orgOptData.Contexts_Folder.Add(lOrgOptionFolder.GetCodeDescForType(Sbm.OrgOption_Folder.CommodityBarcodeImage)); + } + + // Allow option contexts: + List lAllowOption = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_AllowOption); + if (bAllowContacts) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.UpdateAssociationCode)); + if (bAllowCustomers) + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.CustomerAccountDetails)); + if (bAllowStockists) + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.StockistAssociations)); + if (bAllowFinanceAgencies) + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.FinanceAgencyAssociations)); + } + if (bAllowCommodities) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_SalesBudget)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_PartialCodeFilter)); + if (bAllowTransactions) + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Commodity_EditHistoryItem)); + } + if (bAllowTransactions) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_AnyStatus)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRef)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionFilter_RetainRefExt)); + if (bAllowInterfaces_File) + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.TransactionExport_FixedContent)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Order_BillingAddress)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ModifyCommodityDescription)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowCommodityDetails)); + if (StockControlConfig.AllowStockControl()) + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.OrderItem_ShowStockDetails)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Transaction_RetainCurrentViewOnRaise)); + } + if (bAllowSalesOrders) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_OnHold)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_ReplacementOrders)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_DispatchDetails)); + if (bAllowSalesInvoices) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_PartialInvoice)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.SalesOrder_RaiseInvoiceOnCompletion)); + } + } + if (bAllowSalesOrders && bAllowPurchaseOrders) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems)); + } + if (StockControlConfig.AllowStockControl()) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ImminentStock)); + if (StockControlConfig.AllowStockContainers()) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.ManageContainerMovemements)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock)); + } + } + if (bAllowAssets) + { + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Sale)); + orgOptData.Contexts_AllowOption.Add(lAllowOption.GetCodeDescForType(Sbm.OrgOption_AllowOption.Asset_Rental)); + } + + // Caption contexts: + orgOptData.Contexts_Caption.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Caption)); + + // Show field contexts. + // NB This list must be kept up to date with equivalent in 'SapphireConsole::DisplayAttribute': + List lShowField = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_ShowField); + if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Address_LastVisitOn)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DrawingNo)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Department)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CatalogRef)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Volume)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_Density)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_BoxQuantity)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_MaterialCost)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative)) + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CarriageCostIndicative)); + if (StockControlConfig.AllowStockControl()) + { + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2)); + orgOptData.Contexts_ShowField.Add(lShowField.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3)); + } + + // Show column contexts: + List lShowColumn = Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_ShowColumn); + if (bAllowSalesOrders) + { + if (ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_AnnualSalesTarget)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_LastSaleRaised)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Open)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Cytd)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Trans_SalesValue_Lcy)); + } + if (ColumnExists(SbmDbDfn.ColumnIdx.Association_Group)) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Association_Group)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_CatalogRef)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_Weight)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_PackQtySale)); + if (StockControlConfig.AllowStockControl()) + { + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAllocated)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockLevelSales)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Commodity_StockAvailable)); + } + if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl()) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Order_AllocationInd)); + if (bAllowSalesOrders && CodeTypeHasCodes(Sbm.ApplCodeType.DeliveryCourier)) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_DeliveryCourier)); + if (bAllowSalesOrders || bAllowSalesInvoices) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrder_HasInvoice)); + if (bAllowSalesInvoices) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Transaction_ContactArea)); + if (bAllowSalesInvoices && AccountsDfn.IsTransactionTypeManagedByAccounts(Sbm.TransactionType.SalesInvoice)) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Accounts_InvoiceRef)); + if ((bAllowSalesOrders || bAllowPurchaseOrders) && StockControlConfig.AllowStockControl()) + { + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_AllocationInd)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Current)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_Available)); + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.OrderItem_Stock_BySalesLocation)); + } + if (bAllowSalesDispatches) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyDispatched)); + if (bAllowSalesInvoices) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_QtyInvoiced)); + // Check for processes: + if (ProcessMgr.HasProcesses(Sbm.ProcessCategory.Commodity)) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.SalesOrderItem_NextProcess)); + // Check for vehicles: + if (bAllowVehicles) + orgOptData.Contexts_ShowColumn.Add(lShowColumn.GetCodeDescForType(Sbm.OrgOption_ShowColumn.Vehicle_KeyLocation)); + + // Field label contexts: + List 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_Dimensions)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ICNTariffCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CostPrice)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)) + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_PlaceOfOrigin)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCost)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdMaterial)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)) + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_ExWorksCost)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks)) + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_CurrencyIdExWorks)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_SpecSummary)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_MaterialCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_FinishCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_DescDetail)); + if (ColumnExists(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)) + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Commodity_RetailPricePlanned)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Abbrev)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Affiliate_Nature)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_Location)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountManagerCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountHandlerCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountTypeCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_AccountRatingCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactAreaCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactHandlerCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactMethodCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Association_ContactCallCycleCode)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_Ref)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.Transaction_RefExt)); + if (StockControlConfig.AllowStockControl()) + { + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay1)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay2)); + orgOptData.Contexts_FieldLabelAssoc.Add(lFieldLabel.GetCodeDescForType(SbmDbDfn.ColumnIdx.StockLevel_Bay3)); + } + + // Commodity status filter. + List lCmdStatusCat = Internals.GetSystemCodes(Sbm.SystemCode.CommodityStatusCat); + orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Any)); + orgOptData.Values_CommodityStatusCat.Add(lCmdStatusCat.GetCodeDescForType(SbmCommodity.StatusCat.Current)); + + // Commodity Stock Category filter. + List commodityCategories = GetCodeDescsForCodeType(Sbm.ApplCodeType.CommodityCategory, true); + orgOptData.Values_CommodityStockCat.AddRange(commodityCategories); + + // Container status caption. + if (CommodityMgr.ContainerDatabaseIsValid && StockControlConfig.AllowStockContainers()) + orgOptData.Contexts_ContainerStatus.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_ContainerStatusCaption)); + + // Generic options: + orgOptData.Contexts_Minutes.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_Minutes)); + orgOptData.Contexts_PeriodDays.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_PeriodDays)); + orgOptData.Contexts_PeriodWeeks.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_PeriodWeeks)); + + // Minutes. + for (int iMins = 0; iMins <= 30; iMins++) + orgOptData.Values_Minutes.Add(iMins.ToString(), iMins.ToString() + " min" + (iMins == 1 ? "" : "s")); + + // Period - days. + orgOptData.Values_PeriodDays.Add("1", "1 day"); + orgOptData.Values_PeriodDays.Add("2", "2 days"); + orgOptData.Values_PeriodDays.Add("3", "3 days"); + orgOptData.Values_PeriodDays.Add("7", "1 week"); + orgOptData.Values_PeriodDays.Add("14", "2 weeks"); + orgOptData.Values_PeriodDays.Add("21", "3 weeks"); + orgOptData.Values_PeriodDays.Add("30", "30 days"); + orgOptData.Values_PeriodDays.Add("60", "60 days"); + orgOptData.Values_PeriodDays.Add("90", "90 days"); + orgOptData.Values_PeriodDays.Add("120", "120 days"); + orgOptData.Values_PeriodDays.Add("150", "150 days"); + orgOptData.Values_PeriodDays.Add("300", "300 days"); + + // Period - weeks. + orgOptData.Values_PeriodWeeks.Add("0", "0 weeks"); + orgOptData.Values_PeriodWeeks.Add("1", "1 week"); + orgOptData.Values_PeriodWeeks.Add("2", "2 weeks"); + orgOptData.Values_PeriodWeeks.Add("3", "3 weeks"); + orgOptData.Values_PeriodWeeks.Add("4", "4 weeks"); + orgOptData.Values_PeriodWeeks.Add("5", "5 weeks"); + orgOptData.Values_PeriodWeeks.Add("6", "6 weeks"); + orgOptData.Values_PeriodWeeks.Add("7", "7 weeks"); + orgOptData.Values_PeriodWeeks.Add("8", "8 weeks"); + orgOptData.Values_PeriodWeeks.Add("9", "9 weeks"); + orgOptData.Values_PeriodWeeks.Add("10", "10 weeks"); + orgOptData.Values_PeriodWeeks.Add("11", "11 weeks"); + orgOptData.Values_PeriodWeeks.Add("12", "12 weeks"); + orgOptData.Values_PeriodWeeks.Add("13", "13 weeks"); + orgOptData.Values_PeriodWeeks.Add("14", "14 weeks"); + orgOptData.Values_PeriodWeeks.Add("15", "15 weeks"); + orgOptData.Values_PeriodWeeks.Add("16", "16 weeks"); + orgOptData.Values_PeriodWeeks.Add("17", "17 weeks"); + orgOptData.Values_PeriodWeeks.Add("18", "18 weeks"); + orgOptData.Values_PeriodWeeks.Add("19", "19 weeks"); + orgOptData.Values_PeriodWeeks.Add("20", "20 weeks"); + orgOptData.Values_PeriodWeeks.Add("21", "21 weeks"); + orgOptData.Values_PeriodWeeks.Add("22", "22 weeks"); + orgOptData.Values_PeriodWeeks.Add("23", "23 weeks"); + orgOptData.Values_PeriodWeeks.Add("24", "24 weeks"); + orgOptData.Values_PeriodWeeks.Add("25", "25 weeks"); + orgOptData.Values_PeriodWeeks.Add("26", "26 weeks"); + orgOptData.Values_PeriodWeeks.Add("27", "27 weeks"); + orgOptData.Values_PeriodWeeks.Add("28", "28 weeks"); + orgOptData.Values_PeriodWeeks.Add("29", "29 weeks"); + orgOptData.Values_PeriodWeeks.Add("30", "30 weeks"); + + // Numeric Decimals: + orgOptData.Contexts_NumericDecimals.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_NumericDecimals)); + orgOptData.Values_Decimals_0To2.Add("0", "None"); + orgOptData.Values_Decimals_0To2.Add("1", "1 places"); + orgOptData.Values_Decimals_0To2.Add("2", "2 places"); + orgOptData.Values_Decimals_0To4.Add("0", "None"); + orgOptData.Values_Decimals_0To4.Add("1", "1 places"); + orgOptData.Values_Decimals_0To4.Add("2", "2 places"); + orgOptData.Values_Decimals_0To4.Add("3", "3 places"); + orgOptData.Values_Decimals_0To4.Add("4", "4 places"); + + // Commodity types. + orgOptData.Contexts_CommodityType.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.CommodityType)); + orgOptData.Values_CommodityTypes.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.CommodityType)); + + // Sales locations. + orgOptData.Contexts_SalesLocation.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.OrgOption_StockLocation)); + SbmLocation.Params prmLocation = new SbmLocation.Params(); + prmLocation.RestrictToSalesStock = true; + prmLocation.StatusCat = SbmLocation.StatusCat.ActiveOnly; + foreach (SbmLocation location in StockMgr.GetLocationList(prmLocation)) + orgOptData.Values_SalesLocation.Add(SysId.ToString(location.Id), location.Name); return orgOptData; } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr.cs index 37c784c..0fd125e 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmAssetMgr.cs @@ -13,7 +13,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Construction. - protected SbmAssetMgr(ISbmUserContext_Core userContext) : + protected SbmAssetMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmAssetMgr(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs index 43d3ca0..4f3e537 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr.cs @@ -32,7 +32,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Construction. - protected SbmCommodityMgr(ISbmUserContext_Core userContext) : + protected SbmCommodityMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmCommodityMgr(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs index 7221d12..63e3938 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCommodityMgr_Commodity-Utils.cs @@ -275,7 +275,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr String path = ""; 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); } return path; @@ -287,7 +287,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr String path = ""; 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); } return path; diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs index 5edd596..c7c47bb 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmCoreMgr.cs @@ -20,28 +20,9 @@ using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - public abstract class SbmCoreMgr : SbmItemMgr + //======================================================================= + public abstract class SbmCoreMgr : SbmItemMgr { - //------------------------------------------------------------------- - // System code cache. - /// Central repository for system codes used by manager. - private class SystemCodeCache - { - public SystemCodeCache(ISbmUserContext_Core userContext) - { - this.userContext = userContext; - } - private readonly ISbmUserContext_Core userContext; - private Dictionary> systemCodes = new Dictionary>(); - public List GetCodesOfType(Sbm.SystemCode systemCode) - { - if (!systemCodes.ContainsKey(systemCode)) - systemCodes[systemCode] = SbmSystem.GetCodesOfType(userContext, systemCode); - return new List(systemCodes.GetValue(systemCode, new List())); - } - } - //------------------------------------------------------------------- // Code type cache. public class CodeTypeCache @@ -90,14 +71,29 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Data members. - private SbmInternals internals; - private readonly SystemCodeCache systemCodeCache; - private readonly List currencyCodes; - private List currencies; - private List languages; - private List regions; - private List taxCodes; - private List unitsOfMeasure; + private class Members + { + // Externally supplied Internals - disposed elsewhere. + public SbmInternals internalsSupplied; + // Internally constructed Internals - disposed here. + public SbmInternals internals; + // Numeric control values. + 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 currencyCodes; + public List currencies; + public List languages; + public List regions; + public List taxCodes; + public List unitsOfMeasure; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Static initialisation. @@ -107,30 +103,50 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // 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) throw new NotSupportedException("SbmItemMgr User context must be supplied"); - UserContext = userContext; - systemCodeCache = new SystemCodeCache(userContext); - // Numeric formatting values. - 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); + mbr.internalsSupplied = null; + this.UserContext = userContext; + Initialise(); } protected override void Dispose(bool disposing) { if (disposing) { - if (internals != null) internals.Dispose(); + if (mbr.internals != null) mbr.internals.Dispose(); } 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. public async void InitialiseCodeTypesAsync() @@ -151,26 +167,31 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr protected List ItemTypes { get { return GetCodesOfType(Sbm.SystemCode.ItemType); } } protected List InterfaceOptionCodes { get { return GetCodesOfType(Sbm.SystemCode.InterfaceOption); } } // Numeric control values. - protected int WeightDecimals { get; set; } = 0; - protected int LengthDecimals { get; set; } = 0; - protected int VolumeDecimals { get; set; } = 0; - protected int DensityDecimals { get; set; } = 0; - protected int BoxQuantityDecimals { get; set; } = 0; - protected int OrderQuantityDecimals { get; set; } = 0; - // Session. - protected ISbmUserContext_Core UserContext { get; } - protected SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } + protected int WeightDecimals { get { InitialiseNumericControlValues(); return mbr.weightDecimals; } } + protected int LengthDecimals { get { InitialiseNumericControlValues(); return mbr.lengthDecimals; } } + protected int VolumeDecimals { get { InitialiseNumericControlValues(); return mbr.volumeDecimals; } } + protected int DensityDecimals { get { InitialiseNumericControlValues(); return mbr.densityDecimals; } } + protected int BoxQuantityDecimals { get { InitialiseNumericControlValues(); return mbr.boxQuantityDecimals; } } + protected int OrderQuantityDecimals { get { InitialiseNumericControlValues(); return mbr.orderQuantityDecimals; } } + // Internals. protected SbmInternals Internals { get { - if (internals == null) internals = new SbmInternals(UserContext); - return internals; + if (mbr.internalsSupplied != null) return mbr.internalsSupplied; + 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; } } protected SbmAccountsDfn AccountsDfn { get { return Internals.AccountsDfn; } } 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. protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } } 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 SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } } // Currencies. - protected List CurrencyCodes { get { return new List(currencyCodes); } } + protected List CurrencyCodes + { + get + { + if (mbr.currencyCodes == null) + mbr.currencyCodes = SaReferenceDataConsole.GetReferenceDataCodes(ReferenceDataSystemCode.CurrencyCode); + return new List(mbr.currencyCodes); + } + } protected List GetCurrencies() { return Internals.GetCurrencies(); @@ -215,7 +244,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr // Utilities. public List GetCodesOfType(Sbm.SystemCode systemCode) { - return systemCodeCache.GetCodesOfType(systemCode); + return Internals.GetSystemCodes(systemCode); } // Database utilities. 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) { return SessionConsole.AllowOption(configOption); @@ -320,71 +349,71 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr // Currencies. private void PopulateCurrencies() { - if (currencies != null) return; + if (mbr.currencies != null) return; SaCurrency.Params prmCurrency = new SaCurrency.Params(); prmCurrency.StatusCat = SaCurrency.StatusCat.Any; - currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency); + mbr.currencies = ReferenceDataConsole.GetCurrencyList(prmCurrency); } public SaCurrency GetDefaultCurrency() { PopulateCurrencies(); 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) { PopulateCurrencies(); - return currencies.Find(item => item.Id.Equals(currencyId)); + return mbr.currencies.Find(item => item.Id.Equals(currencyId)); } //------------------------------------------------------------------- // Regions. private void PopulateRegions() { - if (regions != null) return; + if (mbr.regions != null) return; SaRegion.Params prmRegion = new SaRegion.Params(); - regions = ReferenceDataConsole.GetRegionList(prmRegion); + mbr.regions = ReferenceDataConsole.GetRegionList(prmRegion); } public SaRegion FindRegionById(SysId regionId) { PopulateRegions(); - return regions.FindById(regionId); + return mbr.regions.FindById(regionId); } //------------------------------------------------------------------- // Tax codes. private void PopulateTaxCodes() { - if (taxCodes != null) return; + if (mbr.taxCodes != null) return; SaTaxCode.Params prmTaxCode = new SaTaxCode.Params(); - taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode); + mbr.taxCodes = ReferenceDataConsole.GetTaxCodeList(prmTaxCode); } public SaTaxCode FindTaxCodeById(SysId taxCodeId) { 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) { PopulateTaxCodes(); - return taxCodes.FindByCodeEffectiveOn(taxCode, effectiveOn); + return mbr.taxCodes.FindByCodeEffectiveOn(taxCode, effectiveOn); } //------------------------------------------------------------------- // Units of measure. private void PopulateUnitsOfMeasure() { - if (taxCodes != null) return; + if (mbr.unitsOfMeasure != null) return; SaUnitMeasure.Params prmUnitOfMeasure = new SaUnitMeasure.Params(); prmUnitOfMeasure.StatusCat = SaUnitMeasure.StatusCat.Any; - unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitOfMeasure); + mbr.unitsOfMeasure = ReferenceDataConsole.GetUnitMeasureList(prmUnitOfMeasure); } public SaUnitMeasure FindUnitOfMeasureById(SysId uomId) { PopulateUnitsOfMeasure(); - return unitsOfMeasure.FindById(uomId); + return mbr.unitsOfMeasure.FindById(uomId); } public List FindUnitsOfMeasureByCategory(SaUomCategory uomCategory) { PopulateUnitsOfMeasure(); - return unitsOfMeasure.FindAll(item => item.Category == uomCategory); + return mbr.unitsOfMeasure.FindAll(item => item.Category == uomCategory); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs index 41872e4..5a6ebe2 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmDataItemMgr.cs @@ -16,6 +16,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr static SbmDataItemMgr() { } + + //------------------------------------------------------------------- + // Construction. + protected SbmDataItemMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmDataItemMgr(ISbmUserOrganisationContext userContext) : + base(userContext) + { + } protected override void Dispose(bool disposing) { if (disposing) @@ -24,13 +35,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr base.Dispose(disposing); } - //------------------------------------------------------------------- - // Construction. - protected SbmDataItemMgr(ISbmUserContext_Core userContext) : - base(userContext) - { - } - //------------------------------------------------------------------- // Utilities. diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs index 5ef7f70..c97d7dd 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmPriceMgr.cs @@ -8,8 +8,8 @@ using System.Collections.Generic; namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { - //======================================================================= - public abstract partial class SbmPriceMgr : SbmCoreMgr + //======================================================================= + public abstract partial class SbmPriceMgr : SbmCoreMgr { //------------------------------------------------------------------- // Data members. @@ -20,7 +20,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Construction. - protected SbmPriceMgr(ISbmUserContext_Core userContext) : + protected SbmPriceMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmPriceMgr(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr.cs index 6b5b40f..d9658b2 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmProcessMgr.cs @@ -19,7 +19,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Construction. - protected SbmProcessMgr(ISbmUserContext_Core userContext) : + protected SbmProcessMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmProcessMgr(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr.cs index d45c32e..6df91b7 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr.cs @@ -16,6 +16,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr static SbmStockMgr() { } + + //------------------------------------------------------------------- + // Construction. + protected SbmStockMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmStockMgr(ISbmUserOrganisationContext userContext) : + base(userContext) + { + } protected override void Dispose(bool disposing) { if (disposing) @@ -24,13 +35,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr base.Dispose(disposing); } - //------------------------------------------------------------------- - // Construction. - protected SbmStockMgr(ISbmUserContext_Core userContext) : - base(userContext) - { - } - //------------------------------------------------------------------- // Properties. // Code lists. diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs index 7a26889..fd78630 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmStockMgr_Location.cs @@ -16,12 +16,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //******************************************************************* // L o c a t i o n s //******************************************************************* - //------------------------------------------------------------------- // Utilities. public SysId GetDefaultSalesStockLocation() { ClearErrorState(); - SysId salesLocationId = UserContext.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.SalesOrderDefault); + SysId salesLocationId = SessionConsole.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.SalesOrderDefault); if (SysId.IsValid(salesLocationId)) { // Check that this location is valid for sales stock. @@ -36,8 +35,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr if (!SysId.IsValid(salesLocationId)) { // 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: SbmLocation.Params prmLocation = new SbmLocation.Params(); @@ -45,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr prmLocation.RestrictToSalesStock = true; 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.SalesStock /*&& location.GetStatusType() == SaStatus.Active*/) @@ -61,7 +59,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr public SysId GetDefaultPurchaseStockLocation() { ClearErrorState(); - SysId purchaseLocationId = UserContext.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.PurchaseOrderDefault); + SysId purchaseLocationId = SessionConsole.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.PurchaseOrderDefault); if (SysId.IsValid(purchaseLocationId)) { purchaseLocationId = GetDefaultSalesStockLocation(); diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr.cs b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr.cs index 9fe237c..a6fe1ce 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr.cs @@ -32,7 +32,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr //------------------------------------------------------------------- // Construction. - protected SbmTransactionMgr(ISbmUserContext_Core userContext) : + protected SbmTransactionMgr(SbmInternals internals) : + base(internals) + { + } + protected SbmTransactionMgr(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs index 9069fd0..43f61fa 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Requirement.cs @@ -313,7 +313,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr { // Alternative text - only populated if promotion description is blank. 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(""); } } diff --git a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs index 3ed85ad..53588fb 100644 --- a/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs +++ b/SaBusMgrStandardBase/Base/Mgr/SbmTransactionMgr_Transaction.cs @@ -27,8 +27,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr public abstract decimal GetTransCostLabourRateHour(SysId transactionId); public abstract bool DeliveryFinancialsAreAvailable(); public abstract bool ChangeTransactionsAssociation(SbmTransaction transaction, SysId assocId); - public abstract bool RefreshAssociatedData(SbmTransaction transaction, List requirements = null); - public abstract bool RefreshAssociatedTransactions(SbmTransaction transaction, List requirements = null); + public abstract bool RefreshAssociatedData(SbmTransaction transaction, List requirements, DbUpdateInfo dbUpdateInfo); + public abstract bool RefreshAssociatedTransactions(SbmTransaction transaction, List requirements, DbUpdateInfo dbUpdateInfo); //------------------------------------------------------------------- // Has transactions. diff --git a/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs b/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs index 57d4966..23656cb 100644 --- a/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs +++ b/SaBusMgrStandardBase/Base/Procs/SbmReport_Base.cs @@ -26,11 +26,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Procs // Configuration. public new class Config : SaReport_Base.Config { - protected Config(ISbmUserContext_Core userContext) + protected Config(ISbmUserOrganisationContext userContext) { UserContext = userContext; } - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs b/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs index c86a0b1..35be3ca 100644 --- a/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs +++ b/SaBusMgrStandardBase/Base/UpdateLog/SbmUpdateLogItemMonitor.cs @@ -37,7 +37,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.UpdateLog //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get { return config.Internals.UserContext; } } + public ISbmUserOrganisationContext UserContext { get { return config.Internals.UserContext; } } //------------------------------------------------------------------- // Internal utilities. diff --git a/SaBusMgrStandardDbas/Dbas/App/SbmInstanceDataCache_Dbas.cs b/SaBusMgrStandardDbas/Dbas/App/SbmInstanceDataCache_Dbas.cs new file mode 100644 index 0000000..2127c82 --- /dev/null +++ b/SaBusMgrStandardDbas/Dbas/App/SbmInstanceDataCache_Dbas.cs @@ -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 +{ + //======================================================================= + /// + /// Practically persistant/static data stored in instance database, eg. Owner configuration options. + /// + 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 ItemOptions { get; } = new List(); + 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 ItemOptions { get; } = new Dictionary(); + } + + //------------------------------------------------------------------- + // Data members. + private SbmInternals internals = null; + // Instance Item Options - keyed on Owner Affiliate Id. + private readonly Dictionary itemOptionCaches = new Dictionary(); + + //------------------------------------------------------------------- + // 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 GetOwnerOptions(ISbmUserOrganisationContext userContext) + { + List ownerOptions = new List(); + 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(ownerItemOptions.ItemOptions); + } + + return ownerOptions; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardDbas/Dbas/App/SbmOrganisationConfig_Dbas.cs b/SaBusMgrStandardDbas/Dbas/App/SbmOrganisationConfig_Dbas.cs new file mode 100644 index 0000000..0fae0c5 --- /dev/null +++ b/SaBusMgrStandardDbas/Dbas/App/SbmOrganisationConfig_Dbas.cs @@ -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; } } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaBusMgrStandardDbas/Dbas/App/SbmSystem_Dbas.cs b/SaBusMgrStandardDbas/Dbas/App/SbmSystem_Dbas.cs index 443385d..16c5c98 100644 --- a/SaBusMgrStandardDbas/Dbas/App/SbmSystem_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/App/SbmSystem_Dbas.cs @@ -47,35 +47,67 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App //------------------------------------------------------------------- // D a t a M a n a g e r s //------------------------------------------------------------------- - public override SbmAccountMgr CreateAccountMgr(ISbmUserContext_Core userContext) + public override SbmAccountMgr CreateAccountMgr(SbmInternals internals) + { + return new SbmAccountMgr_Dbas(internals); + } + public override SbmAccountMgr CreateAccountMgr(ISbmUserOrganisationContext userContext) { return new SbmAccountMgr_Dbas(userContext); } - public override SbmAssetMgr CreateAssetMgr(ISbmUserContext_Core userContext) + public override SbmAssetMgr CreateAssetMgr(SbmInternals internals) + { + return new SbmAssetMgr_Dbas(internals); + } + public override SbmAssetMgr CreateAssetMgr(ISbmUserOrganisationContext userContext) { return new SbmAssetMgr_Dbas(userContext); } - public override SbmCommodityMgr CreateCommodityMgr(ISbmUserContext_Core userContext) + public override SbmCommodityMgr CreateCommodityMgr(SbmInternals internals) + { + return new SbmCommodityMgr_Dbas(internals); + } + public override SbmCommodityMgr CreateCommodityMgr(ISbmUserOrganisationContext userContext) { return new SbmCommodityMgr_Dbas(userContext); } - public override SbmPriceMgr CreatePriceMgr(ISbmUserContext_Core userContext) + public override SbmPriceMgr CreatePriceMgr(SbmInternals internals) + { + return new SbmPriceMgr_Dbas(internals); + } + public override SbmPriceMgr CreatePriceMgr(ISbmUserOrganisationContext userContext) { return new SbmPriceMgr_Dbas(userContext); } - public override SbmDataItemMgr CreateDataItemMgr(ISbmUserContext_Core userContext) + public override SbmDataItemMgr CreateDataItemMgr(SbmInternals internals) + { + return new SbmDataItemMgr_Dbas(internals); + } + public override SbmDataItemMgr CreateDataItemMgr(ISbmUserOrganisationContext userContext) { return new SbmDataItemMgr_Dbas(userContext); } - public override SbmProcessMgr CreateProcessMgr(ISbmUserContext_Core userContext) + public override SbmProcessMgr CreateProcessMgr(SbmInternals internals) + { + return new SbmProcessMgr_Dbas(internals); + } + public override SbmProcessMgr CreateProcessMgr(ISbmUserOrganisationContext userContext) { return new SbmProcessMgr_Dbas(userContext); } - public override SbmStockMgr CreateStockMgr(ISbmUserContext_Core userContext) + public override SbmStockMgr CreateStockMgr(SbmInternals internals) + { + return new SbmStockMgr_Dbas(internals); + } + public override SbmStockMgr CreateStockMgr(ISbmUserOrganisationContext userContext) { return new SbmStockMgr_Dbas(userContext); } - public override SbmTransactionMgr CreateTransactionMgr(ISbmUserContext_Core userContext) + public override SbmTransactionMgr CreateTransactionMgr(SbmInternals internals) + { + return new SbmTransactionMgr_Dbas(internals); + } + public override SbmTransactionMgr CreateTransactionMgr(ISbmUserOrganisationContext userContext) { return new SbmTransactionMgr_Dbas(userContext); } diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs index 8345d9b..f42bdd3 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmProcess_Dbas.cs @@ -26,7 +26,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus base(internals.UserContext, id, affIdOwner, processCategory) { this.internals = internals; - itemDataTypes = SbmSystem.GetCodesOfType(internals.UserContext, Sbm.SystemCode.ItemDataType); + itemDataTypes = internals.GetSystemCodes(Sbm.SystemCode.ItemDataType); Flags = flags; } protected override void Dispose(bool disposing) diff --git a/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs index d51d881..d6f1e5f 100644 --- a/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Bus/SbmTransaction_Dbas.cs @@ -33,10 +33,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus base(internals.UserContext, id, affIdOwner, assocId, transactionType) { this.internals = internals; - transactionTypes = internals.GetCodesOfType(Sbm.SystemCode.TransactionType); - transactionStatusCats = internals.GetCodesOfType(Sbm.SystemCode.TransactionStatusCat); - requirementStatusCats = internals.GetCodesOfType(Sbm.SystemCode.RequirementStatusCat); - constituentStatusCats = internals.GetCodesOfType(Sbm.SystemCode.ConstituentStatusCat); + transactionStatusCats = internals.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat); + requirementStatusCats = internals.GetSystemCodes(Sbm.SystemCode.RequirementStatusCat); + constituentStatusCats = internals.GetSystemCodes(Sbm.SystemCode.ConstituentStatusCat); Flags = flags; } protected override void Dispose(bool disposing) @@ -86,7 +85,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Bus if (TransactionStatusCat == SbmTransaction.StatusCat.Closed) { // Once the 'grace' period has passed, only the status can be modified. - int graceDaysUpdateClosedTrans = Math.Max(0, internals.UserContext.GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction, 0)); + int graceDaysUpdateClosedTrans = Math.Max(0, internals.GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays.UpdateClosedTransaction, 0)); DateTime closed = Closed; detailsAreReadOnly = (DateUtil.IsValid(closed) && closed <= DateTime.Today.AddDays(-graceDaysUpdateClosedTrans)); } diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmCodeTypeConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmCodeTypeConsole_Dbas.cs index 6d7af0d..a90645f 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmCodeTypeConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmCodeTypeConsole_Dbas.cs @@ -10,14 +10,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { //------------------------------------------------------------------- // Construction. - protected SbmCodeTypeConsole_Dbas(ISbmUserContext_Core userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) + protected SbmCodeTypeConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; } //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmDiaryConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmDiaryConsole_Dbas.cs index 56e3188..1dc0a60 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmDiaryConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmDiaryConsole_Dbas.cs @@ -10,14 +10,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { //------------------------------------------------------------------- // Construction. - protected SbmDiaryConsole_Dbas(ISbmUserContext_Core userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) + protected SbmDiaryConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; } //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; set; } + public ISbmUserOrganisationContext UserContext { get; set; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs index 5d4ff8c..f151636 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmInterfaceConsole_Dbas.cs @@ -25,11 +25,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Construction. - protected SbmInterfaceConsole_Dbas(ISbmUserContext_Core userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) + protected SbmInterfaceConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; - dataItemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); - interfaceDataTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceDataType); + dataItemTypes = Internals.GetSystemCodes(Sbm.SystemCode.ItemType); + interfaceDataTypes = internals.GetSystemCodes(Sbm.SystemCode.InterfaceDataType); } protected override void Dispose(bool disposing) { @@ -42,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } } public override short InterfaceDataType { get { return (short)Sbm.ItemType.Interface; } } @@ -68,13 +68,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles private List GetInterfaceTypesForCategory(SaInterfaceCategory interfaceCategory) { if (interfaceCategory == SaInterfaceCategory.Website) - return SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceType_Website); + return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_Website); if (interfaceCategory == SaInterfaceCategory.Accounts) - return SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceType_Accounts); + return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_Accounts); if (interfaceCategory == SaInterfaceCategory.System) - return SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceType_System); + return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_System); if (interfaceCategory == SaInterfaceCategory.File) - return SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceType_File); + return internals.GetSystemCodes(Sbm.SystemCode.InterfaceType_File); return new List(); } public void RegisterInterfaces(String context) diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDataConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDataConsole_Dbas.cs index 6caa361..148bf6e 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDataConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDataConsole_Dbas.cs @@ -10,14 +10,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { //------------------------------------------------------------------- // Construction. - protected SbmItemDataConsole_Dbas(ISbmUserContext_Core userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) + protected SbmItemDataConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; } //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; set; } + public ISbmUserOrganisationContext UserContext { get; set; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDocConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDocConsole_Dbas.cs index ff6d223..f7707ed 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDocConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemDocConsole_Dbas.cs @@ -10,14 +10,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { //------------------------------------------------------------------- // Construction. - protected SbmItemDocConsole_Dbas(ISbmUserContext_Core userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) + protected SbmItemDocConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; } //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; set; } + public ISbmUserOrganisationContext UserContext { get; set; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemOptionConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemOptionConsole_Dbas.cs index 2702503..843172e 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemOptionConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmItemOptionConsole_Dbas.cs @@ -22,7 +22,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Construction. - protected SbmItemOptionConsole_Dbas(ISbmUserContext_Core userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) + protected SbmItemOptionConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; } @@ -38,7 +38,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; set; } + public ISbmUserOrganisationContext UserContext { get; set; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } public override short ItemOptionDataType { get { return (short)Sbm.ItemType.ItemOption; } } private SbmAccountMgr AccountMgr { get { if (accountMgr == null) accountMgr = SbmGlobals.System.CreateAccountMgr(UserContext); return accountMgr; } } diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs index de1e92f..553d900 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmReferenceDataConsole_Dbas.cs @@ -15,7 +15,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Construction. - protected SbmReferenceDataConsole_Dbas(ISbmUserContext_Core userContext) : + protected SbmReferenceDataConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Properties. public SbmSessionContext SessionContext { get; } - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } // Item types. public override short LanguageItemType { get { return (short)Sbm.ItemDataType.Unknown; } } public override short RegionItemType { get { return (short)Sbm.ItemDataType.Region; } } diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs index ee77fe4..6a30dc0 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmSecurityConsole_Dbas.cs @@ -11,6 +11,7 @@ using Sarand.Net.Standard.Base.UpdateLog; using Sarand.Net.Standard.Dbas.Security; using System; using System.Collections.Generic; +using System.Linq; namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { @@ -24,7 +25,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Construction. - protected SbmSecurityConsole_Dbas(ISbmUserContext_Core userContext) : + protected SbmSecurityConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; @@ -41,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } private SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } } public override short SecurityItemDataType { get { return (short)Sbm.ItemType.SecurityItem; } } @@ -61,14 +62,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles if (securityRights == null) { securityRights = new List(); - if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowContacts)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) { securityRights.Add(Sbm.SecurityRight.Affiliate_Create, "AffIns", "Affiliates - Create"); securityRights.Add(Sbm.SecurityRight.Affiliate_Update, "AffUpd", "Affiliates - Update"); securityRights.Add(Sbm.SecurityRight.Association_Create, "AssIns", "Associations - Create"); securityRights.Add(Sbm.SecurityRight.Association_Update, "AssUpd", "Associations - Update"); } - if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowCommodities)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) { securityRights.Add(Sbm.SecurityRight.Commodity_Create, "CmdIns", "Commodities - Create"); securityRights.Add(Sbm.SecurityRight.Commodity_Update, "CmdUpd", "Commodities - Update"); @@ -77,12 +78,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles securityRights.Add(Sbm.SecurityRight.StockTake, "CmdStkTak", "Commodities - Stock Take"); } } - if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowAssets)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Assets)) { securityRights.Add(Sbm.SecurityRight.Asset_Create, "AssetIns", "Assets - Create"); securityRights.Add(Sbm.SecurityRight.Asset_Update, "AssetUpd", "Assets - Update"); } - if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowTransactions)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Transactions)) { securityRights.Add(Sbm.SecurityRight.Transaction_Create, "TraIns", "Transactions - Create"); securityRights.Add(Sbm.SecurityRight.Transaction_Update, "TraUpd", "Transactions - Update"); @@ -106,7 +107,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { securityRights.Add(Sbm.SecurityRight.TimesheetManager, "TimMgr", "Manage - Timesheets"); } - if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.AllowTasks)) + if (SessionConsole != null && SessionConsole.AllowOption(Sbm.ConfigOption.Tasks)) { securityRights.Add(Sbm.SecurityRight.TaskManager, "TskMgr", "Manage - Tasks"); } @@ -121,14 +122,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles { // Construct list of transaction types and statuses to use in security rights. List transactionTypesStatus = new List(); - foreach (TypeCodeDesc transactionType in SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType)) + foreach (TypeCodeDesc transactionType in internals.GetSystemCodes(Sbm.SystemCode.TransactionType)) { Sbm.TransactionType transType = (Sbm.TransactionType)transactionType.Type; // Only interested in sales quotes and orders for now. bool bValidTransType = false; if (!bValidTransType) bValidTransType = (transType == Sbm.TransactionType.SalesQuote); if (!bValidTransType) bValidTransType = (transType == Sbm.TransactionType.SalesOrder); - if (fullList || bValidTransType && SessionConsole.AllowTransactionType(transType)) + if ((fullList || bValidTransType) && SessionConsole.AllowTransactionType(transType)) { // Retrieve status categories for transaction type: foreach (TypeCodeDesc transactionStatus in GetTransactionStatusCats(transType)) @@ -149,15 +150,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles private List GetTransactionStatusCats(Sbm.TransactionType eType) { List transactionStatusCats = new List(); - List transactionStatusCatsAllowed = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionStatusCat); + List transactionStatusCatsAllowed = Internals.GetSystemCodes(Sbm.SystemCode.TransactionStatusCat); switch (eType) { // NB Changes here may also need to be made in SapTransaction::GetTaxEffectiveDate() // and SapphireConsole::UseInProgressTaxDateAsTaxPoint(): // Transaction types that have no 'Pending' stage: case Sbm.TransactionType.SalesLead: - transactionStatusCatsAllowed.Add(transactionStatusCats.Find(item => item.Type == (int)SbmTransaction.StatusCat.Open)); - transactionStatusCatsAllowed.Add(transactionStatusCats.Find(item => item.Type == (int)SbmTransaction.StatusCat.Closed)); + transactionStatusCats.AddRange(transactionStatusCatsAllowed.Where(item => item.Type == (int)SbmTransaction.StatusCat.Open || item.Type == (int)SbmTransaction.StatusCat.Closed)); break; // Transaction types that have no 'Open' stage: case Sbm.TransactionType.ProformaSalesOrder: @@ -165,8 +165,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles case Sbm.TransactionType.ProformaPurchaseOrder: case Sbm.TransactionType.PurchaseDelivery: case Sbm.TransactionType.ProformaSalesInvoice: - transactionStatusCatsAllowed.Add(transactionStatusCatsAllowed.Find(item => item.Type == (int)SbmTransaction.StatusCat.Pending)); - transactionStatusCatsAllowed.Add(transactionStatusCatsAllowed.Find(item => item.Type == (int)SbmTransaction.StatusCat.Closed)); + transactionStatusCats.AddRange(transactionStatusCatsAllowed.Where(item => item.Type == (int)SbmTransaction.StatusCat.Pending || item.Type == (int)SbmTransaction.StatusCat.Closed)); break; default: // All other types have the complete set: @@ -233,7 +232,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles // Transaction types: List transactionTypesDesc = new List(); List transactionTypesDescAllowed = new List(); - foreach (TypeCodeDesc transactionType in SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType)) + foreach (TypeCodeDesc transactionType in internals.GetSystemCodes(Sbm.SystemCode.TransactionType)) { if (SessionConsole.AllowTransactionType((Sbm.TransactionType)transactionType.Type)) transactionTypesDescAllowed.Add(new SysId(transactionType.Type), transactionType.Desc); @@ -260,7 +259,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles // Financial types: List financialTypesDesc = new List(); List financialTypesDescAllowed = new List(); - foreach (TypeCodeDesc financialType in SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.FinancialType)) + foreach (TypeCodeDesc financialType in internals.GetSystemCodes(Sbm.SystemCode.FinancialType)) { financialTypesDescAllowed.Add(new SysId(financialType.Type), financialType.Desc); financialTypesDesc.Add(new SysId(financialType.Type), financialType.Desc); diff --git a/SaBusMgrStandardDbas/Dbas/Consoles/SbmUpdateLogConsole_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Consoles/SbmUpdateLogConsole_Dbas.cs index 64f70aa..0e59aad 100644 --- a/SaBusMgrStandardDbas/Dbas/Consoles/SbmUpdateLogConsole_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Consoles/SbmUpdateLogConsole_Dbas.cs @@ -18,7 +18,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Construction. - protected SbmUpdateLogConsole_Dbas(ISbmUserContext_Core userContext) : + protected SbmUpdateLogConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext)) { UserContext = userContext; @@ -34,7 +34,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles //------------------------------------------------------------------- // Properties. - public ISbmUserContext_Core UserContext { get; } + public ISbmUserOrganisationContext UserContext { get; } public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } } // Consoles. public SaSecurityConsole SecurityConsole diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/Control/SbmcItemMgr_Dbas-ItemParam.cs b/SaBusMgrStandardDbas/Dbas/Mgr/Control/SbmcItemMgr_Dbas-ItemParam.cs index e701743..16eb316 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/Control/SbmcItemMgr_Dbas-ItemParam.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/Control/SbmcItemMgr_Dbas-ItemParam.cs @@ -341,9 +341,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override List GetItemParamQueryFilter(SbmcItemParam.Params prm) { List filter = new List(); + String colId = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Id, aliasItemParam); + String colContext = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Context, aliasItemParam); + String colName = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Name, aliasItemParam); // Id. - String colId = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Id, aliasItemParam); if (prm.IdsIncluded.HasValidIds()) filter.Add($"{colId} IN ({prm.IdsIncluded.Concat(",")})"); if (prm.IdsExcluded.HasValidIds()) @@ -351,21 +353,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Item Id. - String colItemType = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_ItemType, aliasItemParam); - String colItemId = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_ItemId, aliasItemParam); if (prm.ItemIdsIncluded.Any()) { + String colItemType = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_ItemType, aliasItemParam); + String colItemId = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_ItemId, aliasItemParam); HashSet itemFilter = new HashSet(); foreach (ItemId itemId in prm.ItemIdsIncluded) itemFilter.Add($"{colItemType}={itemId.Type} And {colItemId}={SysId.ToLong(itemId.Id)}"); filter.Add(itemFilter.Concat(" Or ", "(", ")")); } + // Context. + if (!StringUtil.IsBlank(prm.Context)) + filter.Add($"{colContext}='{DbQuery.FormatForCondition(prm.Context)}'"); + + // Name. + if (!StringUtil.IsBlank(prm.Name)) + filter.Add($"{colName}='{DbQuery.FormatForCondition(prm.Name)}'"); + // Generic search. if (!StringUtil.IsBlank(prm.Search)) { - String colContext = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Context, aliasItemParam); - String colName = SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Name, aliasItemParam); foreach (String search in Regex.Split(prm.Search, "[\\s,;\\-+]+")) { if (StringUtil.IsBlank(search)) continue; @@ -379,7 +387,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Common Properties. // Notes. - if (!StringUtil.IsEmpty(prm.NotesPartial)) + if (!StringUtil.IsBlank(prm.NotesPartial)) filter.Add($"{SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Notes, aliasItemParam)} LIKE '%{DbQuery.FormatForLike(prm.NotesPartial)}%'"); // Status. @@ -433,6 +441,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (sortColumnNames.IsEmpty()) { // Default sort columns: + sortColumnNames.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_ItemType, aliasItemParam) + " ASC"); + sortColumnNames.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_ItemId, aliasItemParam) + " ASC"); + sortColumnNames.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Context, aliasItemParam) + " ASC"); sortColumnNames.Add(SbmDbDfn_Control.GetColumnNameQual(SbmDbDfn_Control.ColumnIdx.ItemParam_Name, aliasItemParam) + " ASC"); } return sortColumnNames; diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs index fd02f97..48c571e 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Address.cs @@ -36,20 +36,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr new StringPair("Status",address.StatusCode) }; } - public override bool VerifyAsPrimaryAddress(SbmAddress addressPrimary) + public override bool VerifyAsPrimaryAddress(SbmAddress addressPrimary, DbUpdateInfo dbUpdateInfo) { // Check that this is the only primary address for the item. ClearErrorState(); if (addressPrimary == null) return SetErrorState("item not specified"); if (!SysId.IsValid(addressPrimary.Id)) return SetErrorState("invalid item id"); if (!addressPrimary.IsPrimary) return SetErrorState("address is not primary"); - if (db == null) return SetErrorState("database not available"); + if (Database == null) return SetErrorState("database not available"); SysId addressPrimaryId = addressPrimary.Id; String colAddress_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Address_Id); // Identify the other addresses for the same item that are also primary. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address)); qry.Columns.Add(colAddress_Id); qry.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Address_ItemType) + "=" + ((int)addressPrimary.ItemType).ToString()); @@ -57,7 +57,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.Filters.Add(colAddress_Id + "<>" + addressPrimaryId.ToString()); qry.Filters.Add(GetPrimaryAddressFilter(true, aliasAddress)); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (address != null && address.Id != addressPrimaryId && address.IsPrimary) { address.IsPrimary = false; - if (!UpdateAddress(address, UserContext.DbUpdateInfo)) SetErrorState("failed to update adress - " + ErrorState); + if (!UpdateAddress(address, dbUpdateInfo)) SetErrorState("failed to update adress - " + ErrorState); } } } @@ -117,7 +117,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmAddress address = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -152,7 +152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidAddress(address)) return false; if (SysId.IsValid(address.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Address_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbAddress._Id = SysId.ToInt(db.GetNextId("Address", dbUpdateInfo)); + dbAddress._Id = SysId.ToInt(Database.GetNextId("Address", dbUpdateInfo)); } dbAddress.ExecuteInsertCommand(dbCommand); address.Id = new SysId(dbAddress._Id); @@ -187,7 +187,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(address).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -225,7 +225,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!AddressCanBeDeleted(address)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -621,7 +621,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Primary Address Filter public String GetPrimaryAddressFilter(bool match, String aliasTable) { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); return DbQuery.BuildBitMappedFilter(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Flags, aliasAddress), SbmAddress.Flag_Primary, match); } @@ -664,7 +664,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAddressCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address) + " As " + aliasAddress, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address) + " As " + aliasAddress, filter); } public override long GetAddressCount(SbmAddress.Params prm) { @@ -678,14 +678,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List addresses = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAddress); Address_Db dbAddress = new Address_Db(DbInfo); qry.Columns.AddRange(dbAddress.ExistingColumnNames); qry.Filters.AddRange(GetAddressQueryFilter(prm)); qry.OrderBy.AddRange(GetAddressSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -719,7 +719,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAddress); // Address Properties - add columns as defined in query list. @@ -784,8 +784,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs index 81b3ec8..e6c6061 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Affiliate.cs @@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmAffiliate affiliate = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -174,7 +174,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidAffiliate(affiliate)) return false; if (SysId.IsValid(affiliate.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -185,7 +185,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Affiliate_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbAffiliate._Id = SysId.ToInt(db.GetNextId("Affiliate", dbUpdateInfo)); + dbAffiliate._Id = SysId.ToInt(Database.GetNextId("Affiliate", dbUpdateInfo)); } dbAffiliate.ExecuteInsertCommand(dbCommand); affiliate.Id = new SysId(dbAffiliate._Id); @@ -209,7 +209,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(affiliate).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -247,7 +247,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!AffiliateCanBeDeleted(affiliate)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -637,7 +637,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAddress_Phone = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Phone, aliasAffAddPhone); String colAddress_Fax = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Fax, aliasAffAddPhone); // Build the sub query to match addresses with this partial phone number. - DbQuery qryAddressPhone = new DbQuery(db.DbmsType); + DbQuery qryAddressPhone = new DbQuery(Database.DbmsType); qryAddressPhone.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAffAddPhone); qryAddressPhone.Columns.Add(colAddress_Id); qryAddressPhone.Filters.Add(colAddress_Owner + "=" + colAffiliate_Id); @@ -664,7 +664,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAddress_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAffiliate_Address); String colAddress_Owner = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_AffIdOwner, aliasAffiliate_Address); // Build the sub query. - DbQuery qryAddressPostcode = new DbQuery(db.DbmsType); + DbQuery qryAddressPostcode = new DbQuery(Database.DbmsType); qryAddressPostcode.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAffiliate_Address); qryAddressPostcode.Columns.Add(colAddress_Id); qryAddressPostcode.Filters.Add(colAddress_Owner + "=" + colAffiliate_Id); @@ -739,7 +739,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr subFilter += " AND " + GetFlagFilter(SbmAssociation.Flag_Supervised, superMatch, aliasAffAssocRef); } - DbQuery qryAssociationTarget = new DbQuery(db.DbmsType); + DbQuery qryAssociationTarget = new DbQuery(Database.DbmsType); qryAssociationTarget.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAffAssocRef); qryAssociationTarget.Columns.Add(colAssociation_Id); qryAssociationTarget.Filters.Add(subFilter); @@ -763,7 +763,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Restrict to affiliates that are the owner of an association with the specified target: String aliasAffAssExclude = "aAffAssExc"; - DbQuery qryAssociationTarget = new DbQuery(db.DbmsType); + DbQuery qryAssociationTarget = new DbQuery(Database.DbmsType); qryAssociationTarget.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAffAssExclude); qryAssociationTarget.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget, aliasAffAssExclude)); qryAssociationTarget.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner, aliasAffAssExclude) + "=" + colAffiliate_Id); @@ -782,7 +782,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Exclude affiliates that are already a system user for the specified Inteface. String aliasSystemUser = "aSysUser"; - DbQuery qrySystemUser = new DbQuery(db.DbmsType); + DbQuery qrySystemUser = new DbQuery(Database.DbmsType); qrySystemUser.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser), aliasSystemUser); qrySystemUser.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemUser_Id, aliasSystemUser)); qrySystemUser.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemUser_AffiliateId, aliasSystemUser) + "=" + colAffiliate_Id); @@ -851,7 +851,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAffiliateCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate) + " As " + aliasAffiliate, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate) + " As " + aliasAffiliate, filter); } public override long GetAffiliateCount(SbmAffiliate.Params prm) { @@ -865,12 +865,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List affiliateIds = new List(); if (db != null) { - DbQuery qryAffId = new DbQuery(db.DbmsType); + DbQuery qryAffId = new DbQuery(Database.DbmsType); qryAffId.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate)); String colAffiliate_Id = "AffiliateId"; qryAffId.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Affiliate_Id, true), colAffiliate_Id); qryAffId.Filters.AddRange(GetAffiliateQueryFilter(prmAffiliate)); - db.ErrorState = qryAffId.BuildQuery; + Database.ErrorState = qryAffId.BuildQuery; } }*/ @@ -880,14 +880,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List affiliates = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasAffiliate); Affiliate_Db dbAffiliate = new Affiliate_Db(DbInfo); qry.Columns.AddRange(dbAffiliate.ExistingColumnNames); qry.Filters.AddRange(GetAffiliateQueryFilter(prm)); qry.OrderBy.AddRange(GetAffiliateSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -921,7 +921,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasAffiliate); // Affiliate Properties - add columns as defined in query list. @@ -989,7 +989,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (hasColsAddPrim) { // Sub-query to identify primary address with lowest Id for each affiliate. - DbQuery qryAddPrimMinId = new DbQuery(db.DbmsType); + DbQuery qryAddPrimMinId = new DbQuery(Database.DbmsType); qryAddPrimMinId.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address)); qryAddPrimMinId.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Address_ItemType) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); qryAddPrimMinId.Filters.Add(DbQuery.BuildBitMappedFilter(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Address_Flags), SbmAddress.Flag_Primary, true)); @@ -1037,7 +1037,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Count group members. String aliasAffiliate_GroupMembers = "AffGrpMembers"; - DbQuery qryGrpMembers = new DbQuery(db.DbmsType); + DbQuery qryGrpMembers = new DbQuery(Database.DbmsType); qryGrpMembers.Tables.Add((SbmDbDfn.TableIdx.Association).ToString(), aliasAffiliate_GroupMembers); // Was: qryGrpMembers.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasGrpMembers) + ")"); qryGrpMembers.Columns.Add("Count(*)"); @@ -1053,7 +1053,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Count active associations. String aliasAffiliate_Associations_Owner = "AffAssOwner"; - DbQuery qryAssocs = new DbQuery(db.DbmsType); + DbQuery qryAssocs = new DbQuery(Database.DbmsType); qryAssocs.Tables.Add((SbmDbDfn.TableIdx.Association).ToString(), aliasAffiliate_Associations_Owner); qryAssocs.Columns.Add("Count(*)"); qryAssocs.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner, aliasAffiliate_Associations_Owner)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliate)}"); @@ -1066,7 +1066,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Count active associations. String aliasAffiliate_Associations_Target = "AffAssTarget"; - DbQuery qryAssocs = new DbQuery(db.DbmsType); + DbQuery qryAssocs = new DbQuery(Database.DbmsType); qryAssocs.Tables.Add((SbmDbDfn.TableIdx.Association).ToString(), aliasAffiliate_Associations_Target); qryAssocs.Columns.Add("Count(*)"); qryAssocs.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget, aliasAffiliate_Associations_Target)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasAffiliate)}"); @@ -1088,7 +1088,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs index 79c0ad0..cac7eac 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-Association.cs @@ -38,11 +38,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { List types = new List(); // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association)); qry.Columns.Add("DISTINCT " + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type)); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + AffiliateId_Owner.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public List GetTargetIds(SysId affiliateIdOwner, Sbm.AssociationType associationType, List affiliateIncludeIds, List affiliateExcludeIds) { List affiliateIdsTarget = new List(); - if (db == null) return affiliateIdsTarget; + if (Database == null) return affiliateIdsTarget; bool validConfig = true; if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1) { @@ -87,7 +87,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (validConfig) { String colAffiliateIdTarget = "AffIdTgt"; - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget), colAffiliateIdTarget); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + affiliateIdOwner.ToString()); @@ -97,7 +97,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (affiliateExcludeIds.Count > 0) qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " NOT IN(" + affiliateExcludeIds.Concat(",") + ")"); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -115,7 +115,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override List GetAssocIdsForTargets(SysId affiliateIdOwner, Sbm.AssociationType associationType, List affiliateIdsTarget) { List associations = new List(); - if (db == null) return associations; + if (Database == null) return associations; bool validConfig = true; if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1) { @@ -137,14 +137,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (validConfig) { String colAssociationId = "AssocId"; - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id), colAssociationId); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdOwner) + "=" + affiliateIdOwner.ToString()); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Type) + "=" + ((int)associationType).ToString()); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget) + " IN " + affiliateIdsTarget.Concat(",")); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -166,7 +166,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysId.IsValid(affiliateIdOwner) || (int)associationType < 1) return 0; - if (db != null) + if (Database != null) { SbmAssociation.Params prmAssociation = new SbmAssociation.Params { @@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr StatusCat = activeOnly ? SbmAssociation.StatusCat.Active : SbmAssociation.StatusCat.NotDeleted }; String filter = GetAssociationQueryFilter(prmAssociation).Concat(" AND ", "(", ")"); - db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filter); + Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filter); } return 0; } @@ -187,7 +187,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysId.IsValid(affiliateIdOwner) || !SysId.IsValid(affiliateIdTarget)) return 0; - if (db != null) + if (Database != null) { SbmAssociation.Params prmAssociation = new SbmAssociation.Params { @@ -196,7 +196,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr StatusCat = activeOnly ? SbmAssociation.StatusCat.Active : SbmAssociation.StatusCat.NotDeleted }; String filter = GetAssociationQueryFilter(prmAssociation).Concat(" AND ", "(", ")"); - db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filter); + Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filter); } return 0; } @@ -208,7 +208,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysId.IsValid(affiliateIdTarget) || (int)associationType < 1) return 0; - if (db != null) + if (Database != null) { SbmAssociation.Params prmAssociation = new SbmAssociation.Params { @@ -217,7 +217,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr StatusCat = activeOnly ? SbmAssociation.StatusCat.Active : SbmAssociation.StatusCat.NotDeleted }; String filter = GetAssociationQueryFilter(prmAssociation).Concat(" AND ", "(", ")"); - db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filter); + Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filter); } return 0; } @@ -254,7 +254,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmAssociation association = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -348,7 +348,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidAssociation(association)) return false; if (SysId.IsValid(association.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -359,7 +359,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Association_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbAssociation._Id = SysId.ToInt(db.GetNextId("Association", dbUpdateInfo)); + dbAssociation._Id = SysId.ToInt(Database.GetNextId("Association", dbUpdateInfo)); } dbAssociation.ExecuteInsertCommand(dbCommand); association.Id = new SysId(dbAssociation._Id); @@ -383,7 +383,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(association).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -421,7 +421,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!AssociationCanBeDeleted(association)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -813,7 +813,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr SetAssociationColDfn(columnDfn, "Amount trans max", 90, SbmDbDfn.ColumnIdx.Association_AmountTransMax, ColumnAlignment.Right, DataValue.DataType.Double); break; case SbmAssociation.Column.AnnualSalesTarget: - if (UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales)) + if (UserCanViewCommoditySalesFinancials()) { SetAssociationColDfn(columnDfn, "Annual sales target", 90, SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget, ColumnAlignment.Right, DataValue.DataType.Double); columnDfn.NumDecimals = 0; @@ -1241,21 +1241,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr columnDfn.DataName = colAssociation_LastSaleRaised; break; case SbmAssociation.Column.Trans_SalesValue_Open: // Net open sales order value. - if (UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales)) + if (UserCanViewCommoditySalesFinancials()) { SetAssociationColDfn(columnDfn, "Open sales", 80, SbmDbDfn.ColumnIdx.Unknown, ColumnAlignment.Right, DataValue.DataType.Double); columnDfn.DataName = colAssociation_SalesValueOpen; } break; case SbmAssociation.Column.Trans_SalesValue_Cytd: // Net sales order value closed this calendar year. - if (UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales)) + if (UserCanViewCommoditySalesFinancials()) { SetAssociationColDfn(columnDfn, "Sales CYTD", 80, SbmDbDfn.ColumnIdx.Unknown, ColumnAlignment.Right, DataValue.DataType.Double); columnDfn.DataName = colAssociation_SalesValueCytd; } break; case SbmAssociation.Column.Trans_SalesValue_Lcy: // Net sales order value closed last calendar year. - if (UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales)) + if (UserCanViewCommoditySalesFinancials()) { SetAssociationColDfn(columnDfn, "Sales LCY", 80, SbmDbDfn.ColumnIdx.Unknown, ColumnAlignment.Right, DataValue.DataType.Double); columnDfn.DataName = colAssociation_SalesValueLcy; @@ -1305,12 +1305,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Association query filter. public String GetFlagValue(ushort flag, bool match, String aliasTable) { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); return DbQuery.BuildBitMappedFilter(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Flags, aliasTable), flag, match); } public String GetFlagFilter(ushort flag, bool match, String aliasTable) { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); return DbQuery.BuildBitMappedFilter(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Flags, aliasTable), flag, match); } // Has each filter prm-col been specified. @@ -1350,7 +1350,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //Association must also be a member of this contact group. String aliasAssocContactGroup = "aAssConGrp"; - DbQuery queryAssocContactGroup = new DbQuery(db.DbmsType); + DbQuery queryAssocContactGroup = new DbQuery(Database.DbmsType); queryAssocContactGroup.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAssocContactGroup); String colAssocConGrp_AffIdTarget = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AffIdTarget, aliasAssocContactGroup); @@ -1411,7 +1411,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Target affiliate alias not supplied - table is not joined in main query. // Sub query on target affiliate. - DbQuery queryAffTarget = new DbQuery(db.DbmsType); + DbQuery queryAffTarget = new DbQuery(Database.DbmsType); queryAffTarget.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasAffiliateTarget); queryAffTarget.Columns.Add(colAffiliate_Id); queryAffTarget.Filters.Add(colAffiliate_Id + "=" + colAssociation_AffIdTarget); @@ -1466,7 +1466,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Target address alias not supplied - table is not joined in main query. // Sub query on target address. - DbQuery queryAddTarget = new DbQuery(db.DbmsType); + DbQuery queryAddTarget = new DbQuery(Database.DbmsType); queryAddTarget.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAddTarget); queryAddTarget.Columns.Add(colAddress_Id); queryAddTarget.Filters.Add(colAddress_ItemType + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1508,7 +1508,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Target affiliate alias not supplied - table is not joined in main query. // Sub query on target affiliate. - DbQuery queryAffTarget = new DbQuery(db.DbmsType); + DbQuery queryAffTarget = new DbQuery(Database.DbmsType); queryAffTarget.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasAffiliateTarget); queryAffTarget.Columns.Add(colAffiliate_Id); queryAffTarget.Filters.Add(colAffiliate_Id + "=" + colAssociation_AffIdTarget); @@ -1546,7 +1546,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Target address alias not supplied - table is not joined in main query. // Sub query on target address. - DbQuery queryAddTarget = new DbQuery(db.DbmsType); + DbQuery queryAddTarget = new DbQuery(Database.DbmsType); queryAddTarget.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAddTarget); queryAddTarget.Columns.Add(colAddress_Id); queryAddTarget.Filters.Add(colAddress_ItemType + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1597,7 +1597,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterAccountManager.Add(colAssociation_AccountManagerCode + " IN " + accountManagerCodes); // Also include associations where the target has addresses associated with this Account Manager: String aliasAccMgr = "aAccMgr"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAccMgr); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAccMgr)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasAccMgr) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1615,7 +1615,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterAccountHandler.Add(colAssociation_AccountHandlerCode + " IN " + accountHandlerCodes); // Also include associations where the target has addresses associated with this Account Handler: String aliasAccHdr = "aliasAccHdr"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasAccHdr); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasAccHdr)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasAccHdr) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1647,7 +1647,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterContactArea.Add(colAssociation_ContactAreaCode + " IN " + contactAreaCodes); // Also include associations where the target has addresses associated with this Contact Area: String aliasCntArea = "aCntArea"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasCntArea); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasCntArea)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasCntArea) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1665,7 +1665,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterContactHandler.Add(colAssociation_ContactHandlerCode + " IN " + contactHandlerCodes); // Also include associations where the target has addresses associated with this Contact Handler: String aliasCntHdr = "aCntHdr"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasCntHdr); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasCntHdr)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasCntHdr) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1704,7 +1704,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterDeliveryTypeCodes.Add(colAssociation_DeliveryTypeCode + " IN " + deliveryTypeCodes); // Also include associations where the target has addresses associated with this Delivery Type: String aliasDelTypCd = "aDelTypCd"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasDelTypCd); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasDelTypCd)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasDelTypCd) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1722,7 +1722,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterDeliveryMethodCodes.Add(colAssociation_DeliveryMethodCode + " IN " + deliveryMethodCodes); // Also include associations where the target has addresses associated with this Delivery Method: String aliasDelMthdCd = "aDelMthdCd"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasDelMthdCd); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasDelMthdCd)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasDelMthdCd) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1740,7 +1740,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filterDeliveryBookInCodes.Add(colAssociation_DeliveryBookInCode + " IN " + deliveryBookInCodes); // Also include associations where the target has addresses associated with this Delivery BookIn: String aliasDelBkInCd = "aDelBkInCd"; - DbQuery qryAdd = new DbQuery(db.DbmsType); + DbQuery qryAdd = new DbQuery(Database.DbmsType); qryAdd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address), aliasDelBkInCd); qryAdd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_Id, aliasDelBkInCd)); qryAdd.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Address_ItemType, aliasDelBkInCd) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); @@ -1757,7 +1757,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filterTrans = new List(); DateTime dateTime = new DateTime(1970, 1, 1); // Constructed to set DBMS (in case required to format query elements). - DbQuery qryTrans = new DbQuery(db.DbmsType); + DbQuery qryTrans = new DbQuery(Database.DbmsType); String colTransaction_InProgress = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_InProgress); String colTransaction_Closed = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Closed); String colTransaction_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Status); @@ -1822,7 +1822,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Exclude affiliates that are already a system Account for the specified Inteface: String aliasSysAcc = "aSysAcc"; - DbQuery qrySysAcc = new DbQuery(db.DbmsType); + DbQuery qrySysAcc = new DbQuery(Database.DbmsType); qrySysAcc.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount), aliasSysAcc); qrySysAcc.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_Id, aliasSysAcc)); qrySysAcc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_AssocId, aliasSysAcc) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id)); @@ -1856,7 +1856,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Associated Codes - with Seasonal Category Code & Item Link. if (!StringUtil.IsEmpty(prm.SeasonalCategoryCode)) { - DbQuery qryCode = new DbQuery(db.DbmsType); + DbQuery qryCode = new DbQuery(Database.DbmsType); qryCode.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink)); qryCode.Columns.Add("1"); qryCode.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_Type) + "=" + ((int)Sbm.ItemLinkType.ItemCodeList_SeasonalCategory).ToString()); @@ -1913,7 +1913,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAssociationCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association) + " As " + aliasAssociation, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association) + " As " + aliasAssociation, filter); } public override long GetAssociationCount(SbmAssociation.Params prm) { @@ -1927,14 +1927,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List associations = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAssociation); Association_Db dbAssociation = new Association_Db(DbInfo); qry.Columns.AddRange(dbAssociation.ExistingColumnNames); qry.Filters.AddRange(GetAssociationQueryFilter(prm)); qry.OrderBy.AddRange(GetAssociationSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -1966,11 +1966,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Retrieve the database. ClearErrorState(); - bool CanManageFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + bool CanViewFinancials = UserCanViewCommoditySalesFinancials(); //--------------------------------------------------------------------- // Construct Query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasAssociation); // Association columns properties. @@ -2002,9 +2002,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Accounting columns. if (columns.HasId((int)SbmAssociation.Column.DefaultNominalCode) && ColumnExists(SbmDbDfn.ColumnIdx.Association_DefaultNominalCode)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_DefaultNominalCode, aliasAssociation)); - if (columns.HasId((int)SbmAssociation.Column.AmountTransMax) && CanManageFinancials) + if (columns.HasId((int)SbmAssociation.Column.AmountTransMax) && CanViewFinancials) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AmountTransMax, aliasAssociation)); - if (columns.HasId((int)SbmAssociation.Column.AnnualSalesTarget) && CanManageFinancials && ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) + if (columns.HasId((int)SbmAssociation.Column.AnnualSalesTarget) && CanViewFinancials && ColumnExists(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_AnnualSalesTarget, aliasAssociation)); if (columns.HasId((int)SbmAssociation.Column.CreditLimit)) query.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_CreditLimit, aliasAssociation)); @@ -2194,7 +2194,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr else { // Sub-query to identify primary address with lowest Id for each affiliate. - DbQuery qryAddPrimMinId = new DbQuery(db.DbmsType); + DbQuery qryAddPrimMinId = new DbQuery(Database.DbmsType); qryAddPrimMinId.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Address)); qryAddPrimMinId.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Address_ItemType) + "=" + ((int)Sbm.ItemType.Affiliate).ToString()); if (prm.AddressContext == SbmAssociation.Params.AddressContextType.Delivery) @@ -2415,7 +2415,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Last sales order opened. String aliasAssociation_Transaction = "AssocTrn"; - DbQuery queryTrans = new DbQuery(db.DbmsType); + DbQuery queryTrans = new DbQuery(Database.DbmsType); queryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasAssociation_Transaction); queryTrans.Columns.Add("MAX(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Raised, aliasAssociation_Transaction) + ")"); queryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AssocId, aliasAssociation_Transaction) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation)); @@ -2424,11 +2424,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Columns.Add("(" + queryTrans.BuildQuery() + ")", colAssociation_LastSaleRaised); } // Value of Sales Orders. - if (columns.HasId((int)SbmAssociation.Column.Trans_SalesValue_Open) && CanManageFinancials) + if (columns.HasId((int)SbmAssociation.Column.Trans_SalesValue_Open) && CanViewFinancials) { // Net open sales order value. String aliasAssociation_Transaction = "AssocTrn"; - DbQuery queryTrans = new DbQuery(db.DbmsType); + DbQuery queryTrans = new DbQuery(Database.DbmsType); queryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasAssociation_Transaction); queryTrans.Columns.Add("MAX(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AmountNet, aliasAssociation_Transaction) + ")"); queryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AssocId, aliasAssociation_Transaction) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation)); @@ -2436,11 +2436,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr queryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_StatusCat, aliasAssociation_Transaction) + "<>'" + TransactionStatusCats.GetCodeForType(SbmTransaction.StatusCat.Closed) + "'"); query.Columns.Add("(" + queryTrans.BuildQuery() + ")", colAssociation_SalesValueOpen); } - if (columns.HasId((int)SbmAssociation.Column.Trans_SalesValue_Cytd) && CanManageFinancials) + if (columns.HasId((int)SbmAssociation.Column.Trans_SalesValue_Cytd) && CanViewFinancials) { // Net sales order value closed this calendar year. String aliasAssociation_Transaction = "AssocTrn"; - DbQuery queryTrans = new DbQuery(db.DbmsType); + DbQuery queryTrans = new DbQuery(Database.DbmsType); queryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasAssociation_Transaction); queryTrans.Columns.Add("MAX(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AmountNet, aliasAssociation_Transaction) + ")"); queryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AssocId, aliasAssociation_Transaction) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation)); @@ -2449,11 +2449,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr queryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Closed, aliasAssociation_Transaction) + ">=" + DbQuery.FormatDateForCondition(new DateTime(DateTime.Today.Year, 1, 1))); query.Columns.Add("(" + queryTrans.BuildQuery() + ")", colAssociation_SalesValueCytd); } - if (columns.HasId((int)SbmAssociation.Column.Trans_SalesValue_Lcy) && CanManageFinancials) + if (columns.HasId((int)SbmAssociation.Column.Trans_SalesValue_Lcy) && CanViewFinancials) { // Net sales order value closed last calendar year. String aliasAssociation_Transaction = "AssocTrn"; - DbQuery queryTrans = new DbQuery(db.DbmsType); + DbQuery queryTrans = new DbQuery(Database.DbmsType); queryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasAssociation_Transaction); queryTrans.Columns.Add("MAX(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AmountNet, aliasAssociation_Transaction) + ")"); queryTrans.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_AssocId, aliasAssociation_Transaction) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation)); @@ -2486,7 +2486,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (validDatabase && tableIdx != SbmDbDfn.TableIdx.Unknown && columnIdxAssociationId != SbmDbDfn.ColumnIdx.Unknown) { // Number of commodities defined for the association. - DbQuery qryCmd = new DbQuery(db.DbmsType); + DbQuery qryCmd = new DbQuery(Database.DbmsType); qryCmd.Tables.Add(SbmDbDfn.GetTableName(tableIdx), aliasCommodityAssociation); qryCmd.Columns.Add("Count(*)"); qryCmd.Filters.Add(SbmDbDfn.GetColumnNameQual(columnIdxAssociationId, aliasCommodityAssociation) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, aliasAssociation)); @@ -2506,8 +2506,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs index 8227b5a..2ade06f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SysParam.cs @@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmSysParam sysParam = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -100,7 +100,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidSysParam(sysparam)) return false; if (SysId.IsValid(sysparam.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -111,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SysParam_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbSysParam._Id = SysId.ToInt(db.GetNextId("SysParam", dbUpdateInfo)); + dbSysParam._Id = SysId.ToInt(Database.GetNextId("SysParam", dbUpdateInfo)); } dbSysParam.ExecuteInsertCommand(dbCommand); sysparam.Id = new SysId(dbSysParam._Id); @@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(sysparam).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -173,7 +173,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysParamCanBeDeleted(sysparam)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -415,7 +415,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetSysParamCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SysParam) + " As " + aliasSysParam, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SysParam) + " As " + aliasSysParam, filter); } public override long GetSysParamCount(SbmSysParam.Params prm) { @@ -429,14 +429,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List sysParams = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SysParam), aliasSysParam); SysParam_Db dbSysParam = new SysParam_Db(DbInfo); qry.Columns.AddRange(dbSysParam.ExistingColumnNames); qry.Filters.AddRange(GetSysParamQueryFilter(prm)); qry.OrderBy.AddRange(GetSysParamSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -470,7 +470,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SysParam), aliasSysParam); // SysParam Properties - add columns as defined in query list. @@ -510,8 +510,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs index a7254cf..86b336f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccount.cs @@ -72,7 +72,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmSystemAccount systemAccount = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -107,7 +107,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidSystemAccount(systemAccount)) return false; if (SysId.IsValid(systemAccount.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -118,7 +118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SystemAccount_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbSystemAccount._Id = SysId.ToInt(db.GetNextId("SystemAccount", dbUpdateInfo)); + dbSystemAccount._Id = SysId.ToInt(Database.GetNextId("SystemAccount", dbUpdateInfo)); } dbSystemAccount.ExecuteInsertCommand(dbCommand); systemAccount.Id = new SysId(dbSystemAccount._Id); @@ -142,7 +142,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(systemAccount).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SystemAccountCanBeDeleted(systemAccount)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -388,7 +388,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SysId.IsValid(prm.AffiliateExcludeIdUserAccounts)) { // Query SysUsr. - DbQuery qryUsr = new DbQuery(db.DbmsType); + DbQuery qryUsr = new DbQuery(Database.DbmsType); qryUsr.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser), aliasSystemAccount_SysUser); qryUsr.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemUser_Id, aliasSystemAccount_SysUser)); qryUsr.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemUser_AffiliateId, aliasSystemAccount_SysUser) + "=" + prm.AffiliateExcludeIdUserAccounts.ToString()); @@ -396,7 +396,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qryUsr.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_InterfaceId, aliasSystemAccount_SysUser) + "=" + prm.InterfaceId.ToString()); // Query SysAccUsr - accounts that are already associated with this user. - DbQuery qryAccUsr = new DbQuery(db.DbmsType); + DbQuery qryAccUsr = new DbQuery(Database.DbmsType); qryAccUsr.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser), aliasSystemAccount_SysAccUser); qryAccUsr.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccountUser_AccountId, aliasSystemAccount_SysAccUser)); qryAccUsr.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccountUser_UserId, aliasSystemAccount_SysAccUser) + " IN(" + qryUsr.BuildQuery() + ")"); @@ -448,7 +448,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetSystemAccountCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount) + " As " + aliasSystemAccount, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount) + " As " + aliasSystemAccount, filter); } public override long GetSystemAccountCount(SbmSystemAccount.Params prm) { @@ -462,14 +462,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List systemAccounts = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount), aliasSystemAccount); SystemAccount_Db dbSystemAccount = new SystemAccount_Db(DbInfo); qry.Columns.AddRange(dbSystemAccount.ExistingColumnNames); qry.Filters.AddRange(GetSystemAccountQueryFilter(prm)); qry.OrderBy.AddRange(GetSystemAccountSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -502,7 +502,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount), aliasSystemAccount); //--------------------------------------------------------------- - @@ -559,7 +559,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (columns.HasId((int)SbmSystemAccount.Column.UserCount)) { - DbQuery qryUsers = new DbQuery(db.DbmsType); + DbQuery qryUsers = new DbQuery(Database.DbmsType); qryUsers.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser)); qryUsers.Columns.Add("Count(" + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccountUser_UserId) + ")"); qryUsers.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccountUser_AccountId) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_Id, aliasSystemAccount)); @@ -591,8 +591,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs index 2563272..923cdd7 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemAccountUser.cs @@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmSystemAccountUser SystemAccountUser = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -100,7 +100,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidSystemAccountUser(systemAccountUser)) return false; if (SysId.IsValid(systemAccountUser.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -111,7 +111,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SystemAccountUser_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbSystemAccountUser._AccountId = SysId.ToInt(db.GetNextId("SystemAccountUser", dbUpdateInfo)); + dbSystemAccountUser._AccountId = SysId.ToInt(Database.GetNextId("SystemAccountUser", dbUpdateInfo)); } dbSystemAccountUser.ExecuteInsertCommand(dbCommand); systemAccountUser.Id = new SysId(dbSystemAccountUser._AccountId); @@ -136,7 +136,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(systemAccountUser).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -174,7 +174,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SystemAccountUserCanBeDeleted(systemAccountUser)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -353,7 +353,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Interface Id. if (SysId.IsValid(prm.InterfaceId) && !SysId.IsValid(prm.AssocId) && !SysId.IsValid(prm.AffiliateId)) { - DbQuery qryAccount = new DbQuery(db.DbmsType); + DbQuery qryAccount = new DbQuery(Database.DbmsType); qryAccount.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount)); qryAccount.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccount_Id)); qryAccount.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccount_InterfaceId) + "=" + prm.InterfaceId.ToString()); @@ -367,7 +367,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Association Id. if (SysId.IsValid(prm.AssocId)) { - DbQuery qryAccount = new DbQuery(db.DbmsType); + DbQuery qryAccount = new DbQuery(Database.DbmsType); qryAccount.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount)); qryAccount.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccount_Id)); qryAccount.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccount_AssocId) + "=" + prm.AssocId.ToString()); @@ -383,7 +383,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Affiliate Id. if (SysId.IsValid(prm.AffiliateId)) { - DbQuery qryUser = new DbQuery(db.DbmsType); + DbQuery qryUser = new DbQuery(Database.DbmsType); qryUser.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser)); qryUser.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemUser_Id)); qryUser.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemUser_AffiliateId) + "=" + prm.AffiliateId.ToString()); @@ -441,7 +441,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetSystemAccountUserCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser) + " As " + aliasSystemAccountUser, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser) + " As " + aliasSystemAccountUser, filter); } public override long GetSystemAccountUserCount(SbmSystemAccountUser.Params prm) { @@ -455,14 +455,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List systemAccountUsers = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser), aliasSystemAccountUser); SystemAccountUser_Db dbSystemAccountUser = new SystemAccountUser_Db(DbInfo); qry.Columns.AddRange(dbSystemAccountUser.ExistingColumnNames); qry.Filters.AddRange(GetSystemAccountUserQueryFilter(prm)); qry.OrderBy.AddRange(GetSystemAccountUserSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -495,7 +495,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser), aliasSystemAccountUser); // SystemAccountUser Properties - add columns as defined in query list. @@ -589,8 +589,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs index 1fb063e..4d7758d 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas-SystemUser.cs @@ -68,7 +68,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmSystemUser SystemUser = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidSystemUser(systemUser)) return false; if (SysId.IsValid(systemUser.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -114,7 +114,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SystemUser_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbSystemUser._Id = SysId.ToInt(db.GetNextId("SystemUser", dbUpdateInfo)); + dbSystemUser._Id = SysId.ToInt(Database.GetNextId("SystemUser", dbUpdateInfo)); } dbSystemUser.ExecuteInsertCommand(dbCommand); systemUser.Id = new SysId(dbSystemUser._Id); @@ -138,7 +138,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. {GetLogProperties(systemUser).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -176,7 +176,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SystemUserCanBeDeleted(systemUser)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -373,7 +373,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!StringUtil.IsEmpty(prm.EmailPartial)) { // Query contacts (affiliates) by partial email. - DbQuery qryAff = new DbQuery(db.DbmsType); + DbQuery qryAff = new DbQuery(Database.DbmsType); qryAff.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasSystemUser_Affiliate); qryAff.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Id, aliasSystemUser_Affiliate)); qryAff.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Affiliate_Email, aliasSystemUser_Affiliate) + " LIKE '" + DbQuery.FormatForLike(prm.EmailPartial) + "%'"); @@ -385,7 +385,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SysId.IsValid(prm.AssocationExcludeIdUserAccounts)) { // Query system account. - DbQuery qrySysAcc = new DbQuery(db.DbmsType); + DbQuery qrySysAcc = new DbQuery(Database.DbmsType); qrySysAcc.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount), aliasSystemUser_SystemAccount); qrySysAcc.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_Id, aliasSystemUser_SystemAccount)); qrySysAcc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_AssocId, aliasSystemUser_SystemAccount) + "=" + prm.AssocationExcludeIdUserAccounts.ToString()); @@ -393,7 +393,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qrySysAcc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccount_InterfaceId, aliasSystemUser_SystemAccount) + "=" + prm.InterfaceId.ToString()); // Query users that belong to this account. - DbQuery qrySysAccUsr = new DbQuery(db.DbmsType); + DbQuery qrySysAccUsr = new DbQuery(Database.DbmsType); qrySysAccUsr.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser), aliasSystemUser_SystemAccountUser); qrySysAccUsr.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccountUser_UserId, aliasSystemUser_SystemAccountUser)); qrySysAccUsr.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemAccountUser_AccountId, aliasSystemUser_SystemAccountUser) + " IN(" + qrySysAcc.BuildQuery() + ")"); @@ -445,7 +445,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetSystemUserCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser) + " As " + aliasSystemUser, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser) + " As " + aliasSystemUser, filter); } public override long GetSystemUserCount(SbmSystemUser.Params prm) { @@ -459,14 +459,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List systemUsers = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser), aliasSystemUser); SystemUser_Db dbSystemUser = new SystemUser_Db(DbInfo); qry.Columns.AddRange(dbSystemUser.ExistingColumnNames); qry.Filters.AddRange(GetSystemUserQueryFilter(prm)); qry.OrderBy.AddRange(GetSystemUserSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -499,7 +499,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemUser), aliasSystemUser); // SystemUser Properties - add columns as defined in query list. @@ -538,7 +538,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Number of associated accounts: if (columns.HasId((int)SbmSystemUser.Column.AccountCount)) { - DbQuery qryAccounts = new DbQuery(db.DbmsType); + DbQuery qryAccounts = new DbQuery(Database.DbmsType); qryAccounts.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccountUser), aliasSystemUser_SystemAccountUser); qryAccounts.Columns.Add("Count(" + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccountUser_AccountId) + ")", aliasSystemUser_SystemAccountUser); qryAccounts.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SystemAccountUser_UserId) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SystemUser_Id, aliasSystemUser)); @@ -570,8 +570,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas.cs index ff3f2c5..5f6b9f2 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAccountMgr_Dbas.cs @@ -13,15 +13,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Construction. - public SbmAccountMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmAccountMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmAccountMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - DbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); + Initialise(); } protected override void Dispose(bool disposing) { @@ -31,10 +40,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr base.Dispose(disposing); } + //------------------------------------------------------------------- + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); + } + //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get; } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } public override bool SystemAccountDatabaseIsValid { get { return Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount)); } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs index 188c507..6bbf2e6 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Asset.cs @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmAsset asset = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidAsset(asset)) return false; if (SysId.IsValid(asset.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -119,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaAsset_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbAsset._Id = SysId.ToInt(db.GetNextId("Asset", dbUpdateInfo)); + dbAsset._Id = SysId.ToInt(Database.GetNextId("Asset", dbUpdateInfo)); } dbAsset.ExecuteInsertCommand(dbCommand); asset.Id = new SysId(dbAsset._Id); @@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(asset).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!AssetCanBeDeleted(asset)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -521,7 +521,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SysId.IsValid(prm.ProcessIdActive)) { String aliasItemLink = "aAstItemLnk"; - DbQuery qryProc = new DbQuery(db.DbmsType); + DbQuery qryProc = new DbQuery(Database.DbmsType); qryProc.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), aliasItemLink)); qryProc.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom, aliasItemLink)); qryProc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom, aliasItemLink) + "=" + ((int)Sbm.ItemType.Asset).ToString()); @@ -581,7 +581,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAssetCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset) + " As " + aliasAsset, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset) + " As " + aliasAsset, filter); } public override long GetAssetCount(SbmAsset.Params prm) { @@ -595,14 +595,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List assets = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset), aliasAsset); SaAsset_Db dbAsset = new SaAsset_Db(DbInfo); qry.Columns.AddRange(dbAsset.ExistingColumnNames); qry.Filters.AddRange(GetAssetQueryFilter(prm)); qry.OrderBy.AddRange(GetAssetSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -635,7 +635,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset), aliasAsset); // Asset Properties - add columns as defined in query list. @@ -800,8 +800,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs index 58683fa..6729e96 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetCategory.cs @@ -48,15 +48,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public bool HasAssetCategory(SbmAssetCategory.Params prm) { ClearErrorState(); - ISacsDatabase db = SbmGlobals.Application.GetBusMgrDatabase(SessionContext); - if (db != null) + if (Database != null) { - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory))) + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory))) { String filter = GetAssetCategoryQueryFilter(prm).Concat(" AND ", "(", ")"); - db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAssetCategory_Id), 0,*/ filter); + Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAssetCategory_Id), 0,*/ filter); } - else SetErrorState(db.ErrorStateMessage); + else SetErrorState(Database.ErrorStateMessage); } return false; } @@ -79,7 +78,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmAssetCategory assetCategory = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -107,13 +106,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colAssetCategory_AssetType = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAssetCategory_AssetType); String colAssetCategory_DescBrief = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaAssetCategory_DescBrief); - DbQuery qryAssetCat = new DbQuery(db.DbmsType); + DbQuery qryAssetCat = new DbQuery(Database.DbmsType); qryAssetCat.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)); qryAssetCat.Columns.Add(colAssetCategory_Id); qryAssetCat.Columns.Add(colAssetCategory_AssetType); qryAssetCat.Columns.Add(colAssetCategory_DescBrief); qryAssetCat.Filters.AddRange(GetAssetCategoryQueryFilter(prm)); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qryAssetCat.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryAssetCat.BuildQuery())) { while (resultSet != null && resultSet.NextRecord()) { @@ -174,7 +173,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidAssetCategory(assetCategory)) return false; if (SysId.IsValid(assetCategory.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -185,7 +184,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaAssetCategory_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbAssetCategory._Id = SysId.ToInt(db.GetNextId("AssetCategory", dbUpdateInfo)); + dbAssetCategory._Id = SysId.ToInt(Database.GetNextId("AssetCategory", dbUpdateInfo)); } dbAssetCategory.ExecuteInsertCommand(dbCommand); assetCategory.Id = new SysId(dbAssetCategory._Id); @@ -209,7 +208,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(assetCategory).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -247,7 +246,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!AssetCategoryCanBeDeleted(assetCategory)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -513,7 +512,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAssetCategoryCount(String filter) { ClearErrorState(); - return db.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} As {aliasAssetCategory}", filter); + return Database.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory)} As {aliasAssetCategory}", filter); } public override long GetAssetCategoryCount(SbmAssetCategory.Params prm) { @@ -527,14 +526,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List assetCategories = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), aliasAssetCategory); SaAssetCategory_Db dbAssetCategory = new SaAssetCategory_Db(DbInfo); qry.Columns.AddRange(dbAssetCategory.ExistingColumnNames); qry.Filters.AddRange(GetAssetCategoryQueryFilter(prm)); qry.OrderBy.AddRange(GetAssetCategorySortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -567,7 +566,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory), aliasAssetCategory); // AssetCategory Properties - add columns as defined in query list. @@ -610,7 +609,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (columns.HasId(SbmAssetCategory.Column.AssetCount)) { String tableAsset = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset); - DbQuery qryAssetCount = new DbQuery(db.DbmsType); + DbQuery qryAssetCount = new DbQuery(Database.DbmsType); qryAssetCount.Tables.Add(tableAsset, aliasAsset); qryAssetCount.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasAsset)})"); qryAssetCount.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_AssetCategoryId, aliasAsset)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAssetCategory_Id, aliasAsset)}"); @@ -641,8 +640,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs index dbe5147..1b6dc41 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-AssetProcess.cs @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmAssetProcess assetProcess = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidAssetProcess(assetProcess)) return false; if (SysId.IsValid(assetProcess.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -119,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaAssetProcess_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbAssetProcess._Id = SysId.ToInt(db.GetNextId("AssetProcess", dbUpdateInfo)); + dbAssetProcess._Id = SysId.ToInt(Database.GetNextId("AssetProcess", dbUpdateInfo)); } dbAssetProcess.ExecuteInsertCommand(dbCommand); assetProcess.Id = new SysId(dbAssetProcess._Id); @@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(assetProcess).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!AssetProcessCanBeDeleted(assetProcess)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -388,7 +388,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetAssetProcessCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess) + " As " + aliasAssetProcess, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess) + " As " + aliasAssetProcess, filter); } public override long GetAssetProcessCount(SbmAssetProcess.Params prm) { @@ -402,14 +402,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List assetProcesses = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess), aliasAssetProcess); SaAssetProcess_Db dbAssetProcess = new SaAssetProcess_Db(DbInfo); qry.Columns.AddRange(dbAssetProcess.ExistingColumnNames); qry.Filters.AddRange(GetAssetProcessQueryFilter(prm)); qry.OrderBy.AddRange(GetAssetProcessSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -442,7 +442,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetProcess), aliasAssetProcess); // AssetProcess Properties - add columns as defined in query list. @@ -483,8 +483,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs index 1f499a5..d6167f1 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-Vehicle.cs @@ -55,7 +55,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmVehicle vehicle = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -106,7 +106,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidVehicle(vehicle)) return false; if (SysId.IsValid(vehicle.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -117,7 +117,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaVehicle_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbVehicle._Id = SysId.ToInt(db.GetNextId("Vehicle", dbUpdateInfo)); + dbVehicle._Id = SysId.ToInt(Database.GetNextId("Vehicle", dbUpdateInfo)); } dbVehicle.ExecuteInsertCommand(dbCommand); vehicle.Id = new SysId(dbVehicle._Id); @@ -141,7 +141,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed.{GetLogProperties(vehicle).Concat(": ").Concat("", "\n\t")}"); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -179,7 +179,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!VehicleCanBeDeleted(vehicle)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -508,7 +508,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String classDesc = DbQuery.FormatForCondition(prm.ClassDescPartial); if (!StringUtil.IsEmpty(prm.MakeCode) || !classDesc.IsEmpty()) { - DbQuery qryVehicleClass = new DbQuery(db.DbmsType); + DbQuery qryVehicleClass = new DbQuery(Database.DbmsType); qryVehicleClass.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass), aliasVehicle_VehicleClass); qryVehicleClass.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_Id, aliasVehicle_VehicleClass)); if (!StringUtil.IsEmpty(prm.MakeCode)) @@ -533,7 +533,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SysId.IsValid(prm.AssetCatIdInclude) || SysId.IsValid(prm.AssetCatIdExclude) || SysId.IsValid(prm.AssetProcessIdNext)) { String aliasVehicle_Asset = "aVehAst"; - DbQuery qryAsset = new DbQuery(db.DbmsType); + DbQuery qryAsset = new DbQuery(Database.DbmsType); qryAsset.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset), aliasVehicle_Asset); qryAsset.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_Id, aliasVehicle_Asset)); qryAsset.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_ItemType, aliasVehicle_Asset)}={(int)Sbm.ItemType.Vehicle}"); @@ -603,7 +603,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetVehicleCount(String filter) { ClearErrorState(); - return db.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle)} As {aliasVehicle}", filter); + return Database.GetRowCount($"{SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle)} As {aliasVehicle}", filter); } public override long GetVehicleCount(SbmVehicle.Params prm) { @@ -617,14 +617,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List vehicles = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle), aliasVehicle); SaVehicle_Db dbVehicle = new SaVehicle_Db(DbInfo); qry.Columns.AddRange(dbVehicle.ExistingColumnNames); qry.Filters.AddRange(GetVehicleQueryFilter(prm)); qry.OrderBy.AddRange(GetVehicleSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -657,7 +657,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicle), aliasVehicle); // Vehicle Properties - add columns as defined in query list. @@ -713,14 +713,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Event count. - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent))) + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent))) { bool countVehicles = columns.HasId((int)SbmVehicle.Column.EventCount); if (countVehicles) { // Build sub query to directly return the number of associated Events: String aliasVehicle_VehicleEvent = "aVehVehEvt"; - DbQuery qryEvent = new DbQuery(db.DbmsType); + DbQuery qryEvent = new DbQuery(Database.DbmsType); qryEvent.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent), aliasVehicle_VehicleEvent); qryEvent.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_Id, aliasVehicle_VehicleEvent)})"); qryEvent.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleEvent_VehicleId, aliasVehicle_VehicleEvent)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle)}"); @@ -732,11 +732,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr bool bCountFeatures = columns.HasId((int)SbmVehicle.Column.FeatureCount); if (bCountFeatures) { - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature))) + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature))) { // Build sub query to directly return the number of associated Features: String aliasVehicle_VehicleFeature = "aVehVehFtr"; - DbQuery qryFeature = new DbQuery(db.DbmsType); + DbQuery qryFeature = new DbQuery(Database.DbmsType); qryFeature.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature), aliasVehicle_VehicleFeature); qryFeature.Columns.Add($"Count({SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicle_VehicleFeature)})"); qryFeature.Filters.Add($"{SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId, aliasVehicle_VehicleFeature)}={SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicle_Id, aliasVehicle)}"); @@ -754,7 +754,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Build sub query to directly return the number of associated HpiChecks. String aliasVehicle_ItemData = "aVehItmDat"; - DbQuery qryItemData = new DbQuery(db.DbmsType); + DbQuery qryItemData = new DbQuery(Database.DbmsType); qryItemData.Tables.Add(SaItemDataDbDfn.GetTableName(SaItemDataDbDfn.TableIdx.SaItemData), aliasVehicle_ItemData); qryItemData.Columns.Add($"Count({SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_Id, aliasVehicle_ItemData)})"); qryItemData.Filters.Add($"{SaItemDataDbDfn.GetColumnNameQual(SaItemDataDbDfn.ColumnIdx.SaItemData_ItemType, aliasVehicle_ItemData)}={(int)Sbm.ItemType.Vehicle}"); @@ -788,8 +788,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs index ccfa3e0..764ccdb 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleClass.cs @@ -41,12 +41,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List vehicleClasses = new List(); String colVehicleClass_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_Id); String colVehicleClass_DescBrief = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_DescBrief); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass)); qry.Columns.Add(colVehicleClass_Id); qry.Columns.Add(colVehicleClass_DescBrief); qry.Filters.AddRange(GetVehicleClassQueryFilter(prm)); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { while (resultSet != null && resultSet.NextRecord()) { @@ -60,12 +60,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { List models = new List(); String colVehicleClass_Model = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_Model); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass)); qry.DistinctRows = true; qry.Columns.Add(colVehicleClass_Model); qry.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_MakeCode) + "='" + makeCode + "'"); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { while (resultSet != null && resultSet.NextRecord()) { @@ -80,17 +80,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override List GetDerivativesForModel(String makeCode, String model) { List derivatives = new List(); - if (db != null || !StringUtil.IsEmpty(makeCode) && !StringUtil.IsEmpty(model)) + if (Database != null || !StringUtil.IsEmpty(makeCode) && !StringUtil.IsEmpty(model)) { String colVehicleClass_Derivative = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_Derivative); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass)); qry.DistinctRows = true; qry.Columns.Add(colVehicleClass_Derivative); qry.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_MakeCode) + "='" + makeCode + "'"); qry.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleClass_Model) + "='" + model + "'"); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaVehicleClass_Status) + "='" + StatusActive + "'"); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { while (resultSet != null && resultSet.NextRecord()) { @@ -136,7 +136,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmVehicleClass vehicleClass = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -199,7 +199,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidVehicleClass(vehicleClass)) return false; if (SysId.IsValid(vehicleClass.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -210,7 +210,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaVehicleClass_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbVehicleClass._Id = SysId.ToInt(db.GetNextId("VehicleClass", dbUpdateInfo)); + dbVehicleClass._Id = SysId.ToInt(Database.GetNextId("VehicleClass", dbUpdateInfo)); } dbVehicleClass.ExecuteInsertCommand(dbCommand); vehicleClass.Id = new SysId(dbVehicleClass._Id); @@ -234,7 +234,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(vehicleClass).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -272,7 +272,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!VehicleClassCanBeDeleted(vehicleClass)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -611,7 +611,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetVehicleClassCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass) + " As " + aliasVehicleClass, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass) + " As " + aliasVehicleClass, filter); } public override long GetVehicleClassCount(SbmVehicleClass.Params prm) { @@ -625,14 +625,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List vehicleClasses = new List(); - DbQuery qryVehicleClass = new DbQuery(db.DbmsType); + DbQuery qryVehicleClass = new DbQuery(Database.DbmsType); qryVehicleClass.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass), aliasVehicleClass); SaVehicleClass_Db dbVehicleClass = new SaVehicleClass_Db(DbInfo); qryVehicleClass.Columns.AddRange(dbVehicleClass.ExistingColumnNames); qryVehicleClass.Filters.AddRange(GetVehicleClassQueryFilter(prm)); qryVehicleClass.OrderBy.AddRange(GetVehicleClassSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -665,7 +665,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleClass), aliasVehicleClass); // VehicleClass Properties - add columns as defined in query list. @@ -728,8 +728,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs index c60c0e4..56b0baa 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleEvent.cs @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmVehicleEvent vehicleEvent = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidVehicleEvent(vehicleEvent)) return false; if (SysId.IsValid(vehicleEvent.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -119,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaVehicleEvent_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbVehicleEvent._Id = SysId.ToInt(db.GetNextId("VehicleEvent", dbUpdateInfo)); + dbVehicleEvent._Id = SysId.ToInt(Database.GetNextId("VehicleEvent", dbUpdateInfo)); } dbVehicleEvent.ExecuteInsertCommand(dbCommand); vehicleEvent.Id = new SysId(dbVehicleEvent._Id); @@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(vehicleEvent).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!VehicleEventCanBeDeleted(vehicleEvent)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -459,7 +459,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetVehicleEventCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent) + " As " + aliasVehicleEvent, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent) + " As " + aliasVehicleEvent, filter); } public override long GetVehicleEventCount(SbmVehicleEvent.Params prm) { @@ -473,14 +473,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List vehicleEvents = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent), aliasVehicleEvent); SaVehicleEvent_Db dbVehicleEvent = new SaVehicleEvent_Db(DbInfo); qry.Columns.AddRange(dbVehicleEvent.ExistingColumnNames); qry.Filters.AddRange(GetVehicleEventQueryFilter(prm)); qry.OrderBy.AddRange(GetVehicleEventSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -513,7 +513,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleEvent), aliasVehicleEvent); // VehicleEvent Properties - add columns as defined in query list. @@ -587,8 +587,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs index d8bd634..e56774a 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas-VehicleFeature.cs @@ -38,8 +38,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool StoreVehicleFeature(SbmVehicleFeature.Data vehicleFeatureData, DbUpdateInfo dbUpdateInfo) { ClearErrorState(); - if (db == null) return SetErrorState("database is not available"); - if (!db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature))) return SetErrorState("vehicle features not supported"); + if (Database == null) return SetErrorState("database is not available"); + if (!Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature))) return SetErrorState("vehicle features not supported"); if (vehicleFeatureData == null) SetErrorState("vehicle feature data not supplied"); // Check whether the Vehicle Feature exists. @@ -99,7 +99,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysId.IsValid(id.VehicleId) || (int)id.VehicleFeatureSource < 1 || (int)id.VehicleFeatureType < 1) return SetErrorState("Incomplete feature Id specified"); - if (!db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature))) + if (!Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature))) { SbmVehicleFeature.Params prm = new SbmVehicleFeature.Params { @@ -120,13 +120,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); String tableVehicleFeature = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature); - if (!db.TableExists(tableVehicleFeature)) + if (!Database.TableExists(tableVehicleFeature)) { - if (db != null) + if (Database != null) { String filter = GetVehicleFeatureQueryFilter(prm).Concat(" AND ", "(", ")"); String colVehicleFeature_VehicleId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.SaVehicleFeature_VehicleId); - return db.GetRowCount(tableVehicleFeature, /*colVehicleFeature_VehicleId, 0,*/ filter) > 0; + return Database.GetRowCount(tableVehicleFeature, /*colVehicleFeature_VehicleId, 0,*/ filter) > 0; } } else SetErrorState("vehicle features not supported"); @@ -151,7 +151,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmVehicleFeature vehicleFeature = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -207,7 +207,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidVehicleFeature(vehicleFeature)) return false; if (SysId.IsValid(vehicleFeature.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -218,7 +218,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaVehicleFeature_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbVehicleFeature._VehicleId = SysId.ToInt(db.GetNextId("VehicleFeature", dbUpdateInfo)); + dbVehicleFeature._VehicleId = SysId.ToInt(Database.GetNextId("VehicleFeature", dbUpdateInfo)); } dbVehicleFeature.ExecuteInsertCommand(dbCommand); vehicleFeature.Id = new SysId(dbVehicleFeature._VehicleId); @@ -242,7 +242,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(vehicleFeature).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -280,7 +280,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!VehicleFeatureCanBeDeleted(vehicleFeature)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -517,7 +517,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetVehicleFeatureCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature) + " As " + aliasVehicleFeature, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature) + " As " + aliasVehicleFeature, filter); } public override long GetVehicleFeatureCount(SbmVehicleFeature.Params prm) { @@ -531,14 +531,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List vehicleFeatures = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature), aliasVehicleFeature); SaVehicleFeature_Db dbVehicleFeature = new SaVehicleFeature_Db(DbInfo); qry.Columns.AddRange(dbVehicleFeature.ExistingColumnNames); qry.Filters.AddRange(GetVehicleFeatureQueryFilter(prm)); qry.OrderBy.AddRange(GetVehicleFeatureSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -571,7 +571,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaVehicleFeature), aliasVehicleFeature); // VehicleFeature Properties - add columns as defined in query list. @@ -624,8 +624,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas.cs index e7625fc..ee693d7 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmAssetMgr_Dbas.cs @@ -16,22 +16,45 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; - private readonly SbmDbDataItem.SbmDatabaseInfo dbInfo; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Construction. - public SbmAssetMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmAssetMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmAssetMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - dbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); + Initialise(); + } + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); } //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return dbInfo; } } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } //------------------------------------------------------------------- // Utilities. @@ -39,10 +62,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool AssetDatabaseIsValid() { ClearErrorState(); - if (db == null) return SetErrorState("Database not specified"); + if (Database == null) return SetErrorState("Database not specified"); //if (pDb->GetInterfaceType() != SaDatabase::eSaDbInterfaceOdbc) return SetErrorState ("Database not ODBC"); - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory))) return SetErrorState("Asset Category table does not exist"); - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset))) return SetErrorState("Asset table does not exist"); + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAssetCategory))) return SetErrorState("Asset Category table does not exist"); + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset))) return SetErrorState("Asset table does not exist"); return true; } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs index 1d27878..f9aad01 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity-Utils.cs @@ -168,7 +168,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List columnNameValues = new List(); String tableCommodityCustomer = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer); String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId) + "=" + commodityId.ToString(); - if (db != null && Database.TableExists(tableCommodityCustomer) && Database.ExecuteDelete(tableCommodityCustomer, filter) > 0) + if (Database != null && Database.TableExists(tableCommodityCustomer) && Database.ExecuteDelete(tableCommodityCustomer, filter) > 0) SetErrorState("Failed to clear customer commodity details"); } if (!HasErrorState()) @@ -176,7 +176,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Remove Supplier commodity details. String tableCommoditySupplier = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier); String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId) + "=" + commodityId.ToString(); - if (db != null && Database.TableExists(tableCommoditySupplier) && Database.ExecuteDelete(tableCommoditySupplier, filter) > 0) + if (Database != null && Database.TableExists(tableCommoditySupplier) && Database.ExecuteDelete(tableCommoditySupplier, filter) > 0) SetErrorState("Failed to clear Supplier commodity details"); } return false; @@ -197,9 +197,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.Add($"{SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ProductCode)}!='{DbQuery.FormatForCondition(commodity.Code)}'"); List values = new List(); SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ProductCode), commodity.Code, true); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter.Concat(" And ", "(", ")")); - if (db.HasErrorState()) - SetErrorState($"{db.ErrorStateMessage}."); + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter.Concat(" And ", "(", ")")); + if (Database.HasErrorState()) + SetErrorState($"{Database.ErrorStateMessage}."); return !HasErrorState(); } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs index cbbb332..fdb8a43 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Commodity.cs @@ -50,11 +50,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { List types = new List(); // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity)); qry.Columns.Add("DISTINCT " + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Type)); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_AffIdOwner) + "=" + AffiliateId_Owner.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -71,11 +71,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr Sbm.CommodityType commodityType = Sbm.CommodityType.Unknown; if (!SysId.IsValid(commodityId)) return commodityType; // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Type), colType); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id) + "=" + commodityId.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -90,14 +90,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colCostPrice = "CostPrice"; ClearErrorState(); double costPrice = 0.0f; - if (db == null && SysId.IsValid(commodityId)) + if (Database == null && SysId.IsValid(commodityId)) { // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CostPrice), colCostPrice); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id) + "=" + commodityId.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String aliasCommodityTemplate = "aCmdTmpl"; // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.DistinctRows = true; qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), aliasCommodity); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), aliasCommodityTemplate); @@ -125,7 +125,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_CommodityIdSalesProj, aliasCommodity) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, aliasCommodityTemplate)); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_AffIdOwner, aliasCommodityTemplate) + "=" + AffiliateId_Owner.ToString()); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_AffIdOwner, aliasCommodity) + "=" + AffiliateId_Owner.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -168,7 +168,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Build the list of columns to update to bring each commodity into line with this template. int propDecimals = 5; - int ordQtyDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); + int ordQtyDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); List value = new List(); SacsDatabase.AddValuePair(value, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonthlyProp), salesProjMonthlyProp, true); SacsDatabase.AddValuePair(value, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth01), DbQuery.FormatFn_Round(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual) + "*" + StringUtil.FormatNumeric(salesProp[0], (ushort)propDecimals), ordQtyDecimals), false); @@ -185,9 +185,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr SacsDatabase.AddValuePair(value, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_SalesProjMonth12), DbQuery.FormatFn_Round(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Commodity_SalesProjAnnual) + "*" + StringUtil.FormatNumeric(salesProp[11], (ushort)propDecimals), ordQtyDecimals), false); // Perform the update: - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), value, filters.Concat(" AND ", "(", ")")); - if (db.HasErrorState()) - SetErrorState($"{db.ErrorStateMessage}"); + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), value, filters.Concat(" AND ", "(", ")")); + if (Database.HasErrorState()) + SetErrorState($"{Database.ErrorStateMessage}"); return !HasErrorState(); } @@ -219,7 +219,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colReqnt_Status = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Status, alias_Requirement); // Requirements for this commodity: - DbQuery qryReq = new DbQuery(db.DbmsType); + DbQuery qryReq = new DbQuery(Database.DbmsType); qryReq.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), alias_Transaction)); qryReq.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), alias_Requirement)); qryReq.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Quantity, alias_Requirement) + ")"); @@ -251,7 +251,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Calculate the pending movements sourced to sales order requirements. String tableAliasMov = "StkAllMov"; - DbQuery qryAll = new DbQuery(db.DbmsType); + DbQuery qryAll = new DbQuery(Database.DbmsType); qryAll.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), tableAliasMov)); qryAll.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Quantity, tableAliasMov) + ")"); qryAll.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_ItemType, tableAliasMov) + "=" + ((int)Sbm.ItemType.Commodity).ToString()); @@ -268,7 +268,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Calculate the current stock level. String aliasStockLevel = "aCmdStkLvl"; - DbQuery qryLvl = new DbQuery(db.DbmsType); + DbQuery qryLvl = new DbQuery(Database.DbmsType); qryLvl.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasStockLevel)); qryLvl.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Quantity, aliasStockLevel) + ")"); qryLvl.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Type, aliasStockLevel) + "=" + (int)Sbm.StockLevelType.CurrentLevel); @@ -326,7 +326,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // In case this routine is called in isolation (eg. from Requirement manager). PopulateLocationIdLists(); - DbmsType dbmsType = db.DbmsType; + DbmsType dbmsType = Database.DbmsType; // Common definitions. String alias_ContainerItem = "M1CI"; String alias_Container = "M1C"; @@ -356,7 +356,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Planned stock movements for this commodity. - DbQuery qryMov1 = new DbQuery(db.DbmsType); + DbQuery qryMov1 = new DbQuery(Database.DbmsType); qryMov1.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), alias_Movement)); qryMov1.Filters.Add(colMov_ItemType + "=" + ((int)Sbm.ItemType.Commodity).ToString()); qryMov1.Filters.Add(colMov_ItemId + "=" + commodityIdCol); @@ -413,9 +413,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Planned stock movements for containers that include this commodity. String qryMov2a = ""; String qryMov2b = ""; - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container))) + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container))) { - DbQuery qryMov2 = new DbQuery(db.DbmsType); + DbQuery qryMov2 = new DbQuery(Database.DbmsType); qryMov2.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), alias_ContainerItem)); qryMov2.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container), alias_Container)); qryMov2.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), alias_Movement)); @@ -516,7 +516,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Verify that the location table exists. String tableLocation = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location); - if (!db.TableExists(tableLocation)) return; + if (!Database.TableExists(tableLocation)) return; locationIdListPopulated = true; String colLocation_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_Id); @@ -525,13 +525,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colLocation_Status = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_Status); // Stock locations. - DbQuery qryLoc = new DbQuery(db.DbmsType); + DbQuery qryLoc = new DbQuery(Database.DbmsType); qryLoc.Tables.Add(tableLocation); qryLoc.Columns.Add(colLocation_Id); qryLoc.Columns.Add(colLocation_Flags); qryLoc.Columns.Add(colLocation_Status); qryLoc.Filters.Add(colLocation_AffIdOwner + "=" + AffiliateId_Owner.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryLoc.BuildQuery())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryLoc.BuildQuery())) { while (dbResultSet != null && dbResultSet.NextRecord()) { @@ -578,7 +578,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmCommodity commodity = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -627,7 +627,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidCommodity(commodity)) return false; if (SysId.IsValid(commodity.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -638,7 +638,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Commodity_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbCommodity._Id = SysId.ToInt(db.GetNextId("Commodity", dbUpdateInfo)); + dbCommodity._Id = SysId.ToInt(Database.GetNextId("Commodity", dbUpdateInfo)); } dbCommodity.ExecuteInsertCommand(dbCommand); commodity.Id = new SysId(dbCommodity._Id); @@ -662,7 +662,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(commodity).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -700,7 +700,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!CommodityCanBeDeleted(commodity)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -1070,8 +1070,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Getting Commodity column definition. public override ColumnDfn GetCommodityColumnDfn(SbmCommodity.Column columnId, string caption = "", int width = 0) { - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); - bool canViewSupplyFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); + bool canViewSupplyFinancials = UserCanViewCommoditySupplyFinancials(); ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width); switch (columnId) @@ -2449,7 +2449,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String stringLocactionStockId = locactionIdsStock.Concat(","); // Query the current stock level. String aliasStockLevel = "aCmdStkLvl"; - DbQuery qryLvl = new DbQuery(db.DbmsType); + DbQuery qryLvl = new DbQuery(Database.DbmsType); qryLvl.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasStockLevel); qryLvl.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Quantity, aliasStockLevel) + ")"); qryLvl.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Type, aliasStockLevel) + "=" + (int)Sbm.StockLevelType.CurrentLevel); @@ -2475,7 +2475,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Restrict to commodities that belong to the specified price sets. String aliasPrice = "aCmdPrc"; - DbQuery qryPriceSet = new DbQuery(db.DbmsType); + DbQuery qryPriceSet = new DbQuery(Database.DbmsType); qryPriceSet.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPrice); qryPriceSet.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_CommodityId, aliasPrice)); qryPriceSet.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_PriceSetId, aliasPrice) + " In (" + prm.PriceSetIdsIncluded.Concat(",") + ")"); @@ -2485,7 +2485,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Restrict to commodities that do not belong to the specified price sets. String aliasPrice = "aCmdPrc"; - DbQuery qryPriceSet = new DbQuery(db.DbmsType); + DbQuery qryPriceSet = new DbQuery(Database.DbmsType); qryPriceSet.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPrice); qryPriceSet.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_CommodityId, aliasPrice)); qryPriceSet.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_PriceSetId, aliasPrice) + " Not In (" + prm.PriceSetIdsIncluded.Concat(",") + ")"); @@ -2507,7 +2507,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filterAffiliate_CustomerName = "FltCustNameAff"; String filterAssociation_CustomerName = "FltCustNameAss"; // Build query to filter on customer name: - DbQuery qryCustName = new DbQuery(db.DbmsType); + DbQuery qryCustName = new DbQuery(Database.DbmsType); qryCustName.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), filterAffiliate_CustomerName); qryCustName.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filterAssociation_CustomerName); qryCustName.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, filterAssociation_CustomerName)); @@ -2530,7 +2530,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filterAffiliate_SupplierName = "FltSuppNameAff"; String filterAssocation_SupplierName = "FltSuppNameAss"; // Build query to filter on Supplier name. - DbQuery qrySuppName = new DbQuery(db.DbmsType); + DbQuery qrySuppName = new DbQuery(Database.DbmsType); qrySuppName.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), filterAffiliate_SupplierName); qrySuppName.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), filterAssocation_SupplierName); qrySuppName.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, filterAssocation_SupplierName)); @@ -2553,7 +2553,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { String aliasCommodity_Transaction = "aCmdTrn"; String aliasCommodity_Requirement = "aCmdReq"; - DbQuery qryReqnt = new DbQuery(db.DbmsType); + DbQuery qryReqnt = new DbQuery(Database.DbmsType); qryReqnt.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasCommodity_Requirement)); qryReqnt.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasCommodity_Requirement)); qryReqnt.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_AffIdOwner, aliasCommodity_Requirement) + "=" + AffiliateId_Owner.ToString()); @@ -2575,7 +2575,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { if (CanManageCommodityCustomers()) { - DbQuery qryCmdCust = new DbQuery(db.DbmsType); + DbQuery qryCmdCust = new DbQuery(Database.DbmsType); qryCmdCust.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), aliasCommodity_CmdCustomer)); qryCmdCust.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId, aliasCommodity_CmdCustomer)); if (SysId.IsValid(prm.AssociationIdCommodityCustomer)) @@ -2649,7 +2649,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetCommodityCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity) + " As " + aliasCommodity, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity) + " As " + aliasCommodity, filter); } public override long GetCommodityCount(SbmCommodity.Params prm) { @@ -2663,14 +2663,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List commodities = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), aliasCommodity); Commodity_Db dbCommodity = new Commodity_Db(DbInfo); qry.Columns.AddRange(dbCommodity.ExistingColumnNames); qry.Filters.AddRange(GetCommodityQueryFilter(prm)); qry.OrderBy.AddRange(GetCommoditySortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -2702,24 +2702,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); DbQuery query = CompileCommodityQuery(columns, prm); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } public override async Task ExecuteCommodityQueryAsync(List columns, SbmCommodity.Params prm) { ClearErrorState(); DbQuery query = CompileCommodityQuery(columns, prm); - return await DbResultSet_DataReader.ExecuteQueryAsync(db, query.BuildQuery(prm.ResultsPaging)) as DbResultSet; + return await DbResultSet_DataReader.ExecuteQueryAsync(Database, query.BuildQuery(prm.ResultsPaging)) as DbResultSet; } private DbQuery CompileCommodityQuery(List columns, SbmCommodity.Params prm) { ClearErrorState(); PopulateLocationIdLists(); - bool canViewSupplyFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + bool canViewSupplyFinancials = UserCanViewCommoditySupplyFinancials(); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), aliasCommodity); @@ -3028,13 +3028,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Last stock take. if (columns.HasId(SbmCommodity.Column.StockTake_Date)) { - SysId locationIdSales = UserContext.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.SalesOrderDefault); + SysId locationIdSales = Internals.GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation.SalesOrderDefault); if (SysId.IsValid(locationStockId)) locationIdSales = locationStockId; if (SysId.IsValid(locationIdSales)) { // Join to the stock movements to identify the most recent stock take at the default sales location. String aliasCommodity_LastStockTake = "aCmdLST"; - DbQuery qryStTk = new DbQuery(db.DbmsType); + DbQuery qryStTk = new DbQuery(Database.DbmsType); qryStTk.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasCommodity_LastStockTake); qryStTk.Columns.Add("MAX(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Recorded, aliasCommodity_LastStockTake) + ")"); qryStTk.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_CommodityId, aliasCommodity_LastStockTake) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, aliasCommodity)); @@ -3248,7 +3248,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String aliasCommodity_StockCommodity = "aCmdStkCmd"; String aliasCommodity_StockCommodityDate = "aCmdStkCmdDate"; // Sub query form join to consolidate commodity movements by date: - DbQuery qryStkCmd = new DbQuery(db.DbmsType); + DbQuery qryStkCmd = new DbQuery(Database.DbmsType); qryStkCmd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasCommodity_StockCommodity); qryStkCmd.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_ItemId, aliasCommodity_StockCommodity)); qryStkCmd.Columns.Add("Min(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Movement, aliasCommodity_StockCommodity) + ")", dataNameStkDue_NextCmdStkDate); @@ -3291,14 +3291,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Columns.Add(aliasCommodity_StkCmdQty + "." + dataNameStkDue_NextCmdStkQty, dataNameStkDue_NextCmdStkQty); } } - if (StockControlConfig.AllowStockContainers() && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container)) && (bHasStockNextDueCols || bHasContStockNextDueCols) && (SysId.IsValid(locationStockId) || !stringLocactionStockId.IsEmpty())) + if (StockControlConfig.AllowStockContainers() && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container)) && (bHasStockNextDueCols || bHasContStockNextDueCols) && (SysId.IsValid(locationStockId) || !stringLocactionStockId.IsEmpty())) { // When is the next container stock movement due that includes this commodity. // Sub query form join to consolidate commodity movements by date: String aliasCommodity_StockContainer_Movement = "aStkCntMov"; String aliasCommodity_StockContainer_Container = "aStkCntCnt"; String aliasCommodity_StkCntCit = "aStkCntCit"; - DbQuery qryStkCnt = new DbQuery(db.DbmsType); + DbQuery qryStkCnt = new DbQuery(Database.DbmsType); qryStkCnt.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasCommodity_StockContainer_Movement); qryStkCnt.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container), aliasCommodity_StockContainer_Container); qryStkCnt.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasCommodity_StkCntCit); @@ -3354,12 +3354,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if ((columns.HasId(SbmCommodity.Column.Stock_Due_Imminently) || columns.HasId(SbmCommodity.Column.Stock_ImminentLevel)) && (SysId.IsValid(locationStockId) || !stringLocactionStockId.IsEmpty())) { // Calculate the imminent stock level: - if (UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.ImminentStock)) + if (Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.ImminentStock)) { PlannedStockMovements_Params prmPSM = new PlannedStockMovements_Params(); prmPSM.prmCmd = prm; - prmPSM.excludeAwaitingContainers = !UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock); - int weeksImminentStock = Math.Max(0, Math.Min(12, UserContext.GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, 0))); + prmPSM.excludeAwaitingContainers = !Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock); + int weeksImminentStock = Math.Max(0, Math.Min(12, Internals.GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, 0))); prmPSM.latest = DateTime.Today.StartOfWorkingWeek().AddDays(weeksImminentStock * 7); query.Columns.Add(BuildPlannedStockMovementsQuery(prmPSM), dataNameStkDue_Imminent); } @@ -3816,11 +3816,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Commodity Customer count. - if (columns.HasId(SbmCommodity.Column.CommodityCustomer_Count) && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer))) + if (columns.HasId(SbmCommodity.Column.CommodityCustomer_Count) && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer))) { // Count the Customer items for this Commodity. String aliasCommodityCustomerCount = "aCmdCust"; - DbQuery qryProc = new DbQuery(db.DbmsType); + DbQuery qryProc = new DbQuery(Database.DbmsType); qryProc.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), aliasCommodityCustomerCount)); qryProc.Columns.Add("COUNT(*)"); qryProc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId, aliasCommodityCustomerCount) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, aliasCommodity)); @@ -3828,11 +3828,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Columns.Add("(" + qryProc.BuildQuery() + ")", dataNameCommodityCustomerCount); } // Commodity Supplier count. - if (columns.HasId(SbmCommodity.Column.CommoditySupplier_Count) && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier))) + if (columns.HasId(SbmCommodity.Column.CommoditySupplier_Count) && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier))) { // Count the Supplier items for this Commodity. String aliasCommoditySupplierCount = "aCmdCust"; - DbQuery qryProc = new DbQuery(db.DbmsType); + DbQuery qryProc = new DbQuery(Database.DbmsType); qryProc.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier), aliasCommoditySupplierCount)); qryProc.Columns.Add("COUNT(*)"); qryProc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommoditySupplier_CommodityId, aliasCommoditySupplierCount) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, aliasCommodity)); @@ -3846,7 +3846,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Count the processes for this commodity (in the ItemLink table): String aliasProcessCount = "aProc"; - DbQuery qryProc = new DbQuery(db.DbmsType); + DbQuery qryProc = new DbQuery(Database.DbmsType); qryProc.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), aliasProcessCount)); qryProc.Columns.Add("COUNT(*)"); qryProc.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom, aliasProcessCount) + "=" + ((int)Sbm.ItemType.Commodity).ToString()); @@ -3861,7 +3861,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Count the portfolio items for this commodity. String aliasPortfolioItemCount = "CmdPrtItm"; - DbQuery qryPrtItm = new DbQuery(db.DbmsType); + DbQuery qryPrtItm = new DbQuery(Database.DbmsType); qryPrtItm.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem), aliasPortfolioItemCount)); qryPrtItm.Columns.Add("COUNT(*)"); //qryPrtItm.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.PortfolioItem_ItemType,aliasCommodity_PortfolioItem)+"="+String(eSapItemTypeCommodity)); diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs index df4be44..18e2f48 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommodityCustomer.cs @@ -39,7 +39,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool CanManageCommodityCustomers() { if (!AllowConfigOption(Sbm.ConfigOption.CommodityCustomers)) return false; - return db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer)); + return Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer)); } public override bool StoreCommodityCustomers(List commodityCustomers) { @@ -118,11 +118,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { if (!SysId.IsValid(commodityId)) SetErrorState("Commodity must be specified"); - if (db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer))) + if (Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer))) { String filter = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommodityCustomer_CommodityId, null, false) + "=" + commodityId.ToString(); - if (db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), filter) > 0) - SetErrorState("Delete failed - " + db.ErrorState); + if (Database.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), filter) > 0) + SetErrorState("Delete failed - " + Database.ErrorState); } } else SetErrorState(msg_UnableToManageCommodityCustomers); @@ -135,11 +135,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (CanManageCommodityCustomers()) { if (!SysId.IsValid(assocCustomerId)) SetErrorState("Customer must be specified"); - if (db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer))) + if (Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer))) { String filter = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.CommodityCustomer_AssocIdCustomer, null, false) + "=" + assocCustomerId.ToString(); - if (db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), filter) > 0) - SetErrorState("Delete failed - " + db.ErrorState); + if (Database.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), filter) > 0) + SetErrorState("Delete failed - " + Database.ErrorState); } } else SetErrorState(msg_UnableToManageCommodityCustomers); @@ -164,7 +164,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmCommodityCustomer prmCommodityCustomer = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -213,7 +213,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidCommodityCustomer(commodityCustomer)) return false; if (SysId.IsValid(commodityCustomer.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -224,7 +224,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (CommodityCustomer_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbCommodityCustomer._CommodityId = SysId.ToInt(db.GetNextId("CommodityCustomer", dbUpdateInfo)); + dbCommodityCustomer._CommodityId = SysId.ToInt(Database.GetNextId("CommodityCustomer", dbUpdateInfo)); } dbCommodityCustomer.ExecuteInsertCommand(dbCommand); commodityCustomer.Id = new SysId(dbCommodityCustomer._CommodityId); @@ -248,7 +248,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(commodityCustomer).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -286,7 +286,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!CommodityCustomerCanBeDeleted(commodityCustomer)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -510,7 +510,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filter.AddRange(filtersCommodity);// Commodity table is included in the query so filter it directly. else { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), aliasCommodityCustomer_Commodity); qry.Columns.Add("1"); qry.Filters.AddRange(filtersCommodity); @@ -520,7 +520,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // CustomerPartial. if (!StringUtil.IsEmpty(prm.CustomerPartial)) { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasCommodityCustomer_Association); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Affiliate), aliasCommodityCustomer_Affiliate); qry.Columns.Add("1"); @@ -580,7 +580,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetCommodityCustomerCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer) + " As " + aliasCommodityCustomer, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer) + " As " + aliasCommodityCustomer, filter); } public override long GetCommodityCustomerCount(SbmCommodityCustomer.Params prm) { @@ -594,14 +594,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List commodityCustomers = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), aliasCommodityCustomer); CommodityCustomer_Db dbCommodityCustomer = new CommodityCustomer_Db(DbInfo); qry.Columns.AddRange(dbCommodityCustomer.ExistingColumnNames); qry.Filters.AddRange(GetCommodityCustomerQueryFilter(prm)); qry.OrderBy.AddRange(GetCommodityCustomerSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -635,7 +635,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommodityCustomer), aliasCommodityCustomer); //--------------------------------------------------------------- @@ -717,8 +717,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs index 0c00411..7008b8b 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-CommoditySupplier.cs @@ -36,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool CanManageCommoditySuppliers() { if (SessionConsole == null || !AllowConfigOption(Sbm.ConfigOption.CommoditySuppliers)) return false; - return db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier)); + return Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier)); } //------------------------------------------------------------------- @@ -57,7 +57,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmCommoditySupplier commoditySupplier = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -104,7 +104,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool StoreCommoditySuppliers(List commoditySuppliers) { ClearErrorState(); - if (db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier))) + if (Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier))) foreach (SbmCommoditySupplier commoditySupplier in commoditySuppliers) { } @@ -115,7 +115,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); commoditySupplier = null; - if (db != null && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier))) + if (Database != null && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier))) { } return !HasErrorState(); @@ -128,7 +128,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidCommoditySupplier(commoditySupplier)) return false; if (SysId.IsValid(commoditySupplier.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -139,7 +139,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (CommoditySupplier_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbCommoditySupplier._CommodityId = SysId.ToInt(db.GetNextId("CommoditySupplier", dbUpdateInfo)); + dbCommoditySupplier._CommodityId = SysId.ToInt(Database.GetNextId("CommoditySupplier", dbUpdateInfo)); } dbCommoditySupplier.ExecuteInsertCommand(dbCommand); commoditySupplier.Id = new SysId(dbCommoditySupplier._CommodityId); @@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(commoditySupplier).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -201,7 +201,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!CommoditySupplierCanBeDeleted(commoditySupplier)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -481,7 +481,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetCommoditySupplierCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier) + " As " + aliasCommoditySupplier, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier) + " As " + aliasCommoditySupplier, filter); } public override long GetCommoditySupplierCount(SbmCommoditySupplier.Params prm) { @@ -495,14 +495,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List commoditySuppliers = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier), aliasCommoditySupplier); CommoditySupplier_Db dbCommoditySupplier = new CommoditySupplier_Db(DbInfo); qry.Columns.AddRange(dbCommoditySupplier.ExistingColumnNames); qry.Filters.AddRange(GetCommoditySupplierQueryFilter(prm)); qry.OrderBy.AddRange(GetCommoditySupplierSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -536,7 +536,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.CommoditySupplier), aliasCommoditySupplier); // Columns to query. @@ -611,8 +611,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.OrderBy.Add(sortColumn); } - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs index 83f1eab..01dc36f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-Container.cs @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmContainer container = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidContainer(container)) return false; if (SysId.IsValid(container.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -114,7 +114,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Container_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbContainer._Id = SysId.ToInt(db.GetNextId("Container", dbUpdateInfo)); + dbContainer._Id = SysId.ToInt(Database.GetNextId("Container", dbUpdateInfo)); } dbContainer.ExecuteInsertCommand(dbCommand); container.Id = new SysId(dbContainer._Id); @@ -138,7 +138,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(container).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -176,7 +176,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!ContainerCanBeDeleted(container)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -227,7 +227,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private void PopulateFrom(Container_Db dbContainer, SbmContainer container) { container.Id = new SysId(dbContainer._Id); - container.ContainerCategory = (Sbm.ContainerCategory)(dbContainer._Category??0); + container.ContainerCategory = (Sbm.ContainerCategory)(dbContainer._Category ?? 0); container.ContainerType = (Sbm.ContainerType)ContainerTypes.GetTypeForCode(dbContainer._Type); container.Reference = dbContainer._Reference; container.DescBrief = dbContainer._DescBrief; @@ -412,7 +412,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String supplierName = DbQuery.FormatForCondition(prm.SupplierName); if (!StringUtil.IsEmpty(supplierName)) { - DbQuery queryAssociationSupplier = new DbQuery(db.DbmsType); + DbQuery queryAssociationSupplier = new DbQuery(Database.DbmsType); queryAssociationSupplier.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasContainer_AssociationSupplier); queryAssociationSupplier.Columns.Add(colAssociation_IdSupplier); queryAssociationSupplier.Filters.Add(colAssociation_IdSupplier + "=" + colContainer_AssIdSupplier); @@ -440,7 +440,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String customerName = DbQuery.FormatForCondition(prm.CustomerName); if (!StringUtil.IsEmpty(customerName)) { - DbQuery queryAssociationCustomer = new DbQuery(db.DbmsType); + DbQuery queryAssociationCustomer = new DbQuery(Database.DbmsType); queryAssociationCustomer.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), aliasContainer_AssociationCustomer); queryAssociationCustomer.Columns.Add(colAssociation_IdCustomer); queryAssociationCustomer.Filters.Add(colAssociation_IdCustomer + "=" + colContainer_AssIdCustomer); @@ -520,7 +520,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetContainerCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container) + " As " + aliasContainer, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container) + " As " + aliasContainer, filter); } public override long GetContainerCount(SbmContainer.Params prm) { @@ -534,14 +534,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List containers = new List(); - DbQuery DbQuery = new DbQuery(db.DbmsType); + DbQuery DbQuery = new DbQuery(Database.DbmsType); DbQuery.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container), aliasContainer); Container_Db dbContainer = new Container_Db(DbInfo); DbQuery.Columns.AddRange(dbContainer.ExistingColumnNames); DbQuery.Filters.AddRange(GetContainerQueryFilter(prm)); DbQuery.OrderBy.AddRange(GetContainerSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -575,7 +575,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container), aliasContainer); //--------------------------------------------------------------- @@ -682,7 +682,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String aliasTbl_ItemsCount = "ItemCount"; // Build sub query to directly return the number of associated items. - DbQuery qryItemCount = new DbQuery(db.DbmsType); + DbQuery qryItemCount = new DbQuery(Database.DbmsType); qryItemCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasTbl_ItemsCount)); qryItemCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId, aliasTbl_ItemsCount) + ")"); qryItemCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId, aliasTbl_ItemsCount) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Container_Id, aliasContainer)); @@ -694,7 +694,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String aliasTbl_MovementsCount = "MoveCount"; // Build sub query to directly return the number of associated movements. - DbQuery qryMoveCount = new DbQuery(db.DbmsType); + DbQuery qryMoveCount = new DbQuery(Database.DbmsType); qryMoveCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasTbl_MovementsCount)); qryMoveCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Id, aliasTbl_MovementsCount) + ")"); qryMoveCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_ItemType, aliasTbl_MovementsCount) + "=" + ((int)Sbm.ItemType.Container).ToString()); @@ -714,8 +714,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs index 1880625..4d94a62 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-ContainerItem.cs @@ -57,7 +57,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override ushort GetMaxItemSeq(SysId containerId, Sbm.ItemType itemType, SysId itemId) { ClearErrorState(); - ISacsDatabase db = SbmGlobals.Application.GetBusMgrDatabase(SessionContext); if (!HasErrorState()) { String tableContainerItem = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem); @@ -67,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemType) + "=" + ((int)itemType).ToString()); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemId) + "=" + itemId.ToString()); - return (ushort)db.GetRowValue(tableContainerItem, colContainerItem_ItemSeq, filters.Concat(" AND ", "(", ")")).AsLong(); + return (ushort)Database.GetRowValue(tableContainerItem, colContainerItem_ItemSeq, filters.Concat(" AND ", "(", ")")).AsLong(); } return 0; } @@ -90,7 +89,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmContainerItem containerItem = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -139,7 +138,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidContainerItem(containerItem)) return false; if (SysId.IsValid(containerItem.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -150,7 +149,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (ContainerItem_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbContainerItem._ContainerId = SysId.ToInt(db.GetNextId("ContainerItem", dbUpdateInfo)); + dbContainerItem._ContainerId = SysId.ToInt(Database.GetNextId("ContainerItem", dbUpdateInfo)); } dbContainerItem.ExecuteInsertCommand(dbCommand); containerItem.Id = new SysId(dbContainerItem._ContainerId); @@ -174,7 +173,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(containerItem).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -212,7 +211,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!ContainerItemCanBeDeleted(containerItem)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -579,7 +578,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.AddRange(containerFilter); else { - DbQuery qryCont = new DbQuery(db.DbmsType); + DbQuery qryCont = new DbQuery(Database.DbmsType); qryCont.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Container), tableAliasContainer); qryCont.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Container_Id), tableAliasContainer); qryCont.Filters.Add(containerFilter.Concat(" And ", "(", ")")); @@ -651,7 +650,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetContainerItemCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem) + " As " + aliasContainerItem, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem) + " As " + aliasContainerItem, filter); } public override long GetContainerItemCount(SbmContainerItem.Params prm) { @@ -665,14 +664,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List containerItems = new List(); - DbQuery DbQuery = new DbQuery(db.DbmsType); + DbQuery DbQuery = new DbQuery(Database.DbmsType); DbQuery.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasContainerItem); ContainerItem_Db dbContainerItem = new ContainerItem_Db(DbInfo); DbQuery.Columns.AddRange(dbContainerItem.ExistingColumnNames); DbQuery.Filters.AddRange(GetContainerItemQueryFilter(prm)); DbQuery.OrderBy.AddRange(GetContainerItemSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -706,7 +705,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasContainerItem); //--------------------------------------------------------------- @@ -919,7 +918,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Build sub query to directly return the number of associated items. String aliasItemCount = "ItmCount"; - DbQuery qryItemCount = new DbQuery(db.DbmsType); + DbQuery qryItemCount = new DbQuery(Database.DbmsType); qryItemCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasItemCount)); qryItemCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId, aliasItemCount) + ")"); qryItemCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId, aliasItemCount) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ContainerId)); @@ -930,7 +929,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Table aliases for linked Movement table & Build sub query to directly return the number of associated movements. String aliasMovementCount = "MoveCount"; - DbQuery qryMoveCount = new DbQuery(db.DbmsType); + DbQuery qryMoveCount = new DbQuery(Database.DbmsType); qryMoveCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasMovementCount)); qryMoveCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Id, aliasMovementCount) + ")"); qryMoveCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_ItemType, aliasMovementCount) + "=" + ((int)Sbm.ItemType.Container).ToString()); @@ -949,8 +948,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs index be2d240..a9af9f6 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas-PortfolioItem.cs @@ -40,11 +40,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { List types = new List(); // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(TableName_PortfolioItem); qry.Columns.Add("DISTINCT " + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.PortfolioItem_Type)); qry.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.PortfolioItem_AffIdOwner) + "=" + AffiliateId_Owner.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -94,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.Filters.Add(colType + "=" + ((int)Sbm.PortfolioItemType.Category).ToString()); qry.Filters.Add(colItemIdParent + "=" + idParentItem.ToString()); qry.OrderBy.Add(colSeq); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { while (resultSet != null && resultSet.NextRecord()) { @@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!includeSubCategories) qry.Filters.Add(sColType + "=" + ((int)Sbm.PortfolioItemType.Commodity).ToString()); qry.Filters.Add(sColItemIdParent + "=" + idParentItem.ToString()); qry.OrderBy.Add(sColSeq); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { while (resultSet != null && resultSet.NextRecord()) { @@ -263,7 +263,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmPortfolioItem portfolioItem = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -298,7 +298,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidPortfolioItem(portfolioItem)) return false; if (SysId.IsValid(portfolioItem.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -309,7 +309,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (PortfolioItem_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbPortfolioItem._Id = SysId.ToInt(db.GetNextId("PortfolioItem", dbUpdateInfo)); + dbPortfolioItem._Id = SysId.ToInt(Database.GetNextId("PortfolioItem", dbUpdateInfo)); } dbPortfolioItem.ExecuteInsertCommand(dbCommand); portfolioItem.Id = new SysId(dbPortfolioItem._Id); @@ -336,7 +336,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(portfolioItem).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -402,7 +402,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.Filters.Add(colSeq + "<" + portfolioItem.Sequence); qry.OrderBy.Add(colSeq + " DESC"); qry.RowLimit = 2; - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { // Only need to read first record. if (resultSet != null && resultSet.NextRecord()) @@ -460,7 +460,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.Filters.Add(sColSeq + ">" + portfolioItem.Sequence); qry.OrderBy.Add(sColSeq + " ASC"); qry.RowLimit = 2; - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.BuildQuery())) { // Only need to read first record. if (resultSet != null && resultSet.NextRecord()) @@ -509,7 +509,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!PortfolioItemCanBeDeleted(portfolioItem)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -877,7 +877,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetPortfolioItemCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem) + " As " + aliasPortfolioItem, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem) + " As " + aliasPortfolioItem, filter); } public override long GetPortfolioItemCount(SbmPortfolioItem.Params prm) { @@ -891,14 +891,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List portfolioItems = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem), aliasPortfolioItem); PortfolioItem_Db dbPortfolioItem = new PortfolioItem_Db(DbInfo); qry.Columns.AddRange(dbPortfolioItem.ExistingColumnNames); qry.Filters.AddRange(GetPortfolioItemQueryFilter(prm)); qry.OrderBy.AddRange(GetPortfolioItemSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -932,7 +932,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.PortfolioItem), aliasPortfolioItem); //--------------------------------------------------------------- @@ -1019,8 +1019,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas.cs index ed4c4cc..e776972 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmCommodityMgr_Dbas.cs @@ -13,24 +13,46 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; - private readonly SbmDbDataItem.SbmDatabaseInfo dbInfo; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); private readonly DateTime today = DateTime.Today; //------------------------------------------------------------------- // Construction. - public SbmCommodityMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmCommodityMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmCommodityMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - dbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); - OrderQuantityDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); + Initialise(); + } + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); } //------------------------------------------------------------------- // Database properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return dbInfo; } } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } public String TableName_PortfolioItem { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem); } } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs index 7c71475..e9b7ed2 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemBatch.cs @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmItemBatch itemBatch = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -108,7 +108,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidItemBatch(itemBatch)) return false; if (SysId.IsValid(itemBatch.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -119,7 +119,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (ItemBatch_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbItemBatch._Id = SysId.ToInt(db.GetNextId("ItemBatch", dbUpdateInfo)); + dbItemBatch._Id = SysId.ToInt(Database.GetNextId("ItemBatch", dbUpdateInfo)); } dbItemBatch.ExecuteInsertCommand(dbCommand); itemBatch.Id = new SysId(dbItemBatch._Id); @@ -143,7 +143,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(itemBatch).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!ItemBatchCanBeDeleted(itemBatch)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -406,7 +406,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetItemBatchCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemBatch) + " As " + aliasItemBatch, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemBatch) + " As " + aliasItemBatch, filter); } public override long GetItemBatchCount(SbmItemBatch.Params prm) { @@ -420,14 +420,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List itemBatches = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemBatch), aliasItemBatch); ItemBatch_Db dbItemBatch = new ItemBatch_Db(DbInfo); qry.Columns.AddRange(dbItemBatch.ExistingColumnNames); qry.Filters.AddRange(GetItemBatchQueryFilter(prm)); qry.OrderBy.AddRange(GetItemBatchSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -460,7 +460,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemBatch), aliasItemBatch); // ItemBatch Properties - add columns as defined in query list. @@ -483,7 +483,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Build sub query to directly return the number of associated Links: String aliasLink = "aLnk"; - DbQuery qryLinkCount = new DbQuery(db.DbmsType); + DbQuery qryLinkCount = new DbQuery(Database.DbmsType); qryLinkCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasLink)); qryLinkCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_CommodityId, aliasLink) + ")"); qryLinkCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom, aliasLink) + "=" + ((int)Sbm.ItemType.ItemBatch).ToString()); @@ -515,8 +515,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs index 7620512..516edd1 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink-Utils.cs @@ -100,8 +100,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Add(colItemTypeFrom + "=" + ((int)itemType).ToString() + " AND " + colItemIdFrom + "=" + itemId.ToString()); filters.Add(colItemTypeTo + "=" + ((int)itemType).ToString() + " AND " + colItemIdTo + "=" + itemId.ToString()); String filter = filters.Concat(" OR ", "(", ")"); - //return db.ExecuteDelete("DELETE FROM" + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " WHERE " + filter); - db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), filter); + //return Database.ExecuteDelete("DELETE FROM" + SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " WHERE " + filter); + Database.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), filter); return false; } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs index 36a3812..8ede6a4 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas-ItemLink.cs @@ -42,7 +42,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmItemLink itemLink = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -93,7 +93,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filterItemFrom = colItemTypeFrom + "=" + ((int)itemType).ToString() + " AND " + colItemIdFrom + "=" + itemId.ToString(); String filterItemTo = colItemTypeTo + "=" + ((int)itemType).ToString() + " AND " + colItemIdTo + "=" + itemId.ToString(); String filter = "(" + filterItemFrom + ") OR (" + filterItemTo + ")"; - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Type),*/ filter) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), /*SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ItemLink_Type),*/ filter) > 0; } //------------------------------------------------------------------- @@ -112,7 +112,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidItemLink(itemLink)) return false; if (SysId.IsValid(itemLink.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -123,7 +123,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (ItemLink_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - //dbItemLink._Id = SysId.ToInt(db.GetNextId("ItemLink", dbUpdateInfo)); + //dbItemLink._Id = SysId.ToInt(Database.GetNextId("ItemLink", dbUpdateInfo)); } dbItemLink.ExecuteInsertCommand(dbCommand); itemLink.Id = new SysId(0); @@ -147,7 +147,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(itemLink).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -298,7 +298,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!ItemLinkCanBeDeleted(itemLink)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -536,7 +536,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetItemLinkCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " As " + aliasItemLink, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink) + " As " + aliasItemLink, filter); } public override long GetItemLinkCount(SbmItemLink.Params prm) { @@ -550,14 +550,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List itemLinks = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), aliasItemLink); ItemLink_Db dbItemLink = new ItemLink_Db(DbInfo); qry.Columns.AddRange(dbItemLink.ExistingColumnNames); qry.Filters.AddRange(GetItemLinkQueryFilter(prm)); qry.OrderBy.AddRange(GetItemLinkSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -590,7 +590,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), aliasItemLink); // ItemLink Properties - add columns as defined in query list. @@ -635,8 +635,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas.cs index 2c11e0a..7f4187b 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmDataItemMgr_Dbas.cs @@ -16,22 +16,45 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; - private readonly SbmDbDataItem.SbmDatabaseInfo dbInfo; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Construction. - public SbmDataItemMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmDataItemMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmDataItemMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - dbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); + Initialise(); + } + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); } //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return dbInfo; } } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } //------------------------------------------------------------------- // Utilities. diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs index 1995a53..75d1a8c 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-Price.cs @@ -51,7 +51,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmPrice price = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -101,7 +101,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidPrice(price)) return false; if (SysId.IsValid(price.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -132,7 +132,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed." + GetLogProperties(price).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -170,7 +170,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!PriceCanBeDeleted(price)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -465,7 +465,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetPriceCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice) + " As " + aliasPrice, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice) + " As " + aliasPrice, filter); } public override long GetPriceCount(SbmPrice.Params prm) { @@ -479,14 +479,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List prices = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPrice); SaPrice_Db dbPrice = new SaPrice_Db(DbInfo); qry.Columns.AddRange(dbPrice.ExistingColumnNames); qry.Filters.AddRange(GetPriceQueryFilter(prm)); qry.OrderBy.AddRange(GetPriceSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -519,7 +519,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPrice); // Price Properties - add columns as defined in query list. @@ -607,8 +607,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs index 60779ab..e3c2fe8 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas-PriceSet.cs @@ -52,7 +52,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmPriceSet priceSet = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -102,7 +102,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidPriceSet(priceSet)) return false; if (SysId.IsValid(priceSet.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -113,7 +113,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (SaPriceSet_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbPriceSet._Id = SysId.ToInt(db.GetNextId("PriceSet", dbUpdateInfo)); + dbPriceSet._Id = SysId.ToInt(Database.GetNextId("PriceSet", dbUpdateInfo)); } dbPriceSet.ExecuteInsertCommand(dbCommand); priceSet.Id = new SysId(dbPriceSet._Id); @@ -137,7 +137,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed." + GetLogProperties(priceSet).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!PriceSetCanBeDeleted(priceSet)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -225,7 +225,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //priceSet.Id = new SysId(dbPriceSet._Id); //priceSet.AffiliateIdOwner = new SysId(dbPriceSet._AffIdOwner); //priceSet.Reference = dbPriceSet._Ref; - priceSet.PriceType = (Sbm.PriceType)(dbPriceSet._Type??0); + priceSet.PriceType = (Sbm.PriceType)(dbPriceSet._Type ?? 0); priceSet.Name = dbPriceSet._Name; priceSet.CurrencyId = new SysId(dbPriceSet._CurrencyId ?? 0); // Common properties. @@ -421,7 +421,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetPriceSetCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet) + " As " + aliasPriceSet, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet) + " As " + aliasPriceSet, filter); } public override long GetPriceSetCount(SbmPriceSet.Params prm) { @@ -435,14 +435,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List priceSets = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet), aliasPriceSet); SaPriceSet_Db dbPriceSet = new SaPriceSet_Db(DbInfo); qry.Columns.AddRange(dbPriceSet.ExistingColumnNames); qry.Filters.AddRange(GetPriceSetQueryFilter(prm)); qry.OrderBy.AddRange(GetPriceSetSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -475,7 +475,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet), aliasPriceSet); // PriceSet Properties - add columns as defined in query list. @@ -527,7 +527,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (columns.HasId((int)SbmPriceSet.Column.PriceCount)) { String aliasPriceCount = "PriceCount"; - DbQuery qryPrice = new DbQuery(db.DbmsType); + DbQuery qryPrice = new DbQuery(Database.DbmsType); qryPrice.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPrice), aliasPriceCount); qryPrice.Columns.Add("Count(*)"); qryPrice.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPrice_PriceSetId, aliasPriceCount) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaPriceSet_Id, aliasPriceSet)); @@ -546,8 +546,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas.cs index bee2382..ca6a59f 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmPriceMgr_Dbas.cs @@ -13,15 +13,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Construction. - public SbmPriceMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmPriceMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmPriceMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - DbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); + Initialise(); } protected override void Dispose(bool disposing) { @@ -31,10 +40,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr base.Dispose(disposing); } + //------------------------------------------------------------------- + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); + } + //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get; } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } protected String TableName_PriceSet { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet); } } protected String TableName_Price { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet); } } public override bool PriceDatabaseIsValid { get { return Database.TableExists(TableName_PriceSet) && Database.TableExists(TableName_Price); } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-ItemProcess.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-ItemProcess.cs index 8e5b2be..248ecc6 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-ItemProcess.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-ItemProcess.cs @@ -138,7 +138,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String aliasCol_ProcessCategory = "ProcCategory"; String aliasCol_ProcessType = "ProcType"; // Build the query to retrieve item processes and associated process details. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink)); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom), aliasCol_ItemType); @@ -177,7 +177,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr #endif // Filter the 'To' item to match the process. - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -222,13 +222,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (itemType != Sbm.ItemType.Commodity && itemType != Sbm.ItemType.AssetCategory && itemType != Sbm.ItemType.Asset) return SetErrorState("invalid item type"); if (!SysId.IsValid(itemId)) return SetErrorState("invalid item Id"); - if (db == null) return SetErrorState("database unavailable"); + if (Database == null) return SetErrorState("database unavailable"); // Query the number of matching links. List filters = new List(); filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom) + "=" + ((int)itemType).ToString()); filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemIdFrom) + "=" + itemId.ToString()); filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeTo) + "=" + ((int)Sbm.ItemType.Process).ToString()); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), filters.Concat(" AND ")) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), filters.Concat(" AND ")) > 0; } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs index 4db3d5f..9ed19a4 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas-Process.cs @@ -55,7 +55,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr query.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_Category), colCategory); query.Columns.Add("Count(*)", colCount); query.GroupBy.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_Category)); - using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery())) + using (DbResultSet resultSet = DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery())) { while (resultSet.NextRecord()) { @@ -70,7 +70,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_AffIdOwner) + "=" + SysId.ToString(AffiliateId_Owner)); if (processCategory > 0) filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_Category) + "=" + ((int)processCategory).ToString()); - //return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), filters.Concat(" AND ", "(", ")")) > 0; + //return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), filters.Concat(" AND ", "(", ")")) > 0; } return processInfoCache.ProcessCountByCategory.GetValue(processCategory, 0) > 0; } @@ -93,7 +93,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmProcess prmProcess = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -116,7 +116,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { if (!SysId.IsValid(AffiliateId_Owner)) return 0; String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_AffIdOwner) + "=" + AffiliateId_Owner.ToString(); - return (short)db.GetRowValue(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_Seq), filter, DbGetValueType.eDbValueMax).AsLong(); + return (short)Database.GetRowValue(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Process_Seq), filter, DbGetValueType.eDbValueMax).AsLong(); } //------------------------------------------------------------------- @@ -154,7 +154,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidProcess(process)) return false; if (SysId.IsValid(process.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -165,7 +165,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Process_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbProcess._Id = SysId.ToInt(db.GetNextId("Process", dbUpdateInfo)); + dbProcess._Id = SysId.ToInt(Database.GetNextId("Process", dbUpdateInfo)); } dbProcess.ExecuteInsertCommand(dbCommand); process.Id = new SysId(dbProcess._Id); @@ -189,7 +189,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(process).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -227,7 +227,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!ProcessCanBeDeleted(process)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -467,7 +467,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetProcessCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process) + " As " + aliasProcess, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process) + " As " + aliasProcess, filter); } public override long GetProcessCount(SbmProcess.Params prm) { @@ -481,14 +481,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List processes = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), aliasProcess); Process_Db dbProcess = new Process_Db(DbInfo); qry.Columns.AddRange(dbProcess.ExistingColumnNames); qry.Filters.AddRange(GetProcessQueryFilter(prm)); qry.OrderBy.AddRange(GetProcessSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -521,7 +521,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process), aliasProcess); // Process Properties - add columns as defined in query list. @@ -560,8 +560,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas.cs index 6f03349..0695a73 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmProcessMgr_Dbas.cs @@ -16,30 +16,45 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; - private readonly SbmDbDataItem.SbmDatabaseInfo dbInfo; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Construction. - public SbmProcessMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmProcessMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmProcessMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - dbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); + Initialise(); + } + + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); } //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return dbInfo; } } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } protected String TableName_Process { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process); } } protected String TableName_ItemLink { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink); } } public override bool ProcessDatabaseIsValid { get { - if (!TableExists(SbmDbDfn.TableIdx.Process)) return false; - if (!TableExists(SbmDbDfn.TableIdx.ItemLink)) return false; + if (!Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process))) return false; + if (!Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink))) return false; return true; } } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs index 4a3eac6..5ce2b97 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Location.cs @@ -54,7 +54,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmLocation location = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -103,7 +103,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidLocation(location)) return false; if (SysId.IsValid(location.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -114,7 +114,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Location_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbLocation._Id = SysId.ToInt(db.GetNextId("Location", dbUpdateInfo)); + dbLocation._Id = SysId.ToInt(Database.GetNextId("Location", dbUpdateInfo)); } dbLocation.ExecuteInsertCommand(dbCommand); location.Id = new SysId(dbLocation._Id); @@ -138,7 +138,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(location).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -176,7 +176,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!LocationCanBeDeleted(location)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -431,7 +431,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetLocationCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location) + " As " + aliasLocation, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location) + " As " + aliasLocation, filter); } public override long GetLocationCount(SbmLocation.Params prm) { @@ -445,14 +445,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List Locations = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location), aliasLocation); Location_Db dbLocation = new Location_Db(DbInfo); qry.Columns.AddRange(dbLocation.ExistingColumnNames); qry.Filters.AddRange(GetLocationQueryFilter(prm)); qry.OrderBy.AddRange(GetLocationSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -486,7 +486,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location), aliasLocation); //--------------------------------------------------------------- @@ -524,8 +524,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs index 8fffdff..87b604d 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas-Movement.cs @@ -72,7 +72,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool CancelMovementsForSourceItem(Sbm.ItemType itemType, SysId itemId) { ClearErrorState(); - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return true; + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return true; // Commodity database names. String colMovement_ItemId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemId); @@ -83,14 +83,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Retrieve a list of commodities that have actioned movements against this item. List commodityIds = new List(); - DbQuery qryMovCmd = new DbQuery(db.DbmsType); + DbQuery qryMovCmd = new DbQuery(Database.DbmsType); qryMovCmd.DistinctRows = true; qryMovCmd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement)); qryMovCmd.Columns.Add(colMovement_ItemId); qryMovCmd.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemType) + "=" + ((int)Sbm.ItemType.Commodity).ToString()); qryMovCmd.Filters.AddRange(lFilterSourceItem); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryMovCmd.BuildQuery())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryMovCmd.BuildQuery())) { while (dbResultSet != null && dbResultSet.NextRecord()) { @@ -102,9 +102,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update the associated movements to set their status to 'Cancelled'. List values = new List(); SacsDatabase.AddValuePair(values, colMovement_Status, StatusCancelled, true); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), values, lFilterSourceItem.Concat(" AND ", "(", ")")); - if (db.HasErrorState()) - SetErrorState($"{db.ErrorStateMessage}"); + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), values, lFilterSourceItem.Concat(" AND ", "(", ")")); + if (Database.HasErrorState()) + SetErrorState($"{Database.ErrorStateMessage}"); // ToDo CalculateStockLevels(commodityIds); > in Stock-MgrDbas return !HasErrorState(); @@ -113,7 +113,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool ClearMovementsForSourceItem(Sbm.ItemType itemType, SysId itemId) { ClearErrorState(); - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return true; + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return true; // Commodity database names. String colMovement_ItemId = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemId); @@ -124,14 +124,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Retrieve a list of commodities that have actioned movements against this item. List commodityIds = new List(); - DbQuery qryMovCmd = new DbQuery(db.DbmsType); + DbQuery qryMovCmd = new DbQuery(Database.DbmsType); qryMovCmd.DistinctRows = true; qryMovCmd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement)); qryMovCmd.Columns.Add(colMovement_ItemId); qryMovCmd.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemType) + "=" + ((int)Sbm.ItemType.Commodity).ToString()); qryMovCmd.Filters.AddRange(filtersSourceItem); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryMovCmd.BuildQuery())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryMovCmd.BuildQuery())) { while (dbResultSet != null && dbResultSet.NextRecord()) { @@ -141,7 +141,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } // Delete the associated movements. - db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filtersSourceItem.Concat(" AND ", "(", ")")); + Database.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filtersSourceItem.Concat(" AND ", "(", ")")); // ToDo CalculateStockLevels(commodityIds); > in Stock-MgrDbas return !HasErrorState(); @@ -151,11 +151,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override bool SourceItemHasMovements(Sbm.ItemType itemType, SysId itemId) { if ((int)itemType < 1 || !SysId.IsValid(itemId)) return false; - if (db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return false; + if (Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return false; List filtersSourceItem = new List(); filtersSourceItem.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemTypeSource) + ((int)itemType).ToString()); filtersSourceItem.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemIdSource) + "=" + itemId.ToString()); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filtersSourceItem.Concat(" AND ", "(", ")")) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filtersSourceItem.Concat(" AND ", "(", ")")) > 0; } //------------------------------------------------------------------- // Get Movement. @@ -175,7 +175,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmMovement movement = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -224,7 +224,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidMovement(movement)) return false; if (SysId.IsValid(movement.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -235,7 +235,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Movement_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbMovement._Id = SysId.ToInt(db.GetNextId("Movement", dbUpdateInfo)); + dbMovement._Id = SysId.ToInt(Database.GetNextId("Movement", dbUpdateInfo)); } dbMovement.ExecuteInsertCommand(dbCommand); movement.Id = new SysId(dbMovement._Id); @@ -259,7 +259,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(movement).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -297,7 +297,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!MovementCanBeDeleted(movement)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -399,7 +399,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Getting Movement column definition. public override ColumnDfn GetMovementColumnDfn(SbmMovement.Column columnId, string caption = "", int width = 0) { - orderQuantityDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); + orderQuantityDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width); switch (columnId) @@ -651,7 +651,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // *** NOT TESTED beyond here! // Container item table is not in the main query - sub query is required: - DbQuery qryContainer = new DbQuery(db.DbmsType); + DbQuery qryContainer = new DbQuery(Database.DbmsType); qryContainer.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasMovement_ContainerItem); qryContainer.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Container_Id, aliasMovement_Container)); qryContainer.Filters.AddRange(filterContainerItem); @@ -817,7 +817,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetMovementCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement) + " As " + aliasMovement, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement) + " As " + aliasMovement, filter); } public override long GetMovementCount(SbmMovement.Params prm) { @@ -831,14 +831,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List movements = new List(); - DbQuery DbQuery = new DbQuery(db.DbmsType); + DbQuery DbQuery = new DbQuery(Database.DbmsType); DbQuery.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasMovement); Movement_Db dbMovement = new Movement_Db(DbInfo); DbQuery.Columns.AddRange(dbMovement.ExistingColumnNames); DbQuery.Filters.AddRange(GetMovementQueryFilter(prm)); DbQuery.OrderBy.AddRange(GetMovementSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -872,7 +872,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //--------------------------------------------------------------- // Construct query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasMovement); //--------------------------------------------------------------- @@ -1043,8 +1043,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas.cs index 827ec87..50726bf 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmStockMgr_Dbas.cs @@ -16,30 +16,53 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; - private readonly SbmDbDataItem.SbmDatabaseInfo dbInfo; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); //------------------------------------------------------------------- // Construction. - public SbmStockMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmStockMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmStockMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - dbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); + Initialise(); + } + protected override void Dispose(bool disposing) + { + if (disposing) + { + } + base.Dispose(disposing); + } + + //------------------------------------------------------------------- + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); } //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return dbInfo; } } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } //------------------------------------------------------------------- // Utilities. public override bool DatabaseIsValid() { ClearErrorState(); - if (!TableExists(SbmDbDfn.TableIdx.StockLevel)) return SetErrorState("Stock Level table does not exist"); - if (!TableExists(SbmDbDfn.TableIdx.Movement)) return SetErrorState("Movement table does not exist"); + if (!Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel))) return SetErrorState("Stock Level table does not exist"); + if (!Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement))) return SetErrorState("Movement table does not exist"); return true; } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs index 5e077be..6ac6148 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Constituent.cs @@ -53,10 +53,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Update all transactions. String colTransaction_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_Id, false); - DbQuery qryTrans = new DbQuery(db.DbmsType); + DbQuery qryTrans = new DbQuery(Database.DbmsType); qryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction)); qryTrans.Columns.Add(colTransaction_Id); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryTrans.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryTrans.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -68,10 +68,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Update all Requirements. String colRequirement_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_Id, false); - DbQuery qryReqnt = new DbQuery(db.DbmsType); + DbQuery qryReqnt = new DbQuery(Database.DbmsType); qryReqnt.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement)); qryReqnt.Columns.Add(colRequirement_Id); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryReqnt.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryReqnt.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -115,14 +115,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_TransId) + "=" + transId.ToString()); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Status) + "<>'" + StatusCancelled + "'"); - if (db != null) + if (Database != null) { - db.GetRowValue(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Quantity), filters.Concat(" AND ", "(", ")"), DbGetValueType.eDbValueSum); + Database.GetRowValue(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Quantity), filters.Concat(" AND ", "(", ")"), DbGetValueType.eDbValueSum); // Update the total time against the Transaction. List columnValues = new List(); SacsDatabase.AddValuePair(columnValues, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_TimeTot), quantityTot.ToString(), false); String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_Id) + "=" + transId.ToString(); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), columnValues, filter); + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), columnValues, filter); } } return true; @@ -137,14 +137,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filters = new List(); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_ReqntId) + "=" + reqntId.ToString()); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Status) + "<>'" + StatusCancelled + "'"); - if (db != null) + if (Database != null) { - db.GetRowValue(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Quantity), filters.Concat(" AND ", "(", ")"), DbGetValueType.eDbValueSum); + Database.GetRowValue(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Quantity), filters.Concat(" AND ", "(", ")"), DbGetValueType.eDbValueSum); // Update the total time against the Requirement. List columnValues = new List(); SacsDatabase.AddValuePair(columnValues, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_TimeTot), quantityTot.ToString(), false); String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_Id) + "=" + reqntId.ToString(); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), columnValues, filter); + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), columnValues, filter); } } return true; @@ -187,7 +187,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_Effective)); qry.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_AffIdTarget)); @@ -204,7 +204,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.GroupBy.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_AffIdTarget)); qry.GroupBy.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_UomId)); // Retrieve results. - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -317,7 +317,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmConstituent prmituent = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -371,7 +371,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidConstituent(constituent)) return false; if (SysId.IsValid(constituent.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -382,7 +382,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Constituent_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbConstituent._Id = SysId.ToInt(db.GetNextId("Constituent", dbUpdateInfo)); + dbConstituent._Id = SysId.ToInt(Database.GetNextId("Constituent", dbUpdateInfo)); } dbConstituent.ExecuteInsertCommand(dbCommand); constituent.Id = new SysId(dbConstituent._Id); @@ -406,7 +406,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(constituent).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -444,7 +444,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!ConstituentCanBeDeleted(constituent)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -832,10 +832,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Asset serial number. - if (!StringUtil.IsEmpty(prm.AssetSerialFull) || !StringUtil.IsEmpty(prm.AssetSerialPartial) && db.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset))) + if (!StringUtil.IsEmpty(prm.AssetSerialFull) || !StringUtil.IsEmpty(prm.AssetSerialPartial) && Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset))) { // Restrict to constituents associated with the specified asset(s): - DbQuery qryAsset = new DbQuery(db.DbmsType); + DbQuery qryAsset = new DbQuery(Database.DbmsType); String colAsset_SerialNumber = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.SaAsset_SerialNumber); String colConstituent_AssetId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_AssetId); qryAsset.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaAsset)); @@ -913,7 +913,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetConstituentCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent) + " As " + aliasConstituent, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent) + " As " + aliasConstituent, filter); } public override long GetConstituentCount(SbmConstituent.Params prm) { @@ -927,14 +927,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List constituents = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), aliasConstituent); Constituent_Db dbConstituent = new Constituent_Db(DbInfo); qry.Columns.AddRange(dbConstituent.ExistingColumnNames); qry.Filters.AddRange(GetConstituentQueryFilter(prm)); qry.OrderBy.AddRange(GetConstituentSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -967,8 +967,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + DbQuery query = new DbQuery(Database.DbmsType); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); //--------------------------------------------------------------------- // Sort Column ~ lColSort? @@ -1202,8 +1202,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs index 1bc406c..75b15fb 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Requirement.cs @@ -114,8 +114,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!SysId.IsValid(requirementId)) return SetErrorState("Invalid item specified"); String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource) + "=" + SysId.ToString(requirementId); - long rowCount = db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter); - SetErrorState(db.ErrorStateMessage); + long rowCount = Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter); + SetErrorState(Database.ErrorStateMessage); return rowCount > 0; } public override bool RequirementHasConstituents(SysId requirementId, Sbm.ConstituentType constituentType) @@ -124,8 +124,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filter = new List { SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_ReqntId) + "=" + SysId.ToString(requirementId) }; if (constituentType > 0) filter.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_Type) + "=" + ((int)constituentType).ToString()); - long rowCount = db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter.Concat(" AND ", "(", ")")); - SetErrorState(db.ErrorStateMessage); + long rowCount = Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter.Concat(" AND ", "(", ")")); + SetErrorState(Database.ErrorStateMessage); return rowCount > 0; } public override bool ClearRequirementDependentData(SysId requirementId, SysId commodityId) @@ -139,11 +139,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (!HasErrorState()) { String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_ReqntId) + "=" + SysId.ToString(requirementId); - int rowsDeleted = db.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter); - if (db.HasErrorState()) + int rowsDeleted = Database.ExecuteDelete(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filter); + if (Database.HasErrorState()) { String msg = "Failed to clear requirement constituents"; - SaLogger.Warn($"{SysUtil.Fn} {msg}: {db.ErrorStateMessage}. RequirentId: {SysId.ToString(requirementId)}."); + SaLogger.Warn($"{SysUtil.Fn} {msg}: {Database.ErrorStateMessage}. RequirentId: {SysId.ToString(requirementId)}."); SetErrorState(msg); } } @@ -176,8 +176,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filter = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource) + "=" + SysId.ToString(requirementId); List values = new List(); SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource), "0", false); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter); - if (db.HasErrorState()) + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filter); + if (Database.HasErrorState()) SetErrorState("Failed to clear requirement references"); return !HasErrorState(); } @@ -284,7 +284,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Verify that the location table exists. String locationTable = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Location); - if (!db.TableExists(locationTable)) return; + if (!Database.TableExists(locationTable)) return; locationIdListsPopulated = true; String colLocation_Id = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_Id); @@ -293,13 +293,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colLocation_Status = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Location_Status); // Stock locations. - DbQuery qryLoc1 = new DbQuery(db.DbmsType); + DbQuery qryLoc1 = new DbQuery(Database.DbmsType); qryLoc1.Tables.Add(locationTable); qryLoc1.Columns.Add(colLocation_Id); qryLoc1.Columns.Add(colLocation_Flags); qryLoc1.Columns.Add(colLocation_Status); qryLoc1.Filters.Add(colLocation_AffIdOwner + "=" + AffiliateId_Owner.ToString()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryLoc1.BuildQuery())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryLoc1.BuildQuery())) { while (dbResultSet != null && dbResultSet.NextRecord()) { @@ -360,7 +360,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); String filter = GetRequirementQueryFilter(prmRequirement).Concat(" AND ", "(", ")"); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filter) > 0; } //------------------------------------------------------------------- @@ -381,7 +381,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmRequirement prmRequirement = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -435,7 +435,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidRequirement(requirement)) return false; if (SysId.IsValid(requirement.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -446,7 +446,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Requirement_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbRequirement._Id = SysId.ToInt(db.GetNextId("Requirement", dbUpdateInfo)); + dbRequirement._Id = SysId.ToInt(Database.GetNextId("Requirement", dbUpdateInfo)); } dbRequirement.ExecuteInsertCommand(dbCommand); requirement.Id = new SysId(dbRequirement._Id); @@ -470,7 +470,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(requirement).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -507,7 +507,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!RequirementCanBeDeleted(requirement, transactionType)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -598,7 +598,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr requirement.AffiliateIdOwner = new SysId(dbRequirement._AffIdOwner); requirement.AssociationId = new SysId(dbRequirement._AssocId ?? 0); requirement.TransactionId = new SysId(dbRequirement._TransId ?? 0); - requirement.RequirementType = (Sbm.RequirementType)(dbRequirement._Type??0); + requirement.RequirementType = (Sbm.RequirementType)(dbRequirement._Type ?? 0); requirement.Seq = dbRequirement._Seq ?? 0; requirement.RequirementIdSource = new SysId(dbRequirement._ReqntIdSource ?? 0); requirement.Required = dbRequirement._Required ?? default(DateTime); @@ -734,8 +734,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr public override ColumnDfn GetRequirementColumnDfn(SbmRequirement.Column column, string caption = "", int width = 0) { - bool canViewSupplyFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + bool canViewSupplyFinancials = UserCanViewCommoditySupplyFinancials(); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); ColumnDfn columnDfn = new ColumnDfn((int)column, caption, width); switch (column) { @@ -1805,7 +1805,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String tableAlias_Assoc = "aReqAssFlt"; String tableAlias_AssocTarget = "aReqAssTgtFlt"; String colAssociation_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Association_Id, tableAlias_Assoc, false); - DbQuery qryAssoc = new DbQuery(db.DbmsType); + DbQuery qryAssoc = new DbQuery(Database.DbmsType); qryAssoc.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Association), tableAlias_Assoc); qryAssoc.Columns.Add(colAssociation_Id); qryAssoc.Filters.Add(colAssociation_Id + "=" + colRequirement_AssocId); @@ -1880,7 +1880,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (StringUtil.IsEmpty(prm.AliasTransaction)) { // Transaction table not joined in main query - use a sub query. - DbQuery qryTrans = new DbQuery(db.DbmsType); + DbQuery qryTrans = new DbQuery(Database.DbmsType); qryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), prmTrans.TableAlias); qryTrans.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, prmTrans.TableAlias, false)); qryTrans.Filters.AddRange(transactionFilters); @@ -1912,7 +1912,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { String tableAlias_ReqntSource = "ReqSrcFlt"; String colRequirementId_ReqntSource = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, tableAlias_ReqntSource, false); - DbQuery qryTrans = new DbQuery(db.DbmsType); + DbQuery qryTrans = new DbQuery(Database.DbmsType); qryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), tableAlias_ReqntSource); qryTrans.Columns.Add(colRequirementId_ReqntSource); qryTrans.Filters.Add(colRequirementId_ReqntSource + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource, tableAlias, false)); @@ -1968,7 +1968,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String colItemLink_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_Type, tableAlias_ItemLink, false); String colItemLink_ItemTypeFrom = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeFrom, tableAlias_ItemLink, false); String colItemLink_ItemTypeTo = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ItemLink_ItemTypeTo, tableAlias_ItemLink, false); - DbQuery qryLink = new DbQuery(db.DbmsType); + DbQuery qryLink = new DbQuery(Database.DbmsType); qryLink.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink), tableAlias_ItemLink); String tableAlias_ItemLinkReqnt = "aReqItmLinkReqnt"; qryLink.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), tableAlias_ItemLinkReqnt); @@ -2003,7 +2003,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String tableAlias_TransactionProject = "ReqTraProj"; String colTransaction_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, tableAlias_TransactionProject, false); String colTransaction_Type = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Type, tableAlias_TransactionProject, false); - DbQuery qryTrans = new DbQuery(db.DbmsType); + DbQuery qryTrans = new DbQuery(Database.DbmsType); qryTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), tableAlias_TransactionProject); qryTrans.Columns.Add(colTransaction_Id); qryTrans.Filters.Add(colTransaction_Id + "=" + colRequirement_TransId); @@ -2060,7 +2060,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String tableAlias_Commodity = "ReqntCmdFlt"; String colCommodity_Id = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Commodity_Id, tableAlias_Commodity, false); String colRequirement_CommodityId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CommodityId, tableAlias, false); - DbQuery qryCmd = new DbQuery(db.DbmsType); + DbQuery qryCmd = new DbQuery(Database.DbmsType); qryCmd.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Commodity), tableAlias_Commodity); qryCmd.Columns.Add(colCommodity_Id); qryCmd.Filters.Add(colCommodity_Id + "=" + colRequirement_CommodityId); @@ -2126,7 +2126,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetRequirementCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement) + " As " + aliasRequirement, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement) + " As " + aliasRequirement, filter); } public override long GetRequirementCount(SbmRequirement.Params prm) { @@ -2140,14 +2140,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List requirements = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasRequirement); Requirement_Db dbRequirement = new Requirement_Db(DbInfo); qry.Columns.AddRange(dbRequirement.ExistingColumnNames); qry.Filters.AddRange(GetRequirementQueryFilter(prm)); qry.OrderBy.AddRange(GetRequirementSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -2187,9 +2187,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); //------------------------------------------------------------------ // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); - bool canViewSupplyFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + DbQuery query = new DbQuery(Database.DbmsType); + bool canViewSupplyFinancials = UserCanViewCommoditySupplyFinancials(); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); // Columns required. bool requirementPromotionReq = columns.HasId((int)SbmRequirement.Column.PromotionCode) || columns.HasId((int)SbmRequirement.Column.PromotionDesc) || columns.HasId((int)SbmRequirement.Column.Promotion_AltText); @@ -2545,7 +2545,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Build sub query to calculate the total cost total across all items. String aliasRequirement_RequirementCost = "ReqCst"; String colTransCostTotal = "TraReqCount"; - DbQuery qryReqntCost = new DbQuery(db.DbmsType); + DbQuery qryReqntCost = new DbQuery(Database.DbmsType); qryReqntCost.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasRequirement_RequirementCost)); qryReqntCost.Columns.Add("Sum(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CostTotal, aliasRequirement_RequirementCost, false) + ")"); qryReqntCost.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasRequirement_RequirementCost, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasRequirement)); @@ -2812,7 +2812,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------ // Sub Filter to identify matching constituent with lowest sequence number, // or null if no matching links found. - DbQuery qryConstProcSeq = new DbQuery(db.DbmsType); + DbQuery qryConstProcSeq = new DbQuery(Database.DbmsType); String aliasRequirement_ConstituentProcessSeq = "aReqConstProcSeq"; qryConstProcSeq.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), aliasRequirement_ConstituentProcessSeq); qryConstProcSeq.Columns.Add("MIN(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_Seq, aliasRequirement_ConstituentProcessSeq, false) + ")"); @@ -2856,7 +2856,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.ContainerItem_ItemIdSource, aliasRequirment_ContainerItem, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasRequirement)); // Container Item query. - DbQuery qryCntItm = new DbQuery(db.DbmsType); + DbQuery qryCntItm = new DbQuery(Database.DbmsType); String colCntItmCount = "CntItmCount"; qryCntItm.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), aliasRequirment_ContainerItem)); qryCntItm.Filters.AddRange(filters); @@ -2919,7 +2919,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { // Return the number of references for each associated requirement. // ie. the total number of requirements associated with the target requirement. - DbQuery qryAssocReqntRefCount = new DbQuery(db.DbmsType); + DbQuery qryAssocReqntRefCount = new DbQuery(Database.DbmsType); String colAssocReqntRefCount = "AssReqRefCount"; qryAssocReqntRefCount.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink)); qryAssocReqntRefCount.Columns.Add("Count(1)"); @@ -2995,7 +2995,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // WHERE ((TblReqTraReqCount.TransId)=(Requirement.TransId))) AS Req_Count String aliasReqntTrans_RequirementCount = "taTraReqCount"; String colTransReqntCount = "TraReqCount"; - DbQuery qryReqntCount = new DbQuery(db.DbmsType); + DbQuery qryReqntCount = new DbQuery(Database.DbmsType); qryReqntCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasReqntTrans_RequirementCount)); qryReqntCount.Columns.Add("COUNT(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasReqntTrans_RequirementCount, false) + ")"); qryReqntCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasReqntTrans_RequirementCount, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasRequirement)); @@ -3007,7 +3007,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Get the total quantity for this commodity. String aliasReqntTrans_CommodityQuantity = "taRetCmdQty"; String colQuantityTotalByCmd = "QtyTotalByCmd"; - DbQuery qryCmdQty = new DbQuery(db.DbmsType); + DbQuery qryCmdQty = new DbQuery(Database.DbmsType); qryCmdQty.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasReqntTrans_CommodityQuantity)); qryCmdQty.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Quantity, aliasReqntTrans_CommodityQuantity, false) + ")"); qryCmdQty.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CommodityId, aliasReqntTrans_CommodityQuantity, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CommodityId, aliasRequirement)); @@ -3018,7 +3018,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Quantity dispatched. if (columns.HasId((int)SbmRequirement.Column.QuantityDispatched)) { - DbQuery qryReqntDisp = new DbQuery(db.DbmsType); + DbQuery qryReqntDisp = new DbQuery(Database.DbmsType); qryReqntDisp.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasRequirment_SourceRequirementDispatched); qryReqntDisp.Columns.Add("Sum(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Quantity, aliasRequirment_SourceRequirementDispatched, false) + ")"); qryReqntDisp.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource, aliasRequirment_SourceRequirementDispatched, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasRequirement)); @@ -3047,7 +3047,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr transTypeInvoices.Add(Sbm.TransactionType.ProformaPurchaseInvoice.ToString()); transTypeInvoices.Add(Sbm.TransactionType.PurchaseInvoice.ToString()); // Construct sub query to identify associated requirements that belong to invoices that haven't been invoiced. - DbQuery qryReqntInv = new DbQuery(db.DbmsType); + DbQuery qryReqntInv = new DbQuery(Database.DbmsType); qryReqntInv.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasRequirment_SourceRequirementInvoice); qryReqntInv.Columns.Add("Sum(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Quantity, aliasRequirment_SourceRequirementInvoice, false) + ")"); qryReqntInv.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_ReqntIdSource, aliasRequirment_SourceRequirementInvoice, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasRequirement)); @@ -3082,7 +3082,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------ // Stock levels (current level). String aliasRequirement_StockLevel = "aReqStkLvl"; - DbQuery qryStk = new DbQuery(db.DbmsType); + DbQuery qryStk = new DbQuery(Database.DbmsType); qryStk.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasRequirement_StockLevel); qryStk.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Quantity, aliasRequirement_StockLevel, false) + ")"); qryStk.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Type, aliasRequirement_StockLevel, false) + "=" + Sbm.StockLevelType.CurrentLevel.ToString()); @@ -3092,7 +3092,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------ // Stock movements (allocations). String aliasRequirement_Movement = "aReqMov"; - DbQuery qryMov = new DbQuery(db.DbmsType); + DbQuery qryMov = new DbQuery(Database.DbmsType); qryMov.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), aliasRequirement_Movement); qryMov.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Quantity, aliasRequirement_Movement, false) + ")"); qryMov.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Movement_Type, aliasRequirement_Movement, false) + "=" + Sbm.MovementType.SalesAllocation.ToString()); @@ -3120,7 +3120,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Stock level @ Sales Location 1. String aliasRequirement_StockSalesLocation01 = "aReqStkSalLoc01"; String colReqStockSalesLoc01 = "StkSalLoc01"; - DbQuery qryStk = new DbQuery(db.DbmsType); + DbQuery qryStk = new DbQuery(Database.DbmsType); qryStk.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasRequirement_StockSalesLocation01); qryStk.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Quantity, aliasRequirement_StockSalesLocation01, false) + ")"); qryStk.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Type, aliasRequirement_StockSalesLocation01, false) + "=" + Sbm.StockLevelType.CurrentLevel.ToString()); @@ -3136,7 +3136,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Stock level @ Sales Location 2. String aliasRequirement_StockSalesLocation02 = "aReqStkSalLoc02"; String colReqStockSalesLoc02 = "StkSalLoc02"; - DbQuery qryStk = new DbQuery(db.DbmsType); + DbQuery qryStk = new DbQuery(Database.DbmsType); qryStk.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasRequirement_StockSalesLocation02); qryStk.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Quantity, aliasRequirement_StockSalesLocation02, false) + ")"); qryStk.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Type, aliasRequirement_StockSalesLocation02, false) + "=" + Sbm.StockLevelType.CurrentLevel.ToString()); @@ -3152,7 +3152,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Stock level @ Sales Location 3. String aliasRequirement_StockSalesLocation03 = "aReqStkSalLoc03"; String colReqStockSalesLoc03 = "StkSalLoc03"; - DbQuery qryStk = new DbQuery(db.DbmsType); + DbQuery qryStk = new DbQuery(Database.DbmsType); qryStk.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.StockLevel), aliasRequirement_StockSalesLocation03); qryStk.Columns.Add("SUM(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Quantity, aliasRequirement_StockSalesLocation03, false) + ")"); qryStk.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.StockLevel_Type, aliasRequirement_StockSalesLocation03, false) + "=" + Sbm.StockLevelType.CurrentLevel.ToString()); @@ -3164,12 +3164,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------ // Imminent stock. - if (hasStockCol_DueImminent && UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.ImminentStock)) + if (hasStockCol_DueImminent && Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.ImminentStock)) { SbmCommodityMgr_Dbas commodityMgr = null; // NB Must be 'ODBC' version to access query logic. SbmCommodityMgr_Dbas.PlannedStockMovements_Params prmPSM = new SbmCommodityMgr_Dbas.PlannedStockMovements_Params(); - prmPSM.excludeAwaitingContainers = !UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock); - int weeksImminentStock = Math.Max(0, Math.Min(12, UserContext.GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, 0))); + prmPSM.excludeAwaitingContainers = !Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.AwaitingContainersInImminentStock); + int weeksImminentStock = Math.Max(0, Math.Min(12, Internals.GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks.ImminentStockDue, 0))); prmPSM.latest = DateTime.Today.StartOfWorkingWeek().AddDays(weeksImminentStock * 7); prmPSM.commodityIdCol = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CommodityId, aliasRequirement); query.Columns.Add(commodityMgr.BuildPlannedStockMovementsQuery(prmPSM), reqStockDueImmin); @@ -3187,8 +3187,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs index c5df080..dae7756 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas-Transaction.cs @@ -43,7 +43,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } public override decimal GetTransCostLabourRateHourDefault() { - String costLabourRateHour = UserContext.GetOwnerOption_Value(Sbm.OrgOption_Value.CostLabourRateDefault); + String costLabourRateHour = Internals.GetOwnerOption_Value(Sbm.OrgOption_Value.CostLabourRateDefault); return costLabourRateHour.ToDecimal(); } // ToDo GetTransCostLabourRateHourDefault & GetTransCostLabourRateHour for conversion datatype double to decimal! @@ -57,13 +57,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (ColumnExists(SbmDbDfn.ColumnIdx.Transaction_CostLabourRateHour)) { // Construct the query. - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction)); qry.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_CostLabourRateHour), colCostLabourRateHour); qry.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_Id) + "=" + transactionId.ToString()); qry.Filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_CostLabourRateHour) + " IS NOT null"); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { if (dbResultSet != null && dbResultSet.NextRecord()) { @@ -94,7 +94,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String errorStatePrefix = "Failed to change transaction's association - "; // Database connection. - if (!HasErrorState() && db == null) SetErrorState(errorStatePrefix + databaseNotAvailable); + if (!HasErrorState() && Database == null) SetErrorState(errorStatePrefix + databaseNotAvailable); // Validate the transaction. if (!HasErrorState() && (transaction == null || !SysId.IsValid(transaction.Id))) @@ -114,8 +114,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_AssocId), assocId.ToString(), false); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_TransId) + "=" + transaction.Id.ToString()); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), values, filters.Concat(" AND ", "(", ")")); - if (db.HasErrorState()) + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), values, filters.Concat(" AND ", "(", ")")); + if (Database.HasErrorState()) { SetErrorState(errorStatePrefix + "transaction updates failed"); ChangeTransactionsAssociation(transaction, transaction.AssociationId); // To reset changes. @@ -125,8 +125,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_AssocId), assocId.ToString(), false); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_TransId) + "=" + transaction.Id.ToString()); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filters.Concat(" AND ", "(", ")")); - if (db.HasErrorState()) + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), values, filters.Concat(" AND ", "(", ")")); + if (Database.HasErrorState()) { SetErrorState(errorStatePrefix + "requirement updates failed"); ChangeTransactionsAssociation(transaction, transaction.AssociationId); // To reset changes. @@ -137,8 +137,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr filters.Clear(); values.Clear(); SacsDatabase.AddValuePair(values, SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_AssocId), assocId.ToString(), false); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Transaction_Id) + "=" + transaction.Id.ToString()); - db.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), values, filters.Concat(" AND ", "(", ")")); - if (db.HasErrorState()) + Database.ExecuteUpdate(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), values, filters.Concat(" AND ", "(", ")")); + if (Database.HasErrorState()) { SetErrorState(errorStatePrefix + "transaction update failed"); ChangeTransactionsAssociation(transaction, transaction.AssociationId); // To reset changes. @@ -147,7 +147,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr return !HasErrorState(); } - public override bool RefreshAssociatedData(SbmTransaction transaction, List requirements = null) + public override bool RefreshAssociatedData(SbmTransaction transaction, List requirements, DbUpdateInfo dbUpdateInfo) { ClearErrorState(); if (transaction == null) return SetErrorState("Transaction not specified"); @@ -171,7 +171,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } // Refresh totals. if (transaction.RefreshTotals(requirements)) - UpdateTransaction(transaction, UserContext.DbUpdateInfo); + UpdateTransaction(transaction, dbUpdateInfo); else SetErrorState(transaction.ErrorStateMessage); } @@ -182,7 +182,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr return !HasErrorState(); } // Refresh associated transactions (eg. stock allocations on associated sames order when dispatch updated and stock actioned by dispatch). - public override bool RefreshAssociatedTransactions(SbmTransaction transaction, List requirements = null) + public override bool RefreshAssociatedTransactions(SbmTransaction transaction, List requirements, DbUpdateInfo dbUpdateInfo) { // Check whether associated transactions need to be updated. bool refreshAssociatedTransactions = false; @@ -216,9 +216,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List requirementsAssociation = transactionAssociation.GetRequirements(); if (requirementsAssociation.Count > 0) { - RefreshAssociatedData(transactionAssociation, null); + RefreshAssociatedData(transactionAssociation, null, dbUpdateInfo); transactionAssociation.RefreshTotals(requirementsAssociation); - UpdateTransaction(transactionAssociation, UserContext.DbUpdateInfo); + UpdateTransaction(transactionAssociation, dbUpdateInfo); requirementsAssociation.Clear(); } } @@ -237,7 +237,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!SysId.IsValid(transactionId)) return false; - DbmsType dbmsType = db.DbmsType; + DbmsType dbmsType = Database.DbmsType; String colRefCount = "RefCount"; ///Transaction Source References INTRO @@ -255,7 +255,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // 1. Transactions that reference the specified transaction directly. // TransId -> Trans.TransIdSource { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); String aliasTblTransSrc = "tblTraScr"; String tblTransaction = SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasTblTransSrc); @@ -268,7 +268,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // TransId -> ReqntSrc.TransId -> ReqntSrc.Id -> Reqnt.ReqntIdSource // NB Only interested if there are any referenced requirements, not what references them. { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); // Start with requirements belonging to the source transaction. String aliasTblReqntSrc = "tblReqSrc"; String colRequirement_TransId = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasTblReqntSrc, false); @@ -287,9 +287,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // TransSrc.Id -> ReqntSrc.TransId -> ReqntSrc.Id -> ItemLink -> Reqnt.Id -> Reqnt.TransId // NB Only need to check whether there are any links to the source requirements // and don't have to join to the referencing requirements themselves. - if (db.TableExists(SbmDbDfn.TableIdx.ItemLink.ToString()) && UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems)) + if (Database.TableExists(SbmDbDfn.TableIdx.ItemLink.ToString()) && Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems)) { - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); // Start with requirements belonging to the source transaction. String aliasTblReqntSrc = "tblReqSrc"; qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasTblReqntSrc); @@ -309,7 +309,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } // Execute the queries as a single uioned query. String query = queries.Concat("\n Union All \n"); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, query)) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, query)) { // As each sub-query returns a count, any positive count value is sufficient to indicate a reference. while (dbResultSet != null && dbResultSet.NextRecord()) @@ -333,17 +333,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr else if (requirementStatusCat > 0) filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_StatusCat) + "='" + RequirementStatusCats.GetCodeForType(requirementStatusCat) + "'"); // Get row count for these criteria: - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filters.Concat(" AND ", "(", ")")) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), filters.Concat(" AND ", "(", ")")) > 0; } - public override bool TransactionHasConstituents(SysId transactionId, SbmConstituent.StatusCat transactionStatusCat) + public override bool TransactionHasConstituents(SysId transactionId, SbmConstituent.StatusCat constituentStatusCat) { ClearErrorState(); if (!SysId.IsValid(transactionId)) return false; List filters = new List(); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_TransId) + "=" + transactionId.ToString()); - if (transactionStatusCat > 0) - filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_StatusCat) + "='" + SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ConstituentStatusCat/*, transactionStatusCat*/) + "'"); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filters.Concat(" AND ", "(", ")")) > 0; + if (constituentStatusCat > 0) + filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Constituent_StatusCat) + "='" + ConstituentStatusCats.GetCodeForType(constituentStatusCat) + "'"); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), filters.Concat(" AND ", "(", ")")) > 0; } public override bool TransactionHasContainerItems(SysId transactionId) { @@ -355,7 +355,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filterSource = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemTypeSource) + "=" + ((int)Sbm.ItemType.Transaction).ToString() + " AND " + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.ContainerItem_ItemIdSource) + "=" + transactionId.ToString(); List filters = new List(); filters.Add("(" + filterItem + ") OR (" + filterSource + ")"); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), filters.Concat(" AND ", "(", ")")) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem), filters.Concat(" AND ", "(", ")")) > 0; } public override bool TransactionHasStockMovements(SysId transactionId) { @@ -367,7 +367,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String filterSource = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemTypeSource) + "=" + ((int)Sbm.ItemType.Transaction).ToString() + " AND " + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemIdSource) + "=" + transactionId.ToString(); List filters = new List(); filters.Add("(" + filterItem + ") OR (" + filterSource + ")"); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filters.Concat(" AND ", "(", ")")) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filters.Concat(" AND ", "(", ")")) > 0; } public override bool TransactionHasPendingStockMovements(SysId transactionId) { @@ -380,7 +380,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Source item can either be the transaction itself or any one of its requirements: String filterSourceTrans = SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemTypeSource) + "=" + ((int)Sbm.ItemType.Transaction).ToString() + " AND " + SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_ItemIdSource) + "=" + transactionId.ToString(); String aliasTransaction_Reqnt = "TraReq"; - DbQuery qryReqnt = new DbQuery(db.DbmsType); + DbQuery qryReqnt = new DbQuery(Database.DbmsType); qryReqnt.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasTransaction_Reqnt); qryReqnt.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasTransaction_Reqnt, false)); qryReqnt.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasTransaction_Reqnt, false) + "=" + transactionId.ToString()); @@ -390,7 +390,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr List filters = new List(); filters.Add("(" + filterItem + ") OR (" + filterSource + ")"); filters.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Movement_Status) + "='" + SaStatus.Awaiting + "'"); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filters.Concat(" AND ", "(", ")")) > 0; + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Movement), filters.Concat(" AND ", "(", ")")) > 0; } //------------------------------------------------------------------- @@ -411,7 +411,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } SbmTransaction prmTransaction = null; // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -435,7 +435,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); List ids = new List(); String dataName_ReqntId = "ReqntId"; - DbQuery qryReqntTrans = new DbQuery(db.DbmsType); + DbQuery qryReqntTrans = new DbQuery(Database.DbmsType); qryReqntTrans.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction)); qryReqntTrans.Columns.Add(SbmDbDfn.GetColumnName(SbmDbDfn.ColumnIdx.Requirement_Id), dataName_ReqntId); DbQueryJoin joinReqntTrans = new DbQueryJoin(DbJoinType.Inner); @@ -444,7 +444,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qryReqntTrans.Joins.Add(joinReqntTrans); qryReqntTrans.Filters.AddRange(GetTransactionQueryFilter(prmTrans)); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qryReqntTrans.BuildQuery())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qryReqntTrans.BuildQuery())) { while (dbResultSet != null && dbResultSet.NextRecord()) { @@ -496,7 +496,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr ClearErrorState(); if (!IsValidTransaction(transaction)) return false; if (SysId.IsValid(transaction.Id)) return SetErrorState(ErrorMessage.ValiditemId); - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -507,7 +507,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (Transaction_Db.FieldsNonId.Contains("Id")) { // Generate next Id. - dbTransaction._Id = SysId.ToInt(db.GetNextId("Transaction", dbUpdateInfo)); + dbTransaction._Id = SysId.ToInt(Database.GetNextId("Transaction", dbUpdateInfo)); } dbTransaction.ExecuteInsertCommand(dbCommand); transaction.Id = new SysId(dbTransaction._Id); @@ -531,7 +531,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Data not changed. " + GetLogProperties(transaction).Concat(": ").Concat("", "\n\t")); return true; } - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -597,7 +597,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); if (!TransactionCanBeDeleted(transaction)) return false; - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -811,8 +811,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Getting Transaction column definition. public override ColumnDfn GetTransactionColumnDfn(SbmTransaction.Column column, string caption = "", int width = 0) { - bool canViewSupplyFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + bool canViewSupplyFinancials = UserCanViewCommoditySupplyFinancials(); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); ColumnDfn columnDfn = new ColumnDfn((int)column, caption, width); switch (column) { @@ -1265,7 +1265,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr String tableAlias = StringUtil.OnEmpty(prm.TableAlias, aliasTransaction); // DBMS - used to format elements of queries. - DbmsType dbmsType = db != null ? db.DbmsType : DbmsType.General; + DbmsType dbmsType = Database != null ? Database.DbmsType : DbmsType.General; DbQuery qry = new DbQuery(dbmsType); // Column names. @@ -1421,7 +1421,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Inner Join ItemLink Where ItemTypeFrom+To=Requirement And ItemId From|To = ReqSrc.Id // TransId In // Select TransId From Reqnt Where ReqntIdSource In - if (db.TableExists(SbmDbDfn.TableIdx.ItemLink.ToString()) && UserContext.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems)) + if (Database.TableExists(SbmDbDfn.TableIdx.ItemLink.ToString()) && Internals.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.PurchaseItem_AssociatedSalesItems)) { String tableAlias_RequirementSource = "taReqSrc"; DbQuery qryAssocReqnt = new DbQuery(dbmsType); @@ -1726,7 +1726,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr private long GetTransactionCount(String filter) { ClearErrorState(); - return db.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction) + " As " + aliasTransaction, filter); + return Database.GetRowCount(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction) + " As " + aliasTransaction, filter); } public override long GetTransactionCount(SbmTransaction.Params prm) { @@ -1740,14 +1740,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); List transactions = new List(); - DbQuery qry = new DbQuery(db.DbmsType); + DbQuery qry = new DbQuery(Database.DbmsType); qry.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasTransaction); Transaction_Db dbTransaction = new Transaction_Db(DbInfo); qry.Columns.AddRange(dbTransaction.ExistingColumnNames); qry.Filters.AddRange(GetTransactionQueryFilter(prm)); qry.OrderBy.AddRange(GetTransactionSortColumns(prm)); // Query data. - using (var dbConnection = db.CreateConnection()) + using (var dbConnection = Database.CreateConnection()) using (var dbCommand = dbConnection.CreateCommand()) { try @@ -1779,11 +1779,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { ClearErrorState(); - bool canViewSupplyFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySupply); - bool canViewSalesFinancials = UserContext.SecurityProfile_Core.UserCanViewFinancials(Sbm.FinancialType.CommoditySales); + bool canViewSupplyFinancials = UserCanViewCommoditySupplyFinancials(); + bool canViewSalesFinancials = UserCanViewCommoditySalesFinancials(); //--------------------------------------------------------------------- // Construct build database query. - DbQuery query = new DbQuery(db.DbmsType); + DbQuery query = new DbQuery(Database.DbmsType); query.Tables.Add(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasTransaction); //--------------------------------------------------------------------- @@ -2047,7 +2047,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Build sub query to calculate the total cost total across all items. String aliasTransaction_RequirementCost = "aTrnReqCst"; String colNameCostTotal = "CostTotal"; - DbQuery qryReqntCount = new DbQuery(db.DbmsType); + DbQuery qryReqntCount = new DbQuery(Database.DbmsType); qryReqntCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasTransaction_RequirementCost)); qryReqntCount.Columns.Add("Sum(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_CostTotal, aliasTransaction_RequirementCost, false) + ")"); qryReqntCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasTransaction_RequirementCost, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, aliasTransaction)); @@ -2060,7 +2060,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Build sub query to directly return the number of associated requirements. String aliasTransaction_CountRequirement = "aTrnReqCnt"; String colNameCountReqnts = "CountReqnts"; - DbQuery qryReqntCount = new DbQuery(db.DbmsType); + DbQuery qryReqntCount = new DbQuery(Database.DbmsType); qryReqntCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Requirement), aliasTransaction_CountRequirement)); qryReqntCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_Id, aliasTransaction_CountRequirement, false) + ")"); qryReqntCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Requirement_TransId, aliasTransaction_CountRequirement, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, aliasTransaction)); @@ -2073,7 +2073,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Build sub query to directly return the number of associated constituents of type 'Time'. String aliasTransaction_CountTimes = "ConTim"; String colNameCountTimeRecs = "CountTimeRecs"; - DbQuery qryConstTimeCount = new DbQuery(db.DbmsType); + DbQuery qryConstTimeCount = new DbQuery(Database.DbmsType); qryConstTimeCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), aliasTransaction_CountTimes)); qryConstTimeCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_Id, aliasTransaction_CountTimes, false) + ")"); qryConstTimeCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_TransId, aliasTransaction_CountTimes, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, aliasTransaction)); @@ -2087,7 +2087,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Build sub query to directly return the number of associated constituents of type 'Action'. String aliasTransaction_CountActions = "ConAct"; String colNameCountActions = "CountActions"; - DbQuery qryConstActionCount = new DbQuery(db.DbmsType); + DbQuery qryConstActionCount = new DbQuery(Database.DbmsType); qryConstActionCount.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Constituent), aliasTransaction_CountActions)); qryConstActionCount.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_Id, aliasTransaction_CountActions, false) + ")"); qryConstActionCount.Filters.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Constituent_TransId, aliasTransaction_CountActions, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, aliasTransaction)); @@ -2118,7 +2118,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr transTypeInvoices.Add(Sbm.TransactionType.PurchaseInvoice.ToString()); // Construct sub query to check whether invoices have been raised against the transaction (usually a sales order). - DbQuery qryTransInv = new DbQuery(db.DbmsType); + DbQuery qryTransInv = new DbQuery(Database.DbmsType); qryTransInv.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Transaction), aliasTransaction_TransactionInvoice)); qryTransInv.Columns.Add("Count(" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, aliasTransaction_TransactionInvoice, false) + ")"); String filterTransIdSource = SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_TransIdSource, aliasTransaction_TransactionInvoice, false) + "=" + SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.Transaction_Id, aliasTransaction); @@ -2151,7 +2151,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr // Look for Interface Data item directly associated with this transaction - Build sub query to retrieve reference from interface export for this transaction. String aliasTransaction_IntData = "IntData"; String colNameAccountsInvoiceRef = "AccInvRef"; - DbQuery qryIntData = new DbQuery(db.DbmsType); + DbQuery qryIntData = new DbQuery(Database.DbmsType); qryIntData.RowLimit = 1; qryIntData.Tables.Add(new StringPair(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.InterfaceDataItem), aliasTransaction_IntData)); qryIntData.Columns.Add(SbmDbDfn.GetColumnNameQual(SbmDbDfn.ColumnIdx.InterfaceDataItem_ExternalRef, aliasTransaction_IntData, false)); @@ -2170,7 +2170,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr if (prm.RequiresVolumeThrottle()) { // Limit the number of transactions returned: - long maxTransactions = StringUtil.ToLong(UserContext.GetOwnerOption_Value(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter)); + long maxTransactions = StringUtil.ToLong(Internals.GetOwnerOption_Value(Sbm.OrgOption_Value.MaxTransactionsQueriedForEmptyFilter)); if (maxTransactions > 0) { query.RowLimit = (uint)maxTransactions; @@ -2186,8 +2186,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr } //--------------------------------------------------------------------- - //return new DbResultSet_DataTableReader(db, query.BuildQuery()); - return DbResultSet_DataReader.ExecuteQuery(db, query.BuildQuery(prm.ResultsPaging)); + //return new DbResultSet_DataTableReader(Database, query.BuildQuery()); + return DbResultSet_DataReader.ExecuteQuery(Database, query.BuildQuery(prm.ResultsPaging)); } //------------------------------------------------------------------- } diff --git a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs index 4d64527..6aa8162 100644 --- a/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs +++ b/SaBusMgrStandardDbas/Dbas/Mgr/SbmTransactionMgr_Dbas.cs @@ -21,10 +21,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr { //------------------------------------------------------------------- // Data members. - private SacsDatabase db = null; - private readonly SbmDbDataItem.SbmDatabaseInfo dbInfo; - private readonly int orderQuantityDecimals; - private readonly int weightDecimals; + public class Members + { + public SacsDatabase db = null; + public SbmDbDataItem.SbmDatabaseInfo dbInfo; + } + private readonly Members mbr = new Members(); + private int orderQuantityDecimals; + private int weightDecimals; bool locationIdListsPopulated = false; private List locationIds_All; @@ -34,19 +38,30 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr //------------------------------------------------------------------- // Construction. - public SbmTransactionMgr_Dbas(ISbmUserContext_Core userContext) : + public SbmTransactionMgr_Dbas(SbmInternals internals) : + base(internals) + { + Initialise(); + } + public SbmTransactionMgr_Dbas(ISbmUserOrganisationContext userContext) : base(userContext) { - db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); - dbInfo = new SbmDbDataItem.SbmDatabaseInfo(db.DatabaseName, db.GetTableDfns()); - orderQuantityDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); - weightDecimals = UserContext.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityWeight); + Initialise(); + } + + // Initialisation. + private void Initialise() + { + mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase); + mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns()); + orderQuantityDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.OrderQuantity); + weightDecimals = Internals.GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals.CommodityWeight); } //------------------------------------------------------------------- // Properties. - protected ISacsDatabase Database { get { return db; } } - protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return dbInfo; } } + protected ISacsDatabase Database { get { return mbr.db; } } + protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } } //------------------------------------------------------------------- // Utilities. @@ -94,7 +109,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr qry.Joins.Add(joinReqnt); // Execute the query. if (DebugMode) SaLogger.Debug($"{SysUtil.Fn} Query: " + qry.BuildQuery()); - using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, qry.ToString())) + using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(Database, qry.ToString())) { while (!HasErrorState() && dbResultSet != null && dbResultSet.NextRecord()) { diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Address.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Address.cs index 9924d97..f81f5f0 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Address.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Address.cs @@ -32,8 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Address(SbmInternals internals, SbmAddress address) : base(new Config(internals, address.Id)) { - itemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); - addressTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AddressType); + itemTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemType); + addressTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.AddressType); RecordAttrValues(address, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Affiliate.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Affiliate.cs index 8cb7648..b682e89 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Affiliate.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Affiliate.cs @@ -31,7 +31,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Affiliate(SbmInternals internals, SbmAffiliate affiliate) : base(new Config(internals, affiliate.Id)) { - affiliateTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AffiliateType); + affiliateTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.AffiliateType); RecordAttrValues(affiliate, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_AssetCategory.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_AssetCategory.cs index f39bd28..96400c4 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_AssetCategory.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_AssetCategory.cs @@ -32,8 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_AssetCategory(SbmInternals internals, SbmAssetCategory assetCategory) : base(new Config(internals, assetCategory.Id)) { - assetTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssetType); - incomeTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssetIncomeType); + assetTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.AssetType); + incomeTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.AssetIncomeType); RecordAttrValues(assetCategory, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Association.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Association.cs index e8d0f1c..3ba048c 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Association.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Association.cs @@ -32,8 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Association(SbmInternals internals, SbmAssociation association) : base(new Config(internals, association.Id)) { - associationTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.AssociationType); - discountTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.DiscountType); + associationTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.AssociationType); + discountTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.DiscountType); RecordAttrValues(association, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Commodity.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Commodity.cs index cf90b48..aeeb1e8 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Commodity.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Commodity.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Commodity(SbmInternals internals, SbmCommodity commodity) : base(new Config(internals, commodity.Id)) { - commodityTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.CommodityType); + commodityTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.CommodityType); RecordAttrValues(commodity, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Constituent.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Constituent.cs index fa85a6a..4418398 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Constituent.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Constituent.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Constituent(SbmInternals internals, SbmConstituent constituent) : base(new Config(internals, constituent.Id)) { - constituentTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ConstituentType); + constituentTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ConstituentType); RecordAttrValues(constituent, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Container.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Container.cs index adf2b4d..f7e133a 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Container.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Container.cs @@ -32,8 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Container(SbmInternals internals, SbmContainer container) : base(new Config(internals, container.Id)) { - containerCategories = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ContainerCategory); - containerTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ContainerType); + containerCategories = SbmSystem.GetSystemCodes(Sbm.SystemCode.ContainerCategory); + containerTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ContainerType); RecordAttrValues(container, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ContainerItem.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ContainerItem.cs index a66c006..cf5a2f7 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ContainerItem.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ContainerItem.cs @@ -32,8 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_ContainerItem(SbmInternals internals, SbmContainerItem containerItem) : base(new Config(internals, containerItem.Id)) { - itemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); - itemTypeSource = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); + itemTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemType); RecordAttrValues(containerItem, false); } @@ -58,14 +57,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog RecordAttrValue(SbmDbDfn.ColumnIdx.ContainerItem_Quantity, containerItem.Quantity, newValues); - - - - - - - - // Common properties. RecordAttrValue(SbmDbDfn.ColumnIdx.ContainerItem_Notes, containerItem.Notes, newValues); RecordAttrValue(SbmDbDfn.ColumnIdx.ContainerItem_Status, SacsSystem.GetStatusCode(containerItem.Status), newValues); diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemBatch.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemBatch.cs index 3f150fa..cedef1a 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemBatch.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemBatch.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_ItemBatch(SbmInternals internals, SbmItemBatch itemBatch) : base(new Config(internals, itemBatch.Id)) { - itemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); + itemTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemType); RecordAttrValues(itemBatch, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemLink.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemLink.cs index ffeec3e..80a4854 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemLink.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_ItemLink.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_ItemLink(SbmInternals internals, SbmItemLink itemLink) : base(new Config(internals, itemLink.Id)) { - itemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); + itemTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemType); RecordAttrValues(itemLink, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Location.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Location.cs index 19f64d8..134ee54 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Location.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Location.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Location(SbmInternals internals, SbmLocation location) : base(new Config(internals, location.Id)) { - locationCategories = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.LocationCategory); + locationCategories = SbmSystem.GetSystemCodes(Sbm.SystemCode.LocationCategory); RecordAttrValues(location, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Movement.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Movement.cs index 62fb907..7f5c655 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Movement.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Movement.cs @@ -32,9 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Movement(SbmInternals internals, SbmMovement movement) : base(new Config(internals, movement.Id)) { - itemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); - movementTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.MovementType); - itemTypeSources = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ItemType); + itemTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ItemType); + movementTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.MovementType); RecordAttrValues(movement, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_PortfolioItem.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_PortfolioItem.cs index 954dc1e..d3ef166 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_PortfolioItem.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_PortfolioItem.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_PortfolioItem(SbmInternals internals, SbmPortfolioItem portfolioItem) : base(new Config(internals, portfolioItem.Id)) { - portfolioItemTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.PortfolioItemType); + portfolioItemTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.PortfolioItemType); RecordAttrValues(portfolioItem, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Process.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Process.cs index ce26de6..aef033f 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Process.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Process.cs @@ -32,8 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Process(SbmInternals internals, SbmProcess process) : base(new Config(internals, process.Id)) { - processCategories = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ProcessCategory); - processTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.ProcessType); + processCategories = SbmSystem.GetSystemCodes(Sbm.SystemCode.ProcessCategory); + processTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.ProcessType); RecordAttrValues(process, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Requirement.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Requirement.cs index 88dda16..12b8a91 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Requirement.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Requirement.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Requirement(SbmInternals internals, SbmRequirement requirement) : base(new Config(internals, requirement.Id)) { - requirementTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.RequirementType); + requirementTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.RequirementType); RecordAttrValues(requirement, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_SysParam.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_SysParam.cs index 7a5643a..0ae530f 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_SysParam.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_SysParam.cs @@ -31,7 +31,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_SysParam(SbmInternals internals, SbmSysParam sysParam) : base(new Config(internals, sysParam.Id)) { - sysParamCategories = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.SysParamCategory); + sysParamCategories = SbmSystem.GetSystemCodes(Sbm.SystemCode.SysParamCategory); RecordAttrValues(sysParam, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Transaction.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Transaction.cs index 9396a50..f506a7d 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Transaction.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_Transaction.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_Transaction(SbmInternals internals, SbmTransaction transaction) : base(new Config(internals, transaction.Id)) { - transactionTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.TransactionType); + transactionTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.TransactionType); RecordAttrValues(transaction, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleClass.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleClass.cs index ff19f38..ef98b84 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleClass.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleClass.cs @@ -32,9 +32,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_VehicleClass(SbmInternals internals, SbmVehicleClass vehicleClass) : base(new Config(internals, vehicleClass.Id)) { - vehicleTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.VehicleType); - fuelTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.FuelType); - odometerUnits = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.OdometerUnits); + vehicleTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.VehicleType); + fuelTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.FuelType); + odometerUnits = SbmSystem.GetSystemCodes(Sbm.SystemCode.OdometerUnits); RecordAttrValues(vehicleClass, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleEvent.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleEvent.cs index 76a7342..eadbd5f 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleEvent.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleEvent.cs @@ -32,7 +32,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_VehicleEvent(SbmInternals internals, SbmVehicleEvent vehicleEvent) : base(new Config(internals, vehicleEvent.Id)) { - vehicleEventTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.VehicleEventType); + vehicleEventTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.VehicleEventType); RecordAttrValues(vehicleEvent, false); } diff --git a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleFeature.cs b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleFeature.cs index 904e646..5211086 100644 --- a/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleFeature.cs +++ b/SaBusMgrStandardDbas/Dbas/UpdateLog/SbmUpdateLogItemMonitor_VehicleFeature.cs @@ -32,8 +32,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.UpdateLog public SbmUpdateLogItemMonitor_VehicleFeature(SbmInternals internals, SbmVehicleFeature vehicleFeature) : base(new Config(internals, vehicleFeature.Id)) { - vehicleFeatureSources = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.VehicleFeatureSource); - vehicleFeatureTypes = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.VehicleFeatureType); + vehicleFeatureSources = SbmSystem.GetSystemCodes(Sbm.SystemCode.VehicleFeatureSource); + vehicleFeatureTypes = SbmSystem.GetSystemCodes(Sbm.SystemCode.VehicleFeatureType); RecordAttrValues(vehicleFeature, false); } diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs index a7f764f..86a96e9 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmApplication_Control.cs @@ -25,6 +25,7 @@ using static Sarand.Net.Standard.Dbas.Base.SacsDatabaseConsole; using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; using Sarand.Net.Standard.Base.Security; +using Sarand.BusinessMgr.Net.Standard.Dbas.App; namespace Sarand.BusinessMgr.Web.Control.App { @@ -58,7 +59,7 @@ namespace Sarand.BusinessMgr.Web.Control.App public SysId ControlRepositoryId { get; } public HashSet RepositoryContexts { get; } = new HashSet(); public ISacsDatabase BusMgrDatabase { get; set; } - // Core Instance config. + // Instance config. private SbmInstanceConfig instanceConfig = null; public SbmInstanceConfig InstanceConfig { @@ -69,6 +70,17 @@ namespace Sarand.BusinessMgr.Web.Control.App return instanceConfig; } } + // Instance data cache. + private SbmInstanceDataCache instanceDataCache = null; + public SbmInstanceDataCache InstanceDataCache + { + get + { + if (instanceDataCache == null) + instanceDataCache = new SbmInstanceDataCache_Dbas(SessionContext); + return instanceDataCache; + } + } } private readonly Dictionary coreInstances = new Dictionary(); @@ -164,6 +176,16 @@ namespace Sarand.BusinessMgr.Web.Control.App { return coreInstances.GetValue(sessionContext.Index, null)?.InstanceConfig; } + // Instance data cache. + public override SbmInstanceDataCache GetInstanceDataCache(SbmSessionContext sessionContext) + { + return coreInstances.GetValue(sessionContext.Index, null)?.InstanceDataCache; + } + // Organisation configuration. + public override SbmOrganisationConfig GetOrganisationConfig(ISbmUserOrganisationContext userContext) + { + return new SbmOrganisationConfig_Dbas(userContext, GetInstanceDataCache(userContext.SessionContext)); + } // Email configuration. public override SbmEmailConfig EmailConfig { get { return emailConfigs.Values.ToList().getConfigForSession(AppConfig); } } @@ -171,17 +193,17 @@ namespace Sarand.BusinessMgr.Web.Control.App // Consoles. //------------------------------------------------------------------- - public override SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext) + public override SaSecurityConsole CreateSecurityConsole(ISbmUserOrganisationContext userContext) { return new SbmSecurityConsole_Web(userContext); } - public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext) + public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserOrganisationContext userContext) { return null; } - public override SbmEmailConsole CreateEmailConsole(ISbmUserContext_Core userContext) + public override SbmEmailConsole CreateEmailConsole(ISbmUserOrganisationContext userContext) { return new SbmEmailConsole_Control(EmailConfig); } diff --git a/SaBusinessMgrCoreWebControl/Control/App/SbmUserContext_Control.cs b/SaBusinessMgrCoreWebControl/Control/App/SbmUserContext_Control.cs index ef2bae6..3cd5164 100644 --- a/SaBusinessMgrCoreWebControl/Control/App/SbmUserContext_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/App/SbmUserContext_Control.cs @@ -10,7 +10,7 @@ namespace Sarand.BusinessMgr.Web.Control.App /// /// Wrapper class to allow access to core internals from Control application. /// - public class SbmUserContext_Control : ISbmUserContext_Core + public class SbmUserContext_Control : ISbmUserOrganisationContext { //------------------------------------------------------------------- public SbmUserContext_Control(SbmSessionData_Control sessionData) diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs index d492663..269f0c7 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/Param/ParamController-Ajax.cs @@ -215,7 +215,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Param ColumnDfn colContext = ControlItemMgr.GetItemParamColumnDfn(SbmcItemParam.Column.Context); ColumnDfn colName = ControlItemMgr.GetItemParamColumnDfn(SbmcItemParam.Column.Name); ColumnDfn colValue = ControlItemMgr.GetItemParamColumnDfn(SbmcItemParam.Column.Value); - ColumnDfn colFlags = ControlItemMgr.GetItemParamColumnDfn(SbmcItemParam.Column.Status); + ColumnDfn colFlags = ControlItemMgr.GetItemParamColumnDfn(SbmcItemParam.Column.Flags); ColumnDfn colStatus = ControlItemMgr.GetItemParamColumnDfn(SbmcItemParam.Column.Status); List columns = new List() { @@ -360,6 +360,20 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Param return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); } + // Ensure combination of item, name and context not duplicate. + if (model.Param.Context != null && model.Param.Name != null) + { + string controlName = "ParamName"; + SbmcItemParam.Params prmParam = new SbmcItemParam.Params(); + if (itemParam != null) + prmParam.IdsExcluded.Add(itemParam.Id); + prmParam.ItemIdsIncluded.Add(itemId); + prmParam.Context = model.Param.Context; + prmParam.Name = model.Param.Name; + if (ControlItemMgr.GetItemParamCount(prmParam) > 0) + return Json(responseData.SetControlError(controlName, Localiser["msg.validation.duplicate.value"])); + } + // Create new item if required. if (itemParam == null) { diff --git a/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs b/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs index 497a830..cf7ed45 100644 --- a/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/Controllers/SbmController_Control.cs @@ -40,7 +40,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers //------------------------------------------------------------------- /// Control session data protected SbmSessionData_Control SessionData_Control { get { return SessionData as SbmSessionData_Control; } } - public override ISbmUserContext_Core UserContext_Core { get { return new SbmUserContext_Control(SessionData_Control); } } + public override ISbmUserOrganisationContext UserContext_Core { get { return new SbmUserContext_Control(SessionData_Control); } } protected override SbmSessionData_Web DeserializeSessionData(String sessionDataJson) { return JsonConvert.DeserializeObject(sessionDataJson, SbmSessionDataJsonSerializerSettings); diff --git a/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs b/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs index 041ef1b..6338e11 100644 --- a/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs +++ b/SaBusinessMgrCoreWebControl/Control/Models/SbmModel_Control.cs @@ -25,7 +25,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models // Properties. protected SbmApplication_Control ControlApp { get { return SbmApplication_Control.Instance; } } public SbmSessionData_Control SessionData_Control { get { return SessionData as SbmSessionData_Control; } } - public override ISbmUserContext_Core UserContext_Core { get { return new SbmUserContext_Control(SessionData_Control); } } + public override ISbmUserOrganisationContext UserContext_Core { get { return new SbmUserContext_Control(SessionData_Control); } } //------------------------------------------------------------------- public IEnumerable GetInstanceContextsForSelect() diff --git a/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs index 7af67c4..4ed82d8 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/App/SbmApplication_Portal.cs @@ -10,6 +10,7 @@ using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control; using Sarand.BusinessMgr.Net.Standard.Base.Consoles; using Sarand.BusinessMgr.Net.Standard.Base.Core; using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control; +using Sarand.BusinessMgr.Net.Standard.Dbas.App; using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles; using Sarand.BusinessMgr.Web.Portal.Consoles; using Sarand.BusinessMgr.Web.Portal.Helpers; @@ -40,30 +41,21 @@ namespace Sarand.BusinessMgr.Web.Portal.App // Session contexts. private static ushort sessionContextIdx_Next = 100; - private class SessionContextData + /// Core BusinessMgr database instance profile. + private class SessionContextData_Control { - public SessionContextData(SbmSessionContext_Web sessionContext) + public SessionContextData_Control(SbmSessionContext_Web sessionContext, SysId controlOwnerId, SysId controlRepositoryId) { - SessionContext = sessionContext; + this.SessionContext = sessionContext; + this.ControlOwnerId = controlOwnerId; + this.ControlRepositoryId = controlRepositoryId; } public SbmSessionContext_Web SessionContext { get; } public HashSet RepositoryContexts { get; } = new HashSet(); public ISacsDatabase BusMgrDatabase { get; set; } - public virtual SbmInstanceConfig InstanceConfig => null; - // Control database properties. - public bool IsControl { get { return SysId.IsValid(ControlOwnerId) && SysId.IsValid(ControlRepositoryId); } } - public SysId ControlOwnerId { get; protected set; } - public SysId ControlRepositoryId { get; protected set; } - } - private class SessionContextData_Control : SessionContextData - { - public SessionContextData_Control(SbmSessionContext_Web sessionContext, SysId controlOwnerId, SysId controlRepositoryId) : base(sessionContext) - { - this.ControlOwnerId = controlOwnerId; - this.ControlRepositoryId = controlRepositoryId; - } + // Instance configuration - Instance specific Application rules etc. private SbmInstanceConfig instanceConfig = null; - public override SbmInstanceConfig InstanceConfig + public SbmInstanceConfig InstanceConfig { get { @@ -72,8 +64,15 @@ namespace Sarand.BusinessMgr.Web.Portal.App return instanceConfig; } } + // Instance ~persistant data. + private SbmInstanceDataCache_Dbas instanceDataCache; + public SbmInstanceDataCache_Dbas InstanceDataCache { get { if (instanceDataCache == null) { instanceDataCache = new SbmInstanceDataCache_Dbas(SessionContext); } return instanceDataCache; } } + // Control database properties. + public bool IsControl { get { return SysId.IsValid(ControlOwnerId) && SysId.IsValid(ControlRepositoryId); } } + public SysId ControlOwnerId { get; } + public SysId ControlRepositoryId { get; } } - private readonly Dictionary sessionContexts = new Dictionary(); + private readonly Dictionary sessionContexts = new Dictionary(); //------------------------------------------------------------------- // Construction. @@ -146,16 +145,26 @@ namespace Sarand.BusinessMgr.Web.Portal.App { return sessionContexts.GetValue(sessionContext.Index, null)?.InstanceConfig; } + // Instance data cache. + public override SbmInstanceDataCache GetInstanceDataCache(SbmSessionContext sessionContext) + { + return sessionContexts.GetValue(sessionContext.Index, null)?.InstanceDataCache; + } + // Organisation configuration. + public override SbmOrganisationConfig GetOrganisationConfig(ISbmUserOrganisationContext userContext) + { + return new SbmOrganisationConfig_Dbas(userContext, GetInstanceDataCache(userContext.SessionContext)); + } // Email configuration. public override SbmEmailConfig EmailConfig { get { return emailConfigs.Values.ToList().getConfigForSession(AppConfig); } } //------------------------------------------------------------------- // Create Consoles. - public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext) + public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserOrganisationContext userContext) { return new SbmReferenceDataConsole_Portal(userContext); } - public override SbmEmailConsole CreateEmailConsole(ISbmUserContext_Core userContext) + public override SbmEmailConsole CreateEmailConsole(ISbmUserOrganisationContext userContext) { return new SbmEmailConsole_Portal(EmailConfig); } @@ -224,12 +233,12 @@ namespace Sarand.BusinessMgr.Web.Portal.App } //------------------------------------------------------------------- - private SessionContextData PopulateControlSessionContext(String repositoryContext) + private SessionContextData_Control PopulateControlSessionContext(String repositoryContext) { if (StringUtil.IsBlank(repositoryContext)) return null; // Check whether context already exists in cache. - SessionContextData sessionContextData = sessionContexts.Values.FirstOrDefault(sc => sc.IsControl && sc.RepositoryContexts.ContainsCI(repositoryContext)); + SessionContextData_Control sessionContextData = sessionContexts.Values.FirstOrDefault(sc => sc.IsControl && sc.RepositoryContexts.ContainsCI(repositoryContext)); using (DisposableCollection disposables = new DisposableCollection()) { SbmcInstanceMgr controlInstanceMgr = SbmGlobals_Web.System.CreateControlInstanceMgr(); diff --git a/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs index c1203e5..433fb98 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/App/SbmSessionData_Portal.cs @@ -22,7 +22,7 @@ using Sarand.BusinessMgr.Net.Standard.Base.Mgr; namespace Sarand.BusinessMgr.Web.Portal.App { //======================================================================= - public class SbmSessionData_Portal : SbmSessionData_Web, ISbmUserContext_Core + public class SbmSessionData_Portal : SbmSessionData_Web, ISbmUserOrganisationContext { //------------------------------------------------------------------- // Construction. diff --git a/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmReferenceDataConsole_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmReferenceDataConsole_Portal.cs index 0e9f929..216717d 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmReferenceDataConsole_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Consoles/SbmReferenceDataConsole_Portal.cs @@ -14,7 +14,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Consoles //------------------------------------------------------------------- // Construction. - public SbmReferenceDataConsole_Portal(ISbmUserContext_Core userContext) : + public SbmReferenceDataConsole_Portal(ISbmUserOrganisationContext userContext) : base(userContext) { } diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs index 01a8ce9..eb72d55 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/SbmController_Portal.cs @@ -60,7 +60,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers /// Portal session data protected SbmSessionData_Portal SessionData_Portal { get { return SessionData as SbmSessionData_Portal; } } - public override ISbmUserContext_Core UserContext_Core { get { return SessionData_Portal; } } + public override ISbmUserOrganisationContext UserContext_Core { get { return SessionData_Portal; } } /// /// Session data deserialisation. /// @@ -84,7 +84,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers /// - Open user session - store details against Sesion Data. /// - Set 'Keep logged in' cookie if required. /// - protected bool SignUserIn(ISbmUserContext_Core userContext, String repositoryContext, SaSecurityConsole securityConsoleForUser, SbmAccountMgr accountMgrForUser, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List supervisedOrganisations, SbmAssociation associationOrganisation, SbmAffiliate affiliateOrganisation, bool keepLoggedIn, ref String errorMessage) + protected bool SignUserIn(SbmInternals internalsForUser, String repositoryContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List supervisedOrganisations, SbmAssociation associationOrganisation, SbmAffiliate affiliateOrganisation, bool keepLoggedIn, ref String errorMessage) { // Validate Security Item and Affiliate, just in case - should have been done before arriving here! if (securityItemUser == null) @@ -135,28 +135,28 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers securityItemUser.LastLogin = DateTime.Now; securityItemUser.InvalidLoginCount = 0; securityItemUser.LastInvalidLoginAt = DateTime.MinValue; - if (!securityConsoleForUser.UpdateSecurityItem(securityItemUser, DbUpdateInfo)) + if (!internalsForUser.SecurityConsole.UpdateSecurityItem(securityItemUser, DbUpdateInfo)) { - SaLogger.Warn($"{SysUtil.Fn} Failed to update security item for {securityItemUser.EmailAddress}: {securityConsoleForUser.ErrorStateMessage}"); + SaLogger.Warn($"{SysUtil.Fn} Failed to update security item for {securityItemUser.EmailAddress}: {internalsForUser.SecurityConsole.ErrorStateMessage}"); errorMessage = Localiser["security.msg.signin.invalid"]; return false; } // Update affiliate. affiliateUser.KeepLoggedIn_Portal = keepLoggedIn; - if (!accountMgrForUser.UpdateAffiliate(affiliateUser, DbUpdateInfo)) + if (!internalsForUser.AccountMgr.UpdateAffiliate(affiliateUser, DbUpdateInfo)) { - SaLogger.Warn($"{SysUtil.Fn} Failed to update affiliate for {securityItemUser.EmailAddress}: {accountMgrForUser.ErrorStateMessage}"); + SaLogger.Warn($"{SysUtil.Fn} Failed to update affiliate for {securityItemUser.EmailAddress}: {internalsForUser.AccountMgr.ErrorStateMessage}"); errorMessage = Localiser["security.msg.signin.invalid"]; return false; } SaLogger.Info($"{SysUtil.Fn} User session opened for {securityItemUser.EmailAddress}", true); // Create session. - OpenUserSession(userContext.SessionContext, repositoryContext, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation); + OpenUserSession(internalsForUser.SessionContext, repositoryContext, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation); // Configure security profile. - SessionData_Portal.SecurityProfile_Core.RefreshProfile(SessionConsole, securityConsoleForUser, securityItemUser.Id, securityConsoleForUser.GetRegisteredRights()); + SessionData_Portal.SecurityProfile_Core.RefreshProfile(SessionConsole, internalsForUser.SecurityConsole, securityItemUser.Id, internalsForUser.SecurityConsole.GetRegisteredRights()); } // Send the 'Keep Logged In' cookie if requested. @@ -268,13 +268,12 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers { // Consoles and Managers must be associated with the specific context. SbmUserContext_Web userContext = new SbmUserContext_Web(sessionContext); - using (SaSecurityConsole securityConsoleForUser = App.CreateSecurityConsole(userContext)) - using (SbmAccountMgr accountMgrForUser = App.System.CreateAccountMgr(userContext)) + using (SbmInternals internalsForUser = new SbmInternals(userContext)) { - using (SaSecurityItem securityItemUser = securityConsoleForUser.GetUserByEmail(keepLoggedInParams.EmailAddress)) - using (SbmAffiliate affiliateUser = accountMgrForUser.GetAffiliateById(keepLoggedInParams.AffiliateIdUser)) - using (SbmAssociation associationOrganisation = accountMgrForUser.GetAssociationById(keepLoggedInParams.AssociationIdOrganisation)) - using (SbmAffiliate affiliateOrganisation = accountMgrForUser.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null)) + using (SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(keepLoggedInParams.EmailAddress)) + using (SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(keepLoggedInParams.AffiliateIdUser)) + using (SbmAssociation associationOrganisation = internalsForUser.AccountMgr.GetAssociationById(keepLoggedInParams.AssociationIdOrganisation)) + using (SbmAffiliate affiliateOrganisation = internalsForUser.AccountMgr.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null)) { if (securityItemUser != null && affiliateUser != null && associationOrganisation != null && affiliateOrganisation != null) { @@ -282,9 +281,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers { if (affiliateUser.IsStatusCurrent) { - List supervisedOrganisations = accountMgrForUser.GetAffiliatesSupervisedBy(affiliateUser.Id); + List supervisedOrganisations = internalsForUser.AccountMgr.GetAffiliatesSupervisedBy(affiliateUser.Id); String errorMessage = ""; - if (SignUserIn(userContext, keepLoggedInParams.RepositoryContext, securityConsoleForUser, accountMgrForUser, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation, true, ref errorMessage)) + if (SignUserIn(internalsForUser, keepLoggedInParams.RepositoryContext, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation, true, ref errorMessage)) { SaLogger.Info(logPrefix + " 'Keep Logged In' cookie found." + logSuffix); return true; diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs index dfef7d6..240068c 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController-Ajax.cs @@ -99,29 +99,25 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security using (DisposableCollection disposables = new DisposableCollection()) { - - // Account manager. - SaSecurityConsole securityConsoleForUser = App.CreateSecurityConsole(userContext); - disposables.Add(securityConsoleForUser); - SbmAccountMgr accountMgrForUser = SbmGlobals_Web.System.CreateAccountMgr(userContext); - disposables.Add(accountMgrForUser); + SbmInternals internalsForUser = new SbmInternals(userContext); + disposables.Add(internalsForUser); // User's security item. - SaSecurityItem securityItemUser = GetSecurityItemForSignin(userContext, securityConsoleForUser, model); + SaSecurityItem securityItemUser = GetSecurityItemForSignin(userContext, internalsForUser.SecurityConsole, model); disposables.Add(securityItemUser); if (securityItemUser == null) { SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Security Item. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}."); return false; } - if (!securityConsoleForUser.PasswordMatches(securityItemUser, model.Password, userContext.DbUpdateInfo)) + if (!internalsForUser.SecurityConsole.PasswordMatches(securityItemUser, model.Password, userContext.DbUpdateInfo)) { SaLogger.Warn($"{SysUtil.Fn} Supplied password doesn't match Security Item. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}."); return false; } // User's affiliate. - SbmAffiliate affiliateUser = GetAffiliateForSignin(accountMgrForUser, model, securityItemUser); + SbmAffiliate affiliateUser = GetAffiliateForSignin(internalsForUser.AccountMgr, model, securityItemUser); disposables.Add(affiliateUser); if (affiliateUser == null) { @@ -130,7 +126,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security } // User's supervised organisations. - List supervisedOrganisations = accountMgrForUser.GetAffiliatesSupervisedBy(affiliateUser.Id); + List supervisedOrganisations = internalsForUser.AccountMgr.GetAffiliatesSupervisedBy(affiliateUser.Id); if (supervisedOrganisations.IsEmpty()) { SaLogger.Warn($"{SysUtil.Fn} User has no supervised organisations. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}."); @@ -139,7 +135,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security userContext.RefreshUser(securityItemUser, affiliateUser, supervisedOrganisations); // User's organisation association. - SbmAssociation associationOrganisation = GetOrganisationAssociationForSignIn(accountMgrForUser, model, userContext); + SbmAssociation associationOrganisation = GetOrganisationAssociationForSignIn(internalsForUser.AccountMgr, model, userContext); disposables.Add(associationOrganisation); if (associationOrganisation == null) { @@ -148,7 +144,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security } // User's organisation affiliate. - SbmAffiliate affiliateOrganisation = accountMgrForUser.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null); + SbmAffiliate affiliateOrganisation = internalsForUser.AccountMgr.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null); disposables.Add(affiliateOrganisation); if (affiliateOrganisation == null) { @@ -157,7 +153,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security } // Initialise user session. - if (SignUserIn(userContext, model.RepositoryContext, securityConsoleForUser, accountMgrForUser, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation, model.KeepMeSignedIn, ref errorMessage)) + if (SignUserIn(internalsForUser, model.RepositoryContext, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation, model.KeepMeSignedIn, ref errorMessage)) return true; } return false; @@ -398,12 +394,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security { // Consoles and Managers must be associated with the specific context. SbmUserContext_Web userContext = new SbmUserContext_Web(sessionContext); - using (SaSecurityConsole securityConsoleForUser = App.CreateSecurityConsole(userContext)) - using (SbmAccountMgr accountMgrForUser = App.System.CreateAccountMgr(userContext)) + using (SbmInternals internalsForUser = new SbmInternals(userContext)) { // Retrieve user details and validate email address. - securityItemUser = securityConsoleForUser.GetSecurityItemById(SaSecurity.ItemType.User, storePasswordParams.SecurityItemId); - affiliateUser = accountMgrForUser.GetAffiliateById(storePasswordParams.AffiliateId); + securityItemUser = internalsForUser.SecurityConsole.GetSecurityItemById(SaSecurity.ItemType.User, storePasswordParams.SecurityItemId); + affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(storePasswordParams.AffiliateId); if (storePasswordParams.IsValid(securityItemUser, affiliateUser)) { sessionContextForUser = sessionContext; @@ -525,40 +520,35 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security SbmUserContext_Web userContext = new SbmUserContext_Web(sessionContext); // Get user security item and affiliate. - using (SaSecurityConsole securityConsoleForUser = App.CreateSecurityConsole(userContext)) + using (SbmInternals internalsForUser = new SbmInternals(userContext)) + using (SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(model.EmailAddress)) { - using (SaSecurityItem securityItemUser = securityConsoleForUser.GetUserByEmail(model.EmailAddress)) + if (securityItemUser != null) { - if (securityItemUser != null) + using (SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateByUserId(securityItemUser.Id)) { - using (SbmAccountMgr accountMgrForUser = App.System.CreateAccountMgr(userContext)) + if (affiliateUser != null) { - using (SbmAffiliate affiliateUser = accountMgrForUser.GetAffiliateByUserId(securityItemUser.Id)) + if (affiliateUser.Status == SaStatus.Current || affiliateUser.IsStatusActive) { - if (affiliateUser != null) - { - if (affiliateUser.Status == SaStatus.Current || affiliateUser.IsStatusActive) - { - SbmEmailConsole emailConsole = App.CreateEmailConsole(userContext); + SbmEmailConsole emailConsole = App.CreateEmailConsole(userContext); - // Send password request email. - SaEmailData emailData = new SaEmailData(); - emailData.Config = App.EmailConfig; - emailData.AddressesTo.Add(model.EmailAddress); - emailData.Subject = Localiser["security.caption.request.password"]; - PopulateRequestPasswordEmailBody(emailConsole, userContext, emailData, securityItemUser, affiliateUser); - if (emailConsole.SendEmail(emailData)) - SaLogger.Info($"{SysUtil.Fn} Password request email sent to {model.EmailAddress}.", true); - else SaLogger.Warn($"{SysUtil.Fn} Failed to send password request email to {model.EmailAddress}."); - } - else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate is not active"); - } - else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate does not exist. UserId: {SysId.ToString(securityItemUser.Id)}."); + // Send password request email. + SaEmailData emailData = new SaEmailData(); + emailData.Config = App.EmailConfig; + emailData.AddressesTo.Add(model.EmailAddress); + emailData.Subject = Localiser["security.caption.request.password"]; + PopulateRequestPasswordEmailBody(emailConsole, userContext, emailData, securityItemUser, affiliateUser); + if (emailConsole.SendEmail(emailData)) + SaLogger.Info($"{SysUtil.Fn} Password request email sent to {model.EmailAddress}.", true); + else SaLogger.Warn($"{SysUtil.Fn} Failed to send password request email to {model.EmailAddress}."); } + else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate is not active"); } + else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate does not exist. UserId: {SysId.ToString(securityItemUser.Id)}."); } - else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - security item does not exist."); } + else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - security item does not exist."); } } @@ -567,7 +557,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security responseData.SuccessMsg = Localiser["security.msg.request.password.email.sent"]; return Json(responseData); } - private void PopulateRequestPasswordEmailBody(SbmEmailConsole emailConsole, ISbmUserContext_Core userContext, SaEmailData emailData, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser) + private void PopulateRequestPasswordEmailBody(SbmEmailConsole emailConsole, ISbmUserOrganisationContext userContext, SaEmailData emailData, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser) { // Will need to handle culture (language/country) as and when introduced. emailData.MessageBody = SbmResourceHelper.GetResourceText(SbmResourceHelper.TextResource.Email_RequestPassword_Html); diff --git a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController.cs b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController.cs index 3a3e0e0..4601364 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Controllers/Security/SecurityController.cs @@ -82,11 +82,10 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security { // Consoles and Managers must be associated with the specific context. SbmUserContext_Web userContext = new SbmUserContext_Web(sessionContext); - using (SaSecurityConsole securityConsoleForUser = App.CreateSecurityConsole(userContext)) - using (SbmAccountMgr accountMgrForUser = App.System.CreateAccountMgr(userContext)) + using (SbmInternals internalsForUser = new SbmInternals(userContext)) { - using (SaSecurityItem securityItemUser = securityConsoleForUser.GetUserByEmail(changePasswordParams.EmailAddress)) - using (SbmAffiliate affiliateUser = accountMgrForUser.GetAffiliateById(changePasswordParams.AffiliateId)) + using (SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(changePasswordParams.EmailAddress)) + using (SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(changePasswordParams.AffiliateId)) { if (securityItemUser != null && affiliateUser != null) { diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs index 8bf18f6..6e99a16 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/Commodities/Model_Commodity-Config.cs @@ -620,7 +620,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities // Asset. // Asset category. - if (!SessionConsole.AllowOption(Sbm.ConfigOption.AllowAssets)) + if (!SessionConsole.AllowOption(Sbm.ConfigOption.Assets)) config.Field.Hide.Add($"{ItemField.AssetCategory}"); //--------------------------------------------------------------- diff --git a/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs b/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs index 7a067d8..ef6113b 100644 --- a/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs +++ b/SaBusinessMgrCoreWebPortal/Portal/Models/SbmModel_Portal.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc.Rendering; +using NPOI.SS.Formula.Functions; using Sarand.BusinessMgr.Net.Core.Web.App; using Sarand.BusinessMgr.Net.Core.Web.Models; using Sarand.BusinessMgr.Net.Standard.Base.App; @@ -27,7 +28,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models //------------------------------------------------------------------- // Properties. public SbmSessionData_Portal SessionData_Portal { get { return SessionData as SbmSessionData_Portal; } } - public override ISbmUserContext_Core UserContext_Core { get { return SessionData_Portal; } } + public override ISbmUserOrganisationContext UserContext_Core { get { return SessionData_Portal; } } public String OrganisationName { get { return SessionData_Portal?.Organisation?.DisplayName ?? ""; } } //------------------------------------------------------------------- @@ -66,23 +67,34 @@ namespace Sarand.BusinessMgr.Web.Portal.Models public void PopulateMenu() { Menu = new MenuData(); + if (SessionConsole.UserContext == null) return; // Contacts. MenuItemData contactsItem = new MenuItemData() { Caption = @Localiser["label.contacts"] }; - contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.contacts"], Page = "Contacts" }); - contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.customers"], Page = "Customers" }); - contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.suppliers"], Page = "Suppliers" }); - contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.associations"], Page = "Associations" }); + if (SessionConsole.AllowOption(Sbm.ConfigOption.Contacts)) + { + contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.contacts"], Page = "Contacts" }); + contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.customers"], Page = "Customers" }); + contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.suppliers"], Page = "Suppliers" }); + contactsItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.associations"], Page = "Associations" }); + } if (contactsItem.Options.Any()) Menu.Items.Add(contactsItem); // Commodities. MenuItemData commoditiesItem = new MenuItemData() { Caption = @Localiser["label.commodities"] }; - commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.commodities"], Page = "Commodity" }); - commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["caption.asset.categories"], Page = "Assets/AssetCategory" }); - commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.assets"], Page = "Assets/Asset" }); - commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["caption.vehicle.classes"], Page = "Assets/VehicleClass" }); - commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.vehicles"], Page = "Assets/Vehicle" }); + if (SessionConsole.AllowOption(Sbm.ConfigOption.Commodities)) + commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.commodities"], Page = "Commodity" }); + if (SessionConsole.AllowOption(Sbm.ConfigOption.Assets)) + { + commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["caption.asset.categories"], Page = "Assets/AssetCategory" }); + commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.assets"], Page = "Assets/Asset" }); + if (SessionConsole.AllowOption(Sbm.ConfigOption.Vehicles)) + { + commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["caption.vehicle.classes"], Page = "Assets/VehicleClass" }); + commoditiesItem.Options.Add(new MenuOptionData() { Caption = @Localiser["label.vehicles"], Page = "Assets/Vehicle" }); + } + } if (commoditiesItem.Options.Any()) Menu.Items.Add(commoditiesItem); @@ -95,7 +107,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models } //------------------------------------------------------------------- - // View reference data. + // View reference data - Contacts. /// /// List of Affiliate Types for filter dropdown. @@ -125,6 +137,78 @@ namespace Sarand.BusinessMgr.Web.Portal.Models return new SelectList(associationTypes, "Code", "Desc"); } + //------------------------------------------------------------------- + // View reference data - Transactions. + + /// + /// List of Transaction Types for filter dropdown. + /// + public IEnumerable GetTransactionTypeCodesForFilterSelect() + { + List transactionTypes = new List(); + transactionTypes.Add(Sbm.TransactionType.Any, "", Localiser["label.any"]); + foreach (TypeCodeDesc transactionType in GetCodesOfType(Sbm.SystemCode.TransactionType)) + { + if (!SessionConsole.AllowTransactionType((Sbm.TransactionType)transactionType.Type)) continue; + String description = SessionConsole.GetOwnerOption_Caption(Sbm.TransTypeToOrgOption((Sbm.TransactionType)transactionType.Type), Localiser.GetTransactionTypeCaption((Sbm.TransactionType)transactionType.Type)); + transactionTypes.Add(transactionType.Type, transactionType.Code, description); + } + return new SelectList(transactionTypes, "Code", "Desc"); + } + + /// + /// List of Transaction Types for form dropdown. + /// + public IEnumerable GetTransactionTypeCodesForDropdown() + { + List transactionTypes = new List(); + foreach (TypeCodeDesc transactionType in GetCodesOfType(Sbm.SystemCode.TransactionType)) + { + if (!SessionConsole.AllowTransactionType((Sbm.TransactionType)transactionType.Type)) continue; + String description = SessionConsole.GetOwnerOption_Caption(Sbm.TransTypeToOrgOption((Sbm.TransactionType)transactionType.Type), Localiser.GetTransactionTypeCaption((Sbm.TransactionType)transactionType.Type)); + transactionTypes.Add(transactionType.Type, transactionType.Code, description); + } + return new SelectList(transactionTypes, "Code", "Desc"); + } + + //------------------------------------------------------------------- + // View reference data - Commodities. + + /// + /// List of Commodity Types for filter dropdown. + /// + public IEnumerable GetCommodityTypeCodesForFilterSelect() + { + List commodityTypes = new List(); + commodityTypes.Add(Sbm.CommodityType.Any, "", Localiser["label.any"]); + foreach (TypeCodeDesc commodityType in GetCodesOfType(Sbm.SystemCode.CommodityType)) + { + if (commodityType.Type == (int)Sbm.CommodityType.Asset && !SessionConsole.AllowOption(ConfigOption.Assets)) continue; + commodityTypes.Add(commodityType); + } + return new SelectList(commodityTypes, "Code", "Desc"); + } + + /// + /// List of Commodity Types for form dropdown. + /// + public IEnumerable GetCommodityTypeCodesForDropdown() + { + List commodityTypes = new List(); + foreach (TypeCodeDesc commodityType in GetCodesOfType(Sbm.SystemCode.CommodityType)) + { + if (commodityType.Type == (int)Sbm.CommodityType.Asset && !SessionConsole.AllowOption(ConfigOption.Assets)) continue; + commodityTypes.Add(commodityType); + } + return new SelectList(commodityTypes, "Code", "Desc"); + } + + // ToDo - Organisation Option - Show Column: + // case Sbm.SystemCode.OrgOption_ShowColumn: + // if (code.Type == (int) Sbm.OrgOption_ShowColumn.Transaction_ContactArea) + // Desc = "Transaction: " + sessionConsole.GetAttributeCaption(SbmDbDfn.ColumnIdx.Association_ContactAreaCode, "Contact area"); + + //------------------------------------------------------------------- } //=======================================================================