Contacts
This commit is contained in:
@@ -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,9 +98,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create consoles.
|
||||
public override SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext)
|
||||
public override SbmSessionConsole CreateSessionConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return SbmConfigConsole.CreateConsole(sessionContext);
|
||||
return SbmSessionConsole.CreateConsole(userContext);
|
||||
}
|
||||
public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
@@ -114,10 +114,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
return new SbmCodeTypeConsole_Web(userContext);
|
||||
}
|
||||
public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.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.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
//=======================================================================
|
||||
/// <summary>
|
||||
/// Facade Instance configuration for core databases without Control configuration.
|
||||
/// </summary>
|
||||
public class SbmInstanceConfig_Core : SbmInstanceConfig
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmInstanceConfig_Core(SbmSessionContext_Web sessionContext)
|
||||
{
|
||||
this.SessionContext = sessionContext;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Supported application options.
|
||||
public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse)
|
||||
{
|
||||
return defaultResponse;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.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.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmInstanceConfig_Web : SbmInstanceConfig
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SysId controlOwnerId;
|
||||
private readonly SysId controlRepositoryId;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmInstanceConfig_Web(SysId controlOwnerId, SysId controlRepositoryId)
|
||||
{
|
||||
this.controlOwnerId = controlOwnerId;
|
||||
this.controlRepositoryId = controlRepositoryId;
|
||||
PopulateControlParams();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Populate Repository Configuration parameters.
|
||||
private void PopulateControlParams()
|
||||
{
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
{
|
||||
SbmcItemMgr controlItemMgr = SbmGlobals_Web.System.CreateControlItemMgr();
|
||||
if (controlItemMgr != null)
|
||||
{
|
||||
disposables.Add(controlItemMgr);
|
||||
PopulateControlParams(controlItemMgr, new ItemId((short)SbmcHierarchyItem.ItemType.Owner, controlOwnerId));
|
||||
PopulateControlParams(controlItemMgr, new ItemId((short)SbmcHierarchyItem.ItemType.Repository, controlRepositoryId));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void PopulateControlParams(SbmcItemMgr controlItemMgr, ItemId paramItemId)
|
||||
{
|
||||
if (!ItemId.IsValid(paramItemId)) return;
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
// Query item params.
|
||||
SbmcItemParam.Params prmParam = new SbmcItemParam.Params();
|
||||
prmParam.ItemIdsIncluded.Add(paramItemId);
|
||||
prmParam.StatusCat = SbmcItemParam.StatusCat.ActiveOnly;
|
||||
List<SbmcItemParam> itemParams = controlItemMgr.GetItemParamList(prmParam);
|
||||
disposables.AddRange(itemParams);
|
||||
foreach (SbmcItemParam itemParam in itemParams)
|
||||
PopulateControlParam(itemParam);
|
||||
}
|
||||
}
|
||||
private void PopulateControlParam(SbmcItemParam itemParam)
|
||||
{
|
||||
// Affiliate types.
|
||||
if (IsConfigParamOfType(ConfigParamType.AllowedAffiliateTypes, itemParam))
|
||||
AffiliateTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.AffiliateType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
else if (IsConfigParamOfType(ConfigParamType.DisallowedAffiliateTypes, itemParam))
|
||||
AffiliateTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.AffiliateType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
// Association types.
|
||||
else if (IsConfigParamOfType(ConfigParamType.AllowedAssociationTypes, itemParam))
|
||||
AssociationTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.AssociationType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
else if (IsConfigParamOfType(ConfigParamType.DisallowedAssociationTypes, itemParam))
|
||||
AssociationTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.AssociationType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
// Transaction types.
|
||||
else if (IsConfigParamOfType(ConfigParamType.AllowedTransactionTypes, itemParam))
|
||||
TransactionTypes_Allowed.UnionWith(EnumUtil.ParseEnums<Sbm.TransactionType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
else if (IsConfigParamOfType(ConfigParamType.DisallowedTransactionTypes, itemParam))
|
||||
TransactionTypes_Disallowed.UnionWith(EnumUtil.ParseEnums<Sbm.TransactionType>(Regex.Split(itemParam.Value, "[\\s,;\\-]+")));
|
||||
// Application options.
|
||||
else if (IsConfigParamOfType(ConfigParamType.ApplicationOption, itemParam))
|
||||
{
|
||||
Sbm.ConfigOption option = EnumUtil.ParseEnum(itemParam.Name, Sbm.ConfigOption.Unknown);
|
||||
if (option != Sbm.ConfigOption.Unknown)
|
||||
{
|
||||
if (itemParam.Value.EqualsCI(ApplicationOptionValue_Allow))
|
||||
ApplicationOptions_Allowed.Add(option);
|
||||
else if (itemParam.Value.EqualsCI(ApplicationOptionValue_Disallow))
|
||||
ApplicationOptions_Disallowed.Add(option);
|
||||
else if (itemParam.Value.EqualsCI(ApplicationOptionValue_Default))
|
||||
ApplicationOptions_Default.Add(option);
|
||||
else
|
||||
SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option value: {itemParam.Value}. Option: {option}.");
|
||||
}
|
||||
else
|
||||
SaLogger.Warn($"{SysUtil.Fn} Unrecognised application option: {itemParam.Name}.");
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Allowed data component types.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Supported affiliate types.
|
||||
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Allowed = new HashSet<Sbm.AffiliateType>();
|
||||
private readonly HashSet<Sbm.AffiliateType> AffiliateTypes_Disallowed = new HashSet<Sbm.AffiliateType>();
|
||||
public override bool AllowAffiliateType(Sbm.AffiliateType affiliateType)
|
||||
{
|
||||
if (AffiliateTypes_Disallowed.Contains(affiliateType)) return false;
|
||||
if (AffiliateTypes_Allowed.Contains(affiliateType)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Supported affiliate types.
|
||||
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Allowed = new HashSet<Sbm.AssociationType>();
|
||||
private readonly HashSet<Sbm.AssociationType> AssociationTypes_Disallowed = new HashSet<Sbm.AssociationType>();
|
||||
public override bool AllowAssociationType(Sbm.AssociationType affiliateType)
|
||||
{
|
||||
if (AssociationTypes_Disallowed.Contains(affiliateType)) return false;
|
||||
if (AssociationTypes_Allowed.Contains(affiliateType)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Supported affiliate types.
|
||||
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Allowed = new HashSet<Sbm.TransactionType>();
|
||||
private readonly HashSet<Sbm.TransactionType> TransactionTypes_Disallowed = new HashSet<Sbm.TransactionType>();
|
||||
public override bool AllowTransactionType(Sbm.TransactionType affiliateType)
|
||||
{
|
||||
if (TransactionTypes_Disallowed.Contains(affiliateType)) return false;
|
||||
if (TransactionTypes_Allowed.Contains(affiliateType)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Supported application options.
|
||||
private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Allowed = new HashSet<Sbm.ConfigOption>();
|
||||
private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Disallowed = new HashSet<Sbm.ConfigOption>();
|
||||
private readonly HashSet<Sbm.ConfigOption> ApplicationOptions_Default = new HashSet<Sbm.ConfigOption>();
|
||||
public override bool AllowApplicationOption(Sbm.ConfigOption option, bool defaultResponse)
|
||||
{
|
||||
if (ApplicationOptions_Disallowed.Contains(option)) return false;
|
||||
if (ApplicationOptions_Allowed.Contains(option)) return true;
|
||||
if (ApplicationOptions_Default.Contains(option)) return defaultResponse;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
// Properties.
|
||||
public abstract IStringLocalizer MainProperties { get; }
|
||||
public virtual List<IStringLocalizer> AlternativeProperties { get; } = new List<IStringLocalizer>();
|
||||
private HashSet<String> MissingKeysLogged { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||
private HashSet<String> MissingKeysLogged { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Generic phrase translation.
|
||||
@@ -36,7 +36,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key, bool logMissingKey = true)
|
||||
{
|
||||
return GetText(key, new object[] { }, logMissingKey );
|
||||
return GetText(key, new object[] { }, logMissingKey);
|
||||
}
|
||||
public LocalizedString GetText(string key, object param)
|
||||
{
|
||||
@@ -49,22 +49,22 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
public LocalizedString GetText(string key, object[] parameters, bool logMissingKey = true)
|
||||
{
|
||||
LocalizedString text = MainProperties.GetString(key, parameters);
|
||||
if (text.ResourceNotFound)
|
||||
{
|
||||
// Look up key in alternative property files.
|
||||
foreach (IStringLocalizer properties in AlternativeProperties ?? new List<IStringLocalizer>())
|
||||
{
|
||||
text = parameters == null || parameters.IsEmpty() ? properties.GetString(key) : properties.GetString(key, parameters);
|
||||
if (!text.ResourceNotFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (text.ResourceNotFound && logMissingKey && !MissingKeysLogged.Contains(key))
|
||||
{
|
||||
MissingKeysLogged.Add(key);
|
||||
SaLogger.Debug($"{SysUtil.Fn} Key not found: {key}");
|
||||
}
|
||||
return text;
|
||||
if (text.ResourceNotFound)
|
||||
{
|
||||
// Look up key in alternative property files.
|
||||
foreach (IStringLocalizer properties in AlternativeProperties ?? new List<IStringLocalizer>())
|
||||
{
|
||||
text = parameters == null || parameters.IsEmpty() ? properties.GetString(key) : properties.GetString(key, parameters);
|
||||
if (!text.ResourceNotFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (text.ResourceNotFound && logMissingKey && !MissingKeysLogged.Contains(key))
|
||||
{
|
||||
MissingKeysLogged.Add(key);
|
||||
SaLogger.Debug($"{SysUtil.Fn} Key not found: {key}");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Square bracket indexing.
|
||||
@@ -162,6 +162,15 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
return affiliateTypeCodes.GetDescForType(affiliateType, affiliateTypeCodes.GetCodeForType(affiliateType));
|
||||
}
|
||||
|
||||
// Association Type.
|
||||
public String GetAssociationTypeCaption(Sbm.AssociationType associationType)
|
||||
{
|
||||
if ((int)associationType < 1) return "";
|
||||
// ToDo Association Type localisation.
|
||||
List<TypeCodeDesc> associationTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssociationType);
|
||||
return associationTypeCodes.GetDescForType(associationType, associationTypeCodes.GetCodeForType(associationType));
|
||||
}
|
||||
|
||||
// Asset Type.
|
||||
public String GetAssetTypeCaption(Sbm.AssetType assetType)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user