Consolidate User Context
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using System;
|
||||
@@ -14,10 +15,10 @@ 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 ConfigConsole parameter added to avoid local creation. To be reviewed/replaced.
|
||||
public static bool IsViewApplicable(SbmUserContext userContext, SbmConfigConsole configConsole, Sbm.View view)
|
||||
public static bool IsViewApplicable(ISbmUserContext userContext, SbmConfigConsole configConsole, Sbm.View view)
|
||||
{
|
||||
//SbmConfigConsole configConsole = SbmGlobals.GetConfigConsole(userContext.SessionContext);
|
||||
SbmSecurityProfile securityProfile = userContext.SecurityProfile;
|
||||
ISbmSecurityProfile securityProfile = userContext.SecurityProfile;
|
||||
switch (view)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
@@ -262,7 +263,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// A p p l i c a t i o n M e n u
|
||||
//-------------------------------------------------------------------
|
||||
public static bool IsMenuOptionApplicable(SbmUserContext userContext, SbmConfigConsole configConsole, Sbm.MenuOption menuOption)
|
||||
public static bool IsMenuOptionApplicable(ISbmUserContext userContext, SbmConfigConsole configConsole, Sbm.MenuOption menuOption)
|
||||
{
|
||||
String fn = ClassName + ".IsMenuOptionApplicable";
|
||||
if (!userContext.ValidUser)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
@@ -83,16 +84,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Create consoles.
|
||||
public abstract SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext);
|
||||
public abstract SaDiaryConsole CreateDiaryConsole(SbmUserContext userContext);
|
||||
public abstract SaSecurityConsole CreateSecurityConsole(SbmUserContext userContext);
|
||||
public abstract SaCodeTypeConsole CreateCodeTypeConsole(SbmUserContext userContext);
|
||||
public abstract SaReferenceDataConsole CreateReferenceDataConsole(SbmUserContext userContext);
|
||||
public abstract SaItemDataConsole CreateItemDataConsole(SbmUserContext userContext);
|
||||
public abstract SaItemDocConsole CreateItemDocConsole(SbmUserContext userContext);
|
||||
public abstract SaItemOptionConsole CreateItemOptionConsole(SbmUserContext userContext);
|
||||
public abstract SaInterfaceConsole CreateInterfaceConsole(SbmUserContext userContext);
|
||||
public abstract SaUpdateLogConsole CreateUpdateLogConsole(SbmUserContext userContext);
|
||||
public abstract SbmEmailConsole CreateEmailConsole(SbmUserContext userContext);
|
||||
public abstract SaDiaryConsole CreateDiaryConsole(ISbmUserContext userContext);
|
||||
public abstract SaSecurityConsole CreateSecurityConsole(ISbmUserContext userContext);
|
||||
public abstract SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext userContext);
|
||||
public abstract SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext userContext);
|
||||
public abstract SaItemDataConsole CreateItemDataConsole(ISbmUserContext userContext);
|
||||
public abstract SaItemDocConsole CreateItemDocConsole(ISbmUserContext userContext);
|
||||
public abstract SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext userContext);
|
||||
public abstract SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext userContext);
|
||||
public abstract SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext userContext);
|
||||
public abstract SbmEmailConsole CreateEmailConsole(ISbmUserContext userContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Procs;
|
||||
using Sarand.Net.Standard.Accounts.QuickBooks.App;
|
||||
using Sarand.Net.Standard.Accounts.Sage.App;
|
||||
@@ -144,7 +145,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Application Configuration. - AllowOption.
|
||||
public virtual bool AllowOption(SbmUserContext userContext, Sbm.ConfigOption option)
|
||||
public virtual bool AllowOption(ISbmUserContext userContext, Sbm.ConfigOption option)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
@@ -323,24 +324,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
// Item Data Interface.
|
||||
public virtual bool CanUpdateItemData(SbmUserContext userContext, Sbm.ItemDataType itemDataType)
|
||||
public virtual bool CanUpdateItemData(ISbmUserContext userContext, Sbm.ItemDataType itemDataType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool DoUpdateItemData(SbmUserContext userContext, Sbm.ItemDataType itemDataType)
|
||||
public virtual bool DoUpdateItemData(ISbmUserContext userContext, Sbm.ItemDataType itemDataType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool CanRemoveItemData(SbmUserContext userContext, Sbm.ItemDataType itemDataType)
|
||||
public virtual bool CanRemoveItemData(ISbmUserContext userContext, Sbm.ItemDataType itemDataType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Update Log.
|
||||
public virtual bool IsColumnChangeLogged(SbmUserContext userContext, SbmDbDfn.ColumnIdx column)
|
||||
public virtual bool IsColumnChangeLogged(ISbmUserContext userContext, SbmDbDfn.ColumnIdx column)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -357,17 +358,17 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Supported Data Item Types.
|
||||
// Supported affiliate types (all allowed by default).
|
||||
public virtual bool AllowAffiliateType(SbmUserContext userContext, Sbm.AffiliateType type)
|
||||
public virtual bool AllowAffiliateType(ISbmUserContext userContext, Sbm.AffiliateType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Supported Association types (all allowed by default).
|
||||
public virtual bool AllowAssociationType(SbmUserContext userContext, Sbm.AssociationType type)
|
||||
public virtual bool AllowAssociationType(ISbmUserContext userContext, Sbm.AssociationType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Supported Transaction types.
|
||||
public virtual bool AllowTransactionType(SbmUserContext userContext, Sbm.TransactionType type)
|
||||
public virtual bool AllowTransactionType(ISbmUserContext userContext, Sbm.TransactionType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -392,7 +393,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// D a t a O p t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
// Application Configuration. - Display and caption for data attributes.
|
||||
public virtual bool DisplayAttribute(SbmUserContext userContext, SbmDbDfn.ColumnIdx column)
|
||||
public virtual bool DisplayAttribute(ISbmUserContext userContext, SbmDbDfn.ColumnIdx column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
@@ -436,7 +437,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Alternative data value captions.
|
||||
public virtual String GetAttributeCaption(SbmUserContext userContext, SbmDbDfn.ColumnIdx column, string Default)
|
||||
public virtual String GetAttributeCaption(ISbmUserContext userContext, SbmDbDfn.ColumnIdx column, string Default)
|
||||
{
|
||||
String Caption = "";
|
||||
if (column != SbmDbDfn.ColumnIdx.Unknown)
|
||||
@@ -451,7 +452,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// T r a n s a c t i o n O p t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
// Job Tracking Options.
|
||||
public virtual String GetDefaultQuoteDescIntro(SbmUserContext userContext)
|
||||
public virtual String GetDefaultQuoteDescIntro(ISbmUserContext userContext)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -459,11 +460,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Transaction Maintenance Dialogs.
|
||||
/*
|
||||
public SapDlgUpdateTransaction GetCreateTransactionDlg (SbmUserContext userContext, SysId id, Sbm.TransactionType type)
|
||||
public SapDlgUpdateTransaction GetCreateTransactionDlg (ISbmUserContext userContext, SysId id, Sbm.TransactionType type)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public SapDlgUpdateTransaction GetUpdateTransactionDlg (SbmUserContext userContext, Sbm.TransactionType type, bool readOnly)
|
||||
public SapDlgUpdateTransaction GetUpdateTransactionDlg (ISbmUserContext userContext, Sbm.TransactionType type, bool readOnly)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -471,7 +472,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create Transaction.
|
||||
public virtual bool CanCreateTransactionLocally(SbmUserContext userContext, Sbm.TransactionType type)
|
||||
public virtual bool CanCreateTransactionLocally(ISbmUserContext userContext, Sbm.TransactionType type)
|
||||
{
|
||||
if (!AllowTransactionType(userContext, type)) return false;
|
||||
// Refresh options.
|
||||
@@ -553,7 +554,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
System, Manual, Option
|
||||
}
|
||||
public virtual AssignTransRefMethod TransactionAssignRefMethod(SbmUserContext userContext, Sbm.TransactionType transTypes)
|
||||
public virtual AssignTransRefMethod TransactionAssignRefMethod(ISbmUserContext userContext, Sbm.TransactionType transTypes)
|
||||
{
|
||||
return AssignTransRefMethod.System;
|
||||
}
|
||||
@@ -561,20 +562,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
ByOwnerType, ByType
|
||||
}
|
||||
public virtual AssignTransRefSource TransactionAssignRefSource(SbmUserContext userContext, Sbm.TransactionType transTypes)
|
||||
public virtual AssignTransRefSource TransactionAssignRefSource(ISbmUserContext userContext, 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(SbmUserContext userContext, Sbm.TransactionType transTypes)
|
||||
public virtual Sbm.TransactionType GetTransactionTypeForNextId(ISbmUserContext userContext, Sbm.TransactionType transTypes)
|
||||
{
|
||||
return transTypes;
|
||||
}
|
||||
|
||||
// NextId key value.
|
||||
public virtual String GetTransactionNextIdKey(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType)
|
||||
public virtual String GetTransactionNextIdKey(ISbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType eType)
|
||||
{
|
||||
idAssoc = new SysId();
|
||||
Sbm.TransactionType transTypes = GetTransactionTypeForNextId(userContext, eType);
|
||||
@@ -590,7 +591,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
|
||||
// Set the minimum Id for transactions of the specified type.
|
||||
public virtual bool SetMinTransactionId(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
|
||||
public virtual bool SetMinTransactionId(ISbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long iId)
|
||||
{
|
||||
bool set = false;
|
||||
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
|
||||
@@ -604,7 +605,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// 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
|
||||
(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
|
||||
(ISbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
|
||||
{
|
||||
String Ref = "";
|
||||
if (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) != null)
|
||||
@@ -617,7 +618,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
|
||||
public virtual String FormatTransactionCreateRef
|
||||
(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt)
|
||||
(ISbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes, long RefInt)
|
||||
{
|
||||
String Ref = "";
|
||||
if (RefInt > 0)
|
||||
@@ -633,7 +634,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return Ref;
|
||||
}
|
||||
|
||||
public virtual int GetTransactionRefSeqLength(SbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
|
||||
public virtual int GetTransactionRefSeqLength(ISbmUserContext userContext, SysId AffiliateId_Owner, SysId idAssoc, Sbm.TransactionType transTypes)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
@@ -647,7 +648,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Raise Transaction.
|
||||
public virtual bool CanRaiseTransaction(SbmUserContext userContext, Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo)
|
||||
public virtual bool CanRaiseTransaction(ISbmUserContext userContext, Sbm.TransactionType typeFrom, Sbm.TransactionType typeTo)
|
||||
{
|
||||
if (!AllowTransactionType(userContext, typeFrom) || !AllowTransactionType(userContext, typeTo)) return false;
|
||||
if (!CanCreateTransactionLocally(userContext, typeTo)) return false;
|
||||
@@ -743,7 +744,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseFrom(SbmUserContext userContext, Sbm.TransactionType typeFrom)
|
||||
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseFrom(ISbmUserContext userContext, Sbm.TransactionType typeFrom)
|
||||
{
|
||||
// Build the list of transaction types that are allowed to be raised from the specified type.
|
||||
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
|
||||
@@ -758,7 +759,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseTo(SbmUserContext userContext, Sbm.TransactionType typeTo)
|
||||
public virtual List<TypeCodeDesc> GetTransactionTypesForRaiseTo(ISbmUserContext userContext, Sbm.TransactionType typeTo)
|
||||
{
|
||||
// Build the list of transaction types that are allowed to be raised to the specified type.
|
||||
List<TypeCodeDesc> transTypes = new List<TypeCodeDesc>();
|
||||
@@ -776,7 +777,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Prepare Requirements Transaction. - Prepare copied list of requirements, eg. when raising from another transaction.
|
||||
public virtual bool PrepareCopiedRequirements(SbmUserContext userContext, SbmTransaction transSource, List<SbmRequirement> requireList, Sbm.TransactionType type)
|
||||
public virtual bool PrepareCopiedRequirements(ISbmUserContext userContext, SbmTransaction transSource, List<SbmRequirement> requireList, Sbm.TransactionType type)
|
||||
{
|
||||
type = new Sbm.TransactionType();
|
||||
//transSource; requireList; type;
|
||||
@@ -785,7 +786,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Remove Transaction.- By default, not allowed if transaction has requirements.
|
||||
public virtual bool CanRemoveTransactionWithRequirements(SbmUserContext userContext, SbmTransaction transaction, int requirementCount)
|
||||
public virtual bool CanRemoveTransactionWithRequirements(ISbmUserContext userContext, SbmTransaction transaction, int requirementCount)
|
||||
{
|
||||
if (transaction == null || !SysId.IsValid(transaction.Id)) return false;
|
||||
return (requirementCount < 1);
|
||||
@@ -793,7 +794,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tax Effective Date. - TransTypes that should use the 'In Progress' date as tax point as opposed to the 'Raised' date.
|
||||
public virtual bool UseInProgressTaxDateAsTaxPoint(SbmUserContext userContext, Sbm.TransactionType transactionType)
|
||||
public virtual bool UseInProgressTaxDateAsTaxPoint(ISbmUserContext userContext, Sbm.TransactionType transactionType)
|
||||
{
|
||||
switch (transactionType)
|
||||
{
|
||||
@@ -811,14 +812,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// R e q u i r e m e n t O p t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
// Requirement Actions.
|
||||
public virtual bool SearchCommodityOnCreateRequirement(SbmUserContext userContext, Sbm.TransactionType transactionType)
|
||||
public virtual bool SearchCommodityOnCreateRequirement(ISbmUserContext userContext, Sbm.TransactionType transactionType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Requirement Costing.
|
||||
public virtual SbmRequirementCostingConfig GetRequirementCostingConfig(SbmUserContext userContext)
|
||||
public virtual SbmRequirementCostingConfig GetRequirementCostingConfig(ISbmUserContext userContext)
|
||||
{
|
||||
SbmRequirementCostingConfig cfgRequirementCosting = new SbmRequirementCostingConfig();
|
||||
return cfgRequirementCosting;
|
||||
@@ -828,21 +829,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// C o m m o d i t y O p t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
// Commodity Management.
|
||||
public virtual Sbm.CommodityType GetCommodityTypeDefault(SbmUserContext userContext, Sbm.OrgOption_CommodityType commodityType)
|
||||
public virtual Sbm.CommodityType GetCommodityTypeDefault(ISbmUserContext userContext, Sbm.OrgOption_CommodityType commodityType)
|
||||
{
|
||||
// Default = 'Stock'.
|
||||
return Sbm.CommodityType.Stock;
|
||||
}
|
||||
|
||||
// Clean-up imported data (default no action).
|
||||
public virtual bool CleanupImportedCommodity(SbmUserContext userContext, SbmCommodity commodity)
|
||||
public virtual bool CleanupImportedCommodity(ISbmUserContext userContext, SbmCommodity commodity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Stock Control
|
||||
public virtual SbmStockControlConfig GetStockControlConfig(SbmUserContext userContext)
|
||||
public virtual SbmStockControlConfig GetStockControlConfig(ISbmUserContext userContext)
|
||||
{
|
||||
SbmStockControlConfig cfgStockControl = new SbmStockControlConfig();
|
||||
return cfgStockControl;
|
||||
@@ -852,20 +853,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// R e p o r t i n g
|
||||
//-------------------------------------------------------------------
|
||||
// Available reports (over and above standard).
|
||||
public virtual List<SbmReport_Base> GetReports(SbmUserContext userContext, Sbm.View view)
|
||||
public virtual List<SbmReport_Base> GetReports(ISbmUserContext userContext, Sbm.View view)
|
||||
{
|
||||
return new List<SbmReport_Base>();
|
||||
}
|
||||
public virtual bool ItemHasDiaryReports(SbmUserContext userContext/*SaItemId &*/)
|
||||
public virtual bool ItemHasDiaryReports(ISbmUserContext userContext/*SaItemId &*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
public virtual List<SbmReport_Base> GetDiaryReports(SbmUserContext userContext, SaDiaryReport_Params &)
|
||||
public virtual List<SbmReport_Base> GetDiaryReports(ISbmUserContext userContext, SaDiaryReport_Params &)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public virtual List<SbmReport_Base> GetDiaryReportsForItem(SbmUserContext userContext, ItemId itemId)
|
||||
public virtual List<SbmReport_Base> GetDiaryReportsForItem(ISbmUserContext userContext, ItemId itemId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -882,7 +883,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
/// <summary>Sales Invoice report horizontal lines [Bool]</summary>
|
||||
RptSalesInvoiceHorizontalLines = 111,
|
||||
}
|
||||
public virtual DataValue GetDefaultProcessParam(SbmUserContext userContext, ProcessParam prm)
|
||||
public virtual DataValue GetDefaultProcessParam(ISbmUserContext userContext, ProcessParam prm)
|
||||
{
|
||||
switch (prm)
|
||||
{
|
||||
@@ -895,18 +896,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Automated processes.
|
||||
public virtual bool PerformProcess(SbmUserContext userContext, Sbm.ProcessType type)
|
||||
public virtual bool PerformProcess(ISbmUserContext userContext, Sbm.ProcessType type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Available data import/export processes (over and above standard).
|
||||
public virtual List<ISbmProcess_DataImport> GetImportProcesses(SbmUserContext userContext, Sbm.InterfaceDataType dataType, List<SysId> itemIds)
|
||||
public virtual List<ISbmProcess_DataImport> GetImportProcesses(ISbmUserContext userContext, Sbm.InterfaceDataType dataType, List<SysId> itemIds)
|
||||
{
|
||||
return new List<ISbmProcess_DataImport>();
|
||||
}
|
||||
|
||||
public virtual List<ISbmProcess_DataExport> GetExportProcesses(SbmUserContext userContext, Sbm.InterfaceDataType dataType, List<SysId> itemIds)
|
||||
public virtual List<ISbmProcess_DataExport> GetExportProcesses(ISbmUserContext userContext, Sbm.InterfaceDataType dataType, List<SysId> itemIds)
|
||||
{
|
||||
return new List<ISbmProcess_DataExport>();
|
||||
}
|
||||
@@ -925,7 +926,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
public String ItemDesc { get; }
|
||||
public String ItemText { get; }
|
||||
};
|
||||
public virtual DataExportItemDetails GetDataExportInvoiceItemDetails(SbmUserContext userContext, SbmRequirement requirement)
|
||||
public virtual DataExportItemDetails GetDataExportInvoiceItemDetails(ISbmUserContext userContext, SbmRequirement requirement)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -933,7 +934,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// I n t e r f a c e O p t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
public virtual bool AllowInterfaces(SbmUserContext userContext)
|
||||
public virtual bool AllowInterfaces(ISbmUserContext userContext)
|
||||
{
|
||||
if (AllowInterfaceCategory(userContext, SaInterfaceCategory.Website)) return true;
|
||||
if (AllowInterfaceCategory(userContext, SaInterfaceCategory.Accounts)) return true;
|
||||
@@ -942,7 +943,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool AllowInterfaceCategory(SbmUserContext userContext, SaInterfaceCategory interfaceCategory)
|
||||
public virtual bool AllowInterfaceCategory(ISbmUserContext userContext, SaInterfaceCategory interfaceCategory)
|
||||
{
|
||||
// By default, only website and file interfaces are allowed.
|
||||
switch (interfaceCategory)
|
||||
@@ -954,7 +955,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool AllowInterface(SbmUserContext userContext, SaInterfaceCategory interfaceCategory, short interfaceType)
|
||||
public virtual bool AllowInterface(ISbmUserContext userContext, SaInterfaceCategory interfaceCategory, short interfaceType)
|
||||
{
|
||||
if (!AllowInterfaceCategory(userContext, interfaceCategory)) return false;
|
||||
switch (interfaceCategory)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
@@ -100,7 +101,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
public virtual String LinkSuffix { get { return ""; } }
|
||||
//---------------------------------------------------------------
|
||||
// Utilities.
|
||||
public virtual bool Refresh(SbmUserContext userContext)
|
||||
public virtual bool Refresh(ISbmUserContext userContext)
|
||||
{
|
||||
ItemCount = 0;
|
||||
switch (LinkType)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
@@ -58,7 +59,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmInternals(SbmUserContext userContext)
|
||||
public SbmInternals(ISbmUserContext userContext)
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
@@ -96,9 +97,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Session properties.
|
||||
public SbmApplication Application { get { return SbmGlobals.Application; } }
|
||||
public SbmUserContext UserContext { get; }
|
||||
public ISbmUserContext UserContext { get; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
public SbmSecurityProfile SecurityProfile { get { return UserContext.SecurityProfile; } }
|
||||
public ISbmSecurityProfile SecurityProfile { get { return UserContext.SecurityProfile; } }
|
||||
public SbmAccountsDfn AccountsDfn { get { if (accountsDfn == null) accountsDfn = new SbmAccountsDfn(UserContext); { return accountsDfn; } } }
|
||||
// Database.
|
||||
public ISacsDatabase BusMgrDatabase { get { return Application.GetBusMgrDatabase(SessionContext); } }
|
||||
@@ -114,6 +115,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return new List<TypeCodeDesc>(systemCodeCache.GetValueOrDefault(systemCode, new List<TypeCodeDesc>()));
|
||||
}
|
||||
public List<TypeCodeDesc> AffiliateTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.AffiliateType); } }
|
||||
public List<TypeCodeDesc> CommodityTypeCodes { get { return GetCodesOfType(Sbm.SystemCode.CommodityType); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Managers.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -11,7 +12,7 @@ using System.Collections.Generic;
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmSecurityProfile : SaErrorStateItem
|
||||
public class SbmSecurityProfile : SaErrorStateItem, ISbmSecurityProfile
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -23,7 +24,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmSecurityProfile(SbmUserContext userContext, bool includeHostSecurityProfile)
|
||||
public SbmSecurityProfile(ISbmUserContext userContext, bool includeHostSecurityProfile)
|
||||
{
|
||||
this.UserContext = userContext;
|
||||
this.includeHostSecurityProfile = includeHostSecurityProfile;
|
||||
@@ -37,7 +38,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[JsonIgnore]
|
||||
public SbmUserContext UserContext { get; }
|
||||
public ISbmUserContext UserContext { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Refresh profile.
|
||||
@@ -195,8 +196,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
public bool UserCanViewFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
|
||||
{
|
||||
if (Financial.ConfigOption_AllowFinancialsAccessControl) return true;
|
||||
if (IsSecurityRightGranted(Sbm.SecurityRight.Financial_Update) || IsSecurityRightGranted(Sbm.SecurityRight.Financial_View))
|
||||
if (!Financial.ConfigOption_AllowFinancialsAccessControl) return true;
|
||||
if (Financial.CanUpdateFinancials || Financial.CanViewFinancials)
|
||||
{
|
||||
// If specific type of financial is requested, check that view is not denied.
|
||||
if (financialType > 0 && IsSecurityRightDenied(Sbm.SecurityRight.Financial_ViewByType, new SysId((int)financialType)))
|
||||
@@ -208,8 +209,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
public bool UserCanUpdateFinancials(Sbm.FinancialType financialType = Sbm.FinancialType.Any)
|
||||
{
|
||||
if (Financial.ConfigOption_AllowFinancialsAccessControl) return true;
|
||||
if (IsSecurityRightGranted(Sbm.SecurityRight.Financial_Update))
|
||||
if (!Financial.ConfigOption_AllowFinancialsAccessControl) return true;
|
||||
if (Financial.CanUpdateFinancials)
|
||||
{
|
||||
// If specific type of financial is requested, check that update is not denied.
|
||||
if (financialType > 0 && IsSecurityRightDenied(Sbm.SecurityRight.Financial_UpdateByType, new SysId((int)financialType)))
|
||||
@@ -219,7 +220,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType)
|
||||
public bool UserCanAccessFinancialViewOfType(Sbm.FinancialType financialType)
|
||||
{
|
||||
if ((int)financialType < 1) return false;
|
||||
// If specific type of financial is requested, check that view is not denied.
|
||||
@@ -228,7 +229,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UserCanAccessFinancialUpdateOfType(Sbm.FinancialType financialType)
|
||||
public bool UserCanAccessFinancialUpdateOfType(Sbm.FinancialType financialType)
|
||||
{
|
||||
if ((int)financialType < 1) return false;
|
||||
// If specific type of financial is requested, check that update is not denied.
|
||||
@@ -250,6 +251,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
public bool CanUpdate { get; internal set; } = false;
|
||||
}
|
||||
public ContactsProfile Contacts { get; internal set; }
|
||||
public bool UserCanCreateContacts { get { return Contacts.CanCreate; } }
|
||||
public bool UserCanUpdateContacts { get { return Contacts.CanUpdate; } }
|
||||
private void RefreshContactsProfile(SbmConfigConsole configConsole)
|
||||
{
|
||||
Contacts.CanUpdate = (UserHasSecurityRight(Sbm.SecurityRight.Affiliate_Update));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
@@ -26,19 +28,21 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
SessionIdx = sessionIdx;
|
||||
ItemIdx = itemIdx;
|
||||
SessionContext = sessionContext;
|
||||
userData = CreateUserData(SessionContext, null, null);
|
||||
userData = CreateUserData(SessionContext, null, null, null);
|
||||
organisationData = new OrganisationData(null, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// Primary constructor - on user login.
|
||||
/// <para>SessionContext and UserAccount must be supplied.</para>
|
||||
/// <para>Roles list is optional.</para>
|
||||
/// </summary>
|
||||
protected SbmSessionData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser)
|
||||
protected SbmSessionData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOrganisations, SbmAssociation associationOrganisation, SbmAffiliate affiliateOrganisation)
|
||||
{
|
||||
SessionIdx = ++sessionIdxRoot;
|
||||
ItemIdx = 1000;
|
||||
SessionContext = sessionContext;
|
||||
userData = CreateUserData(SessionContext, securityItemUser, affiliateUser);
|
||||
userData = CreateUserData(SessionContext, securityItemUser, affiliateUser, supervisedOrganisations);
|
||||
organisationData = new OrganisationData(associationOrganisation, affiliateOrganisation);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -57,16 +61,16 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DbUpdateInfo(User.AffiliateId, StringUtil.OnEmpty(User.DisplayName, User.EmailAddress), SbmSystem.ComputerName);
|
||||
return new DbUpdateInfo(User.AffiliateId, StringUtil.OnEmpty(userData.DisplayName, userData.EmailAddress), SbmSystem.ComputerName);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// User.
|
||||
public class UserData
|
||||
public class UserData : ISbmUserContext.IUserData
|
||||
{
|
||||
protected UserData() { }
|
||||
protected UserData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser)
|
||||
protected UserData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOrganisations)
|
||||
{
|
||||
if (securityItemUser != null)
|
||||
{
|
||||
@@ -75,13 +79,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (affiliateUser != null)
|
||||
{
|
||||
AffiliateId = affiliateUser.Id;
|
||||
Refresh(securityItemUser, affiliateUser);
|
||||
Refresh(securityItemUser, affiliateUser, supervisedOrganisations);
|
||||
if (sessionContext.Application == Sbm.Application.WebControl)
|
||||
KeepLoggedIn = affiliateUser.KeepLoggedIn_Control;
|
||||
else if (sessionContext.Application == Sbm.Application.WebPortal)
|
||||
KeepLoggedIn = affiliateUser.KeepLoggedIn_Portal;
|
||||
else Debugger.Break();
|
||||
}
|
||||
this.supervisedOrganisations = supervisedOrganisations;
|
||||
}
|
||||
protected UserData(UserData userData)
|
||||
{
|
||||
@@ -92,6 +97,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
LastName = userData.LastName;
|
||||
DisplayName = userData.DisplayName;
|
||||
EmailAddress = userData.EmailAddress;
|
||||
supervisedOrganisations = userData.supervisedOrganisations;
|
||||
KeepLoggedIn = userData.KeepLoggedIn;
|
||||
}
|
||||
// Properties.
|
||||
@@ -102,10 +108,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
public String LastName { get; protected set; }
|
||||
public String DisplayName { get; protected set; }
|
||||
public String EmailAddress { get; protected set; }
|
||||
/// <summary>User managed associations - Id and display name.</summary>
|
||||
public List<SysIdString> SupervisedOrganisations { get { return new List<SysIdString>(supervisedOrganisations); } }
|
||||
protected List<SysIdString> supervisedOrganisations { get; } = new List<SysIdString>();
|
||||
public bool KeepLoggedIn { get; protected set; }
|
||||
public bool UserAccountSupplied { get; protected set; }
|
||||
// Refresh properties.
|
||||
protected bool Refresh(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser)
|
||||
protected bool Refresh(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOrganisations)
|
||||
{
|
||||
// Check that user matches the session.
|
||||
if (!SysId.IsValid(SecurityItemId) || !SysId.IsValid(securityItemUser?.Id ?? null) || !SecurityItemId.Equals(securityItemUser.Id)) return false;
|
||||
@@ -116,20 +125,49 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
FirstName = affiliateUser.FirstName;
|
||||
LastName = affiliateUser.LastName;
|
||||
DisplayName = affiliateUser.GetDisplayName();
|
||||
this.supervisedOrganisations.Clear();
|
||||
this.supervisedOrganisations.AddRange(supervisedOrganisations);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected abstract UserData CreateUserData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser);
|
||||
protected abstract UserData CreateUserData(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOrganisations);
|
||||
|
||||
/// <summary>User account details.</summary>
|
||||
private UserData userData;
|
||||
public UserData User { get { return userData; } }
|
||||
public ISbmUserContext.IUserData User { get { return userData; } }
|
||||
public bool ValidUser { get { return SysId.IsValid(userData.SecurityItemId) && SysId.IsValid(userData.AffiliateId); } }
|
||||
public bool KeepLoggedIn { get { return userData.KeepLoggedIn; } }
|
||||
|
||||
/// <summary>User - JSON deserialisation route.</summary>
|
||||
protected void SetUser(UserData user)
|
||||
{
|
||||
if (this.userData != null && User.UserAccountSupplied)
|
||||
if (this.userData != null && userData.UserAccountSupplied)
|
||||
throw new NotSupportedException("Session User cannot be replaced.");
|
||||
this.userData = user;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Organisation.
|
||||
public class OrganisationData : ISbmUserContext.IOrganisationData
|
||||
{
|
||||
private OrganisationData() { }
|
||||
public OrganisationData(SbmAssociation associationOrganisation, SbmAffiliate affiliateOrganisation)
|
||||
{
|
||||
AffiliateId = affiliateOrganisation?.Id ?? null;
|
||||
AffiliateType = affiliateOrganisation?.AffiliateType ?? Sbm.AffiliateType.Unknown;
|
||||
AssociationId = associationOrganisation?.Id ?? null;
|
||||
DisplayName = affiliateOrganisation?.GetDisplayName() ?? "";
|
||||
InterfaceContext = SbmAccountMgr.GetInterfaceContext(AffiliateId);
|
||||
}
|
||||
public SysId AffiliateId { get; protected set; }
|
||||
public Sbm.AffiliateType AffiliateType { get; protected set; }
|
||||
public SysId AssociationId { get; protected set; }
|
||||
public String DisplayName { get; protected set; }
|
||||
public String InterfaceContext { get; }
|
||||
}
|
||||
protected OrganisationData organisationData;
|
||||
public ISbmUserContext.IOrganisationData Organisation { get { return organisationData; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
@@ -23,9 +24,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
}
|
||||
// Refresh context.
|
||||
public void RefreshUser(SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
|
||||
public void RefreshUser(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
|
||||
{
|
||||
SetUserData(affiliateUser, supervisedOwners);
|
||||
SetUserData(securityItemUser, affiliateUser, supervisedOwners);
|
||||
}
|
||||
public void ClearUser()
|
||||
{
|
||||
@@ -61,8 +62,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Properties.
|
||||
public SbmUserContext UserContext { get { return userContext; } }
|
||||
public SbmSessionContext SessionContext { get { return userContext.SessionContext; } }
|
||||
public SbmSecurityProfile SecurityProfile { get { return UserContext.SecurityProfile; } }
|
||||
protected SaItemOption.Cache OrganisationConfigOptionsCache { get { return UserContext.Organisation.configOptionsCache; } }
|
||||
public ISbmSecurityProfile SecurityProfile { get { return UserContext.SecurityProfile; } }
|
||||
protected SaItemOption.Cache OrganisationConfigOptionsCache { get { return UserContext.OrganisationConfigOptionsCache; } }
|
||||
// User parameters.
|
||||
protected SbmSysParamCache SysParamCache { get; }
|
||||
|
||||
@@ -85,8 +86,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Clear existing User details.
|
||||
ClearUserSession();
|
||||
|
||||
using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext))
|
||||
using (SaSecurityConsole securityConsole = SbmGlobals.Application.CreateSecurityConsole(UserContext))
|
||||
using (SbmAccountMgr accountMgr = CreateAccountMgr())
|
||||
{
|
||||
// Security item.
|
||||
SaSecurityItem securityItemUser = securityConsole.GetSecurityItemById(SaSecurity.ItemType.User, userId);
|
||||
|
||||
SbmAffiliate affiliateUser = accountMgr.GetAffiliateByUserId(userId);
|
||||
if (affiliateUser == null)
|
||||
{
|
||||
@@ -94,14 +100,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return false;
|
||||
}
|
||||
List<SysIdString> userSupervisedOwners = accountMgr.GetAffiliatesSupervisedBy(affiliateUser.Id);
|
||||
userContext.RefreshUser(affiliateUser, userSupervisedOwners);
|
||||
userContext.RefreshUser(securityItemUser, affiliateUser, userSupervisedOwners);
|
||||
|
||||
// Populate security rights.
|
||||
using (SbmConfigConsole configConsole = SbmGlobals.Application.CreateConfigConsole(UserContext.SessionContext))
|
||||
using (SaSecurityConsole securityConsole = SbmGlobals.Application.CreateSecurityConsole(UserContext))
|
||||
{
|
||||
SecurityProfile.RefreshProfile(configConsole, securityConsole, userId, securityRights);
|
||||
}
|
||||
SecurityProfile.RefreshProfile(configConsole, securityConsole, userId, securityRights);
|
||||
|
||||
// Reinstate previous owner if defined and verify that it is in the supervised list.
|
||||
SysId affiliateIdOwner = UserContext.Organisation.AffiliateId;
|
||||
@@ -154,6 +156,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
}
|
||||
|
||||
public SaSecurityConsole SaSecurityConsole { get; private set; }
|
||||
|
||||
// Data managers.
|
||||
protected SbmAccountMgr CreateAccountMgr()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
@@ -17,14 +18,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected Construction - use derived objects.
|
||||
public SbmSysParamCache(SbmUserContext userContext)
|
||||
public SbmSysParamCache(ISbmUserContext userContext)
|
||||
{
|
||||
this.UserContext = userContext;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SbmUserContext UserContext { get; }
|
||||
public ISbmUserContext UserContext { get; }
|
||||
public SysId AffiliateIdUser { get; private set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
@@ -23,7 +24,7 @@ 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(SbmConfigConsole configConsole, SaCodeTypeConsole codeTypeConsole, SbmUserContext userContext)
|
||||
public static void RegisterCodeTypes(SbmConfigConsole configConsole, SaCodeTypeConsole codeTypeConsole, ISbmUserContext userContext)
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// C o m m o d i t i e s
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
@@ -74,14 +75,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// S y s t e m C o d e s
|
||||
//-------------------------------------------------------------------
|
||||
private static String GetOwnerOption_Caption(SbmUserContext userContext, Sbm.OrgOption_Caption orgOption_Caption, String defaultValue)
|
||||
private static String GetOwnerOption_Caption(ISbmUserContext userContext, Sbm.OrgOption_Caption orgOption_Caption, String defaultValue)
|
||||
{
|
||||
// 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<TypeCodeDesc> GetCodesOfType(SbmUserContext userContext, Sbm.SystemCode systemCode)
|
||||
public static List<TypeCodeDesc> GetCodesOfType(ISbmUserContext userContext, Sbm.SystemCode systemCode)
|
||||
{
|
||||
SbmConfigConsole configConsole = null; // SbmGlobals.GetConfigConsole(userContext.SessionContext);
|
||||
switch (systemCode)
|
||||
@@ -480,14 +481,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// D a t a M a n a g e r s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract SbmAccountMgr CreateAccountMgr(SbmUserContext userContext);
|
||||
public abstract SbmAssetMgr CreateAssetMgr(SbmUserContext userContext);
|
||||
public abstract SbmCommodityMgr CreateCommodityMgr(SbmUserContext userContext);
|
||||
public abstract SbmPriceMgr CreatePriceMgr(SbmUserContext userContext);
|
||||
public abstract SbmDataItemMgr CreateDataItemMgr(SbmUserContext userContext);
|
||||
public abstract SbmProcessMgr CreateProcessMgr(SbmUserContext userContext);
|
||||
public abstract SbmStockMgr CreateStockMgr(SbmUserContext userContext);
|
||||
public abstract SbmTransactionMgr CreateTransactionMgr(SbmUserContext userContext);
|
||||
public abstract SbmAccountMgr CreateAccountMgr(ISbmUserContext userContext);
|
||||
public abstract SbmAssetMgr CreateAssetMgr(ISbmUserContext userContext);
|
||||
public abstract SbmCommodityMgr CreateCommodityMgr(ISbmUserContext userContext);
|
||||
public abstract SbmPriceMgr CreatePriceMgr(ISbmUserContext userContext);
|
||||
public abstract SbmDataItemMgr CreateDataItemMgr(ISbmUserContext userContext);
|
||||
public abstract SbmProcessMgr CreateProcessMgr(ISbmUserContext userContext);
|
||||
public abstract SbmStockMgr CreateStockMgr(ISbmUserContext userContext);
|
||||
public abstract SbmTransactionMgr CreateTransactionMgr(ISbmUserContext userContext);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A p p l i c a t i o n P r o p e r t i e s
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,45 +14,57 @@ using System.Collections.Generic;
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmUserContext
|
||||
public class SbmUserContext : ISbmUserContext
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
// User profile.
|
||||
public class UserData
|
||||
public class UserData : ISbmUserContext.IUserData
|
||||
{
|
||||
protected UserData() { }
|
||||
protected readonly List<SysIdString> supervisedOwners = new List<SysIdString>();
|
||||
/// <summary>User Security Item Id.</summary>
|
||||
public SysId SecItemId { get; protected set; } = new SysId();
|
||||
public SysId SecurityItemId { get; protected set; } = new SysId();
|
||||
/// <summary>User Affiliate Id.</summary>
|
||||
public SysId AffiliateId { get; protected set; } = new SysId();
|
||||
/// <summary>User first name.</summary>
|
||||
public String FirstName { get; protected set; } = "";
|
||||
/// <summary>User last name.</summary>
|
||||
public String LastName { get; protected set; } = "";
|
||||
/// <summary>User display name.</summary>
|
||||
public String DisplayName { get; protected set; } = "";
|
||||
/// <summary>User email address.</summary>
|
||||
public String EmailAddress { get; protected set; } = "";
|
||||
/// <summary>User managed associations - Id and display name.</summary>
|
||||
public List<SysIdString> SupervisedOwners { get { return new List<SysIdString>(supervisedOwners); } }
|
||||
public List<SysIdString> SupervisedOrganisations { get { return new List<SysIdString>(supervisedOwners); } }
|
||||
}
|
||||
private class UserData_Internal : UserData
|
||||
{
|
||||
internal UserData_Internal() { }
|
||||
internal void Clear()
|
||||
{
|
||||
SecItemId = new SysId();
|
||||
SecurityItemId = new SysId();
|
||||
AffiliateId = new SysId();
|
||||
FirstName = "";
|
||||
LastName = "";
|
||||
DisplayName = "";
|
||||
EmailAddress = "";
|
||||
supervisedOwners.Clear();
|
||||
}
|
||||
internal void Refresh(SysId securityItemId, SysId affiliateId, String displayName, List<SysIdString> supervisedOwners)
|
||||
internal void Refresh(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
|
||||
{
|
||||
SecItemId = SysId.InvalidOnNull(securityItemId);
|
||||
AffiliateId = SysId.InvalidOnNull(affiliateId);
|
||||
DisplayName = StringUtil.EmptyOnNull(displayName).TrimAll();
|
||||
SecurityItemId = SysId.InvalidOnNull(securityItemUser?.Id ?? null);
|
||||
AffiliateId = SysId.InvalidOnNull(affiliateUser?.Id ?? null);
|
||||
FirstName = StringUtil.EmptyOnNull(affiliateUser?.FirstName ?? "").TrimAll();
|
||||
LastName = StringUtil.EmptyOnNull(affiliateUser?.LastName ?? "").TrimAll();
|
||||
DisplayName = StringUtil.EmptyOnNull(affiliateUser?.GetDisplayName() ?? "").TrimAll();
|
||||
EmailAddress = StringUtil.EmptyOnNull(securityItemUser?.EmailAddress ?? "");
|
||||
this.supervisedOwners.Clear();
|
||||
this.supervisedOwners.AddRange(supervisedOwners);
|
||||
}
|
||||
}
|
||||
// Owner profile - selected organisation to manage.
|
||||
public class OrganisationData
|
||||
public class OrganisationData : ISbmUserContext.IOrganisationData
|
||||
{
|
||||
internal OrganisationData() { }
|
||||
// Organisation options.
|
||||
@@ -115,24 +129,26 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
organisationData = new OrganisationData_Internal();
|
||||
SecurityProfile = new SbmSecurityProfile(this, true);
|
||||
securityProfile = new SbmSecurityProfile(this, true);
|
||||
DbUpdateInfo = new DbUpdateInfo(User.AffiliateId, User.DisplayName, SacsSystem.ComputerName);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SbmSessionContext SessionContext { get; protected set; }
|
||||
public UserData User { get { return userData; } }
|
||||
public bool ValidUser { get { return SysId.IsValid(userData.SecItemId) && SysId.IsValid(userData.AffiliateId); } }
|
||||
public OrganisationData Organisation { get { return organisationData; } }
|
||||
public ISbmUserContext.IUserData User { get { return userData; } }
|
||||
public bool ValidUser { get { return SysId.IsValid(userData.SecurityItemId) && SysId.IsValid(userData.AffiliateId); } }
|
||||
public ISbmUserContext.IOrganisationData Organisation { get { return organisationData; } }
|
||||
public DbUpdateInfo DbUpdateInfo { get; private set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Security profile.
|
||||
public SbmSecurityProfile SecurityProfile { get; protected set; }
|
||||
private SbmSecurityProfile securityProfile { get; set; }
|
||||
public ISbmSecurityProfile SecurityProfile { 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);
|
||||
@@ -142,7 +158,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
public String GetOrganisationOption(String optionName, String context)
|
||||
{
|
||||
// Retrieve the requested value from the cache.
|
||||
return Organisation.configOptionsCache.ItemOptions.GetOptionValue(optionName, context);
|
||||
return organisationData.configOptionsCache.ItemOptions.GetOptionValue(optionName, context);
|
||||
}
|
||||
public String GetOwnerOption_Value(Sbm.OrgOption_Value eCol)
|
||||
{
|
||||
@@ -185,14 +201,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
String value = GetOrganisationOption(Sbm.OrganisationOption.ShowColumn, context).Trim();
|
||||
return StringUtil.ToBool(value);
|
||||
}
|
||||
public String GetOwnerOption_FieldLabel(SbmDbDfn.ColumnIdx eCol, String sDefault)
|
||||
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 : sDefault); // Return default if no label defined.
|
||||
return (!value.IsEmpty() ? value : defautValue); // Return default if no label defined.
|
||||
}
|
||||
public int GetOwnerOption_Minutes(Sbm.OrgOption_Minutes eLimit, int iDefault)
|
||||
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);
|
||||
@@ -203,9 +219,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (iUpdateLimit > 0)
|
||||
return iUpdateLimit;
|
||||
}
|
||||
return iDefault;
|
||||
return defautValue;
|
||||
}
|
||||
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodDays eLimit, int iDefault)
|
||||
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);
|
||||
@@ -216,9 +232,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (iUpdateLimit > 0)
|
||||
return iUpdateLimit;
|
||||
}
|
||||
return iDefault;
|
||||
return defautValue;
|
||||
}
|
||||
public int GetOwnerOption_UpdateLimit(Sbm.OrgOption_PeriodWeeks eLimit, int iDefault)
|
||||
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);
|
||||
@@ -229,14 +245,14 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (iUpdateLimit > 0)
|
||||
return iUpdateLimit;
|
||||
}
|
||||
return iDefault;
|
||||
return defautValue;
|
||||
}
|
||||
public int GetOwnerOption_NumericDecimals(Sbm.OrgOption_NumericDecimals eNumDecimals, int iDefault = 2)
|
||||
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 = iDefault;
|
||||
int iNumDecimals = defautValue;
|
||||
if (!value.IsEmpty())
|
||||
iNumDecimals = value.ToShort();
|
||||
iNumDecimals = Math.Min(4, Math.Max(0, iNumDecimals));
|
||||
@@ -264,9 +280,9 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Modify properties - internal only.
|
||||
protected void SetUserData(SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
|
||||
protected void SetUserData(SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOwners)
|
||||
{
|
||||
userData.Refresh(affiliateUser.UserId, affiliateUser.Id, affiliateUser.GetDisplayName(), supervisedOwners);
|
||||
userData.Refresh(securityItemUser, affiliateUser, supervisedOwners);
|
||||
DbUpdateInfo = new DbUpdateInfo(User.AffiliateId, User.DisplayName, SacsSystem.ComputerName);
|
||||
}
|
||||
protected void ClearUserData()
|
||||
@@ -281,9 +297,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
String fn = GetType().Name + ".SetOrganisationData";
|
||||
|
||||
// Interface context for selected organisation.
|
||||
String interfaceContext = "";
|
||||
if (SysId.IsValid(affiliateIdOrganisation))
|
||||
interfaceContext = "ORG" + StringUtil.PadLeft(SysId.ToString(affiliateIdOrganisation), 5, '0');
|
||||
String interfaceContext = SbmAccountMgr.GetInterfaceContext(affiliateIdOrganisation);
|
||||
|
||||
SbmAffiliate affiliateOrganisation = null;
|
||||
SbmAssociation associationInternal = null;
|
||||
@@ -330,7 +344,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
}
|
||||
protected void SetSecurityProfile(SbmSecurityProfile securityProfile)
|
||||
{
|
||||
SecurityProfile = securityProfile;
|
||||
this.securityProfile = securityProfile;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user