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;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
|
||||
{
|
||||
public class SbmCodeTypeConsole_Web : SbmCodeTypeConsole_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCodeTypeConsole_Web(ISbmUserContext_Core userContext) : base(userContext)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override MaintainCodeTypesFunction MaintainCodeTypesFn => throw new NotImplementedException();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
public SbmEmailConsole_Web(SbmEmailConfig emailConfig) :
|
||||
protected SbmEmailConsole_Web(SbmEmailConfig emailConfig) :
|
||||
base(emailConfig)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmSecurityConsole_Web(ISbmUserContext userContext) : base(userContext)
|
||||
public SbmSecurityConsole_Web(ISbmUserContext_Core userContext) : base(userContext)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Consoles
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmUpdateLogConsole_Web(ISbmUserContext userContext) : base(userContext)
|
||||
public SbmUpdateLogConsole_Web(ISbmUserContext_Core userContext) : base(userContext)
|
||||
{
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -31,14 +32,14 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
//=======================================================================
|
||||
public abstract class SbmController_Base : SaController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private SbmSysParamCache sysParamCache = null;
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private SbmInternals_Control internals_Control;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SbmController_Base(SbmLocaliser localiser)
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SbmController_Base(SbmLocaliser localiser)
|
||||
{
|
||||
Localiser = localiser;
|
||||
|
||||
@@ -51,26 +52,26 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (sysParamCache != null) sysParamCache.Dispose();
|
||||
sysParamCache = null;
|
||||
if (internals != null) internals.Dispose();
|
||||
internals = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
if (internals != null) internals.Dispose();
|
||||
internals = null;
|
||||
if (internals_Control != null) internals_Control.Dispose();
|
||||
internals_Control = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected SbmLocaliser Localiser { get; }
|
||||
public SbmLocaliser Localiser { get; }
|
||||
protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
|
||||
public SbmAppConfig AppConfig { get { return App.AppConfig; } }
|
||||
public abstract SbmSessionContext SessionContext { get; }
|
||||
public abstract ISbmUserContext UserContext { get; }
|
||||
// Business components.
|
||||
public SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext); return internals; } }
|
||||
protected SbmSysParamCache SysParamCache { get { if (sysParamCache == null) sysParamCache = new SbmSysParamCache(UserContext); return sysParamCache; } }
|
||||
// Managers.
|
||||
public SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
public abstract ISbmUserContext_Core UserContext_Core { get; }
|
||||
// Business components.
|
||||
public SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext_Core); return internals; } }
|
||||
public SbmInternals_Control Internals_Control { get { if (internals_Control == null) internals_Control = new SbmInternals_Control(); return internals_Control; } }
|
||||
// Managers.
|
||||
public SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
public SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } }
|
||||
public SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } }
|
||||
public SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } }
|
||||
@@ -78,6 +79,10 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
public SbmStockMgr StockMgr { get { return Internals.StockMgr; } }
|
||||
public SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } }
|
||||
public SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
||||
// Control.
|
||||
protected SbmcAccountMgr ControlAccountMgr { get { return Internals_Control.ControlAccountMgr; } }
|
||||
protected SbmcInstanceMgr ControlInstanceMgr { get { return Internals_Control.ControlInstanceMgr; } }
|
||||
protected SbmcItemMgr ControlItemMgr { get { return Internals_Control.ControlItemMgr; } }
|
||||
// Consoles.
|
||||
public SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } }
|
||||
public SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
||||
@@ -103,24 +108,12 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
//-------------------------------------------------------------------
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
|
||||
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
base.OnActionExecuting(filterContext);
|
||||
}
|
||||
public override void OnActionExecuted(ActionExecutedContext filterContext)
|
||||
{
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
|
||||
// ToDo Store system params.
|
||||
if (sysParamCache != null)
|
||||
{
|
||||
if (sysParamCache.Modified)
|
||||
{
|
||||
sysParamCache.Store();
|
||||
SaLogger.Info($"{SysUtil.Fn} User params stored.");
|
||||
}
|
||||
}
|
||||
|
||||
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
base.OnActionExecuted(filterContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,14 +66,13 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public override SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
|
||||
public override ISbmUserContext UserContext { get { return SessionData; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Action execution events.
|
||||
//-------------------------------------------------------------------
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
|
||||
// Refreh model properties.
|
||||
SbmModel_Base baseModel = ViewData.Model as SbmModel_Base;
|
||||
@@ -83,7 +82,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
}
|
||||
public override void OnActionExecuted(ActionExecutedContext filterContext)
|
||||
{
|
||||
if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
//if (DebugMode) SaLogger.Debug($"{SysUtil.Fn}" + (ViewData.Model != null ? " Model: " + ViewData.Model : ""));
|
||||
|
||||
// Refreh model properties.
|
||||
SbmModel_Base baseModel = ViewData.Model as SbmModel_Base;
|
||||
@@ -133,10 +132,21 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
|
||||
model.RedirectLocation.Home_SessionExpired = GetRedirectLocation(RedirectLocation.WebAppHome_SessionExpired);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Online encryption parameters.
|
||||
//-------------------------------------------------------------------
|
||||
// Portal Request Password encryption parameters (key & IV) are defined in
|
||||
// the base Controller so that they can be shared with the Admin application.
|
||||
// NB IV value is generated from the key and fixed so that it doesn't change when the application restarts.
|
||||
// IV Must be regenerated if key is changed.
|
||||
protected static String Base64Key_RequestPassword_Portal { get; } = SacsEncryptionHelper.EncodePlainKey("[5Abus1neSSmGR~Request#Password}", SacsEncryptionHelper.KeyLength);
|
||||
//private static String Base64IV_RequestPassword_Generated_Portal = SacsEncryptionHelper.InitSymmetricEncryptionIV(Base64Key_RequestPassword_Portal);
|
||||
protected static String Base64IV_RequestPassword_Portal { get; } = "8TRhBayBJZmACQ6pld1F9A==";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Session.
|
||||
//-------------------------------------------------------------------
|
||||
public bool ValidUserSession { get { return SessionData?.ValidUserSession ?? false; } }
|
||||
public bool ValidUserSession { get { return SessionData?.ValidUser ?? false; } }
|
||||
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } }
|
||||
// Referrer.
|
||||
public String Referer { get { return Request.Headers["Referer"].ToString(); } }
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Helpers
|
||||
//-------------------------------------------------------------------
|
||||
// Session Contexts.
|
||||
//-------------------------------------------------------------------
|
||||
public static SbmSessionContext GetSessionContext (ushort idx)
|
||||
public static SbmSessionContext GetSessionContext(ushort idx)
|
||||
{
|
||||
SbmApplication_Web app = SbmGlobals_Web.Application;
|
||||
return app.GetSessionContext(idx);
|
||||
@@ -57,10 +57,10 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Helpers
|
||||
continue;
|
||||
}
|
||||
// Verify Db Identifier.
|
||||
List<string> dbIdentifiers = app.GetDbIdentifiers(sessionContext);
|
||||
HashSet<string> dbIdentifiers = app.GetDbIdentifiers(sessionContext);
|
||||
if (!dbIdentifiers.ContainsCI(dbIdentifier))
|
||||
continue;
|
||||
ISacsDatabase db = app.GetBusMgrDatabase(sessionContext);
|
||||
ISacsDatabase db = app.GetBusMgrDatabase(sessionContext);
|
||||
if (db == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Database for idx: " + sessionContextIdx);
|
||||
|
||||
@@ -5,7 +5,10 @@ using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Controllers;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
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.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
@@ -25,76 +28,95 @@ using System.Text;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.Models
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmModel_Base : SaModel
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
//=======================================================================
|
||||
public abstract class SbmModel_Base : SaModel
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SbmInternals internals;
|
||||
private SbmInternals_Control internals_Control;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SbmModel_Base(SbmLocaliser localiser)
|
||||
{
|
||||
Localiser = localiser;
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SbmModel_Base(SbmLocaliser localiser)
|
||||
{
|
||||
Localiser = localiser;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Application properties.
|
||||
private SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
|
||||
protected SbmAppConfig AppConfig { get { return App.AppConfig; } }
|
||||
protected SbmSystem_Web System { get { return App.System_Web; } }
|
||||
public String SessionCookieName { get { return App.SessionCookieName; } }
|
||||
public SbmSessionData SessionData { get { return SessionData_Web; } }
|
||||
public SbmSessionData_Web SessionData_Web { get; set; }
|
||||
public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose();
|
||||
internals = null;
|
||||
if (internals_Control != null) internals_Control.Dispose();
|
||||
internals_Control = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Application properties.
|
||||
private SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
|
||||
protected SbmAppConfig AppConfig { get { return App.AppConfig; } }
|
||||
protected SbmSystem_Web System { get { return App.System_Web; } }
|
||||
public String SessionCookieName { get { return App.SessionCookieName; } }
|
||||
public SbmSessionData SessionData { get { return SessionData_Web; } }
|
||||
public SbmSessionData_Web SessionData_Web { get; set; }
|
||||
public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
|
||||
public abstract ISbmUserContext_Core UserContext_Core { get; }
|
||||
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SbmSystem.ComputerName); } }
|
||||
public SbmLocaliser Localiser { get; }
|
||||
// Request properties.
|
||||
public SbmController_Web Controller { get; set; }
|
||||
public CultureInfo SessionCulture { get { return Controller?.SessionCulture ?? CultureInfo.InvariantCulture; } }
|
||||
public SbmLocaliser Localiser { get; }
|
||||
// Request properties.
|
||||
public SbmController_Web Controller { get; set; }
|
||||
public CultureInfo SessionCulture { get { return Controller?.SessionCulture ?? CultureInfo.InvariantCulture; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Page configuration.
|
||||
public String InstanceVersion { get { return !StringUtil.IsEmpty(App.AppConfig.Instance) ? App.AppConfig.Instance + " v" + Sbm.Version.GetFullVersion() : "v" + Sbm.Version.GetAppVersion(); } }
|
||||
//-------------------------------------------------------------------
|
||||
// Page configuration.
|
||||
public String InstanceVersion { get { return !StringUtil.IsEmpty(App.AppConfig.Instance) ? App.AppConfig.Instance + " v" + Sbm.Version.GetFullVersion() : "v" + Sbm.Version.GetAppVersion(); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Business components.
|
||||
// NB Keep these accessors protected to avoid them being called by teh model binding logic before the session data is ready.
|
||||
protected SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(SessionData_Web); return internals; } }
|
||||
// Managers.
|
||||
protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
protected SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } }
|
||||
protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } }
|
||||
protected SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } }
|
||||
protected SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } }
|
||||
protected SbmStockMgr StockMgr { get { return Internals.StockMgr; } }
|
||||
protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } }
|
||||
protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
||||
//-------------------------------------------------------------------
|
||||
// Business components.
|
||||
// NB Keep these accessors protected to avoid them being called by the model binding logic before the session data is ready.
|
||||
protected SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(UserContext_Core); return internals; } }
|
||||
public SbmInternals_Control Internals_Control { get { if (internals_Control == null) internals_Control = new SbmInternals_Control(); return internals_Control; } }
|
||||
// Managers.
|
||||
protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
|
||||
protected SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } }
|
||||
protected SbmCommodityMgr CommodityMgr { get { return Internals.CommodityMgr; } }
|
||||
protected SbmPriceMgr PriceMgr { get { return Internals.PriceMgr; } }
|
||||
protected SbmTransactionMgr TransactionMgr { get { return Internals.TransactionMgr; } }
|
||||
protected SbmStockMgr StockMgr { get { return Internals.StockMgr; } }
|
||||
protected SbmProcessMgr ProcessMgr { get { return Internals.ProcessMgr; } }
|
||||
protected SbmDataItemMgr DataItemMgr { get { return Internals.DataItemMgr; } }
|
||||
// Control.
|
||||
protected SbmcAccountMgr ControlAccountMgr { get { return Internals_Control.ControlAccountMgr; } }
|
||||
protected SbmcInstanceMgr ControlInstanceMgr { get { return Internals_Control.ControlInstanceMgr; } }
|
||||
protected SbmcItemMgr ControlItemMgr { get { return Internals_Control.ControlItemMgr; } }
|
||||
// Consoles.
|
||||
protected SbmConfigConsole ConfigConsole { get { return Internals.ConfigConsole; } }
|
||||
protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
||||
protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
||||
protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } }
|
||||
protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } }
|
||||
// Configurations.
|
||||
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
|
||||
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
|
||||
// System codes.
|
||||
protected List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); }
|
||||
protected SaDiaryConsole DiaryConsole { get { return Internals.DiaryConsole; } }
|
||||
protected SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
||||
protected SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
||||
protected SaReferenceDataConsole ReferenceDataConsole { get { return Internals.ReferenceDataConsole; } }
|
||||
protected SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
||||
protected SaInterfaceConsole InterfaceConsole { get { return Internals.InterfaceConsole; } }
|
||||
protected SaItemDocConsole ItemDocConsole { get { return Internals.ItemDocConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
|
||||
protected SaItemDataConsole ItemDataConsole { get { return Internals.ItemDataConsole; } }
|
||||
// Configurations.
|
||||
protected SbmStockControlConfig StockControlConfig { get { return Internals.StockControlConfig; } }
|
||||
protected SbmRequirementCostingConfig RequirementCostingConfig { get { return Internals.RequirementCostingConfig; } }
|
||||
// System codes.
|
||||
protected List<TypeCodeDesc> GetCodesOfType(Sbm.SystemCode systemCode) { return Internals.GetCodesOfType(systemCode); }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Security.
|
||||
public bool ValidUserSession { get { return SessionData?.ValidUserSession ?? false; } }
|
||||
public bool AwaitingLogin { get { return !ValidUserSession; } }
|
||||
public bool KeepLoggedIn { get { return !AwaitingLogin && SessionData.KeepLoggedIn; } }
|
||||
/// <summary>Maximum length allowed for password entry: sign-up, change password etc.</summary>
|
||||
public int PasswordMaxLength { get; } = 32;
|
||||
//-------------------------------------------------------------------
|
||||
// Security.
|
||||
public bool ValidUserSession { get { return SessionData?.ValidUser ?? false; } }
|
||||
public bool AwaitingLogin { get { return !ValidUserSession; } }
|
||||
public bool KeepLoggedIn { get { return !AwaitingLogin && SessionData_Web.KeepLoggedIn; } }
|
||||
/// <summary>Maximum length allowed for password entry: sign-up, change password etc.</summary>
|
||||
public int PasswordMaxLength { get; } = 32;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
@@ -113,105 +135,133 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Form control value max length - code type tables.
|
||||
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
|
||||
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
|
||||
/// </summary>
|
||||
public int GetControlMaxLength(SaCodeTypeDbDfn.ColumnIdx column)
|
||||
{
|
||||
int maxLength = (int)SaCodeTypeDbDfn.GetColTextLen(column);
|
||||
switch (column)
|
||||
{
|
||||
case SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name:
|
||||
case SaCodeTypeDbDfn.ColumnIdx.SaCode_Description:
|
||||
return Math.Min(maxLength, 100);
|
||||
}
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Form control value max length - BusinessMgr tables.
|
||||
/// <para>In many cases the database columns allow plenty of extra space for the value, in case they need to be encrypted.</para>
|
||||
/// <para>Hence, several cases where the value entered in the control isn't allowed the full database length.</para>
|
||||
/// </summary>
|
||||
public int GetControlMaxLength(SbmDbDfn.ColumnIdx column)
|
||||
{
|
||||
int maxLength = (int)SbmDbDfn.GetColTextLen(column);
|
||||
switch (column)
|
||||
{
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_Email:
|
||||
return Math.Min(maxLength, 100);
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_FirstName:
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_LastName:
|
||||
return Math.Min(maxLength, 40);
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_Name:
|
||||
return Math.Min(maxLength, 80);
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_PhoneMain:
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile:
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt:
|
||||
return Math.Min(maxLength, 20);
|
||||
case SbmDbDfn.ColumnIdx.Address_Postcode:
|
||||
return Math.Min(maxLength, 16);
|
||||
}
|
||||
return maxLength;
|
||||
}
|
||||
{
|
||||
int maxLength = (int)SbmDbDfn.GetColTextLen(column);
|
||||
switch (column)
|
||||
{
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_Email:
|
||||
return Math.Min(maxLength, 100);
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_FirstName:
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_LastName:
|
||||
return Math.Min(maxLength, 40);
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_Name:
|
||||
return Math.Min(maxLength, 80);
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_PhoneMain:
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_PhoneMobile:
|
||||
case SbmDbDfn.ColumnIdx.Affiliate_PhoneAlt:
|
||||
return Math.Min(maxLength, 20);
|
||||
case SbmDbDfn.ColumnIdx.Address_Postcode:
|
||||
return Math.Min(maxLength, 16);
|
||||
}
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copyright notice.
|
||||
public HtmlString CopyrightNotice
|
||||
{
|
||||
get
|
||||
{
|
||||
int initialYear = 2020;
|
||||
int currentYear = DateTime.Today.Year;
|
||||
return Localiser.GetHtmlText("copyright.symbol.year.html", (initialYear != currentYear ? initialYear + "-" : "") + currentYear.ToString());
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Copyright notice.
|
||||
public HtmlString CopyrightNotice
|
||||
{
|
||||
get
|
||||
{
|
||||
int initialYear = 2020;
|
||||
int currentYear = DateTime.Today.Year;
|
||||
return Localiser.GetHtmlText("copyright.symbol.year.html", (initialYear != currentYear ? initialYear + "-" : "") + currentYear.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Display data - Dates.
|
||||
public String FormatDateForDisplay(DateTime value)
|
||||
{
|
||||
return DateUtil.Format(value, "d-MMM-yy", SessionCulture);
|
||||
}
|
||||
public String FormatDateTimeForDisplay(DateTime value)
|
||||
{
|
||||
return StringUtil.TrimAll(DateUtil.Format(value, "d-MMM-yy HH:mm", SessionCulture));
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Display data - Dates.
|
||||
public String FormatDateForDisplay(DateTime? value)
|
||||
{
|
||||
return DateUtil.Format(value, "d-MMM-yy", SessionCulture);
|
||||
}
|
||||
public String FormatDateTimeForDisplay(DateTime? value)
|
||||
{
|
||||
return StringUtil.TrimAll(DateUtil.Format(value, "d-MMM-yy HH:mm", SessionCulture));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Form data - Dates.
|
||||
// Format may depend on locale, but as long as these methods are used consistently,
|
||||
// there should be consistent formatting, display and parsing of date values.
|
||||
public String CalendarDateFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
// JQuery-UI DatePicker date format.
|
||||
// Format:
|
||||
// d Single digit day of month
|
||||
// dd Double digit day of month
|
||||
// D 3 letter day of week abbreviation.
|
||||
// DD Day of week.
|
||||
// m Single digit month.
|
||||
// mm Double digit month.
|
||||
// M 3 letter month abbreviation.
|
||||
// MM Month name.
|
||||
// yy 4 digit year.
|
||||
// Examples:
|
||||
// dd/mm/yy 07/04/2012
|
||||
// dd-M-yy 07-Apr-2012
|
||||
// d-M-yy 7-Apr-2012
|
||||
return "dd-M-yy";
|
||||
}
|
||||
}
|
||||
public String FormatDateForForm(DateTime value)
|
||||
{
|
||||
return DateUtil.Format(value, "dd-MMM-yyyy");
|
||||
}
|
||||
public DateTime ParseDateFromForm(String value)
|
||||
{
|
||||
return DateUtil.ParseExact(value, "dd-MMM-yyyy");
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Form data - Dates.
|
||||
// Format may depend on locale, but as long as these methods are used consistently,
|
||||
// there should be consistent formatting, display and parsing of date values.
|
||||
public String CalendarDateFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
// JQuery-UI DatePicker date format.
|
||||
// Format:
|
||||
// d Single digit day of month
|
||||
// dd Double digit day of month
|
||||
// D 3 letter day of week abbreviation.
|
||||
// DD Day of week.
|
||||
// m Single digit month.
|
||||
// mm Double digit month.
|
||||
// M 3 letter month abbreviation.
|
||||
// MM Month name.
|
||||
// yy 4 digit year.
|
||||
// Examples:
|
||||
// dd/mm/yy 07/04/2012
|
||||
// dd-M-yy 07-Apr-2012
|
||||
// d-M-yy 7-Apr-2012
|
||||
return "dd-M-yy";
|
||||
}
|
||||
}
|
||||
public String FormatDateForForm(DateTime value)
|
||||
{
|
||||
return DateUtil.Format(value, "dd-MMM-yyyy");
|
||||
}
|
||||
public DateTime ParseDateFromForm(String value)
|
||||
{
|
||||
return DateUtil.ParseExact(value, "dd-MMM-yyyy");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Link URLs.
|
||||
public class LinksData
|
||||
{
|
||||
public String Facebook { get; } = "https://www.facebook.com/BusinessMgr/";
|
||||
public String LinkedIn { get; } = "https://www.linkedin.com/company/BusinessMgr/about/";
|
||||
}
|
||||
public LinksData Links { get; } = new LinksData();
|
||||
//-------------------------------------------------------------------
|
||||
// Link URLs.
|
||||
public class LinksData
|
||||
{
|
||||
public String Facebook { get; } = "https://www.facebook.com/BusinessMgr/";
|
||||
public String LinkedIn { get; } = "https://www.linkedin.com/company/BusinessMgr/about/";
|
||||
}
|
||||
public LinksData Links { get; } = new LinksData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Form data.
|
||||
// NB Use methods rathe rthan accessors for properties that depend on session data
|
||||
// to avoid the model binding logic invoking a getter before it's ready for use.
|
||||
|
||||
/// <summary>List of Address Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetCodeTypesForSelect()
|
||||
{
|
||||
List<CodeDesc> codeTypes = new List<CodeDesc>();
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.SortColumns.Add(CodeTypeConsole.GetCodeTypeColumnDfn(SaCodeType.Column.Name));
|
||||
foreach (SaCodeType codeType in CodeTypeConsole.GetCodeTypeList(prmCodeType))
|
||||
codeTypes.Add(codeType.Code, codeType.Name);
|
||||
return new SelectList(codeTypes, "Code", "Desc");
|
||||
}
|
||||
|
||||
/// <summary>List of Address Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetAddressTypeCodesForSelect()
|
||||
{
|
||||
@@ -220,15 +270,15 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
|
||||
|
||||
/// <summary>List of Affiliate Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetAffiliateTypeCodesForSelect()
|
||||
{
|
||||
return new SelectList(GetCodesOfType(Sbm.SystemCode.AffiliateType), "Code", "Desc");
|
||||
}
|
||||
{
|
||||
return new SelectList(GetCodesOfType(Sbm.SystemCode.AffiliateType), "Code", "Desc");
|
||||
}
|
||||
|
||||
/// <summary>List of Association Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetAssociationTypeCodesForSelect()
|
||||
{
|
||||
return new SelectList(GetCodesOfType(Sbm.SystemCode.AssociationType), "Code", "Desc");
|
||||
}
|
||||
/// <summary>List of Association Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetAssociationTypeCodesForSelect()
|
||||
{
|
||||
return new SelectList(GetCodesOfType(Sbm.SystemCode.AssociationType), "Code", "Desc");
|
||||
}
|
||||
|
||||
/// <summary>List of Commodity Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetCommodityTypeCodesForSelect()
|
||||
@@ -237,6 +287,13 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
|
||||
return new SelectList(GetCodesOfType(Sbm.SystemCode.CommodityType), "Code", "Desc");
|
||||
}
|
||||
|
||||
/// <summary>List of Asset Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> GetAssetTypeCodesForSelect()
|
||||
{
|
||||
|
||||
return new SelectList(GetCodesOfType(Sbm.SystemCode.AssetType), "Code", "Desc");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Form properties.
|
||||
/// <summary>
|
||||
@@ -245,9 +302,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
|
||||
/// <para>Populates value on logout form to identify default site for next login.</para>
|
||||
/// </summary>
|
||||
public ushort SessionIdx { get { return SessionContext?.Index ?? 0; } }
|
||||
public String FormAction { get; set; }
|
||||
public String FormAction { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user