Portal signin via Control Instance
This commit is contained in:
@@ -21,144 +21,25 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
public SbmAppConfig(String context, ConfigurationSection configSection, SbmAppConfig defaultConfig)
|
||||
{
|
||||
Context = context;
|
||||
populateDefaults(defaultConfig);
|
||||
PopulateDefaults(defaultConfig);
|
||||
PopulateConfig(configSection);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
private void populateDefaults(SbmAppConfig defaultConfig)
|
||||
{
|
||||
if (defaultConfig == null) return;
|
||||
Security.Password.MinLength = defaultConfig.Security.Password.MinLength;
|
||||
Security.SignIn.KeepLoggedIn.Allowed = defaultConfig.Security.SignIn.KeepLoggedIn.Allowed;
|
||||
Security.SignIn.KeepLoggedIn.CookieExpiresDays = defaultConfig.Security.SignIn.KeepLoggedIn.CookieExpiresDays;
|
||||
}
|
||||
private void PopulateConfig(ConfigurationSection configSection)
|
||||
{
|
||||
if (configSection != null)
|
||||
{
|
||||
// Environments.
|
||||
foreach (ConfigurationSection environmentSection in configSection.GetSection("Environments").GetChildren())
|
||||
environments.Add(StringUtil.TrimAll(environmentSection.Value));
|
||||
Instance = StringUtil.OnEmpty(configSection["Instance"], Instance);
|
||||
// Security.
|
||||
IConfigurationSection securitySection = configSection.GetSection("Security");
|
||||
if (securitySection.Exists())
|
||||
{
|
||||
// Security - Password.
|
||||
IConfigurationSection securityPasswordSection = securitySection.GetSection("Password");
|
||||
if (securityPasswordSection.Exists())
|
||||
{
|
||||
Security.Password.MinLength = StringUtil.ToInt(securityPasswordSection["MinLength"], Security.Password.MinLength);
|
||||
}
|
||||
// Security - Sign-Up.
|
||||
IConfigurationSection securitySignUpSection = securitySection.GetSection("SignUp");
|
||||
if (securitySignUpSection.Exists())
|
||||
{
|
||||
}
|
||||
// Security - Sign-In.
|
||||
IConfigurationSection securitySignInSection = securitySection.GetSection("SignIn");
|
||||
if (securitySignInSection.Exists())
|
||||
{
|
||||
IConfigurationSection keepLoggedInSection = securitySignInSection.GetSection("SignIn");
|
||||
if (keepLoggedInSection.Exists())
|
||||
{
|
||||
Security.SignIn.KeepLoggedIn.Allowed = StringUtil.ToBool(StringUtil.OnEmpty(keepLoggedInSection["Allowed"], Security.SignIn.KeepLoggedIn.Allowed.ToString()));
|
||||
Security.SignIn.KeepLoggedIn.CookieExpiresDays = StringUtil.ToInt(keepLoggedInSection["CookieExpiresDays"], Security.SignIn.KeepLoggedIn.CookieExpiresDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Email.
|
||||
IConfigurationSection emailSection = configSection.GetSection("Email");
|
||||
if (emailSection.Exists())
|
||||
{
|
||||
Email.Context = emailSection["Context"];
|
||||
PopulateEmailConfig(Email.ContactUs, emailSection.GetSection("ContactUs"));
|
||||
PopulateEmailConfig(Email.Signup_Activate, emailSection.GetSection("Signup").GetSection("Activate"));
|
||||
PopulateEmailConfig(Email.Signup_Welcome, emailSection.GetSection("Signup").GetSection("Welcome"));
|
||||
}
|
||||
|
||||
// Documents.
|
||||
IConfigurationSection documentsSection = configSection.GetSection("Documents");
|
||||
if (documentsSection.Exists())
|
||||
{
|
||||
Documents.RootFolder = StringUtil.OnEmpty(documentsSection["RootFolder"], Documents.RootFolder);
|
||||
}
|
||||
|
||||
// Logging.
|
||||
IConfigurationSection loggingSection = configSection.GetSection("Logging");
|
||||
if (loggingSection.Exists())
|
||||
{
|
||||
Logging.RootFolder = StringUtil.OnEmpty(loggingSection["RootFolder"], Logging.RootFolder);
|
||||
}
|
||||
|
||||
// Control database.
|
||||
IConfigurationSection controlDatabaseSection = configSection.GetSection("ControlDatabase");
|
||||
if (controlDatabaseSection.Exists())
|
||||
{
|
||||
ControlDatabase = new DatabaseConfig();
|
||||
extractDatabaseConfig(ControlDatabase, controlDatabaseSection);
|
||||
}
|
||||
// Template database.
|
||||
IConfigurationSection templateDatabaseSection = configSection.GetSection("TemplateDatabase");
|
||||
if (templateDatabaseSection.Exists())
|
||||
{
|
||||
TemplateDatabase = new DatabaseConfig();
|
||||
extractDatabaseConfig(TemplateDatabase, templateDatabaseSection);
|
||||
}
|
||||
// BusinessMgr databases.
|
||||
IConfigurationSection busMgrDatabasesSection = configSection.GetSection("BusMgrDatabases");
|
||||
if (busMgrDatabasesSection.Exists())
|
||||
{
|
||||
foreach (IConfigurationSection busMgrDbSection in busMgrDatabasesSection.GetChildren())
|
||||
{
|
||||
SbmAppConfig.DatabaseConfig dbConfig = new SbmAppConfig.DatabaseConfig();
|
||||
extractDatabaseConfig(dbConfig, busMgrDbSection);
|
||||
BusMgrDatabases.Add(dbConfig);
|
||||
}
|
||||
}
|
||||
|
||||
// Variants.
|
||||
foreach (ConfigurationSection variantSection in configSection.GetSection("Variants").GetChildren())
|
||||
{
|
||||
// Variants override selected values but must match the application root folder to identify a specific instance.
|
||||
String applicationRootPath = variantSection["ApplicationRootFolder"];
|
||||
if (StringUtil.IsEmpty(applicationRootPath)) continue;
|
||||
if (!SbmSystem.ApplicationFolder.EqualsCI(applicationRootPath)) continue;
|
||||
PopulateConfig(variantSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void PopulateEmailConfig(EmailConfig.SpecificEmailConfig config, IConfigurationSection emailSection)
|
||||
{
|
||||
if (!emailSection.Exists()) return;
|
||||
foreach (var addressTo in emailSection.GetSection("AddressesTo").GetChildren())
|
||||
config.AddressesTo.Add(StringUtil.TrimAll(addressTo.Value));
|
||||
foreach (var addressCc in emailSection.GetSection("AddressesCc").GetChildren())
|
||||
config.AddressesCc.Add(StringUtil.TrimAll(addressCc.Value));
|
||||
foreach (var addressBcc in emailSection.GetSection("AddressesBcc").GetChildren())
|
||||
config.AddressesBcc.Add(StringUtil.TrimAll(addressBcc.Value));
|
||||
}
|
||||
private void extractDatabaseConfig(DatabaseConfig database, IConfigurationSection databaseSection)
|
||||
{
|
||||
if (!databaseSection.Exists()) return;
|
||||
IConfigurationSection identifiersSection = databaseSection.GetSection("Identifiers");
|
||||
if (identifiersSection.Exists())
|
||||
{
|
||||
foreach (var identifier in identifiersSection.GetChildren())
|
||||
database.Identifiers.Add(StringUtil.TrimAll(identifier.Value));
|
||||
}
|
||||
database.Location = StringUtil.OnEmpty(databaseSection["Location"], database.Location);
|
||||
database.User = StringUtil.OnEmpty(databaseSection["User"], database.User);
|
||||
database.Password = StringUtil.OnEmpty(databaseSection["Password"], database.Password);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Properties.
|
||||
public String Context { get; }
|
||||
public List<String> Environments { get { return new List<String>(environments); } }
|
||||
public String Instance { get; set; } = "";
|
||||
// URLs.
|
||||
public class URLConfig
|
||||
{
|
||||
public class PortalConfig
|
||||
{
|
||||
public String Root { get; set; }
|
||||
}
|
||||
public PortalConfig Portal { get; } = new PortalConfig();
|
||||
}
|
||||
public URLConfig URL { get; } = new URLConfig();
|
||||
// Security.
|
||||
public class SecurityConfig
|
||||
{
|
||||
@@ -232,6 +113,155 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
}
|
||||
public LoggingConfig Logging { get; } = new LoggingConfig();
|
||||
|
||||
//---------------------------------------------------------------
|
||||
private void PopulateDefaults(SbmAppConfig defaultConfig)
|
||||
{
|
||||
if (defaultConfig == null) return;
|
||||
Security.Password.MinLength = defaultConfig.Security.Password.MinLength;
|
||||
Security.SignIn.KeepLoggedIn.Allowed = defaultConfig.Security.SignIn.KeepLoggedIn.Allowed;
|
||||
Security.SignIn.KeepLoggedIn.CookieExpiresDays = defaultConfig.Security.SignIn.KeepLoggedIn.CookieExpiresDays;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
private void PopulateConfig(ConfigurationSection configSection)
|
||||
{
|
||||
if (configSection != null)
|
||||
{
|
||||
// Environments.
|
||||
foreach (ConfigurationSection environmentSection in configSection.GetSection("Environments").GetChildren())
|
||||
environments.Add(StringUtil.TrimAll(environmentSection.Value));
|
||||
Instance = StringUtil.OnEmpty(configSection["Instance"], Instance);
|
||||
|
||||
// URLs.
|
||||
IConfigurationSection urls = configSection.GetSection("URLs");
|
||||
if (urls.Exists())
|
||||
{
|
||||
IConfigurationSection portalUrls = urls.GetSection("Portal");
|
||||
if (portalUrls.Exists())
|
||||
{
|
||||
URL.Portal.Root = portalUrls["Root"];
|
||||
}
|
||||
}
|
||||
|
||||
// Security.
|
||||
IConfigurationSection securitySection = configSection.GetSection("Security");
|
||||
if (securitySection.Exists())
|
||||
{
|
||||
// Security - Password.
|
||||
IConfigurationSection securityPasswordSection = securitySection.GetSection("Password");
|
||||
if (securityPasswordSection.Exists())
|
||||
{
|
||||
Security.Password.MinLength = StringUtil.ToInt(securityPasswordSection["MinLength"], Security.Password.MinLength);
|
||||
}
|
||||
// Security - Sign-Up.
|
||||
IConfigurationSection securitySignUpSection = securitySection.GetSection("SignUp");
|
||||
if (securitySignUpSection.Exists())
|
||||
{
|
||||
}
|
||||
// Security - Sign-In.
|
||||
IConfigurationSection securitySignInSection = securitySection.GetSection("SignIn");
|
||||
if (securitySignInSection.Exists())
|
||||
{
|
||||
IConfigurationSection keepLoggedInSection = securitySignInSection.GetSection("SignIn");
|
||||
if (keepLoggedInSection.Exists())
|
||||
{
|
||||
Security.SignIn.KeepLoggedIn.Allowed = StringUtil.ToBool(StringUtil.OnEmpty(keepLoggedInSection["Allowed"], Security.SignIn.KeepLoggedIn.Allowed.ToString()));
|
||||
Security.SignIn.KeepLoggedIn.CookieExpiresDays = StringUtil.ToInt(keepLoggedInSection["CookieExpiresDays"], Security.SignIn.KeepLoggedIn.CookieExpiresDays);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Email.
|
||||
IConfigurationSection emailSection = configSection.GetSection("Email");
|
||||
if (emailSection.Exists())
|
||||
{
|
||||
Email.Context = emailSection["Context"];
|
||||
PopulateEmailConfig(Email.ContactUs, emailSection.GetSection("ContactUs"));
|
||||
PopulateEmailConfig(Email.Signup_Activate, emailSection.GetSection("Signup").GetSection("Activate"));
|
||||
PopulateEmailConfig(Email.Signup_Welcome, emailSection.GetSection("Signup").GetSection("Welcome"));
|
||||
}
|
||||
|
||||
// Documents.
|
||||
IConfigurationSection documentsSection = configSection.GetSection("Documents");
|
||||
if (documentsSection.Exists())
|
||||
{
|
||||
Documents.RootFolder = StringUtil.OnEmpty(documentsSection["RootFolder"], Documents.RootFolder);
|
||||
}
|
||||
|
||||
// Logging.
|
||||
IConfigurationSection loggingSection = configSection.GetSection("Logging");
|
||||
if (loggingSection.Exists())
|
||||
{
|
||||
Logging.RootFolder = StringUtil.OnEmpty(loggingSection["RootFolder"], Logging.RootFolder);
|
||||
}
|
||||
|
||||
// Control database.
|
||||
IConfigurationSection controlDatabaseSection = configSection.GetSection("ControlDatabase");
|
||||
if (controlDatabaseSection.Exists())
|
||||
{
|
||||
ControlDatabase = new DatabaseConfig();
|
||||
ExtractDatabaseConfig(ControlDatabase, controlDatabaseSection);
|
||||
}
|
||||
|
||||
// Template database.
|
||||
IConfigurationSection templateDatabaseSection = configSection.GetSection("TemplateDatabase");
|
||||
if (templateDatabaseSection.Exists())
|
||||
{
|
||||
TemplateDatabase = new DatabaseConfig();
|
||||
ExtractDatabaseConfig(TemplateDatabase, templateDatabaseSection);
|
||||
}
|
||||
|
||||
// BusinessMgr databases.
|
||||
IConfigurationSection busMgrDatabasesSection = configSection.GetSection("BusMgrDatabases");
|
||||
if (busMgrDatabasesSection.Exists())
|
||||
{
|
||||
foreach (IConfigurationSection busMgrDbSection in busMgrDatabasesSection.GetChildren())
|
||||
{
|
||||
SbmAppConfig.DatabaseConfig dbConfig = new SbmAppConfig.DatabaseConfig();
|
||||
ExtractDatabaseConfig(dbConfig, busMgrDbSection);
|
||||
BusMgrDatabases.Add(dbConfig);
|
||||
}
|
||||
}
|
||||
|
||||
// Variants.
|
||||
foreach (ConfigurationSection variantSection in configSection.GetSection("Variants").GetChildren())
|
||||
{
|
||||
// Variants override selected values but must match the application root folder to identify a specific instance.
|
||||
String applicationRootPath = variantSection["ApplicationRootFolder"];
|
||||
if (StringUtil.IsEmpty(applicationRootPath)) continue;
|
||||
if (!SbmSystem.ApplicationFolder.EqualsCI(applicationRootPath)) continue;
|
||||
PopulateConfig(variantSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
private void PopulateEmailConfig(EmailConfig.SpecificEmailConfig config, IConfigurationSection emailSection)
|
||||
{
|
||||
if (!emailSection.Exists()) return;
|
||||
foreach (var addressTo in emailSection.GetSection("AddressesTo").GetChildren())
|
||||
config.AddressesTo.Add(StringUtil.TrimAll(addressTo.Value));
|
||||
foreach (var addressCc in emailSection.GetSection("AddressesCc").GetChildren())
|
||||
config.AddressesCc.Add(StringUtil.TrimAll(addressCc.Value));
|
||||
foreach (var addressBcc in emailSection.GetSection("AddressesBcc").GetChildren())
|
||||
config.AddressesBcc.Add(StringUtil.TrimAll(addressBcc.Value));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
private void ExtractDatabaseConfig(DatabaseConfig database, IConfigurationSection databaseSection)
|
||||
{
|
||||
if (!databaseSection.Exists()) return;
|
||||
IConfigurationSection identifiersSection = databaseSection.GetSection("Identifiers");
|
||||
if (identifiersSection.Exists())
|
||||
{
|
||||
foreach (var identifier in identifiersSection.GetChildren())
|
||||
database.Identifiers.Add(StringUtil.TrimAll(identifier.Value));
|
||||
}
|
||||
database.Location = StringUtil.OnEmpty(databaseSection["Location"], database.Location);
|
||||
database.User = StringUtil.OnEmpty(databaseSection["User"], database.User);
|
||||
database.Password = StringUtil.OnEmpty(databaseSection["Password"], database.Password);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -3,6 +3,7 @@ using Sarand.BusinessMgr.Net.Core.Web.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -101,46 +102,42 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
return SbmConfigConsole.CreateConsole(sessionContext);
|
||||
}
|
||||
public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext userContext)
|
||||
public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaSecurityConsole CreateSecurityConsole(ISbmUserContext userContext)
|
||||
public override SaSecurityConsole CreateSecurityConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return new SbmSecurityConsole_Web(userContext);
|
||||
}
|
||||
public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext userContext)
|
||||
public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return new SbmCodeTypeConsole_Web(userContext);
|
||||
}
|
||||
public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext userContext)
|
||||
public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext userContext)
|
||||
public override SaItemDocConsole CreateItemDocConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaItemDocConsole CreateItemDocConsole(ISbmUserContext userContext)
|
||||
public override SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext userContext)
|
||||
public override SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext userContext)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext userContext)
|
||||
public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext_Core userContext)
|
||||
{
|
||||
return new SbmUpdateLogConsole_Web(userContext);
|
||||
}
|
||||
public override SbmEmailConsole CreateEmailConsole(ISbmUserContext userContext)
|
||||
{
|
||||
return new SbmEmailConsole_Web(EmailConfig);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
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,14 +28,15 @@ 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);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Generic phrase translation.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key)
|
||||
public LocalizedString GetText(string key, bool logMissingKey = true)
|
||||
{
|
||||
return GetText(key, new object[] { });
|
||||
return GetText(key, new object[] { }, logMissingKey );
|
||||
}
|
||||
public LocalizedString GetText(string key, object param)
|
||||
{
|
||||
@@ -45,21 +46,25 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
return GetText(key, new object[] { param1, param2 });
|
||||
}
|
||||
public LocalizedString GetText(string key, object[] parameters)
|
||||
public LocalizedString GetText(string key, object[] parameters, bool logMissingKey = true)
|
||||
{
|
||||
LocalizedString text = MainProperties.GetString(key, parameters);
|
||||
if (text.ResourceNotFound)
|
||||
{
|
||||
SaLogger.Debug($"{SysUtil.Fn} Key not found: {key}");
|
||||
// Look up key in alternative property files.
|
||||
foreach (IStringLocalizer properties in AlternativeProperties ?? new List<IStringLocalizer>())
|
||||
{
|
||||
text = properties.GetString(key, parameters);
|
||||
if (!text.ResourceNotFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
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.
|
||||
@@ -127,12 +132,17 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Specific phrase translation.
|
||||
// Code descriptions.
|
||||
//-------------------------------------------------------------------
|
||||
private class CodeCache
|
||||
{
|
||||
public List<TypeCodeDesc> affiliateTypeCodes;
|
||||
// To be completed.
|
||||
public Dictionary<Sbm.SystemCode, List<TypeCodeDesc>> codes { get; } = new Dictionary<Sbm.SystemCode, List<TypeCodeDesc>>();
|
||||
public List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode codeType)
|
||||
{
|
||||
if (!codes.ContainsKey(codeType))
|
||||
codes.Add(codeType, SbmSystem.GetCodesOfType(null, codeType));
|
||||
return codes.GetValueOrDefault(codeType, new List<TypeCodeDesc>());
|
||||
}
|
||||
}
|
||||
private CodeCache codes = new CodeCache();
|
||||
|
||||
@@ -144,13 +154,21 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
}
|
||||
|
||||
// Affiliate Type.
|
||||
public String GetAffiliateTypeTypeCaption(Sbm.AffiliateType participation)
|
||||
public String GetAffiliateTypeCaption(Sbm.AffiliateType affiliateType)
|
||||
{
|
||||
if ((int)participation < 1) return "";
|
||||
if (codes.affiliateTypeCodes == null)
|
||||
codes.affiliateTypeCodes = SbmSystem.GetCodesOfType(null, Sbm.SystemCode.AffiliateType);
|
||||
if ((int)affiliateType < 1) return "";
|
||||
// ToDo Affiliate Type localisation.
|
||||
return codes.affiliateTypeCodes.GetDescForType(participation);
|
||||
List<TypeCodeDesc> affiliateTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AffiliateType);
|
||||
return affiliateTypeCodes.GetDescForType(affiliateType, affiliateTypeCodes.GetCodeForType(affiliateType));
|
||||
}
|
||||
|
||||
// Asset Type.
|
||||
public String GetAssetTypeCaption(Sbm.AssetType assetType)
|
||||
{
|
||||
if ((int)assetType < 1) return "";
|
||||
// ToDo Asset Type localisation.
|
||||
List<TypeCodeDesc> assetTypeCodes = codes.GetCodesOfType(Sbm.SystemCode.AssetType);
|
||||
return assetTypeCodes.GetDescForType(assetType, assetTypeCodes.GetCodeForType(assetType));
|
||||
}
|
||||
|
||||
// To be completed.
|
||||
|
||||
@@ -11,32 +11,25 @@ using System.Text;
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SbmSessionData_Web : SbmSessionData, ISbmUserContext
|
||||
public abstract class SbmSessionData_Web : SbmSessionData
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction - for JSON deserialisation.
|
||||
protected SbmSessionData_Web(long sessionIdx, int itemIdx, SbmSessionContext sessionContext) :
|
||||
base(sessionIdx, itemIdx, sessionContext)
|
||||
{
|
||||
securityProfile = new SbmSecurityProfile(this, false);
|
||||
}
|
||||
// Protected construction.
|
||||
protected SbmSessionData_Web(SbmSessionContext sessionContext) :
|
||||
base(sessionContext)
|
||||
{
|
||||
securityProfile = new SbmSecurityProfile(this, false);
|
||||
}
|
||||
// Protected construction.
|
||||
protected SbmSessionData_Web(SbmSessionContext sessionContext, SaSecurityItem securityItemUser, SbmAffiliate affiliateUser, List<SysIdString> supervisedOrganisations, SbmAssociation associationOrganisation, SbmAffiliate affiliateOrganisation) :
|
||||
base(sessionContext, securityItemUser, affiliateUser, supervisedOrganisations, associationOrganisation, affiliateOrganisation)
|
||||
{
|
||||
securityProfile = new SbmSecurityProfile(this, false);
|
||||
}
|
||||
// Protected construction.
|
||||
protected SbmSessionData_Web(SbmSessionContext sessionContext) :
|
||||
base(sessionContext)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Security Profile.
|
||||
private readonly SbmSecurityProfile securityProfile;
|
||||
public ISbmSecurityProfile SecurityProfile { get { return securityProfile; } }
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
[JsonIgnore]
|
||||
public abstract bool KeepLoggedIn { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ToDo: Organisation configuration.
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.App;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
Reference in New Issue
Block a user