3.0.1.7 Business object disposability
This commit is contained in:
@@ -87,8 +87,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (interfaceProcess != null) interfaceProcess.Dispose(); interfaceProcess = null;
|
||||
if (interfaceObj != null) interfaceObj.Dispose(); interfaceObj = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
@@ -191,10 +189,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
|
||||
else if (!HasErrorMessage())
|
||||
AddErrorMessage("Failed to store interface process: " + InterfaceConsole.ErrorStateMessage);
|
||||
|
||||
// Clean-up.
|
||||
interfaceProcess.Dispose();
|
||||
interfaceProcess = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
// Populate Repository Configuration parameters.
|
||||
private void PopulateControlParams()
|
||||
{
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
SbmcItemMgr controlItemMgr = SbmGlobals_Web.System.CreateControlItemMgr();
|
||||
if (controlItemMgr != null)
|
||||
@@ -80,14 +80,13 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
private void PopulateControlParams(SbmcItemMgr controlItemMgr, ItemId paramItemId)
|
||||
{
|
||||
if (!ItemId.IsValid(paramItemId)) return;
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,12 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
String fn = GetType().Name + ".Invoke"; // SysUtil.Fn not useable.
|
||||
// Log action.
|
||||
//String rawTarget = context.Features.Get<IHttpRequestFeature>().RawTarget;
|
||||
HashSet<String> pathsToIgnore = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase) { "/Security/Ajax/ScorePassword", "/Security/Ajax/KeepLoggedIn" };
|
||||
if (SbmSystem.DebugMode && !context.Request.Method.EqualsCI("GET") && !pathsToIgnore.Contains($"{context.Request.Path}"))
|
||||
SaLogger.Debug($"{SysUtil.Fn} Action: '{Regex.Replace($"{context.Request.Path}", "^/", "")}'. Method: {context.Request.Method}.");
|
||||
SaLogger.Debug($"{fn} Action: '{Regex.Replace($"{context.Request.Path}", "^/", "")}'. Method: {context.Request.Method}.");
|
||||
|
||||
// Intercept POST requests and apply anti-forgery test.
|
||||
if (HttpMethods.IsPost(context.Request.Method))
|
||||
@@ -59,7 +60,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Middleware
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
SaLogger.Warn($"{fn} " + ExceptionUtil.GetLogMessage(exc));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "3.0.1.6";
|
||||
private static String version { get; } = "3.0.1.7";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion() { return version; }
|
||||
public static String GetAppVersion()
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
/// <summary>Clear the params cached for the current user.</summary>
|
||||
public void Clear()
|
||||
{
|
||||
ListUtil.ClearAndDispose(mbr.UserSysParams);
|
||||
mbr.UserSysParams.Clear();
|
||||
Modified = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
mbr.InterfaceOptions.AddRange(Internals.GetSystemCodes(Sbm.SystemCode.InterfaceOption));
|
||||
Reset();
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
/// <para>- Initialisation of new repository.</para>
|
||||
/// <para>- Bringing static (tax codes etc) and reference data up to date.</para>
|
||||
/// </summary>
|
||||
public abstract class SbmCoreInstanceConsole : SaErrorStateItem, ISbmCoreInstanceConsole
|
||||
public abstract class SbmCoreInstanceConsole : SacsDisposableStateItem, ISbmCoreInstanceConsole
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
@@ -266,7 +266,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
ClearErrorState();
|
||||
if (!ValidateRepositoryInitialisionData(initData)) return false;
|
||||
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Organisation Contact.
|
||||
@@ -284,7 +284,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
// Create new organisation.
|
||||
affiliateOrganisation = Internals.AccountMgr.CreateAffiliate(Sbm.AffiliateType.Commercial);
|
||||
}
|
||||
disposables.Add(affiliateOrganisation);
|
||||
|
||||
// Populate properties.
|
||||
affiliateOrganisation.Name = initData.Organisation.Name;
|
||||
@@ -312,7 +311,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
|
||||
// Retrieve existing Internal Association for Organisation.
|
||||
SbmAssociation associationInternal = Internals.AccountMgr.GetInternalAssociation(affiliateOrganisation.Id);
|
||||
disposables.Add(associationInternal);
|
||||
if (associationInternal != null && SysId.IsValid(initData.Organisation.AssociationId) && !associationInternal.Id.Equals(initData.Organisation.AssociationId))
|
||||
// Failed to validate existing Internal Association against supplied Association Id.
|
||||
return SetErrorState($"Identified Internal Association (Id. {initData.Organisation.AssociationId}) doesn't match existing association ({associationInternal.Id}).");
|
||||
@@ -322,7 +320,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
associationInternal = Internals.AccountMgr.GetAssociationById(initData.Organisation.AssociationId);
|
||||
if (associationInternal == null)
|
||||
return SetErrorState($"Failed to retrieve supplied Internal Association. Id: {initData.Organisation.AssociationId}.");
|
||||
disposables.Add(associationInternal);
|
||||
if (!associationInternal.AffiliateIdOwner.Equals(affiliateOrganisation.Id))
|
||||
return SetErrorState($"Supplied Internal Association has different Owner ({associationInternal.AffiliateIdOwner}) to Organisation ({affiliateOrganisation.Id}).");
|
||||
if (!associationInternal.AffiliateIdTarget.Equals(affiliateOrganisation.Id))
|
||||
@@ -330,7 +327,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
}
|
||||
if (associationInternal == null)
|
||||
associationInternal = Internals.AccountMgr.CreateAssociation(affiliateOrganisation.Id, Sbm.AssociationType.Internal, affiliateOrganisation.Id);
|
||||
disposables.Add(associationInternal);
|
||||
|
||||
// Store Internal Association.
|
||||
if (!SysId.IsValid(associationInternal.Id))
|
||||
@@ -359,7 +355,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
securityItemUser = SecurityConsole.GetSecurityItemById(SaSecurity.ItemType.User, initData.User.SecurityItemId);
|
||||
if (securityItemUser == null)
|
||||
return SetErrorState($"Failed to retrieve supplied User Security Item. Id: {initData.User.SecurityItemId}.");
|
||||
disposables.Add(securityItemUser);
|
||||
if (!securityItemUser.Code.Equals(initData.User.Code))
|
||||
return SetErrorState($"Supplied User Security Item doesn't match supplied code. Expected: {initData.User.Code}. Found: {securityItemUser.Code}.");
|
||||
}
|
||||
@@ -367,7 +362,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
{
|
||||
// Retrieve Security Item by code.
|
||||
securityItemUser = SecurityConsole.GetSecurityItemByCode(SaSecurity.ItemType.User, initData.User.Code);
|
||||
disposables.Add(securityItemUser);
|
||||
}
|
||||
if (securityItemUser == null)
|
||||
{
|
||||
@@ -377,7 +371,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
securityItemUser = SecurityConsole.GetSecurityItemByCode(SaSecurity.ItemType.User, initData.User.Code);
|
||||
if (securityItemUser == null)
|
||||
return SetErrorState($"Failed to retrieve User Security Item after creation. Code: {initData.User.Code}.");
|
||||
disposables.Add(securityItemUser);
|
||||
}
|
||||
|
||||
// Populate User Security Item properties.
|
||||
@@ -404,28 +397,24 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
affiliateUser = Internals.AccountMgr.GetAffiliateById(initData.User.AffiliateId);
|
||||
if (affiliateUser == null)
|
||||
return SetErrorState($"Failed to retrieve User Contact. Id: {initData.User.AffiliateId}.");
|
||||
disposables.Add(affiliateUser);
|
||||
}
|
||||
|
||||
if (affiliateUser == null)
|
||||
{
|
||||
// Retrieve User Contact by User Code.
|
||||
affiliateUser = Internals.AccountMgr.GetAffiliateByUserId(securityItemUser.Id);
|
||||
disposables.Add(affiliateUser);
|
||||
}
|
||||
|
||||
if (affiliateUser == null)
|
||||
{
|
||||
// Retrieve User Contact by name.
|
||||
affiliateUser = Internals.AccountMgr.GetIndividualByName(initData.User.FirstName, initData.User.LastName);
|
||||
disposables.Add(affiliateUser);
|
||||
}
|
||||
|
||||
if (affiliateUser == null)
|
||||
{
|
||||
// Create User Contact.
|
||||
affiliateUser = Internals.AccountMgr.CreateAffiliate(Sbm.AffiliateType.Individual);
|
||||
disposables.Add(affiliateUser);
|
||||
}
|
||||
|
||||
// Populate User Contact properties.
|
||||
@@ -454,7 +443,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
if (associationMember == null)
|
||||
// Create Member Association.
|
||||
associationMember = Internals.AccountMgr.CreateAssociation(affiliateOrganisation.Id, Sbm.AssociationType.Member, affiliateUser.Id);
|
||||
disposables.Add(associationMember);
|
||||
associationMember.Supervised = true;
|
||||
|
||||
// Store User Association.
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Consoles
|
||||
/// <para>- Populate example data.</para>
|
||||
/// <para>- Populate Demo Account User.</para>
|
||||
/// </summary>
|
||||
public abstract class SbmDemoInstanceConsole : SaErrorStateItem, ISbmDemoInstanceConsole
|
||||
public abstract class SbmDemoInstanceConsole : SacsDisposableStateItem, ISbmDemoInstanceConsole
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
@@ -69,12 +69,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control
|
||||
if (ItemId.IsValid(itemId))
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
if (itemId.Type == (short)SbmcHierarchyItem.ItemType.UserAccount)
|
||||
{
|
||||
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(itemId.Id);
|
||||
disposables.Add(userAccount);
|
||||
if (userAccount != null)
|
||||
return userAccount.GetDisplayName();
|
||||
return $"UserAccount #{itemId.Id}";
|
||||
@@ -82,7 +81,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control
|
||||
if (itemId.Type == (short)SbmcHierarchyItem.ItemType.Owner)
|
||||
{
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(itemId.Id);
|
||||
disposables.Add(owner);
|
||||
if (owner != null)
|
||||
return owner.Name;
|
||||
return $"Owner #{itemId.Id}";
|
||||
@@ -90,7 +88,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control
|
||||
if (itemId.Type == (short)SbmcHierarchyItem.ItemType.Repository)
|
||||
{
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(itemId.Id);
|
||||
disposables.Add(repository);
|
||||
if (repository != null)
|
||||
return repository.Context;
|
||||
return $"Repository #{itemId.Id}";
|
||||
|
||||
@@ -175,22 +175,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(associationId)) return null;
|
||||
using (SbmAssociation association = GetAssociationById(associationId))
|
||||
{
|
||||
if (association != null)
|
||||
return GetAffiliateById(association.AffiliateIdTarget);
|
||||
}
|
||||
SbmAssociation association = GetAssociationById(associationId);
|
||||
if (association != null)
|
||||
return GetAffiliateById(association.AffiliateIdTarget);
|
||||
return null;
|
||||
}
|
||||
public SbmAffiliate GetTargetAffiliateByAssocTypeCode(Sbm.AssociationType associationType, String associationCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
if ((int)associationType < 1 || StringUtil.IsBlank(associationCode)) return null;
|
||||
using (SbmAssociation association = GetAssociationByTypeCode(associationType, associationCode))
|
||||
{
|
||||
if (association != null)
|
||||
return GetAffiliateById(association.AffiliateIdTarget);
|
||||
}
|
||||
SbmAssociation association = GetAssociationByTypeCode(associationType, associationCode);
|
||||
if (association != null)
|
||||
return GetAffiliateById(association.AffiliateIdTarget);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -431,10 +427,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
prmAffiliate.AssociationType = Sbm.AssociationType.Member;
|
||||
prmAffiliate.TargetSupervised = SbmAffiliate.Params.Supervised.Yes;
|
||||
foreach (SbmAffiliate affiliate in GetAffiliateList(prmAffiliate))
|
||||
{
|
||||
affiliateIdNames.Add(affiliate.Id, affiliate.Name);
|
||||
affiliate.Dispose();
|
||||
}
|
||||
return affiliateIdNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,13 +350,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
if (errField.TaxCodeId != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.TaxCodeId))
|
||||
{
|
||||
// Association TaxCode.
|
||||
using (SaTaxCode taxCode = Internals.GetTaxCodeById(data.TaxCodeId))
|
||||
SaTaxCode taxCode = Internals.GetTaxCodeById(data.TaxCodeId);
|
||||
if (taxCode == null)
|
||||
{
|
||||
if (taxCode == null)
|
||||
{
|
||||
errField.TaxCodeId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Tax Code not found");
|
||||
}
|
||||
errField.TaxCodeId = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Tax Code not found");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -78,13 +78,11 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
else
|
||||
{
|
||||
// Retrieve the parent and make a note of its parent.
|
||||
using (SbmPortfolioItem parentPortfolioItem = GetPortfolioItemById(itemIdParent))
|
||||
{
|
||||
if (parentPortfolioItem != null)
|
||||
itemIdParent = parentPortfolioItem.ItemIdParent;
|
||||
else
|
||||
itemIdParent = new SysId();
|
||||
}
|
||||
SbmPortfolioItem parentPortfolioItem = GetPortfolioItemById(itemIdParent);
|
||||
if (parentPortfolioItem != null)
|
||||
itemIdParent = parentPortfolioItem.ItemIdParent;
|
||||
else
|
||||
itemIdParent = new SysId();
|
||||
}
|
||||
}
|
||||
return publishedToWebStore;
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
List<SbmCostEstimate> costEstimatesCopy = null;
|
||||
if (commodity.CostEstimates == null && SysId.IsValid(commodity.Id))
|
||||
{
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
SbmItemLink.Params prmItemLink = new SbmItemLink.Params();
|
||||
prmItemLink.ItemLinkType = Sbm.ItemLinkType.ItemCostEstimate;
|
||||
@@ -221,7 +221,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
List<SbmItemLink> itemLinks = DataItemMgr.GetItemLinkList(prmItemLink);
|
||||
if (itemLinks != null)
|
||||
{
|
||||
disposables.AddRange(itemLinks);
|
||||
foreach (SbmItemLink itemLink in itemLinks)
|
||||
{
|
||||
SbmCostEstimate costEstimate = new SbmCostEstimate(itemLink.DataContent);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.8.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.8.3" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.10.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.10.1" />
|
||||
<PackageReference Include="System.Data.Odbc" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
[TestMethod]
|
||||
public void Test_Application_SessionData_Serialization()
|
||||
{
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Internals.
|
||||
SbmcAccountMgr accountMgr = Internals_Control.ControlAccountMgr;
|
||||
@@ -42,7 +42,6 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
|
||||
// User account.
|
||||
SbmcUserAccount userAccount = accountMgr.GetUserAccountByEmailAddress("andy@sarand.com");
|
||||
disposables.Add(userAccount);
|
||||
Assert.IsNotNull(userAccount);
|
||||
|
||||
// Session Context?
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
public void Test_Application_Internals_Control()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Control internals.
|
||||
Assert.IsNotNull(Internals_Control);
|
||||
@@ -82,11 +82,10 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
public void Test_Application_CoreInstanceConsole()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Repository.
|
||||
SbmcRepository repository = GetRandomActiveRepository();
|
||||
disposables.Add(repository);
|
||||
Assert.IsNotNull(repository);
|
||||
|
||||
// Instance console.
|
||||
@@ -101,11 +100,10 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
public void Test_Application_Internals_Core()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Repository.
|
||||
SbmcRepository repository = GetRandomActiveRepository();
|
||||
disposables.Add(repository);
|
||||
Assert.IsNotNull(repository);
|
||||
|
||||
// Instance console.
|
||||
@@ -120,11 +118,10 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
public void Test_Application_SessionContexts()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Repository.
|
||||
SbmcRepository repository = GetRandomActiveRepository();
|
||||
disposables.Add(repository);
|
||||
Assert.IsNotNull(repository);
|
||||
|
||||
SbmCoreInstanceConsole instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
|
||||
|
||||
@@ -73,13 +73,8 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
// Core Instance Console.
|
||||
protected SbmCoreInstanceConsole_Control CreateCoreInstanceConsole(String repositoryContext)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
{
|
||||
SbmcRepository repository = Internals_Control.ControlInstanceMgr.GetRepositoryByContext(repositoryContext);
|
||||
disposables.Add(repository);
|
||||
return new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
|
||||
}
|
||||
SbmcRepository repository = Internals_Control.ControlInstanceMgr.GetRepositoryByContext(repositoryContext);
|
||||
return new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>Sarand.BusinessMgr.Test</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.8.3" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.8.3" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.10.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.10.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
public void Test_PasswordEncoding()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Session configuration.
|
||||
string repositoryContext = "Mimo";
|
||||
@@ -51,7 +51,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
Dictionary<string, string> passwordHashes = new Dictionary<string, string>();
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Session configuration.
|
||||
string repositoryContext = "Mimo";
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
public void Test_SessionData_Demo()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Demo Session configuration.
|
||||
string repositoryContext = Sbm.RepositoryContext_Demo;
|
||||
@@ -49,7 +49,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
public void Test_SessionData_NonDemo()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Non-Demo Session configuration.
|
||||
string repositoryContext = "Mimo";
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
public void Test_Application_ControlInternals()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Control database.
|
||||
SbmInternals_Control internalsControl = new SbmInternals_Control();
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
public void Test_Application_SessionData_Serialization()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Session configuration.
|
||||
string repositoryContext = "Mimo";
|
||||
@@ -163,7 +163,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
public void Test_Application_SessionData_SecurityProfile()
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
// Initialisation.
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
/// </summary>
|
||||
public ushort GetCoreSessionIndexForControlRepository(SysId ownerId, SysId repositoryId)
|
||||
{
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
CoreInstanceContextData sessionContext = coreInstances.Values.FirstOrDefault(item => item.ControlRepositoryId.Equals(repositoryId));
|
||||
if (sessionContext != null) return sessionContext.SessionContext.Index;
|
||||
@@ -143,7 +143,6 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
SbmcInstanceMgr instanceMgr = System.CreateControlInstanceMgr();
|
||||
disposables.Add(instanceMgr);
|
||||
SbmcRepository repository = instanceMgr.GetRepositoryById(repositoryId);
|
||||
disposables.Add(repository);
|
||||
if (repository != null)
|
||||
{
|
||||
// Core database connection.
|
||||
@@ -216,7 +215,7 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
{
|
||||
Development = env.IsDevelopment();
|
||||
environmentName = env.EnvironmentName;
|
||||
SaLogger.LogFilenamePrefix = "Sbm-Web-Adm";
|
||||
SaLogger.LogFilenamePrefix = "Sbm-Web-Ctl";
|
||||
SaLogger.IncludeHostInFileMessage = false;
|
||||
SaLogger.IncludeUserInFileMessage = false;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Sarand.BusinessMgr.Web.Control.Components
|
||||
protected bool SignUserIn(SbmcUserAccount userAccount, bool keepLoggedIn, ref string errorMessage)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Validate User Account, just in case - should have been done before arriving here!
|
||||
if (userAccount == null)
|
||||
@@ -160,25 +160,23 @@ namespace Sarand.BusinessMgr.Web.Control.Components
|
||||
string logSuffix = keepLoggedInParams.GetValidParams().Concat("", " ", ".");
|
||||
if (keepLoggedInParams.IsValid())
|
||||
{
|
||||
using (SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(keepLoggedInParams.UserAccountId))
|
||||
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(keepLoggedInParams.UserAccountId);
|
||||
if (userAccount != null)
|
||||
{
|
||||
if (userAccount != null)
|
||||
if (userAccount.IsStatusActive)
|
||||
{
|
||||
if (userAccount.IsStatusActive)
|
||||
string errorMessage = "";
|
||||
if (SignUserIn(userAccount, true, ref errorMessage))
|
||||
{
|
||||
string errorMessage = "";
|
||||
if (SignUserIn(userAccount, true, ref errorMessage))
|
||||
{
|
||||
// Successful login.
|
||||
SaLogger.Info($"{SysUtil.Fn} Keep Logged In cookie found.{logSuffix}");
|
||||
return true;
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but failed to sign user in: {errorMessage}.{logSuffix}");
|
||||
// Successful login.
|
||||
SaLogger.Info($"{SysUtil.Fn} Keep Logged In cookie found.{logSuffix}");
|
||||
return true;
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but UserAccount is not active.{logSuffix}");
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but failed to sign user in: {errorMessage}.{logSuffix}");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but UserAccount not found.{logSuffix}");
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but UserAccount is not active.{logSuffix}");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but UserAccount not found.{logSuffix}");
|
||||
}
|
||||
ClearKeepLoggedInCookie();
|
||||
return false;
|
||||
|
||||
+4
-8
@@ -181,7 +181,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -191,7 +191,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account
|
||||
|
||||
// Retrieve item.
|
||||
SbmcUserAccount user = ControlAccountMgr.GetUserAccountById(userAccountId);
|
||||
disposables.Add(user);
|
||||
if (user == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve user for Id: '" + userAccountId + "'");
|
||||
@@ -222,7 +221,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify user.
|
||||
@@ -234,7 +233,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account
|
||||
|
||||
// Retrieve user.
|
||||
SbmcUserAccount user = ControlAccountMgr.GetUserAccountByEmailAddress(model.Filter.EmailAddress);
|
||||
disposables.Add(user);
|
||||
if (user == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve user for Email: " + model.Filter.EmailAddress);
|
||||
@@ -283,12 +281,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmcUserAccount user = ControlAccountMgr.GetUserAccountById(userAccountId);
|
||||
disposables.Add(user);
|
||||
if (user == null && SysId.IsValid(userAccountId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve user for Id: '" + model.User.Id + "'");
|
||||
@@ -364,13 +361,12 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Account
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve user.
|
||||
SysId userAccountId = SysId.ToSysId(model.User.Id);
|
||||
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(userAccountId);
|
||||
disposables.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve user for Id: '" + model.User.Id + "'");
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -175,7 +175,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Retrieve item.
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(ownerId);
|
||||
disposables.Add(owner);
|
||||
if (owner == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve owner for Id: '" + ownerId + "'");
|
||||
@@ -224,12 +223,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(ownerId);
|
||||
disposables.Add(owner);
|
||||
if (owner == null && SysId.IsValid(ownerId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve owner for Id: '" + model.Owner.Id + "'");
|
||||
|
||||
+3
-8
@@ -164,7 +164,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -174,7 +174,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Retrieve item.
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(repositoryId);
|
||||
disposables.Add(repository);
|
||||
if (repository == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve repository for Id: '" + repositoryId + "'");
|
||||
@@ -183,7 +182,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Owner.
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(repository.OwnerId);
|
||||
disposables.Add(owner);
|
||||
if (owner == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve owner for Id: '" + repository.OwnerId + "'");
|
||||
@@ -231,7 +229,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -241,7 +239,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Retrieve item.
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(repositoryId);
|
||||
disposables.Add(repository);
|
||||
if (repository == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve repository for Id: '" + repositoryId + "'");
|
||||
@@ -309,12 +306,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(repositoryId);
|
||||
disposables.Add(repository);
|
||||
if (repository == null && SysId.IsValid(repositoryId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve repository for Id: '" + model.Repository.Id + "'");
|
||||
@@ -324,7 +320,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
// Owner.
|
||||
SysId ownerId = repository?.OwnerId ?? SysId.ToSysId(model.Repository.OwnerId);
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(ownerId);
|
||||
disposables.Add(owner);
|
||||
if (owner == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve owner for Id: '" + ownerId + "'");
|
||||
|
||||
+2
-4
@@ -59,7 +59,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Validate Repository.
|
||||
@@ -70,7 +70,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryByContext(model.DatabaseFilter.Context);
|
||||
disposables.Add(repository);
|
||||
if (repository == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Context: {model.DatabaseFilter.Context}.");
|
||||
@@ -165,7 +164,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Validate Repository.
|
||||
@@ -176,7 +175,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryByContext(model.DatabaseFilter.Context);
|
||||
disposables.Add(repository);
|
||||
if (repository == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Context: {model.DatabaseFilter.Context}.");
|
||||
|
||||
+2
-14
@@ -98,7 +98,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Validate Repository.
|
||||
@@ -109,7 +109,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(repositoryId);
|
||||
disposables.Add(repository);
|
||||
if (repository == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Id: {repositoryId}.");
|
||||
@@ -120,7 +119,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Owner.
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(repository.OwnerId);
|
||||
disposables.Add(owner);
|
||||
if (owner == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Owner does not exist. Id: {repository.OwnerId}.");
|
||||
@@ -140,9 +138,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
foreach (SbmAssociation association in instanceConsole.Internals.AccountMgr.GetAssociationList(prm))
|
||||
{
|
||||
// Retrieve Organisation details.
|
||||
disposables.Add(association);
|
||||
SbmAffiliate affiliateOrganisation = instanceConsole.Internals.AccountMgr.GetAffiliateById(association.AffiliateIdOwner);
|
||||
disposables.Add(affiliateOrganisation);
|
||||
|
||||
// Organisation details.
|
||||
RepositoryOrganisationData organisation = new RepositoryOrganisationData()
|
||||
@@ -163,12 +159,9 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
prmAffiliateUser.SortColumns.Add(instanceConsole.Internals.AccountMgr.GetAffiliateColumnDfn(SbmAffiliate.Column.Id));
|
||||
foreach (SbmAffiliate affiliateUser in instanceConsole.Internals.AccountMgr.GetAffiliateList(prmAffiliateUser))
|
||||
{
|
||||
disposables.Add(affiliateUser);
|
||||
|
||||
// Lookup security details.
|
||||
if (!SysId.IsValid(affiliateUser.UserId)) continue;
|
||||
SaSecurityItem securityItemUser = instanceConsole.Internals.SecurityConsole.GetSecurityItemById(SaSecurity.ItemType.User, affiliateUser.UserId);
|
||||
disposables.Add(securityItemUser);
|
||||
if (securityItemUser == null) continue;
|
||||
|
||||
// Confirm security rights (SuperUser).
|
||||
@@ -219,7 +212,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Validate Repository.
|
||||
@@ -230,7 +223,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SbmcRepository repository = ControlInstanceMgr.GetRepositoryById(repositoryId);
|
||||
disposables.Add(repository);
|
||||
if (repository == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Id: {repositoryId}.");
|
||||
@@ -254,7 +246,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Validate Organisation Affiliate.
|
||||
SbmAffiliate affiliateOrganisation = instanceConsole.Internals.AccountMgr.GetAffiliateById(affiliateIdOrganisation);
|
||||
disposables.Add(affiliateOrganisation);
|
||||
if (affiliateOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Affiliate not found for existing Organisation. Id: {model.Organisation.AffiliateId}.");
|
||||
@@ -278,7 +269,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
{
|
||||
// Validate Internal Association.
|
||||
SbmAssociation associationOrganisation = instanceConsole.Internals.AccountMgr.GetAssociationById(associationIdInternal);
|
||||
disposables.Add(associationOrganisation);
|
||||
if (associationOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Association not found for existing Organisation. Id: {model.Organisation.AssociationId}.");
|
||||
@@ -329,7 +319,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
|
||||
// Validate User Affiliate.
|
||||
SbmAffiliate affiliateUser = instanceConsole.Internals.AccountMgr.GetAffiliateById(affiliateIdUser);
|
||||
disposables.Add(affiliateUser);
|
||||
if (affiliateUser == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Affiliate not found for existing User. Id: {model.User.AffiliateId}.");
|
||||
@@ -352,7 +341,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
{
|
||||
// Validate User Security Item.
|
||||
SaSecurityItem securityItemUser = instanceConsole.Internals.SecurityConsole.GetSecurityItemById(SaSecurity.ItemType.User, secItemIdUser);
|
||||
disposables.Add(securityItemUser);
|
||||
if (securityItemUser == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Security Item not found for existing User. Id: {model.User.SecurityItemId}.");
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Param
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -287,7 +287,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Param
|
||||
|
||||
// Retrieve item.
|
||||
SbmcItemParam itemParam = ControlItemMgr.GetItemParamById(itemParamId);
|
||||
disposables.Add(itemParam);
|
||||
if (itemParam == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve itemParam for Id: '" + itemParamId + "'");
|
||||
@@ -336,12 +335,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Param
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmcItemParam itemParam = ControlItemMgr.GetItemParamById(itemParamId);
|
||||
disposables.Add(itemParam);
|
||||
if (itemParam == null && SysId.IsValid(itemParamId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Item Param for Id: '" + model.Param.Id + "'");
|
||||
|
||||
+5
-11
@@ -42,12 +42,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Get user account.
|
||||
SbmcUserAccount userAccount = GetUserAccountForSignin(model, responseData);
|
||||
disposables.Add(userAccount);
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
@@ -100,7 +99,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
SbmcUserAccount userAccount = null;
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify user account.
|
||||
@@ -108,7 +107,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
prmUserAccount.EmailAddress = model.EmailAddress;
|
||||
prmUserAccount.StatusCat = SbmcUserAccount.StatusCat.Any;
|
||||
List<SbmcUserAccount> userAccounts = ControlAccountMgr.GetUserAccountList(prmUserAccount);
|
||||
disposables.AddRange(userAccounts);
|
||||
foreach (SbmcUserAccount userAccountCandidate in userAccounts)
|
||||
{
|
||||
// Account must be active to allow sign-in.
|
||||
@@ -165,12 +163,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
return Json(responseData.SetSessionExpired(messageTitle, Localiser["security.msg.warn.sessionExpired"]));
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve user account - in case sign-out needs to be recorded.
|
||||
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(SessionData_Control.User.UserAccountId);
|
||||
disposables.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} System error on sign-out - failed to retrieve account details. Id: " + SysId.ToInt(SessionData_Control.User.UserAccountId));
|
||||
@@ -230,7 +227,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
String messageTitle = Localiser["caption.change.password"];
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// If 'Request Password' encrypted params (from email link) are present,
|
||||
@@ -243,7 +240,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
{
|
||||
// Retrieve user account details and validate email address.
|
||||
userAccount = ControlAccountMgr.GetUserAccountById(requestPasswordParams.UserAccountId);
|
||||
disposables.Add(userAccount);
|
||||
if (requestPasswordParams.IsValid(userAccount))
|
||||
{
|
||||
validRequestPasswordParams = true;
|
||||
@@ -264,7 +260,6 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
if (userAccount == null && SessionData_Control != null)
|
||||
{
|
||||
userAccount = ControlAccountMgr.GetUserAccountById(SessionData_Control.User.UserAccountId);
|
||||
disposables.Add(userAccount);
|
||||
}
|
||||
if (userAccount == null)
|
||||
return Json(responseData.SetControlError(nameof(model.Password), "System error - failed to retrieve account details."));
|
||||
@@ -336,12 +331,11 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve user account.
|
||||
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountByEmailAddress(model.EmailAddress);
|
||||
disposables.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to " + model.EmailAddress + " - account does not exist");
|
||||
else if (!userAccount.IsStatusActive)
|
||||
|
||||
@@ -68,32 +68,30 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers
|
||||
if (requestPasswordParams.IsValid())
|
||||
{
|
||||
String logSuffix = requestPasswordParams.GetValidParams().Concat("", " ", ".");
|
||||
using (SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(requestPasswordParams.UserAccountId))
|
||||
SbmcUserAccount userAccount = ControlAccountMgr.GetUserAccountById(requestPasswordParams.UserAccountId);
|
||||
if (userAccount != null)
|
||||
{
|
||||
if (userAccount != null)
|
||||
if (userAccount.IsStatusActive)
|
||||
{
|
||||
if (userAccount.IsStatusActive)
|
||||
if (requestPasswordParams.IsValid(userAccount))
|
||||
{
|
||||
if (requestPasswordParams.IsValid(userAccount))
|
||||
{
|
||||
model.rpe = encryptedParams;
|
||||
validSessionRequired = false;
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but invalid. {logSuffix}");
|
||||
model.rpe = encryptedParams;
|
||||
validSessionRequired = false;
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but account is not active. {logSuffix}");
|
||||
else SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but invalid. {logSuffix}");
|
||||
}
|
||||
else
|
||||
else SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but account is not active. {logSuffix}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// User Account not found - redirect to Portal application.
|
||||
String redirectParamName = ParamName_RequestPasswordEncrypted + "2";
|
||||
SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but account is not 'Admin'. {logSuffix}");
|
||||
if (!Request.Query.Keys.Contains(redirectParamName) && !StringUtil.IsEmpty(AppConfig.URL.Portal.Root))
|
||||
{
|
||||
// User Account not found - redirect to Portal application.
|
||||
String redirectParamName = ParamName_RequestPasswordEncrypted + "2";
|
||||
SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but account is not 'Admin'. {logSuffix}");
|
||||
if (!Request.Query.Keys.Contains(redirectParamName) && !StringUtil.IsEmpty(AppConfig.URL.Portal.Root))
|
||||
{
|
||||
UriBuilder uri = new UriBuilder(Regex.Replace(AppConfig.URL.Portal.Root, "/$", "") + "/Security/ChangePassword");
|
||||
uri.Query = $"{ParamName_RequestPasswordEncrypted}={Uri.EscapeDataString(encryptedParams)}&{redirectParamName}";
|
||||
return Redirect(uri.Uri.OriginalString);
|
||||
}
|
||||
UriBuilder uri = new UriBuilder(Regex.Replace(AppConfig.URL.Portal.Root, "/$", "") + "/Security/ChangePassword");
|
||||
uri.Query = $"{ParamName_RequestPasswordEncrypted}={Uri.EscapeDataString(encryptedParams)}&{redirectParamName}";
|
||||
return Redirect(uri.Uri.OriginalString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.System
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposableItems = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposableItems = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Database instance.
|
||||
Sbm.Database databaseInstance = EnumUtil.ParseEnum(StringUtil.EmptyOnNull(model.DatabaseFilter.Instance), Sbm.Database.Unknown);
|
||||
@@ -190,7 +190,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.System
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposableItems = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposableItems = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Database instance.
|
||||
@@ -438,7 +438,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.System
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposableItems = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposableItems = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Parameters.
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Account
|
||||
public bool ValidateUserData(Sacs.Web.Components.SaController.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// User email.
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Instance
|
||||
public bool ValidateOwnerData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Owner name.
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Instance
|
||||
public bool ValidateRepositoryData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Repository Owner.
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Instance
|
||||
public bool ValidateRepositoryData(SbmController_Base.AjaxResponse_Data responseData, SbmcRepository repository)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Sarand.BusinessMgr.Web.Control.Models.Param
|
||||
public bool ValidateParamData(Sacs.Web.Components.SaController.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
// Check whether data suggests that Param exists.
|
||||
bool paramExists = StringUtil.ToBool(Param.Exists) && SysId.IsValid(SysId.ToSysId(Param.Id));
|
||||
|
||||
@@ -61,10 +61,10 @@
|
||||
<tr>
|
||||
<th class="width20pc pl-1">@Localiser["label.schema"]</th>
|
||||
<th class="width25pc">@Localiser["label.table"]</th>
|
||||
<th class="width10pc center">@Localiser["label.rows"]</th>
|
||||
<th class="width10pc center">@Localiser["label.columns"]</th>
|
||||
<th class="width10pc center">@Localiser["label.indices"]</th>
|
||||
<th class="width10pc center">@Localiser["label.rows"]</th>
|
||||
<th class="width5pc"></th>
|
||||
<th class="width1pc"></th>
|
||||
</tr>
|
||||
<tr><td colspan="6"><div class="sbc-panel-messages"></div></td></tr>
|
||||
</thead>
|
||||
@@ -83,9 +83,9 @@
|
||||
<tr class="sbc-row-item Table">
|
||||
<td><div class="SchemaName pl-1"></div></td>
|
||||
<td><div class="TableName"></div></td>
|
||||
<td><div class="RowCount center"></div></td>
|
||||
<td><div class="ColumnCount center"></div></td>
|
||||
<td><div class="IndexCount center"></div></td>
|
||||
<td><div class="RowCount center"></div></td>
|
||||
<td>
|
||||
<div class="right">
|
||||
@* Burger menu *@
|
||||
|
||||
@@ -172,9 +172,18 @@ ul.nav.sbc-burger.navbar-dark .dropdown:hover
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
|
||||
ul.nav.sbc-burger .sbc-ellipsis-dot
|
||||
ul.nav.sbc-burger a .sbc-ellipsis-dot
|
||||
{
|
||||
display: inline-block;
|
||||
width: 2px;
|
||||
height: 2px;
|
||||
margin: 1px 2px 4px 2px;
|
||||
background-color: #808080;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
ul.nav.sbc-burger a:hover .sbc-ellipsis-dot
|
||||
{
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
margin: 0 1px 3px 1px;
|
||||
|
||||
@@ -54,9 +54,13 @@
|
||||
$item.prop('id', cd.getItemId(item));
|
||||
$('.SchemaName', $item).text(item.schemaName);
|
||||
$('.TableName', $item).text(item.tableName);
|
||||
if (item.rowCount) $('.RowCount', $item).text(item.rowCount);
|
||||
if (item.columnCount) $('.ColumnCount', $item).text(item.columnCount);
|
||||
if (item.indexCount) $('.IndexCount', $item).text(item.indexCount);
|
||||
if (item.rowCount) $('.RowCount', $item).text(item.rowCount);
|
||||
// Actions.
|
||||
var $bgr = $('.sbc-burger', $item).hide();
|
||||
let $mnu = $('ul.sbc-dropdown-menu', $bgr).empty();
|
||||
$bgr.toggle(!!$('.sbc-dropdown-item', $mnu).length);
|
||||
return $item;
|
||||
}
|
||||
cd.getItemId = function (item)
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
Development = env.IsDevelopment();
|
||||
environmentName = env.EnvironmentName;
|
||||
SaLogger.LogFilenamePrefix = "Sbm-Web-Onl";
|
||||
SaLogger.LogFilenamePrefix = "Sbm-Web-Prt";
|
||||
SaLogger.IncludeHostInFileMessage = false;
|
||||
SaLogger.IncludeUserInFileMessage = false;
|
||||
|
||||
@@ -262,11 +262,9 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
SbmcRepository.Params prmRepository = new SbmcRepository.Params();
|
||||
prmRepository.ContextsIncluded.Add(repositoryContext);
|
||||
SbmcRepository repository = controlInstanceMgr.GetRepository(prmRepository);
|
||||
disposables.Add(repository);
|
||||
|
||||
// Retrieve Repository Owner.
|
||||
SbmcOwner owner = controlInstanceMgr.GetOwnerById(repository?.OwnerId);
|
||||
disposables.Add(owner);
|
||||
|
||||
// Validate configuration.
|
||||
if (repository != null && owner != null)
|
||||
|
||||
@@ -212,35 +212,34 @@ namespace Sarand.BusinessMgr.Web.Portal.Components
|
||||
SbmSessionData_Portal sessionDataForUser = new SbmSessionData_Portal(sessionContext, keepLoggedInParams.RepositoryContext, null, null, null, null);
|
||||
using (SbmInternals internalsForUser = new SbmInternals(sessionDataForUser))
|
||||
{
|
||||
using (SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(keepLoggedInParams.EmailAddress))
|
||||
using (SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(keepLoggedInParams.AffiliateIdUser))
|
||||
using (SbmAssociation associationOrganisation = internalsForUser.AccountMgr.GetAssociationById(keepLoggedInParams.AssociationIdOrganisation))
|
||||
using (SbmAffiliate affiliateOrganisation = internalsForUser.AccountMgr.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null))
|
||||
SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(keepLoggedInParams.EmailAddress);
|
||||
SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(keepLoggedInParams.AffiliateIdUser);
|
||||
SbmAssociation associationOrganisation = internalsForUser.AccountMgr.GetAssociationById(keepLoggedInParams.AssociationIdOrganisation);
|
||||
SbmAffiliate affiliateOrganisation = internalsForUser.AccountMgr.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null);
|
||||
|
||||
if (securityItemUser != null && affiliateUser != null && associationOrganisation != null && affiliateOrganisation != null)
|
||||
{
|
||||
if (securityItemUser != null && affiliateUser != null && associationOrganisation != null && affiliateOrganisation != null)
|
||||
if (securityItemUser.Id.Equals(keepLoggedInParams.SecurityItemId) && affiliateUser.UserId.Equals(securityItemUser.Id))
|
||||
{
|
||||
if (securityItemUser.Id.Equals(keepLoggedInParams.SecurityItemId) && affiliateUser.UserId.Equals(securityItemUser.Id))
|
||||
if (affiliateUser.IsStatusCurrent)
|
||||
{
|
||||
if (affiliateUser.IsStatusCurrent)
|
||||
// Bring the Session Data up to date with the session properties.
|
||||
sessionDataForUser.Refresh(securityItemUser, affiliateUser, associationOrganisation, affiliateOrganisation);
|
||||
string errorMessage = "";
|
||||
if (SignUserIn(sessionDataForUser, internalsForUser, securityItemUser, affiliateUser, associationOrganisation, affiliateOrganisation, true, ref errorMessage))
|
||||
{
|
||||
// Bring the Session Data up to date with the session properties.
|
||||
sessionDataForUser.Refresh(securityItemUser, affiliateUser, associationOrganisation, affiliateOrganisation);
|
||||
string errorMessage = "";
|
||||
if (SignUserIn(sessionDataForUser, internalsForUser, securityItemUser, affiliateUser, associationOrganisation, affiliateOrganisation, true, ref errorMessage))
|
||||
{
|
||||
// User auto-login successful.
|
||||
SaLogger.Info(logPrefix + " 'Keep Logged In' cookie found." + logSuffix);
|
||||
return true;
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "failed to sign user in: " + errorMessage + "." + logSuffix);
|
||||
// User auto-login successful.
|
||||
SaLogger.Info(logPrefix + " 'Keep Logged In' cookie found." + logSuffix);
|
||||
return true;
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Affiliate is not active." + logSuffix);
|
||||
else SaLogger.Warn(logPrefix + "failed to sign user in: " + errorMessage + "." + logSuffix);
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Security Item and Affiliate are inconsistent. " + logSuffix);
|
||||
else SaLogger.Warn(logPrefix + "Affiliate is not active." + logSuffix);
|
||||
}
|
||||
else if (!demoContext)
|
||||
SaLogger.Warn(logPrefix + "Security Item or Affiliate not found. " + logSuffix);
|
||||
else SaLogger.Warn(logPrefix + "Security Item and Affiliate are inconsistent. " + logSuffix);
|
||||
}
|
||||
else if (!demoContext)
|
||||
SaLogger.Warn(logPrefix + "Security Item or Affiliate not found. " + logSuffix);
|
||||
}
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Keep Logged In cookie found but no matching session contexts found." + logSuffix);
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -347,7 +347,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
|
||||
|
||||
// Retrieve item.
|
||||
SbmAddress address = AccountMgr.GetAddressById(addressId);
|
||||
disposables.Add(address);
|
||||
if (address == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve address for Id: '{model.Address.Id}'");
|
||||
@@ -398,12 +397,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
|
||||
}
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmAddress address = AccountMgr.GetAddressById(addressId);
|
||||
disposables.Add(address);
|
||||
if (address == null && SysId.IsValid(addressId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve address for Id: '{model.Address.Id}'");
|
||||
@@ -430,7 +428,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
|
||||
if (address == null)
|
||||
{
|
||||
address = AccountMgr.CreateAddress((Sbm.ItemType)addressItemId.Type, addressItemId.Id, model.GetAddressType());
|
||||
disposables.Add(address);
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
@@ -536,7 +533,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -546,7 +543,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
|
||||
|
||||
// Retrieve item.
|
||||
SbmAddress address = AccountMgr.GetAddressById(addressId);
|
||||
disposables.Add(address);
|
||||
if (address == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve address for Id: '{model.Address.Id}'");
|
||||
|
||||
+2
-5
@@ -261,7 +261,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -271,7 +271,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
|
||||
// Retrieve item.
|
||||
SbmAssetCategory assetCategory = AssetMgr.GetAssetCategoryById(assetCategoryId);
|
||||
disposables.Add(assetCategory);
|
||||
if (assetCategory == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve assetCategory for Id: '" + assetCategoryId + "'");
|
||||
@@ -321,12 +320,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmAssetCategory assetCategory = AssetMgr.GetAssetCategoryById(assetCategoryId);
|
||||
disposables.Add(assetCategory);
|
||||
if (assetCategory == null && SysId.IsValid(assetCategoryId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Asset Category for Id: '" + model.AssetCategory.Id + "'");
|
||||
@@ -343,7 +341,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
assetCategory = AssetMgr.CreateAssetCategory(model.AssetCategory.AssetType);
|
||||
disposables.Add(assetCategory);
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -266,7 +266,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
|
||||
// Retrieve item.
|
||||
SbmAsset asset = AssetMgr.GetAssetById(assetId);
|
||||
disposables.Add(asset);
|
||||
if (asset == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve asset for Id: '" + assetId + "'");
|
||||
@@ -275,7 +274,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
|
||||
// Retrieve category.
|
||||
SbmAssetCategory assetCategory = AssetMgr.GetAssetCategoryById(asset.AssetCategoryId);
|
||||
disposables.Add(assetCategory);
|
||||
if (assetCategory == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve asset category for Id: '" + asset.AssetCategoryId + "'");
|
||||
@@ -325,12 +323,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmAsset asset = AssetMgr.GetAssetById(assetId);
|
||||
disposables.Add(asset);
|
||||
if (asset == null && SysId.IsValid(assetId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Asset for Id: '" + model.Asset.Id + "'");
|
||||
@@ -342,7 +339,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
if (asset != null)
|
||||
{
|
||||
assetCategory = AssetMgr.GetAssetCategoryById(asset.AssetCategoryId);
|
||||
disposables.Add(assetCategory);
|
||||
if (assetCategory == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Asset Category for existing Asset. Id: '" + asset.AssetCategoryId + "'");
|
||||
@@ -352,7 +348,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Assets
|
||||
else
|
||||
{
|
||||
assetCategory = AssetMgr.GetAssetCategoryById(SysId.ToSysId(model.Asset.CategoryId));
|
||||
disposables.Add(assetCategory);
|
||||
if (assetCategory == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Asset Category for new Asset. Id: '" + model.Asset.CategoryId + "'");
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -190,7 +190,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
|
||||
// Retrieve item.
|
||||
SaCode code = CodeTypeConsole.GetCodeById(codeId);
|
||||
disposables.Add(code);
|
||||
if (code == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve code for Id: '" + codeId + "'");
|
||||
@@ -199,7 +198,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
|
||||
// Retrieve code type.
|
||||
SaCodeType codeType = CodeTypeConsole.GetCodeTypeById(code.CodeTypeId);
|
||||
disposables.Add(codeType);
|
||||
if (codeType == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve code type for Id: '" + code.CodeTypeId + "'");
|
||||
@@ -248,12 +246,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SaCode code = CodeTypeConsole.GetCodeById(codeId);
|
||||
disposables.Add(code);
|
||||
if (code == null && SysId.IsValid(codeId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Code Type for Id: '" + model.Code.Id + "'");
|
||||
@@ -265,7 +262,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
if (code != null)
|
||||
{
|
||||
codeType = CodeTypeConsole.GetCodeTypeById(code.CodeTypeId);
|
||||
disposables.Add(codeType);
|
||||
if (codeType == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Code Type for existing Code. Id: '" + code.CodeTypeId + "'");
|
||||
@@ -275,7 +271,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
else
|
||||
{
|
||||
codeType = CodeTypeConsole.GetCodeTypeByCode(model.Code.CodeTypeCode);
|
||||
disposables.Add(codeType);
|
||||
if (codeType == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Code Type for new Code. Code: '" + model.Code.CodeTypeCode + "'");
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -214,7 +214,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
|
||||
// Retrieve item.
|
||||
SaCodeType codeType = CodeTypeConsole.GetCodeTypeById(codeTypeId);
|
||||
disposables.Add(codeType);
|
||||
if (codeType == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Code Type for Id: {codeTypeId}.");
|
||||
@@ -263,12 +262,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Codes
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SaCodeType codeType = CodeTypeConsole.GetCodeTypeById(codeTypeId);
|
||||
disposables.Add(codeType);
|
||||
if (codeType == null && SysId.IsValid(codeTypeId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Asset Category for Id: {model.CodeType.Id}.");
|
||||
|
||||
+2
-5
@@ -367,7 +367,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -377,7 +377,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
|
||||
// Retrieve item.
|
||||
SbmCommodity commodity = CommodityMgr.GetCommodityById(commodityId);
|
||||
disposables.Add(commodity);
|
||||
if (commodity == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve commodity for Id: '{model.Commodity.Id}'");
|
||||
@@ -428,12 +427,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
}
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmCommodity commodity = CommodityMgr.GetCommodityById(commodityId);
|
||||
disposables.Add(commodity);
|
||||
if (commodity == null && SysId.IsValid(commodityId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve commodity for Id: '{model.Commodity.Id}'");
|
||||
@@ -444,7 +442,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
|
||||
if (commodity == null)
|
||||
{
|
||||
commodity = CommodityMgr.CreateCommodity(model.GetCommodityType(), model.Commodity.Code);
|
||||
disposables.Add(commodity);
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
|
||||
+5
-12
@@ -61,11 +61,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
else
|
||||
{
|
||||
// Retrieve owner contact details.
|
||||
using (SbmAffiliate affiliateOwner = AccountMgr.GetAffiliateById(association.AffiliateIdOwner))
|
||||
{
|
||||
if (affiliateOwner != null)
|
||||
data.Field.Value.Add($"{Model_Association.ItemField.Owner}", affiliateOwner.GetDisplayName());
|
||||
}
|
||||
SbmAffiliate affiliateOwner = AccountMgr.GetAffiliateById(association.AffiliateIdOwner);
|
||||
if (affiliateOwner != null)
|
||||
data.Field.Value.Add($"{Model_Association.ItemField.Owner}", affiliateOwner.GetDisplayName());
|
||||
}
|
||||
data.Field.Value.Add($"{Model_Association.ItemField.Target}", affiliateTarget.GetDisplayName());
|
||||
data.Field.Value.Add($"{Model_Association.ItemField.ReferenceExt}", association.RefExt);
|
||||
@@ -301,7 +299,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -311,7 +309,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
|
||||
// Retrieve item.
|
||||
SbmAssociation association = AccountMgr.GetAssociationById(associationId);
|
||||
disposables.Add(association);
|
||||
if (association == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve association for Id: '" + model.Association.Id + "'");
|
||||
@@ -319,7 +316,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
}
|
||||
|
||||
SbmAffiliate affiliateTarget = AccountMgr.GetAffiliateById(association.AffiliateIdTarget);
|
||||
disposables.Add(affiliateTarget);
|
||||
|
||||
// Construct response.
|
||||
model.PopulateItemConfig(responseData.Config, association, affiliateTarget);
|
||||
@@ -354,7 +350,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Validate item Id against 'Exists' flag.
|
||||
@@ -373,7 +369,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmAssociation association = AccountMgr.GetAssociationById(associationId);
|
||||
disposables.Add(association);
|
||||
if (association == null && SysId.IsValid(associationId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve association for Id: '" + model.Association.Id + "'");
|
||||
@@ -391,7 +386,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
}
|
||||
// New item.
|
||||
association = AccountMgr.CreateAssociation(SessionData_Portal.Organisation.AffiliateId, associationType, SysId.ToSysId(model.Association.TargetId));
|
||||
disposables.Add(association);
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
@@ -498,7 +492,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
|
||||
}
|
||||
|
||||
SbmAffiliate affiliateTarget = AccountMgr.GetAffiliateById(association.AffiliateIdTarget);
|
||||
disposables.Add(affiliateTarget);
|
||||
|
||||
// Construct response.
|
||||
model.PopulateItemConfig(responseData.Config, association, affiliateTarget);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Home
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
@@ -95,7 +95,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
|
||||
// User's security item.
|
||||
SaSecurityItem securityItemUser = GetSecurityItemForSignin(sessionDataForUser, internalsForUser.SecurityConsole, model);
|
||||
disposables.Add(securityItemUser);
|
||||
if (securityItemUser == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Security Item. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}.");
|
||||
@@ -109,7 +108,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
|
||||
// User's affiliate.
|
||||
SbmAffiliate affiliateUser = GetAffiliateForSignin(internalsForUser.AccountMgr, model, securityItemUser);
|
||||
disposables.Add(affiliateUser);
|
||||
if (affiliateUser == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Affiliate for signin. Database: {busMgrDatabase.DatabaseName}. UserId: {SysId.ToString(securityItemUser.Id)}.");
|
||||
@@ -121,7 +119,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
|
||||
// User's organisation association.
|
||||
SbmAssociation associationOrganisation = GetOrganisationAssociationForSignIn(internalsForUser, model, sessionDataForUser);
|
||||
disposables.Add(associationOrganisation);
|
||||
if (associationOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to identify Organisation Association. Database: {busMgrDatabase.DatabaseName}. Email: {model.EmailAddress}.");
|
||||
@@ -130,7 +127,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
|
||||
// User's organisation affiliate.
|
||||
SbmAffiliate affiliateOrganisation = internalsForUser.AccountMgr.GetAffiliateById(associationOrganisation?.AffiliateIdOwner ?? null);
|
||||
disposables.Add(affiliateOrganisation);
|
||||
if (affiliateOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Affiliate for organisation. Database: {busMgrDatabase.DatabaseName}. Id: " + SysId.ToString(associationOrganisation?.Id ?? null));
|
||||
@@ -167,7 +163,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
if (!securityConsoleForUser.UpdateSecurityItem(securityItemUser, userContext.DbUpdateInfo))
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to store invalid sign-in attempt against User: {model.EmailAddress}. {AccountMgr.ErrorStateMessage}", true);
|
||||
SaLogger.Warn($"{SysUtil.Fn} Attempt to sign-in to User {model.EmailAddress} with invalid password. Attempt: {securityItemUser.InvalidLoginCount}.", true);
|
||||
securityItemUser.Dispose(); securityItemUser = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -193,7 +188,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
if (affiliate.Status != SaStatus.Current)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Invalid Affiliate status for User Id: {SysId.ToString(securityItemUser.Id)}. Email: {model.EmailAddress}. Found: {affiliate.Status.ToString()}. Expected: Current.", true);
|
||||
affiliate.Dispose(); affiliate = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -395,9 +389,9 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
else
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} 'Request Password' parameters supplied but invalid. Email: {storePasswordParams.EmailAddress}. SecurityItemId: {SysId.ToString(storePasswordParams.SecurityItemId)}. AffiliateId: {SysId.ToString(storePasswordParams.AffiliateId)}.");
|
||||
if (securityItemUser != null) securityItemUser.Dispose(); securityItemUser = null;
|
||||
if (affiliateUser != null) affiliateUser.Dispose(); affiliateUser = null;
|
||||
if (internalsForUser != null) internalsForUser.Dispose(); internalsForUser = null;
|
||||
securityItemUser = null;
|
||||
affiliateUser = null;
|
||||
internalsForUser = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,21 +403,15 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
// User specific Internals if Request Password params supplied, otherwise use Session Internals for current User Session.
|
||||
SbmInternals internalsForStorePassword = internalsForUser ?? Internals;
|
||||
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
disposables.Add(internalsForUser);
|
||||
disposables.Add(securityItemUser);
|
||||
disposables.Add(affiliateUser);
|
||||
|
||||
// Retrieve user details if not previously populated.
|
||||
if (securityItemUser == null && SessionData_Portal != null)
|
||||
securityItemUser = internalsForStorePassword.SecurityConsole.GetSecurityItemById(SaSecurity.ItemType.User, SessionData_Portal.User.SecurityItemId);
|
||||
disposables.Add(securityItemUser);
|
||||
if (securityItemUser == null)
|
||||
return Json(responseData.SetControlError(nameof(model.Password), "System error - failed to retrieve security item details."));
|
||||
if (affiliateUser == null && SessionData_Portal != null)
|
||||
affiliateUser = internalsForStorePassword.AccountMgr.GetAffiliateById(SessionData_Portal.User.AffiliateId);
|
||||
disposables.Add(affiliateUser);
|
||||
if (affiliateUser == null)
|
||||
return Json(responseData.SetControlError(nameof(model.Password), "System error - failed to retrieve affiliate details."));
|
||||
|
||||
@@ -505,33 +493,31 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
|
||||
// Get user security item and affiliate.
|
||||
using (SbmInternals internalsForUser = new SbmInternals(sessionDataForUser))
|
||||
using (SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(model.EmailAddress))
|
||||
{
|
||||
SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(model.EmailAddress);
|
||||
if (securityItemUser != null)
|
||||
{
|
||||
using (SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateByUserId(securityItemUser.Id))
|
||||
SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateByUserId(securityItemUser.Id);
|
||||
if (affiliateUser != null)
|
||||
{
|
||||
if (affiliateUser != null)
|
||||
sessionDataForUser.Refresh(securityItemUser, affiliateUser, null, null);
|
||||
if (affiliateUser.Status == SaStatus.Current || affiliateUser.IsStatusActive)
|
||||
{
|
||||
sessionDataForUser.Refresh(securityItemUser, affiliateUser, null, null);
|
||||
if (affiliateUser.Status == SaStatus.Current || affiliateUser.IsStatusActive)
|
||||
{
|
||||
SbmEmailConsole emailConsole = internalsForUser.EmailConsole;
|
||||
SbmEmailConsole emailConsole = internalsForUser.EmailConsole;
|
||||
|
||||
// Send password request email.
|
||||
SaEmailData emailData = new SaEmailData();
|
||||
emailData.Config = App.EmailConfig;
|
||||
emailData.AddressesTo.Add(model.EmailAddress);
|
||||
emailData.Subject = $"BusinessMgr - {Localiser["caption.request.password"]}";
|
||||
PopulateRequestPasswordEmailBody(emailConsole, sessionDataForUser, emailData, securityItemUser, affiliateUser);
|
||||
if (emailConsole.SendEmail(emailData))
|
||||
SaLogger.Info($"{SysUtil.Fn} Password request email sent to {model.EmailAddress}.", true);
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Failed to send password request email to {model.EmailAddress}.");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate is not active");
|
||||
// Send password request email.
|
||||
SaEmailData emailData = new SaEmailData();
|
||||
emailData.Config = App.EmailConfig;
|
||||
emailData.AddressesTo.Add(model.EmailAddress);
|
||||
emailData.Subject = $"BusinessMgr - {Localiser["caption.request.password"]}";
|
||||
PopulateRequestPasswordEmailBody(emailConsole, sessionDataForUser, emailData, securityItemUser, affiliateUser);
|
||||
if (emailConsole.SendEmail(emailData))
|
||||
SaLogger.Info($"{SysUtil.Fn} Password request email sent to {model.EmailAddress}.", true);
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Failed to send password request email to {model.EmailAddress}.");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate does not exist. UserId: {SysId.ToString(securityItemUser.Id)}.");
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate is not active");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - affiliate does not exist. UserId: {SysId.ToString(securityItemUser.Id)}.");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Unable to send password request email to {model.EmailAddress} - security item does not exist.");
|
||||
}
|
||||
|
||||
@@ -101,29 +101,27 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
SbmSessionData_Portal sessionDataForUser = new SbmSessionData_Portal(sessionContext, changePasswordParams.RepositoryContext, null, null, null, null);
|
||||
using (SbmInternals internalsForUser = new SbmInternals(sessionDataForUser))
|
||||
{
|
||||
using (SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(changePasswordParams.EmailAddress))
|
||||
using (SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(changePasswordParams.AffiliateId))
|
||||
SaSecurityItem securityItemUser = internalsForUser.SecurityConsole.GetUserByEmail(changePasswordParams.EmailAddress);
|
||||
SbmAffiliate affiliateUser = internalsForUser.AccountMgr.GetAffiliateById(changePasswordParams.AffiliateId);
|
||||
sessionDataForUser.Refresh(securityItemUser, affiliateUser, null, null);
|
||||
if (securityItemUser != null && affiliateUser != null)
|
||||
{
|
||||
sessionDataForUser.Refresh(securityItemUser, affiliateUser, null, null);
|
||||
if (securityItemUser != null && affiliateUser != null)
|
||||
if (securityItemUser.Id.Equals(changePasswordParams.SecurityItemId) && affiliateUser.UserId.Equals(securityItemUser.Id))
|
||||
{
|
||||
if (securityItemUser.Id.Equals(changePasswordParams.SecurityItemId) && affiliateUser.UserId.Equals(securityItemUser.Id))
|
||||
if (affiliateUser.IsStatusCurrent)
|
||||
{
|
||||
if (affiliateUser.IsStatusCurrent)
|
||||
if (changePasswordParams.IsValid(securityItemUser, affiliateUser))
|
||||
{
|
||||
if (changePasswordParams.IsValid(securityItemUser, affiliateUser))
|
||||
{
|
||||
model.rpe = encryptedParams;
|
||||
validSessionRequired = false;
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Security Item and Affiliate are incompatible with parameters. " + logSuffix);
|
||||
model.rpe = encryptedParams;
|
||||
validSessionRequired = false;
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Affiliate is not active. " + logSuffix);
|
||||
else SaLogger.Warn(logPrefix + "Security Item and Affiliate are incompatible with parameters. " + logSuffix);
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Security Item and Affiliate are inconsistent. " + logSuffix);
|
||||
else SaLogger.Warn(logPrefix + "Affiliate is not active. " + logSuffix);
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Security Item or Affiliate not found. " + logSuffix);
|
||||
else SaLogger.Warn(logPrefix + "Security Item and Affiliate are inconsistent. " + logSuffix);
|
||||
}
|
||||
else SaLogger.Warn(logPrefix + "Security Item or Affiliate not found. " + logSuffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -170,7 +170,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Vehicles
|
||||
RefreshModel(model);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
@@ -180,7 +180,6 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Vehicles
|
||||
|
||||
// Retrieve item.
|
||||
SbmVehicleClass vehicleClass = AssetMgr.GetVehicleClassById(vehicleClassId);
|
||||
disposables.Add(vehicleClass);
|
||||
if (vehicleClass == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve vehicleClass for Id: '" + vehicleClassId + "'");
|
||||
@@ -229,12 +228,11 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Vehicles
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SbmVehicleClass vehicleClass = AssetMgr.GetVehicleClassById(vehicleClassId);
|
||||
disposables.Add(vehicleClass);
|
||||
if (vehicleClass == null && SysId.IsValid(vehicleClassId))
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve Vehicle Class for Id: '" + model.VehicleClass.Id + "'");
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets
|
||||
public bool ValidateAssetData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Asset Category.
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets
|
||||
public bool ValidateAssetCategoryData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// AssetCategory type.
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Codes
|
||||
public bool ValidateCodeData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Code Type.
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Codes
|
||||
public bool ValidateCodeTypeData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Code.
|
||||
|
||||
@@ -219,83 +219,78 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
|
||||
|
||||
if (!responseData.HasControlErrors())
|
||||
{
|
||||
using (DisposableCollection<SacsDisposable> disposables = new DisposableCollection<SacsDisposable>())
|
||||
// Retrieve existing commodity.
|
||||
SbmCommodity commodity = null;
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
{
|
||||
// Retrieve existing commodity.
|
||||
SbmCommodity commodity = null;
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
{
|
||||
commodity = CommodityMgr.GetCommodityById(SysId.ToSysId(Commodity.Id));
|
||||
disposables.Add(commodity);
|
||||
if (commodity == null)
|
||||
responseData.SetMessage(Localiser["label.commodity"], Localiser["msg.something.gone.wrong"]);
|
||||
}
|
||||
commodity = CommodityMgr.GetCommodityById(SysId.ToSysId(Commodity.Id));
|
||||
if (commodity == null)
|
||||
responseData.SetMessage(Localiser["label.commodity"], Localiser["msg.something.gone.wrong"]);
|
||||
}
|
||||
|
||||
if (!responseData.HasControlErrors())
|
||||
if (!responseData.HasControlErrors())
|
||||
{
|
||||
// Validate status.
|
||||
String controlName = "CommodityStatusCode";
|
||||
if (GetCommodityStatus() == SaStatus.Current)
|
||||
{
|
||||
// Validate status.
|
||||
String controlName = "CommodityStatusCode";
|
||||
if (GetCommodityStatus() == SaStatus.Current)
|
||||
// Check that no other current commodity exists with this code.
|
||||
SbmCommodity.Params prmCommodity = new SbmCommodity.Params();
|
||||
// Ignore this commodity if it already exists.
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.Id));
|
||||
// Ignore the commodity being superseded, if any.
|
||||
if (SysId.IsValid(SysId.ToSysId(Commodity.IdSupersede)))
|
||||
prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.IdSupersede));
|
||||
// Same code and issue.
|
||||
prmCommodity.CodeFull = Commodity.Code;
|
||||
prmCommodity.DrawingIssueFull = Commodity.DrawingIssue;
|
||||
// Restrict to same customer.
|
||||
prmCommodity.AssociationIdCustomer = Commodity.AssocIdCustomer != null ? SysId.ToSysId(Commodity.AssocIdCustomer) : commodity?.AssociationIdCustomer;
|
||||
prmCommodity.StatusCat = SbmCommodity.StatusCat.Current;
|
||||
List<SbmCommodity> commodities = CommodityMgr.GetCommodityList(prmCommodity);
|
||||
foreach (SbmCommodity commodityByCode in commodities)
|
||||
{
|
||||
// Check that no other current commodity exists with this code.
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
String msg = $"Another current Commodity already exists with this code: {Commodity.Code}.";
|
||||
if (SysId.IsValid(commodityByCode.AssociationIdCustomer))
|
||||
msg += $" Customer: {AccountMgr.GetAssociationTargetName(commodityByCode.AssociationIdCustomer)}.";
|
||||
else
|
||||
msg += $" Customer: None.";
|
||||
if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue))
|
||||
msg += $" Issue: {Commodity.DrawingIssue}.";
|
||||
else
|
||||
msg += $" Issue: None.";
|
||||
SaLogger.Warn($"{SysUtil.Fn} {msg}");
|
||||
responseData.SetControlError(GetFieldName(Model_Commodity.ItemField.Code), Localiser["msg.validation.duplicate.value"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (GetCommodityStatus() == SaStatus.Superseded)
|
||||
{
|
||||
// Has the status already been confirmed.
|
||||
if (!StringUtil.ToBool(Commodity.SupersededStatusConfirmed))
|
||||
{
|
||||
// Check that a current commodity exists with this code.
|
||||
SbmCommodity.Params prmCommodity = new SbmCommodity.Params();
|
||||
// Ignore this commodity if it already exists.
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.Id));
|
||||
// Ignore the commodity being superseded, if any.
|
||||
if (SysId.IsValid(SysId.ToSysId(Commodity.IdSupersede)))
|
||||
prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.IdSupersede));
|
||||
// Same code and issue.
|
||||
// Same code.
|
||||
prmCommodity.CodeFull = Commodity.Code;
|
||||
prmCommodity.DrawingIssueFull = Commodity.DrawingIssue;
|
||||
// Restrict to same customer.
|
||||
prmCommodity.AssociationIdCustomer = Commodity.AssocIdCustomer != null ? SysId.ToSysId(Commodity.AssocIdCustomer) : commodity?.AssociationIdCustomer;
|
||||
prmCommodity.StatusCat = SbmCommodity.StatusCat.Current;
|
||||
List<SbmCommodity> commodities = CommodityMgr.GetCommodityList(prmCommodity);
|
||||
disposables.AddRange(commodities);
|
||||
foreach (SbmCommodity commodityByCode in commodities)
|
||||
if (CommodityMgr.GetCommodityCount(prmCommodity) > 0)
|
||||
{
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
String msg = $"Another current Commodity already exists with this code: {Commodity.Code}.";
|
||||
if (SysId.IsValid(commodityByCode.AssociationIdCustomer))
|
||||
msg += $" Customer: {AccountMgr.GetAssociationTargetName(commodityByCode.AssociationIdCustomer)}.";
|
||||
else
|
||||
msg += $" Customer: None.";
|
||||
if (SessionConsole.DisplayAttribute(SbmDbDfn.ColumnIdx.Commodity_DrawingIssue))
|
||||
msg += $" Issue: {Commodity.DrawingIssue}.";
|
||||
else
|
||||
msg += $" Issue: None.";
|
||||
SaLogger.Warn($"{SysUtil.Fn} {msg}");
|
||||
responseData.SetControlError(GetFieldName(Model_Commodity.ItemField.Code), Localiser["msg.validation.duplicate.value"]);
|
||||
break;
|
||||
String msg = "There are no other Commodities for this code\nwith a status of 'Current'.\n\nAre you sure that this commodity should be set to 'Superseded'?";
|
||||
responseData.SetConfirmMessage(Localiser["label.commodity"], msg);
|
||||
}
|
||||
}
|
||||
else if (GetCommodityStatus() == SaStatus.Superseded)
|
||||
{
|
||||
// Has the status already been confirmed.
|
||||
if (!StringUtil.ToBool(Commodity.SupersededStatusConfirmed))
|
||||
{
|
||||
// Check that a current commodity exists with this code.
|
||||
SbmCommodity.Params prmCommodity = new SbmCommodity.Params();
|
||||
// Ignore this commodity if it already exists.
|
||||
if (StringUtil.ToBool(Commodity.Exists) && SysId.IsValid(SysId.ToSysId(Commodity.Id)))
|
||||
prmCommodity.IdsExcluded.Add(SysId.ToSysId(Commodity.Id));
|
||||
// Same code.
|
||||
prmCommodity.CodeFull = Commodity.Code;
|
||||
prmCommodity.StatusCat = SbmCommodity.StatusCat.Current;
|
||||
if (CommodityMgr.GetCommodityCount(prmCommodity) > 0)
|
||||
{
|
||||
String msg = "There are no other Commodities for this code\nwith a status of 'Current'.\n\nAre you sure that this commodity should be set to 'Superseded'?";
|
||||
responseData.SetConfirmMessage(Localiser["label.commodity"], msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GetCommodityStatus() == SaStatus.Discontinued)
|
||||
{
|
||||
}
|
||||
else if (GetCommodityStatus() == SaStatus.Deleted)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (GetCommodityStatus() == SaStatus.Discontinued)
|
||||
{
|
||||
}
|
||||
else if (GetCommodityStatus() == SaStatus.Deleted)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Vehicles
|
||||
public bool ValidateVehicleData(SbmController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Vehicle Class.
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Vehicles
|
||||
public bool ValidateVehicleClassData(Sacs.Web.Components.SaController.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
|
||||
// Make.
|
||||
|
||||
@@ -185,9 +185,18 @@ ul.nav.sbm-burger.navbar-dark .dropdown:hover
|
||||
border-color: #c0c0c0;
|
||||
}
|
||||
|
||||
ul.nav.sbm-burger .sbm-ellipsis-dot
|
||||
ul.nav.sbm-burger a .sbm-ellipsis-dot
|
||||
{
|
||||
display: inline-block;
|
||||
width: 2px;
|
||||
height: 2px;
|
||||
margin: 1px 2px 4px 2px;
|
||||
background-color: #808080;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
ul.nav.sbm-burger a:hover .sbm-ellipsis-dot
|
||||
{
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
margin: 0 1px 3px 1px;
|
||||
|
||||
Reference in New Issue
Block a user