3.0.1.7 Business object disposability

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