3.0.1.8 Control repository status check on update
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
internal class SbmHousekeepingService : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
Task housekeepingTask = null;
|
||||
CancellationTokenSource cts = null;
|
||||
int housekeepingInProgressIterationNum = 0;
|
||||
int housekeepingInProgressIterationMax = 3;
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
// Wait for a period before invoking housekeeping.
|
||||
await Task.Delay(TimeSpan.FromHours(1), stoppingToken);
|
||||
|
||||
try
|
||||
{
|
||||
// Check if previous housekeeping is still in progress.
|
||||
if (housekeepingTask != null && !housekeepingTask.IsCompleted)
|
||||
{
|
||||
++housekeepingInProgressIterationNum;
|
||||
|
||||
if (housekeepingInProgressIterationNum >= housekeepingInProgressIterationMax)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Previous housekeeping processing still in progress after {housekeepingInProgressIterationNum} iterations - cancelling and starting new processing.");
|
||||
cts.Cancel();
|
||||
housekeepingInProgressIterationNum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Previous housekeeping still in progress.
|
||||
SaLogger.Warn($"{SysUtil.Fn} Previous housekeeping processing still in progress. Counter: {housekeepingInProgressIterationNum}.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
housekeepingTask = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
cts = CancellationTokenSource.CreateLinkedTokenSource(stoppingToken);
|
||||
DoHousekeeping(cts.Token);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error($"{SysUtil.Fn} {exc.GetType().Name} performing application housekeeping.\n{ExceptionUtil.GetMessage(exc)}");
|
||||
}
|
||||
}, stoppingToken);
|
||||
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
SaLogger.Error($"{SysUtil.Fn} {exc.GetType().Name} invoking application housekeeping.\n{ExceptionUtil.GetMessage(exc)}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DoHousekeeping(CancellationToken ct)
|
||||
{
|
||||
SbmGlobals_Web.Application.DoHousekeeping(ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,16 @@ using Microsoft.Net.Http.Headers;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Middleware;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmStartup_Web
|
||||
public class SbmStartup_Web : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -40,6 +40,12 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -61,12 +67,16 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
// Authentication service.
|
||||
// Required to handle 'Forbidden' responses etc.
|
||||
config.services
|
||||
.AddAuthentication(options => {
|
||||
.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = "forbidScheme";
|
||||
options.DefaultForbidScheme = "forbidScheme";
|
||||
options.AddScheme<SbmAuthenticationHandler>("forbidScheme", "Handle Forbidden");
|
||||
});
|
||||
|
||||
// Periodic housekeeping.
|
||||
config.services.AddHostedService<SbmHousekeepingService>();
|
||||
|
||||
// Added to support memory caching of sessions.
|
||||
config.services.AddMemoryCache();
|
||||
//config.services.AddDistributedMemoryCache(); - for multiple web servers.
|
||||
@@ -112,7 +122,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
|
||||
.AddDataAnnotationsLocalization()
|
||||
// Ignore null values during object serialiation.
|
||||
.AddJsonOptions(options => { options.JsonSerializerOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull; });
|
||||
// Jun24 Was: .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
|
||||
// Jun24 Was: .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
|
||||
|
||||
// Configure localisation middleware.
|
||||
config.services.Configure<RequestLocalizationOptions>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
@@ -15,7 +13,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
public static class Version
|
||||
{
|
||||
private static String version { get; } = "3.0.1.7";
|
||||
private static String version { get; } = "3.0.1.8";
|
||||
// Retrieve version.
|
||||
public static String GetFullVersion() { return version; }
|
||||
public static String GetAppVersion()
|
||||
@@ -37,23 +35,25 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Version history.
|
||||
//-------------------------------------------------------------------
|
||||
// 3.0.1 19-Feb-25 Portal Transactions.
|
||||
// 3.0.1.1 19-Feb-25 Portal tidy.
|
||||
// 3.0.1.2 26-Feb-25 Requirements & tidy.
|
||||
// 3.0.1.3 02-Mar-25 Requirements.
|
||||
// 3.0.1.4 02-Mar-25 Fix pre-login crash on GetCurrencyDecimals().
|
||||
// 3.0.1.5 03-Mar-25 Refresh Transaction. Assets tidy.
|
||||
// 3.0.1.6 05-May-25 Addresses.
|
||||
// 3.0.1 19-Feb-25 Portal Transactions.
|
||||
// 3.0.1.1 19-Feb-25 Portal tidy.
|
||||
// 3.0.1.2 26-Feb-25 Requirements & tidy.
|
||||
// 3.0.1.3 02-Mar-25 Requirements.
|
||||
// 3.0.1.4 02-Mar-25 Fix pre-login crash on GetCurrencyDecimals().
|
||||
// 3.0.1.5 03-Mar-25 Refresh Transaction. Assets tidy.
|
||||
// 3.0.1.6 05-May-25 Addresses.
|
||||
// 3.0.1.7 21-Oct-25 Business object disposability.
|
||||
// 3.0.1.8 26-Oct-25 Control repository status check on update.
|
||||
//-------------------------------------------------------------------
|
||||
// 3.0.0 Jul-2021 Initial demo test version.
|
||||
// 02-Feb-25 Initial live deployment.
|
||||
// 3.0.0.1 08-Feb-25 Demo repository registration.
|
||||
// 3.0.0.2 08-Feb-25 Production SMTP config.
|
||||
// 3.0.0.3 10-Feb-25 Osie feedback #1. Control Repository Schema, Logs.
|
||||
// 3.0.0.4 11-Feb-25 Portal Commodity Sales properties. Control Index population.
|
||||
// 3.0.0.5 12-Feb-25 Portal Security forms tidy. Default Commodity type. Code Types and Codes.
|
||||
// 3.0.0.6 13-Feb-25 Main page layouts. Demo Account registration.
|
||||
// 3.0.0.7 17-Feb-25 Demo Transaction population.
|
||||
// 3.0.0 Jul-2021 Initial demo test version.
|
||||
// 02-Feb-25 Initial live deployment.
|
||||
// 3.0.0.1 08-Feb-25 Demo repository registration.
|
||||
// 3.0.0.2 08-Feb-25 Production SMTP config.
|
||||
// 3.0.0.3 10-Feb-25 Osie feedback #1. Control Repository Schema, Logs.
|
||||
// 3.0.0.4 11-Feb-25 Portal Commodity Sales properties. Control Index population.
|
||||
// 3.0.0.5 12-Feb-25 Portal Security forms tidy. Default Commodity type. Code Types and Codes.
|
||||
// 3.0.0.6 13-Feb-25 Main page layouts. Demo Account registration.
|
||||
// 3.0.0.7 17-Feb-25 Demo Transaction population.
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
|
||||
@@ -234,7 +233,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Interfaces must be available.
|
||||
if (internals.InterfaceConsole == null || !internals.InterfaceConsole.DatabaseIsValid) return false;
|
||||
// System Account & User tables must be available.
|
||||
ISacsDatabase busMgrDb = SbmGlobals.Application.GetBusMgrDatabase(sessionConsole.UserContext.SessionContext);
|
||||
ISacsDatabase busMgrDb = internals.BusMgrDatabase;
|
||||
if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemAccount)) return false;
|
||||
if (!SbmGlobals.Application.DbTableExists(busMgrDb, SbmDbDfn.TableIdx.SystemUser)) return false;
|
||||
return true;
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SbmApplication : SacsDisposable
|
||||
//=======================================================================
|
||||
public abstract class SbmApplication : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -45,28 +37,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
return properties.GetPropertyValue(section, name);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
// --- Properties ---
|
||||
|
||||
public abstract SbmSystem System { get; }
|
||||
// Control & Template Databases.
|
||||
public abstract ISacsDatabase GetControlDatabase();
|
||||
public abstract ISacsDatabase GetTemplateDatabase();
|
||||
// Business Mgr Database.
|
||||
public abstract HashSet<string> GetRepositoryContexts(SbmSessionContext sessionContext);
|
||||
public abstract ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext);
|
||||
public IDatabaseInfo CreateBusMgrDbInfo(SbmSessionContext sessionContext)
|
||||
{
|
||||
return GetBusMgrDatabase(sessionContext).CreateDbInfo();
|
||||
}
|
||||
public abstract ISacsDatabase CreateBusMgrDatabase(SbmSessionContext sessionContext);
|
||||
// Instance and Organisation profiles.
|
||||
public abstract SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext);
|
||||
public abstract SbmInstanceDataCache GetInstanceDataCache(SbmSessionContext sessionContext);
|
||||
public abstract SbmOrganisationConfig GetOrganisationConfig(ISbmUserOrganisationContext userContext);
|
||||
// Database utilities.
|
||||
public IDatabaseInfo CreateDbInfo(ISacsDatabase db)
|
||||
{
|
||||
return db?.CreateDbInfo() ?? null;
|
||||
}
|
||||
public bool DbTableExists(ISacsDatabase db, SbmDbDfn.TableIdx tableIdx)
|
||||
{
|
||||
return db?.TableExists(SbmDbDfn.GetTableName(tableIdx)) ?? false;
|
||||
@@ -84,6 +68,10 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Email configuration.
|
||||
public abstract SbmEmailConfig EmailConfig { get; }
|
||||
|
||||
// --- Utilities ---
|
||||
|
||||
public abstract void DoHousekeeping(CancellationToken ct);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SbmGlobals
|
||||
@@ -22,13 +11,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
// Application.
|
||||
public static SbmApplication Application { get; set; } = null;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Database.
|
||||
public static ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext)
|
||||
{
|
||||
return Application != null ? Application.GetBusMgrDatabase(sessionContext) : null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Clear globals.
|
||||
public static void Clear()
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
@@ -17,15 +13,28 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
|
||||
public SbmInstanceDataCache() { }
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Retrieve Item Options for Owner Organisation configuration.
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Item Options for Owner Organisation configuration.
|
||||
/// </summary>
|
||||
/// <param name="userContext"></param>
|
||||
/// <returns></returns>
|
||||
public abstract List<SaItemOption> GetOwnerOptions(ISbmUserOrganisationContext userContext);
|
||||
|
||||
/// <summary>
|
||||
/// Resets the state of the cache to its initial condition.
|
||||
/// </summary>
|
||||
/// <remarks>Typically done when something significant about the instance (eg. db connection configuration) has changed.</remarks>
|
||||
public abstract void Reset();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
using Sarand.Net.Standard.Base.Email;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
@@ -17,7 +15,6 @@ using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -61,41 +58,46 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SbmSystem system = SbmGlobals.System;
|
||||
// Managers.
|
||||
private class Managers
|
||||
private class DataMembers
|
||||
{
|
||||
public SbmAccountMgr accountMgr;
|
||||
public SbmAssetMgr assetMgr;
|
||||
public SbmCommodityMgr commodityMgr;
|
||||
public SbmPriceMgr priceMgr;
|
||||
public SbmTransactionMgr transactionMgr;
|
||||
public SbmStockMgr stockMgr;
|
||||
public SbmProcessMgr processMgr;
|
||||
public SbmDataItemMgr dataItemMgr;
|
||||
public SbmSystem system { get; } = SbmGlobals.System;
|
||||
public ISacsDatabase busMgrDatabase { get; set; }
|
||||
// Managers.
|
||||
public class Managers
|
||||
{
|
||||
public SbmAccountMgr accountMgr;
|
||||
public SbmAssetMgr assetMgr;
|
||||
public SbmCommodityMgr commodityMgr;
|
||||
public SbmPriceMgr priceMgr;
|
||||
public SbmTransactionMgr transactionMgr;
|
||||
public SbmStockMgr stockMgr;
|
||||
public SbmProcessMgr processMgr;
|
||||
public SbmDataItemMgr dataItemMgr;
|
||||
}
|
||||
public Managers mgr { get; } = new Managers();
|
||||
// Consoles.
|
||||
public class Consoles
|
||||
{
|
||||
public SbmInstanceSchemaConsole instanceSchemaConsole;
|
||||
public SbmSessionConsole sessionConsole;
|
||||
public SbmAccountsConsole accountsConsole;
|
||||
public SaDiaryConsole diaryConsole;
|
||||
public SaSecurityConsole securityConsole;
|
||||
public SaCodeTypeConsole codeTypeConsole;
|
||||
public SaReferenceDataConsole referenceDataConsole;
|
||||
public SaUpdateLogConsole updateLogConsole;
|
||||
public SaInterfaceConsole interfaceConsole;
|
||||
public SaItemDocConsole itemDocConsole;
|
||||
public SaItemOptionConsole itemOptionConsole;
|
||||
public SaItemDataConsole itemDataConsole;
|
||||
public SbmEmailConsole emailConsole;
|
||||
}
|
||||
public Consoles con { get; } = new Consoles();
|
||||
// Configurations.
|
||||
public SbmStockControlConfig stockControlConfig { get; set; }
|
||||
public SbmRequirementCostingConfig requirementCostingConfig { get; set; }
|
||||
}
|
||||
private readonly Managers mgr = new Managers();
|
||||
// Consoles.
|
||||
private class Consoles
|
||||
{
|
||||
public SbmInstanceSchemaConsole instanceSchemaConsole;
|
||||
public SbmSessionConsole sessionConsole;
|
||||
public SbmAccountsConsole accountsConsole;
|
||||
public SaDiaryConsole diaryConsole;
|
||||
public SaSecurityConsole securityConsole;
|
||||
public SaCodeTypeConsole codeTypeConsole;
|
||||
public SaReferenceDataConsole referenceDataConsole;
|
||||
public SaUpdateLogConsole updateLogConsole;
|
||||
public SaInterfaceConsole interfaceConsole;
|
||||
public SaItemDocConsole itemDocConsole;
|
||||
public SaItemOptionConsole itemOptionConsole;
|
||||
public SaItemDataConsole itemDataConsole;
|
||||
public SbmEmailConsole emailConsole;
|
||||
}
|
||||
private readonly Consoles con = new Consoles();
|
||||
// Configurations.
|
||||
private SbmStockControlConfig stockControlConfig;
|
||||
private SbmRequirementCostingConfig requirementCostingConfig;
|
||||
private DataMembers mbr { get; } = new DataMembers();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
@@ -121,27 +123,27 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
if (disposing)
|
||||
{
|
||||
// Managers.
|
||||
if (mgr.accountMgr != null) mgr.accountMgr.Dispose();
|
||||
if (mgr.assetMgr != null) mgr.assetMgr.Dispose();
|
||||
if (mgr.commodityMgr != null) mgr.commodityMgr.Dispose();
|
||||
if (mgr.priceMgr != null) mgr.priceMgr.Dispose();
|
||||
if (mgr.transactionMgr != null) mgr.transactionMgr.Dispose();
|
||||
if (mgr.stockMgr != null) mgr.stockMgr.Dispose();
|
||||
if (mgr.processMgr != null) mgr.processMgr.Dispose();
|
||||
if (mgr.dataItemMgr != null) mgr.dataItemMgr.Dispose();
|
||||
if (mbr.mgr.accountMgr != null) mbr.mgr.accountMgr.Dispose();
|
||||
if (mbr.mgr.assetMgr != null) mbr.mgr.assetMgr.Dispose();
|
||||
if (mbr.mgr.commodityMgr != null) mbr.mgr.commodityMgr.Dispose();
|
||||
if (mbr.mgr.priceMgr != null) mbr.mgr.priceMgr.Dispose();
|
||||
if (mbr.mgr.transactionMgr != null) mbr.mgr.transactionMgr.Dispose();
|
||||
if (mbr.mgr.stockMgr != null) mbr.mgr.stockMgr.Dispose();
|
||||
if (mbr.mgr.processMgr != null) mbr.mgr.processMgr.Dispose();
|
||||
if (mbr.mgr.dataItemMgr != null) mbr.mgr.dataItemMgr.Dispose();
|
||||
// Consoles.
|
||||
// Database console doesn't require disposal.
|
||||
if (con.sessionConsole != null) con.sessionConsole.Dispose();
|
||||
if (con.diaryConsole != null) con.diaryConsole.Dispose();
|
||||
if (con.securityConsole != null) con.securityConsole.Dispose();
|
||||
if (con.codeTypeConsole != null) con.codeTypeConsole.Dispose();
|
||||
if (con.referenceDataConsole != null) con.referenceDataConsole.Dispose();
|
||||
if (con.updateLogConsole != null) con.updateLogConsole.Dispose();
|
||||
if (con.interfaceConsole != null) con.interfaceConsole.Dispose();
|
||||
if (con.itemDocConsole != null) con.itemDocConsole.Dispose();
|
||||
if (con.itemOptionConsole != null) con.itemOptionConsole.Dispose();
|
||||
if (con.itemDataConsole != null) con.itemDataConsole.Dispose();
|
||||
if (con.itemDataConsole != null) con.itemDataConsole.Dispose();
|
||||
if (mbr.con.sessionConsole != null) mbr.con.sessionConsole.Dispose();
|
||||
if (mbr.con.diaryConsole != null) mbr.con.diaryConsole.Dispose();
|
||||
if (mbr.con.securityConsole != null) mbr.con.securityConsole.Dispose();
|
||||
if (mbr.con.codeTypeConsole != null) mbr.con.codeTypeConsole.Dispose();
|
||||
if (mbr.con.referenceDataConsole != null) mbr.con.referenceDataConsole.Dispose();
|
||||
if (mbr.con.updateLogConsole != null) mbr.con.updateLogConsole.Dispose();
|
||||
if (mbr.con.interfaceConsole != null) mbr.con.interfaceConsole.Dispose();
|
||||
if (mbr.con.itemDocConsole != null) mbr.con.itemDocConsole.Dispose();
|
||||
if (mbr.con.itemOptionConsole != null) mbr.con.itemOptionConsole.Dispose();
|
||||
if (mbr.con.itemDataConsole != null) mbr.con.itemDataConsole.Dispose();
|
||||
if (mbr.con.itemDataConsole != null) mbr.con.itemDataConsole.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +154,19 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
public ISbmUserOrganisationContext UserContext { get; }
|
||||
public SbmSessionContext SessionContext { get { return UserContext?.SessionContext; } }
|
||||
public ISbmSecurityProfile_Core SecurityProfile { get { return UserContext.SecurityProfile; } }
|
||||
public SbmAccountsConsole AccountsConsole { get { if (con.accountsConsole == null) con.accountsConsole = new SbmAccountsConsole(this); { return con.accountsConsole; } } }
|
||||
public SbmAccountsConsole AccountsConsole { get { if (mbr.con.accountsConsole == null) mbr.con.accountsConsole = new SbmAccountsConsole(this); { return mbr.con.accountsConsole; } } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Database.
|
||||
public ISacsDatabase BusMgrDatabase { get { return Application.GetBusMgrDatabase(SessionContext); } }
|
||||
public ISacsDatabase BusMgrDatabase
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mbr.busMgrDatabase == null)
|
||||
mbr.busMgrDatabase = Application.CreateBusMgrDatabase(SessionContext);
|
||||
return mbr.busMgrDatabase;
|
||||
}
|
||||
}
|
||||
public DbUpdateInfo DbUpdateInfo { get { return UserContext.DbUpdateInfo; } }
|
||||
// Schema.
|
||||
public bool TableExists(String tableName)
|
||||
@@ -288,72 +298,72 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.accountMgr == null)
|
||||
mgr.accountMgr = system.CreateAccountMgr(this);
|
||||
return mgr.accountMgr;
|
||||
if (mbr.mgr.accountMgr == null)
|
||||
mbr.mgr.accountMgr = mbr.system.CreateAccountMgr(this);
|
||||
return mbr.mgr.accountMgr;
|
||||
}
|
||||
}
|
||||
public SbmAssetMgr AssetMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.assetMgr == null)
|
||||
mgr.assetMgr = system.CreateAssetMgr(this);
|
||||
return mgr.assetMgr;
|
||||
if (mbr.mgr.assetMgr == null)
|
||||
mbr.mgr.assetMgr = mbr.system.CreateAssetMgr(this);
|
||||
return mbr.mgr.assetMgr;
|
||||
}
|
||||
}
|
||||
public SbmCommodityMgr CommodityMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.commodityMgr == null)
|
||||
mgr.commodityMgr = system.CreateCommodityMgr(this);
|
||||
return mgr.commodityMgr;
|
||||
if (mbr.mgr.commodityMgr == null)
|
||||
mbr.mgr.commodityMgr = mbr.system.CreateCommodityMgr(this);
|
||||
return mbr.mgr.commodityMgr;
|
||||
}
|
||||
}
|
||||
public SbmPriceMgr PriceMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.priceMgr == null)
|
||||
mgr.priceMgr = system.CreatePriceMgr(this);
|
||||
return mgr.priceMgr;
|
||||
if (mbr.mgr.priceMgr == null)
|
||||
mbr.mgr.priceMgr = mbr.system.CreatePriceMgr(this);
|
||||
return mbr.mgr.priceMgr;
|
||||
}
|
||||
}
|
||||
public SbmTransactionMgr TransactionMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.transactionMgr == null)
|
||||
mgr.transactionMgr = system.CreateTransactionMgr(this);
|
||||
return mgr.transactionMgr;
|
||||
if (mbr.mgr.transactionMgr == null)
|
||||
mbr.mgr.transactionMgr = mbr.system.CreateTransactionMgr(this);
|
||||
return mbr.mgr.transactionMgr;
|
||||
}
|
||||
}
|
||||
public SbmStockMgr StockMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.stockMgr == null)
|
||||
mgr.stockMgr = system.CreateStockMgr(this);
|
||||
return mgr.stockMgr;
|
||||
if (mbr.mgr.stockMgr == null)
|
||||
mbr.mgr.stockMgr = mbr.system.CreateStockMgr(this);
|
||||
return mbr.mgr.stockMgr;
|
||||
}
|
||||
}
|
||||
public SbmProcessMgr ProcessMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.processMgr == null)
|
||||
mgr.processMgr = system.CreateProcessMgr(this);
|
||||
return mgr.processMgr;
|
||||
if (mbr.mgr.processMgr == null)
|
||||
mbr.mgr.processMgr = mbr.system.CreateProcessMgr(this);
|
||||
return mbr.mgr.processMgr;
|
||||
}
|
||||
}
|
||||
public SbmDataItemMgr DataItemMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mgr.dataItemMgr == null)
|
||||
mgr.dataItemMgr = SbmGlobals.System.CreateDataItemMgr(this);
|
||||
return mgr.dataItemMgr;
|
||||
if (mbr.mgr.dataItemMgr == null)
|
||||
mbr.mgr.dataItemMgr = SbmGlobals.System.CreateDataItemMgr(this);
|
||||
return mbr.mgr.dataItemMgr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,89 +373,89 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.instanceSchemaConsole == null) { con.instanceSchemaConsole = new SbmInstanceSchemaConsole(BusMgrDatabase); }
|
||||
return con.instanceSchemaConsole;
|
||||
if (mbr.con.instanceSchemaConsole == null) { mbr.con.instanceSchemaConsole = new SbmInstanceSchemaConsole(BusMgrDatabase); }
|
||||
return mbr.con.instanceSchemaConsole;
|
||||
}
|
||||
}
|
||||
public SbmSessionConsole SessionConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.sessionConsole == null) { con.sessionConsole = SbmGlobals.System.CreateSessionConsole(this); }
|
||||
return con.sessionConsole;
|
||||
if (mbr.con.sessionConsole == null) { mbr.con.sessionConsole = SbmGlobals.System.CreateSessionConsole(this); }
|
||||
return mbr.con.sessionConsole;
|
||||
}
|
||||
}
|
||||
public SaDiaryConsole DiaryConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.diaryConsole == null) { con.diaryConsole = SbmGlobals.System.CreateDiaryConsole(this); }
|
||||
return con.diaryConsole;
|
||||
if (mbr.con.diaryConsole == null) { mbr.con.diaryConsole = SbmGlobals.System.CreateDiaryConsole(this); }
|
||||
return mbr.con.diaryConsole;
|
||||
}
|
||||
}
|
||||
public SaSecurityConsole SecurityConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.securityConsole == null) { con.securityConsole = SbmGlobals.System.CreateSecurityConsole(this); }
|
||||
return con.securityConsole;
|
||||
if (mbr.con.securityConsole == null) { mbr.con.securityConsole = SbmGlobals.System.CreateSecurityConsole(this); }
|
||||
return mbr.con.securityConsole;
|
||||
}
|
||||
}
|
||||
public SaCodeTypeConsole CodeTypeConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.codeTypeConsole == null) { con.codeTypeConsole = SbmGlobals.System.CreateCodeTypeConsole(this); }
|
||||
return con.codeTypeConsole;
|
||||
if (mbr.con.codeTypeConsole == null) { mbr.con.codeTypeConsole = SbmGlobals.System.CreateCodeTypeConsole(this); }
|
||||
return mbr.con.codeTypeConsole;
|
||||
}
|
||||
}
|
||||
public SaReferenceDataConsole ReferenceDataConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.referenceDataConsole == null) { con.referenceDataConsole = SbmGlobals.System.CreateReferenceDataConsole(this); }
|
||||
return con.referenceDataConsole;
|
||||
if (mbr.con.referenceDataConsole == null) { mbr.con.referenceDataConsole = SbmGlobals.System.CreateReferenceDataConsole(this); }
|
||||
return mbr.con.referenceDataConsole;
|
||||
}
|
||||
}
|
||||
public SaUpdateLogConsole UpdateLogConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.updateLogConsole == null) { con.updateLogConsole = SbmGlobals.System.CreateUpdateLogConsole(this); }
|
||||
return con.updateLogConsole;
|
||||
if (mbr.con.updateLogConsole == null) { mbr.con.updateLogConsole = SbmGlobals.System.CreateUpdateLogConsole(this); }
|
||||
return mbr.con.updateLogConsole;
|
||||
}
|
||||
}
|
||||
public SaInterfaceConsole InterfaceConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.interfaceConsole == null) { con.interfaceConsole = SbmGlobals.System.CreateInterfaceConsole(this); }
|
||||
return con.interfaceConsole;
|
||||
if (mbr.con.interfaceConsole == null) { mbr.con.interfaceConsole = SbmGlobals.System.CreateInterfaceConsole(this); }
|
||||
return mbr.con.interfaceConsole;
|
||||
}
|
||||
}
|
||||
public SaItemDocConsole ItemDocConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.itemDocConsole == null) { con.itemDocConsole = SbmGlobals.System.CreateItemDocConsole(this); }
|
||||
return con.itemDocConsole;
|
||||
if (mbr.con.itemDocConsole == null) { mbr.con.itemDocConsole = SbmGlobals.System.CreateItemDocConsole(this); }
|
||||
return mbr.con.itemDocConsole;
|
||||
}
|
||||
}
|
||||
public SaItemOptionConsole ItemOptionConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.itemOptionConsole == null)
|
||||
con.itemOptionConsole = SbmGlobals.System.CreateItemOptionConsole(this);
|
||||
return con.itemOptionConsole;
|
||||
if (mbr.con.itemOptionConsole == null)
|
||||
mbr.con.itemOptionConsole = SbmGlobals.System.CreateItemOptionConsole(this);
|
||||
return mbr.con.itemOptionConsole;
|
||||
}
|
||||
}
|
||||
public SaItemDataConsole ItemDataConsole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.itemDataConsole == null) { con.itemDataConsole = SbmGlobals.System.CreateItemDataConsole(this); }
|
||||
return con.itemDataConsole;
|
||||
if (mbr.con.itemDataConsole == null) { mbr.con.itemDataConsole = SbmGlobals.System.CreateItemDataConsole(this); }
|
||||
return mbr.con.itemDataConsole;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,8 +466,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
get
|
||||
{
|
||||
if (con.emailConsole == null) { con.emailConsole = SbmGlobals.System.CreateEmailConsole(EmailConfig); }
|
||||
return con.emailConsole;
|
||||
if (mbr.con.emailConsole == null) { mbr.con.emailConsole = SbmGlobals.System.CreateEmailConsole(EmailConfig); }
|
||||
return mbr.con.emailConsole;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,18 +477,18 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.App
|
||||
{
|
||||
get
|
||||
{
|
||||
if (stockControlConfig == null)
|
||||
stockControlConfig = SessionConsole.GetStockControlConfig();
|
||||
return stockControlConfig;
|
||||
if (mbr.stockControlConfig == null)
|
||||
mbr.stockControlConfig = SessionConsole.GetStockControlConfig();
|
||||
return mbr.stockControlConfig;
|
||||
}
|
||||
}
|
||||
public SbmRequirementCostingConfig RequirementCostingConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
if (requirementCostingConfig == null)
|
||||
requirementCostingConfig = SessionConsole.GetRequirementCostingConfig();
|
||||
return requirementCostingConfig;
|
||||
if (mbr.requirementCostingConfig == null)
|
||||
mbr.requirementCostingConfig = SessionConsole.GetRequirementCostingConfig();
|
||||
return mbr.requirementCostingConfig;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,8 +258,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
SbmApplication application = SbmGlobals.Application;
|
||||
if (application != null)
|
||||
{
|
||||
ISacsDatabase busMgrDb = application.GetBusMgrDatabase(SessionContext);
|
||||
return application.DbTableExists(busMgrDb, tableIdx);
|
||||
return application.DbTableExists(Internals.BusMgrDatabase, tableIdx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -268,8 +267,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Base.Mgr
|
||||
SbmApplication application = SbmGlobals.Application;
|
||||
if (application != null)
|
||||
{
|
||||
ISacsDatabase busMgrDb = application.GetBusMgrDatabase(SessionContext);
|
||||
return application.DbColumnExists(busMgrDb, columnIdx);
|
||||
return application.DbColumnExists(Internals.BusMgrDatabase, columnIdx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
{
|
||||
@@ -21,6 +18,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
private class ItemOptionData
|
||||
{
|
||||
public ItemOptionData(ItemId itemId)
|
||||
@@ -46,16 +44,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
private SbmInternals internals = null;
|
||||
|
||||
// Instance Item Options - keyed on Owner Affiliate Id.
|
||||
private readonly Dictionary<ItemId, ItemOptionsCacheData> itemOptionCaches = new Dictionary<ItemId, ItemOptionsCacheData>();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
|
||||
public SbmInstanceDataCache_Dbas(SbmSessionContext sessionContext)
|
||||
{
|
||||
this.SessionContext = sessionContext;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (internals != null) internals.Dispose(); internals = null;
|
||||
@@ -64,7 +66,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public SbmSessionContext SessionContext { get; }
|
||||
|
||||
public SbmSessionContext SessionContext { get; }
|
||||
private SbmInternals Internals { get { if (internals == null) { internals = new SbmInternals(SessionContext); }; return internals; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -108,6 +111,20 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.App
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Resets the state of the cache to its initial condition.
|
||||
/// </summary>
|
||||
/// <remarks>Typically done when something significant about the instance (eg. db connection configuration) has changed.</remarks>
|
||||
public override void Reset()
|
||||
{
|
||||
lock (itemOptionCaches)
|
||||
{
|
||||
itemOptionCaches.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
@@ -35,7 +31,7 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
private SbmSessionContext SessionContext { get { return mbr.SessionContext; } }
|
||||
private ISacsDatabase Database { get { if (mbr.Database == null) { mbr.Database = SbmGlobals.Application.GetBusMgrDatabase(SessionContext); } return mbr.Database; } }
|
||||
private ISacsDatabase Database { get { if (mbr.Database == null) { mbr.Database = SbmGlobals.Application.CreateBusMgrDatabase(SessionContext); } return mbr.Database; } }
|
||||
private new IndexStats IndexStats { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.Diary;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
@@ -10,7 +9,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmDiaryConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmDiaryConsole_Dbas(ISbmUserOrganisationContext userContext)
|
||||
: base(SbmGlobals.Application.CreateBusMgrDatabase(userContext.SessionContext))
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.ItemData;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
@@ -10,7 +9,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmItemDataConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmItemDataConsole_Dbas(ISbmUserOrganisationContext userContext)
|
||||
: base(SbmGlobals.Application.CreateBusMgrDatabase(userContext.SessionContext))
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.ItemDocs;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
@@ -10,7 +9,8 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Consoles
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SbmItemDocConsole_Dbas(ISbmUserOrganisationContext userContext) : base(SbmGlobals.Application.GetBusMgrDatabase(userContext.SessionContext))
|
||||
protected SbmItemDocConsole_Dbas(ISbmUserOrganisationContext userContext)
|
||||
: base(SbmGlobals.Application.CreateBusMgrDatabase(userContext.SessionContext))
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
@@ -15,7 +14,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -44,14 +42,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
public override bool SystemAccountDatabaseIsValid { get { return Database.TableExists(SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SystemAccount)); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
@@ -18,7 +17,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -47,14 +45,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
@@ -15,7 +14,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -45,14 +43,13 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Database properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
public String TableName_PortfolioItem { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ContainerItem); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
@@ -18,7 +17,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -47,14 +45,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
@@ -15,7 +14,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -44,14 +42,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
protected String TableName_PriceSet { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet); } }
|
||||
protected String TableName_Price { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.SaPriceSet); } }
|
||||
public override bool PriceDatabaseIsValid { get { return Database.TableExists(TableName_PriceSet) && Database.TableExists(TableName_Price); } }
|
||||
|
||||
@@ -3,7 +3,6 @@ using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
|
||||
namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
@@ -18,7 +17,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -39,14 +37,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
protected String TableName_Process { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.Process); } }
|
||||
protected String TableName_ItemLink { get { return SbmDbDfn.GetTableName(SbmDbDfn.TableIdx.ItemLink); } }
|
||||
public override bool ProcessDatabaseIsValid
|
||||
|
||||
@@ -8,7 +8,6 @@ using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -22,7 +21,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -51,14 +49,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
@@ -9,7 +9,6 @@ using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -23,7 +22,6 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Data members.
|
||||
public class DataMembers
|
||||
{
|
||||
public SacsDatabase db = null;
|
||||
public SbmDbDataItem.SbmDatabaseInfo dbInfo;
|
||||
}
|
||||
private readonly DataMembers mbr = new DataMembers();
|
||||
@@ -44,14 +42,12 @@ namespace Sarand.BusinessMgr.Net.Standard.Dbas.Mgr
|
||||
// Initialisation.
|
||||
private void Initialise()
|
||||
{
|
||||
mbr.db = (SbmGlobals.Application.GetBusMgrDatabase(SessionContext) as SacsDatabase);
|
||||
mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(mbr.db.DatabaseName, mbr.db.GetTableDfns());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected ISacsDatabase Database { get { return mbr.db; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { return mbr.dbInfo; } }
|
||||
protected ISacsDatabase Database { get { return Internals.BusMgrDatabase; } }
|
||||
protected SbmDbDataItem.SbmDatabaseInfo DbInfo { get { if (mbr.dbInfo is null) mbr.dbInfo = new SbmDbDataItem.SbmDatabaseInfo(Database.DatabaseName, Database.GetTableDfns()); return mbr.dbInfo; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Mgr.Control;
|
||||
using Sarand.BusinessMgr.Web.Control.Consoles;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
@@ -129,7 +126,7 @@ namespace Sarand.BusinessMgr.Test.Web.Control.App
|
||||
Assert.IsNotNull(instanceConsole);
|
||||
|
||||
// Session Context.
|
||||
ushort sessionIdx = App_Control.GetCoreSessionIndexForControlRepository(repository.OwnerId, repository.Id);
|
||||
ushort sessionIdx = App_Control.GetCoreSessionIndexForControlRepository(repository.Id);
|
||||
SbmSessionContext sessionContext = App_Control.GetSessionContextByIndex(sessionIdx);
|
||||
Assert.IsNotNull(sessionContext);
|
||||
Assert.AreEqual(sessionIdx, sessionContext.Index);
|
||||
|
||||
@@ -12,7 +12,6 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Helpers;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
@@ -41,7 +40,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
string repositoryContext = "Mimo";
|
||||
SbmSessionContext sessionContext = GetCoreSessionContext(repositoryContext);
|
||||
Assert.IsNotNull(sessionContext);
|
||||
ISacsDatabase busMgrDatabase = AppPortal.GetBusMgrDatabase(sessionContext);
|
||||
ISacsDatabase busMgrDatabase = AppPortal.CreateBusMgrDatabase(sessionContext);
|
||||
|
||||
// Session data.
|
||||
SbmSessionData_Portal sessionData = new SbmSessionData_Portal(sessionContext, repositoryContext, null, null, null, null);
|
||||
@@ -172,7 +171,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
|
||||
string repositoryContext = "Mimo";
|
||||
SbmSessionContext sessionContext = GetCoreSessionContext(repositoryContext);
|
||||
Assert.IsNotNull(sessionContext);
|
||||
ISacsDatabase busMgrDatabase = AppPortal.GetBusMgrDatabase(sessionContext);
|
||||
ISacsDatabase busMgrDatabase = AppPortal.CreateBusMgrDatabase(sessionContext);
|
||||
|
||||
// User Session.
|
||||
SbmSessionData_Portal sessionData = new SbmSessionData_Portal(sessionContext, repositoryContext, null, null, null, null);
|
||||
|
||||
@@ -26,6 +26,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Control.App
|
||||
{
|
||||
@@ -52,19 +53,53 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
private ISacsDatabase templateDatabase = null;
|
||||
// Core Session contexts - to access Core database via repository configuration.
|
||||
private static ushort sessionContextIdx_Next = 101;
|
||||
private class CoreInstanceContextData
|
||||
private class CoreInstanceContextData : SacsDisposable
|
||||
{
|
||||
public CoreInstanceContextData(SbmSessionContext_Web sessionContext, SysId controlOwnerId, SysId controlRepositoryId)
|
||||
public CoreInstanceContextData(SbmSessionContext_Web sessionContext, SbmcRepository repository)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
ControlOwnerId = controlOwnerId;
|
||||
ControlRepositoryId = controlRepositoryId;
|
||||
ControlRepositoryId = repository.Id;
|
||||
RefreshRepository(repository);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
instanceDataCache?.Dispose();
|
||||
instanceDataCache = null;
|
||||
}
|
||||
public void RefreshRepository(SbmcRepository repository)
|
||||
{
|
||||
bool contextChanged = false;
|
||||
if (ControlOwnerId is null || !ControlOwnerId.Equals(repository.OwnerId))
|
||||
{
|
||||
ControlOwnerId = repository.OwnerId;
|
||||
contextChanged = true;
|
||||
}
|
||||
if (!RepositoryContexts.Contains(repository.Context))
|
||||
{
|
||||
RepositoryContexts.Clear();
|
||||
RepositoryContexts.Add(repository.Context);
|
||||
contextChanged = true;
|
||||
}
|
||||
// Database.
|
||||
SacsDatabaseConsole.OdbcConfig odbcConfig = SbmCoreInstanceConsole_Dbas.GetRepositoryOdbcConfig(repository);
|
||||
if (!odbcConfig.ConnectionString.EqualsCI(OdbcConfig?.ConnectionString ?? ""))
|
||||
{
|
||||
OdbcConfig = odbcConfig;
|
||||
contextChanged = true;
|
||||
}
|
||||
if (contextChanged)
|
||||
{
|
||||
instanceConfig = null;
|
||||
instanceDataCache?.Reset();
|
||||
}
|
||||
PropertiesPopulated = DateTime.Now;
|
||||
}
|
||||
public SbmSessionContext_Web SessionContext { get; }
|
||||
public SysId ControlOwnerId { get; }
|
||||
public SysId ControlRepositoryId { get; }
|
||||
public SysId ControlOwnerId { get; private set; }
|
||||
public SysId ControlRepositoryId { get; init; }
|
||||
public HashSet<string> RepositoryContexts { get; } = new HashSet<string>();
|
||||
public ISacsDatabase BusMgrDatabase { get; set; }
|
||||
public SacsDatabaseConsole.OdbcConfig OdbcConfig { get; private set; }
|
||||
public DateTime PropertiesPopulated { get; private set; } = DateTime.Now;
|
||||
// Instance config.
|
||||
private SbmInstanceConfig instanceConfig = null;
|
||||
public SbmInstanceConfig InstanceConfig
|
||||
@@ -108,9 +143,20 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
foreach (var coreInstance in coreInstances.Values)
|
||||
coreInstance.Dispose();
|
||||
coreInstances.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
public static SbmApplication_Control Instance { get { return appInstance; } }
|
||||
// Application Configuration.
|
||||
public override Net.Core.Web.App.SbmAppConfig AppConfig { get { return appConfigs.Values.ToList().getConfigForApplication(); } }
|
||||
@@ -128,12 +174,13 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
{
|
||||
return new List<SbmSessionContext>(coreInstances.Values.Select(item => item.SessionContext));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identify the Core session context by the Repository Id.
|
||||
/// <para>If context not yet defined for Repository, load and then return index.</para>
|
||||
/// <para>If repository not found, return 0.</para>
|
||||
/// </summary>
|
||||
public ushort GetCoreSessionIndexForControlRepository(SysId ownerId, SysId repositoryId)
|
||||
public ushort GetCoreSessionIndexForControlRepository(SysId repositoryId)
|
||||
{
|
||||
using (DisposableCollection<ISacsDisposable> disposables = new DisposableCollection<ISacsDisposable>())
|
||||
{
|
||||
@@ -145,19 +192,11 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
SbmcRepository repository = instanceMgr.GetRepositoryById(repositoryId);
|
||||
if (repository != null)
|
||||
{
|
||||
// Core database connection.
|
||||
SacsDatabaseConsole.OdbcConfig odbcConfig = SbmCoreInstanceConsole_Dbas.GetRepositoryOdbcConfig(repository);
|
||||
SacsDatabase busMgrDatabase = SacsDatabaseConsole.OpenOdbcDatabase(odbcConfig);
|
||||
if (busMgrDatabase.HasErrorState())
|
||||
SaLogger.Warn($"{SysUtil.Fn} BusMgr Database: " + busMgrDatabase.DatabaseName + ". Initialisation error: " + busMgrDatabase.ErrorStateMessage);
|
||||
|
||||
// Session context.
|
||||
ushort sessionContextIdx = sessionContextIdx_Next++;
|
||||
if (sessionContextIdx_Control < 1)
|
||||
sessionContextIdx_Control = sessionContextIdx;
|
||||
CoreInstanceContextData sessionContextData = new CoreInstanceContextData(new SbmSessionContext_Web(sessionContextIdx, Sbm.Application.WebControl), ownerId, repositoryId);
|
||||
sessionContextData.RepositoryContexts.Add(repository.Context);
|
||||
sessionContextData.BusMgrDatabase = busMgrDatabase;
|
||||
CoreInstanceContextData sessionContextData = new CoreInstanceContextData(new SbmSessionContext_Web(sessionContextIdx, Sbm.Application.WebControl), repository);
|
||||
coreInstances.Add(sessionContextData.SessionContext.Index, sessionContextData);
|
||||
return sessionContextData.SessionContext.Index;
|
||||
}
|
||||
@@ -165,6 +204,18 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the session context properties for the specified repository.
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public void RefreshInstanceSessionProperties(SbmcRepository repository)
|
||||
{
|
||||
// Find session context and refresh repository properties.
|
||||
CoreInstanceContextData sessionContext = coreInstances.Values.FirstOrDefault(item => item.ControlRepositoryId.Equals(repository.Id));
|
||||
if (sessionContext != null)
|
||||
sessionContext.RefreshRepository(repository);
|
||||
}
|
||||
|
||||
// Databases.
|
||||
public override ISacsDatabase GetControlDatabase() { return controlDatabase; }
|
||||
public override ISacsDatabase GetTemplateDatabase() { return templateDatabase; }
|
||||
@@ -172,9 +223,12 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
{
|
||||
return coreInstances.GetValue(sessionContext.Index, null)?.RepositoryContexts ?? new HashSet<string>();
|
||||
}
|
||||
public override ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext)
|
||||
public override ISacsDatabase CreateBusMgrDatabase(SbmSessionContext sessionContext)
|
||||
{
|
||||
return coreInstances.GetValue(sessionContext.Index, null)?.BusMgrDatabase;
|
||||
ISacsDatabase busMgrDatabase = SacsDatabaseConsole.OpenOdbcDatabase(coreInstances.GetValue(sessionContext.Index, null)?.OdbcConfig);
|
||||
if (busMgrDatabase.HasErrorState())
|
||||
SaLogger.Warn($"{SysUtil.Fn} BusMgr Database: " + busMgrDatabase.DatabaseName + ". Initialisation error: " + busMgrDatabase.ErrorStateMessage);
|
||||
return busMgrDatabase;
|
||||
}
|
||||
// Instance configuration.
|
||||
public override SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext)
|
||||
@@ -196,7 +250,6 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Consoles.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
public static SbmEmailConsole_Control CreateEmailConsole_Control(SbmEmailConfig emailConfig)
|
||||
{
|
||||
@@ -205,6 +258,7 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
|
||||
/// <summary>Initialise environment - from Startup.</summary>
|
||||
internal void InitWebHostEnvironment(IWebHostEnvironment env)
|
||||
{
|
||||
@@ -308,6 +362,7 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Generate database definition.
|
||||
|
||||
private void GenerateDatabaseDefinition(SbmDbDfnGenerator.DatabaseInstance dbInstance, ISacsDatabase db)
|
||||
{
|
||||
if (!SbmSystem.DebugMode) return;
|
||||
@@ -317,6 +372,7 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
// Generate database definitions.
|
||||
GenerateDatabaseDefinition(dbInstance, db.ConnectionString);
|
||||
}
|
||||
|
||||
private void GenerateDatabaseDefinition(SbmDbDfnGenerator.DatabaseInstance dbInstance, String connectionString)
|
||||
{
|
||||
if (!SbmSystem.DebugMode) return;
|
||||
@@ -328,6 +384,22 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
//SaUpdateLogDbDfnGenerator.Generate(database.ConnectionString);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Housekeeping.
|
||||
|
||||
private class HousekeepingConfig
|
||||
{
|
||||
}
|
||||
private HousekeepingConfig housekeepingConfig = new HousekeepingConfig();
|
||||
|
||||
/// <summary>
|
||||
/// Perform periodic application housekeeping.
|
||||
/// </summary>
|
||||
public override void DoHousekeeping(CancellationToken ct)
|
||||
{
|
||||
SaLogger.Info($"{SysUtil.Fn} Doing housekeeping.", true);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Control.App
|
||||
{
|
||||
@@ -28,6 +23,14 @@ namespace Sarand.BusinessMgr.Web.Control.App
|
||||
// Initialise application.
|
||||
application = new SbmApplication_Control(Configuration);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
application.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
||||
using Sarand.BusinessMgr.Net.Standard.Dbas.Consoles;
|
||||
using Sarand.BusinessMgr.Web.Control.App;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Control.Consoles
|
||||
{
|
||||
@@ -42,6 +30,8 @@ namespace Sarand.BusinessMgr.Web.Control.Consoles
|
||||
mbr.OwnerId = repository.OwnerId;
|
||||
mbr.RepositoryId = repository.Id;
|
||||
this.SessionData_Control = sessionData_Control;
|
||||
// In case Repository definition has changed since Instance was registered with Application.
|
||||
App_Control.RefreshInstanceSessionProperties(repository);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
@@ -64,7 +54,7 @@ namespace Sarand.BusinessMgr.Web.Control.Consoles
|
||||
/// <summary>Core internals for accessing core managers etc.</summary>
|
||||
protected SbmInternals CreateCoreInternals()
|
||||
{
|
||||
ushort sessionIndex = App_Control.GetCoreSessionIndexForControlRepository(mbr.OwnerId, mbr.RepositoryId);
|
||||
ushort sessionIndex = App_Control.GetCoreSessionIndexForControlRepository(mbr.RepositoryId);
|
||||
SbmSessionContext sessionContext = App_Control.GetSessionContextByIndex(sessionIndex);
|
||||
return new SbmInternals(sessionContext);
|
||||
}
|
||||
|
||||
+7
-5
@@ -20,7 +20,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
// Definitions.
|
||||
|
||||
// Repository data.
|
||||
private class RepositoryListData : AjaxResponse_Data.ItemData_Base
|
||||
internal class RepositoryListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public String OwnerName { get; set; }
|
||||
public String Context { get; set; }
|
||||
@@ -28,12 +28,12 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
public String InstanceName { get; set; }
|
||||
public String DatabaseName { get; set; }
|
||||
}
|
||||
private class RepositoryItemData : RepositoryListData
|
||||
internal class RepositoryItemData : RepositoryListData
|
||||
{
|
||||
public String OwnerId { get; set; }
|
||||
public String UserName { get; set; }
|
||||
}
|
||||
private void PopulateRepositoryResponseListData(SbmModel_Control model, RepositoryListData data, SbmcOwner owner, SbmcRepository repository)
|
||||
internal static void PopulateRepositoryResponseListData(SbmModel_Control model, RepositoryListData data, SbmcOwner owner, SbmcRepository repository)
|
||||
{
|
||||
data.Id = SysId.ToString(repository.Id);
|
||||
data.OwnerName = owner.Name;
|
||||
@@ -44,7 +44,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
data.StatusCode = repository.StatusCode;
|
||||
data.StatusDesc = repository.StatusDesc;
|
||||
}
|
||||
private void PopulateRepositoryResponseItemData(SbmModel_Control model, RepositoryItemData data, SbmcOwner owner, SbmcRepository repository)
|
||||
internal static void PopulateRepositoryResponseItemData(SbmModel_Control model, RepositoryItemData data, SbmcOwner owner, SbmcRepository repository)
|
||||
{
|
||||
PopulateRepositoryResponseListData(model, data, owner, repository);
|
||||
data.OwnerId = SysId.ToString(repository.OwnerId);
|
||||
@@ -147,7 +147,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
// Construction.
|
||||
public AjaxResponse_Repository(SbmModel_Control model) : base(model) { }
|
||||
// Repository details.
|
||||
public RepositoryItemData repository { get; } = new RepositoryItemData();
|
||||
public RepositoryItemData repository { get; } = new();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -367,6 +367,8 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + ControlInstanceMgr.ErrorStateMessage));
|
||||
}
|
||||
responseData.SetNotification(messageTitle, Localiser["msg.item.updated"]);
|
||||
// In case Repository definition has changed since Instance was registered with Application.
|
||||
App_Control.RefreshInstanceSessionProperties(repository);
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
|
||||
+9
-3
@@ -1,11 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Bus.Control;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.Data;
|
||||
using Sarand.BusinessMgr.Web.Control.Components;
|
||||
using Sarand.BusinessMgr.Web.Control.Consoles;
|
||||
@@ -13,7 +11,6 @@ using Sarand.BusinessMgr.Web.Control.Models.Instance;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
@@ -198,6 +195,8 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_RepositoryInitialise(SbmModel_Control model) : base(model) { }
|
||||
// Repository details - to mimic response from GetRepositoryList.
|
||||
public RepositoryController.RepositoryListData Repository { get; } = new();
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("Instance/Repository/Ajax/Initialise")]
|
||||
@@ -228,6 +227,12 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
SaLogger.Warn($"{SysUtil.Fn} Repository does not exist. Id: {repositoryId}.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SbmcOwner owner = ControlInstanceMgr.GetOwnerById(repository.OwnerId);
|
||||
if (owner == null)
|
||||
{
|
||||
SaLogger.Warn($"{SysUtil.Fn} Owner does not exist. Id: {repository.OwnerId}.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Core Instance Console.
|
||||
SbmCoreInstanceConsole_Control instanceConsole = new SbmCoreInstanceConsole_Control(SessionData_Control, repository);
|
||||
@@ -397,6 +402,7 @@ namespace Sarand.BusinessMgr.Web.Control.Controllers.Instance
|
||||
return Json(responseData.SetMessage(messageTitle, repositoryConsole.ErrorStateMessage));
|
||||
|
||||
// Complete response.
|
||||
RepositoryController.PopulateRepositoryResponseListData(model, responseData.Repository, owner, repository);
|
||||
responseData.Success = true;
|
||||
}
|
||||
return Json(responseData);
|
||||
|
||||
@@ -40,10 +40,13 @@
|
||||
|
||||
@* Filter Panel *@
|
||||
<div class="sbc-panel-filter">
|
||||
<div class="row pb4">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch", @maxlength = "32" })
|
||||
<div class="row pb-0">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 row">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch sbc-input", @maxlength = "32" })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -40,10 +40,14 @@
|
||||
|
||||
@* Filter Panel *@
|
||||
<div class="sbc-panel-filter">
|
||||
<div class="row pb4">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch", @maxlength = "32" })
|
||||
<div class="row pb-0">
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-4 row">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch sbc-input", @maxlength = "32" })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,16 +41,18 @@
|
||||
<div class="sbc-panel-filter">
|
||||
@Html.HiddenFor(model => model.DatabaseFilter.Instance, new { @id = "", @class = "FilterInstance" })
|
||||
<div class="row">
|
||||
<div class="col-sm-4 row pb4">
|
||||
<div class="col-sm-4 row pb-0">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.context"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.DropDownListFor(model => model.DatabaseFilter.Context, Model.GetInstanceContextsForSelect(), "", new { @id = "", @class = "FilterContext" })
|
||||
@Html.DropDownListFor(model => model.DatabaseFilter.Context, Model.GetInstanceContextsForSelect(), "", new { @id = "", @class = "FilterContext sbc-select" })
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4 row pb4">
|
||||
<div class="col-sm-4 row pb-0">
|
||||
</div>
|
||||
<div class="col-sm-4 row pb-0">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.DatabaseFilter.Search, new { @type = "search", @id = "", @class = "FilterSearch", @maxlength = "32" })
|
||||
@Html.TextBoxFor(model => model.DatabaseFilter.Search, new { @type = "search", @id = "", @class = "FilterSearch sbc-input", @maxlength = "32" })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -38,16 +38,18 @@
|
||||
@* Filter Panel *@
|
||||
<div class="sbc-panel-filter">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 row pb4">
|
||||
<div class="col-sm-4 row pb-0">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.context"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.DropDownListFor(model => model.DatabaseFilter.Context, Model.GetInstanceContextsForSelect(), "", new { @id = "", @class = "FilterContext" })
|
||||
@Html.DropDownListFor(model => model.DatabaseFilter.Context, Model.GetInstanceContextsForSelect(), "", new { @id = "", @class = "FilterContext sbc-select" })
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4 row pb4">
|
||||
<div class="col-sm-4 row pb-0">
|
||||
</div>
|
||||
<div class="col-sm-4 row pb-0">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.DatabaseFilter.Search, new { @type = "search", @id = "", @class = "FilterSearch", @maxlength = "32" })
|
||||
@Html.TextBoxFor(model => model.DatabaseFilter.Search, new { @type = "search", @id = "", @class = "FilterSearch sbc-input", @maxlength = "32" })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,10 +41,14 @@
|
||||
|
||||
@* Filter Panel *@
|
||||
<div class="sbc-panel-filter">
|
||||
<div class="row pb4">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch", @maxlength = "32" })
|
||||
<div class="row pb-0">
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-4 row">
|
||||
<div class="col-sm-5 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-7">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch sbc-input", @maxlength = "32" })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -43,16 +43,16 @@
|
||||
@* Filter Panel *@
|
||||
<div class="sbc-panel-filter">
|
||||
<div class="row">
|
||||
<div class="col-sm-8 row pb4">
|
||||
<div class="col-sm-8 row pb-0">
|
||||
<div class="col-sm-3 sbc-label text-left text-sm-right">@Localiser["label.item"]</div>
|
||||
<div class="col row">
|
||||
<div class="fixed">
|
||||
@Html.DropDownListFor(model => model.Filter.ItemType, Model.GetParamItemTypesForSelect(), new { @id = "", @class = "FilterItemType mr-1" })
|
||||
<div class="fixed mb-1 mb-sm-0 mr-sm-1">
|
||||
@Html.DropDownListFor(model => model.Filter.ItemType, Model.GetParamItemTypesForSelect(), new { @id = "", @class = "FilterItemType sbc-select" })
|
||||
</div>
|
||||
<div class="col-sm row">
|
||||
<input type="hidden" id="" name="Filter.ItemId" class="FilterItemId" />
|
||||
<div class="col">
|
||||
<input type="text" id="" class="FilterItem fullwidth" readonly="readonly" style="" />
|
||||
<div class="col mr-1">
|
||||
<input type="text" id="" class="FilterItem sbc-input fullwidth" readonly="readonly" style="" />
|
||||
</div>
|
||||
<div class="fixed">
|
||||
<div class="sbc-action FilterItemSearch"><img src="/img/action/search24.png" alt="" title=""></div>
|
||||
@@ -63,7 +63,7 @@
|
||||
<div class="col-sm-4 row pb4">
|
||||
<div class="col-sm-4 sbc-label text-left text-sm-right">@Localiser["label.search"]</div>
|
||||
<div class="col-sm-8">
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch fullwidth", @maxlength = "32" })
|
||||
@Html.TextBoxFor(model => model.Filter.Search, new { @type = "search", @id = "", @class = "FilterSearch sbc-input fullwidth", @maxlength = "32" })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
crossorigin="anonymous"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" />
|
||||
</environment>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
|
||||
<link rel="stylesheet" href="~/css/sbc-base.css?@Model.HrefVersion" />
|
||||
<link rel="stylesheet" href="~/css/sbc-main.css?@Model.HrefVersion" />
|
||||
<link rel="stylesheet" href="~/css/sbc-data.css?@Model.HrefVersion" />
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
}
|
||||
|
||||
<style>
|
||||
.sbc-panel.LogFiles select
|
||||
{
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
#dlgLogFile .FileData
|
||||
{
|
||||
font-family: Courier New, Courier, monospace;
|
||||
@@ -57,21 +62,29 @@
|
||||
{
|
||||
<input type="hidden" name="LogsFilter.Filename" class="FilterLogFilename" />
|
||||
<div class="row">
|
||||
<div class="col-sm-12 row mb-1">
|
||||
<div class="col-sm-4 col-md-3 sbc-label text-left text-sm-right" style="padding-top:2px;">@Localiser["label.root.folder"]</div>
|
||||
<div class="col-sm-8 col-md-9 sbc-value mt-1 bold">@(Model.LoggingRootFolder)</div>
|
||||
<div class="col-sm-12 row mb-2">
|
||||
<div class="col-sm-3 col-md-3 sbc-label pt-1 text-left text-sm-right">@Localiser["label.root.folder"]</div>
|
||||
<div class="col-sm-9 col-md-9 sbc-value pt-1 bold">@(Model.LoggingRootFolder)</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 row">
|
||||
<div class="col-sm-4 col-md-5 sbc-label text-left text-sm-right">@Localiser["label.folder"]</div>
|
||||
<div class="col-sm-8 col-md-7 mb-1"><div style="max-width:200px;"><select id="cbFilterLogFolder" name="LogsFilter.Folder" class="FilterLogFolder"></select></div></div>
|
||||
<div class="col-sm-3 col-md-4 sbc-label text-left text-sm-right">@Localiser["label.folder"]</div>
|
||||
<div class="col-sm-9 col-md-8 mb-1"><div style="max-width:200px;"><select id="cbFilterLogFolder" name="LogsFilter.Folder" class="FilterLogFolder sbc-select"></select></div></div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-4 row">
|
||||
<div class="col-sm-3 col-md-4 sbc-label text-left text-sm-right">@Localiser["label.year"]</div>
|
||||
<div class="col-sm-9 col-md-8 mb-1">
|
||||
<select id="cbFilterLogYear" name="LogsFilter.Year" class="FilterLogYear sbc-select" style="max-width:100px;"></select>
|
||||
<span class="sbc-icon fa-solid fa-chevron-left text-info icon-year-prev"></span>
|
||||
<span class="sbc-icon fa-solid fa-chevron-right text-info icon-year-next"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 row">
|
||||
<div class="col-sm-4 col-md-5 sbc-label text-left text-sm-right">@Localiser["label.year"]</div>
|
||||
<div class="col-sm-8 col-md-7 mb-1"><div style="max-width:200px;"><select id="cbFilterLogYear" name="LogsFilter.Year" class="FilterLogYear"></select></div></div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-4 row">
|
||||
<div class="col-sm-4 col-md-5 sbc-label text-left text-sm-right">@Localiser["label.month"]</div>
|
||||
<div class="col-sm-8 col-md-7"><div style="max-width:200px;"><select id="cbFilterLogMonth" name="LogsFilter.Month" class="FilterLogMonth"></select></div></div>
|
||||
<div class="col-sm-3 col-md-4 sbc-label text-left text-sm-right">@Localiser["label.month"]</div>
|
||||
<div class="col-sm-9 col-md-8">
|
||||
<select id="cbFilterLogMonth" name="LogsFilter.Month" class="FilterLogMonth sbc-select" style="max-width:100px;"></select>
|
||||
<span class="sbc-icon fa-solid fa-chevron-left text-info icon-month-prev"></span>
|
||||
<span class="sbc-icon fa-solid fa-chevron-right text-info icon-month-next"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
.sbc-panel-data .sbc-panel-filter .sbc-label
|
||||
{
|
||||
padding: 2px 8px 0 0;
|
||||
padding: 4px 8px 0 0;
|
||||
}
|
||||
|
||||
/* Data panel - Content */
|
||||
|
||||
@@ -167,8 +167,10 @@
|
||||
|
||||
.sbc-form .sbc-input, .sbc-form .sbc-textarea, .sbc-form .sbc-select
|
||||
{
|
||||
padding: 3px 8px 4px 8px;
|
||||
box-sizing: border-box;
|
||||
padding: 3px 8px 3px 8px;
|
||||
width: 100%;
|
||||
min-height: 1rem;
|
||||
font-size: 1rem;
|
||||
line-height: 1.25;
|
||||
background-color: #fff;
|
||||
|
||||
@@ -232,6 +232,35 @@ a:focus
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Icons */
|
||||
|
||||
.sbc-icon
|
||||
{
|
||||
display: inline-block;
|
||||
min-width: 24px;
|
||||
height: 20px;
|
||||
padding: 2px;
|
||||
text-align: center;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
vertical-align: middle;
|
||||
border: solid 1px #e0e0e0;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sbc-icon:active {
|
||||
background-color: #d4af37;
|
||||
box-shadow: inset 2px 2px 6px #aaa;
|
||||
border-color: #b0b0b0;
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.sbc-icon:hover
|
||||
{
|
||||
border-color:#17a2b8;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
|
||||
.sbc-button-cta, .sbc-button-action
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
sbc.refreshControlValues(response.controlValues);
|
||||
if (!response.success) return;
|
||||
env.$dlg.init.dialog('close');
|
||||
if (env.cfg.fnSuccess) env.cfg.fnSuccess();
|
||||
if (env.cfg.fnSuccess) env.cfg.fnSuccess(response.repository);
|
||||
delete env.cfg;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,11 @@
|
||||
let items = response.repositories || [];
|
||||
if (!items.length)
|
||||
return $pnl.msgs.append($('<div class="sbc-message">' + sbc.msg.dataNoneFound + '</div>')).fadeIn(500);
|
||||
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
|
||||
$table.append(ir.populateItem(ir.getItemRowTemplate(), items[itemIdx]));
|
||||
ir.refreshRepoInfo(items[0].id, 500);
|
||||
for (const item of items)
|
||||
{
|
||||
$table.append(ir.populateItem(ir.getItemRowTemplate(), item));
|
||||
ir.addRepoForInfo(item);
|
||||
}
|
||||
}
|
||||
ir.populateItem = function ($item, item)
|
||||
{
|
||||
@@ -79,6 +81,29 @@
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
const reposForInfo = [];
|
||||
ir.addRepoForInfo = (item) =>
|
||||
{
|
||||
if (reposForInfo.some(repo => repo.id == item.id)) return;
|
||||
ir.clearRepoInfo(item);
|
||||
reposForInfo.push(item);
|
||||
if (reposForInfo.length == 1) ir.refreshNextRepoInfo();
|
||||
}
|
||||
ir.clearRepoInfo = (item) =>
|
||||
{
|
||||
$pnl.table.find('#' + ir.getItemId(item)).find('.RepositoryInitialised').empty();
|
||||
}
|
||||
ir.resetRefreshRepoInfo = () =>
|
||||
{
|
||||
reposForInfo.length = 0;
|
||||
sbc.cancelAjaxRequest(ir.ajax.repoInit);
|
||||
}
|
||||
ir.refreshNextRepoInfo = () =>
|
||||
{
|
||||
if (ir.ajax.repoInit?.timeout) return;
|
||||
let repo = reposForInfo.shift();
|
||||
if (repo?.id) ir.refreshRepoInfo(repo.id, 200);
|
||||
}
|
||||
ir.refreshRepoInfo = function (id, delay)
|
||||
{
|
||||
$frm.itemId.find('.RepositoryId').val(id);
|
||||
@@ -103,13 +128,11 @@
|
||||
}
|
||||
else $repoInit.append($('<div>').append($('<img style="width:16px">').prop('src', '/img/icon/tick-24.png')));
|
||||
$bgr.toggle(!!$('.sbc-dropdown-item', $mnu).length);
|
||||
let $next = $item.next();
|
||||
if ($next.length) ir.refreshRepoInfo($next.prop('id').replace(/[^0-9]/g, ''), 200);
|
||||
ir.refreshNextRepoInfo();
|
||||
}
|
||||
ir.onInitRepo = function (id)
|
||||
ir.onInitRepo = function (item)
|
||||
{
|
||||
//sbc.debug('onInitRepo', id);
|
||||
ir.refreshResults(50);
|
||||
ir.addRepoForInfo(item);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -237,6 +260,7 @@
|
||||
$('table tbody', $pnl.table).prepend($item).show();
|
||||
}
|
||||
ir.populateItem($item, item);
|
||||
ir.addRepoForInfo(item);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
@@ -136,6 +136,19 @@
|
||||
var sel = $(':selected', $sel).length;
|
||||
($info || $('.sbc-info', $sel.closest('.sbc-form-control'))).text(sel == 0 ? sbc.lbl.noneSelected : sbc.lbl.numberSelected.replace(/\{0\}/g, sel));
|
||||
}
|
||||
sbc.offsetSelectedOption = ($sel, offset) =>
|
||||
{
|
||||
var currentIndex = $sel.prop('selectedIndex');
|
||||
var optionsCount = $sel.find('option').length;
|
||||
if (optionsCount === 0) return;
|
||||
var newIndex = currentIndex + offset;
|
||||
if (newIndex < 0) newIndex = 0;
|
||||
if (newIndex >= optionsCount) newIndex = optionsCount - 1;
|
||||
if (newIndex != currentIndex)
|
||||
$sel.prop('selectedIndex', newIndex).trigger('change');
|
||||
}
|
||||
|
||||
|
||||
sbc.initCalendars = function (sel, opt)
|
||||
{
|
||||
return $(sel).datepicker(opt || {});
|
||||
@@ -148,6 +161,7 @@
|
||||
$(this).datepicker('setDate', null).datepicker('hide').trigger('change');
|
||||
});
|
||||
}
|
||||
|
||||
sbc.refreshPaging = function (response, context, refreshFn)
|
||||
{
|
||||
if (sbc.resultsPaging.fn.refreshPaging)
|
||||
@@ -341,15 +355,20 @@
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Ajax.
|
||||
sbc.doAjaxRequest = function (ajax, delay)
|
||||
sbc.doAjaxRequest = (ajax, delay) =>
|
||||
{
|
||||
win.clearTimeout(ajax.timeout);
|
||||
if (!ajax.noWaitIcon) sbc.doPleaseWait();
|
||||
ajax.timeout = setTimeout(function () { sbc.execAjaxRequest(ajax); }, Math.max(50, parseInt(delay || 0, 10)));
|
||||
}
|
||||
sbc.execAjaxRequest = function (ajax)
|
||||
sbc.cancelAjaxRequest = (ajax) =>
|
||||
{
|
||||
win.clearTimeout(ajax?.timeout);
|
||||
}
|
||||
sbc.execAjaxRequest = (ajax) =>
|
||||
{
|
||||
win.clearTimeout(ajax.timeout);
|
||||
delete ajax.timeout;
|
||||
if (ajax.request) ajax.request.abort();
|
||||
var cfgAjax =
|
||||
{
|
||||
|
||||
@@ -275,6 +275,10 @@
|
||||
$ctrl.cbFolders = $frm.filter.find('#cbFilterLogFolder').on('change', function () { sl.refreshYears(250); });
|
||||
$ctrl.cbYears = $frm.filter.find('#cbFilterLogYear').on('change', function () { sl.refreshMonths(250); });
|
||||
$ctrl.cbMonths = $frm.filter.find('#cbFilterLogMonth').on('change', function () { sl.refreshFiles(250); });
|
||||
$('.icon-year-prev').on('click', () => { sbc.offsetSelectedOption($ctrl.cbYears, -1) });
|
||||
$('.icon-year-next').on('click', () => { sbc.offsetSelectedOption($ctrl.cbYears, 1) });
|
||||
$('.icon-month-prev').on('click', () => { sbc.offsetSelectedOption($ctrl.cbMonths, -1) });
|
||||
$('.icon-month-next').on('click', () => { sbc.offsetSelectedOption($ctrl.cbMonths, 1) });
|
||||
|
||||
var opt = sbc.dlgOpts();
|
||||
opt.buttons[sbc.lbl.close] = function () { $(this).dialog('close'); sl.setFileData(); };
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Control.Consoles;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.Helpers;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
@@ -17,25 +15,16 @@ using Sarand.BusinessMgr.Web.Portal.Consoles;
|
||||
using Sarand.BusinessMgr.Web.Portal.Helpers;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Diary;
|
||||
using Sarand.Net.Standard.Base.Interfaces;
|
||||
using Sarand.Net.Standard.Base.IO;
|
||||
using Sarand.Net.Standard.Base.ItemData;
|
||||
using Sarand.Net.Standard.Base.ItemDocs;
|
||||
using Sarand.Net.Standard.Base.ItemOptions;
|
||||
using Sarand.Net.Standard.Base.ReferenceData;
|
||||
using Sarand.Net.Standard.Base.Security;
|
||||
using Sarand.Net.Standard.Base.UpdateLog;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
@@ -52,17 +41,51 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
// Session contexts.
|
||||
private static ushort sessionContextIdx_Next = 100;
|
||||
/// <summary>Core BusinessMgr database instance profile.</summary>
|
||||
private class SessionContextData_Control
|
||||
private class SessionContextData_Control : SacsDisposable
|
||||
{
|
||||
public SessionContextData_Control(SbmSessionContext_Web sessionContext, SysId controlOwnerId, SysId controlRepositoryId)
|
||||
public SessionContextData_Control(SbmSessionContext_Web sessionContext, SbmcRepository repository)
|
||||
{
|
||||
this.SessionContext = sessionContext;
|
||||
this.ControlOwnerId = controlOwnerId;
|
||||
this.ControlRepositoryId = controlRepositoryId;
|
||||
this.ControlRepositoryId = repository.Id;
|
||||
RefreshRepository(repository);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
instanceDataCache?.Dispose();
|
||||
instanceDataCache = null;
|
||||
}
|
||||
public void RefreshRepository(SbmcRepository repository)
|
||||
{
|
||||
bool contextChanged = false;
|
||||
if (ControlOwnerId is null || !ControlOwnerId.Equals(repository.OwnerId))
|
||||
{
|
||||
ControlOwnerId = repository.OwnerId;
|
||||
contextChanged = true;
|
||||
}
|
||||
if (!RepositoryContexts.Contains(repository.Context))
|
||||
{
|
||||
RepositoryContexts.Clear();
|
||||
RepositoryContexts.Add(repository.Context);
|
||||
contextChanged = true;
|
||||
}
|
||||
// Database.
|
||||
SacsDatabaseConsole.OdbcConfig odbcConfig = SbmCoreInstanceConsole_Dbas.GetRepositoryOdbcConfig(repository);
|
||||
if (!odbcConfig.ConnectionString.EqualsCI(OdbcConfig?.ConnectionString ?? ""))
|
||||
{
|
||||
OdbcConfig = odbcConfig;
|
||||
contextChanged = true;
|
||||
}
|
||||
if (contextChanged)
|
||||
{
|
||||
instanceConfig = null;
|
||||
instanceDataCache?.Reset();
|
||||
}
|
||||
PropertiesPopulated = DateTime.Now;
|
||||
}
|
||||
public SbmSessionContext_Web SessionContext { get; }
|
||||
public HashSet<string> RepositoryContexts { get; } = new HashSet<string>();
|
||||
public ISacsDatabase BusMgrDatabase { get; set; }
|
||||
public SacsDatabaseConsole.OdbcConfig OdbcConfig { get; set; }
|
||||
public DateTime PropertiesPopulated { get; private set; } = DateTime.Now;
|
||||
// Instance configuration - Instance specific Application rules etc.
|
||||
private SbmInstanceConfig instanceConfig = null;
|
||||
public SbmInstanceConfig InstanceConfig
|
||||
@@ -79,7 +102,7 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
public SbmInstanceDataCache_Dbas InstanceDataCache { get { if (instanceDataCache == null) { instanceDataCache = new SbmInstanceDataCache_Dbas(SessionContext); } return instanceDataCache; } }
|
||||
// Control database properties.
|
||||
public bool IsControl { get { return SysId.IsValid(ControlOwnerId) && SysId.IsValid(ControlRepositoryId); } }
|
||||
public SysId ControlOwnerId { get; }
|
||||
public SysId ControlOwnerId { get; set; }
|
||||
public SysId ControlRepositoryId { get; }
|
||||
}
|
||||
private readonly Dictionary<int, SessionContextData_Control> sessionContexts = new Dictionary<int, SessionContextData_Control>();
|
||||
@@ -104,6 +127,16 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
SaLogger.Error($"{SysUtil.Fn} Application instance already established.");
|
||||
Instance = this;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
foreach (var coreInstance in sessionContexts.Values)
|
||||
coreInstance.Dispose();
|
||||
sessionContexts.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
@@ -146,9 +179,12 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override ISacsDatabase GetBusMgrDatabase(SbmSessionContext sessionContext)
|
||||
public override ISacsDatabase CreateBusMgrDatabase(SbmSessionContext sessionContext)
|
||||
{
|
||||
return sessionContexts.GetValue(sessionContext?.Index ?? 0, null)?.BusMgrDatabase;
|
||||
ISacsDatabase busMgrDatabase = SacsDatabaseConsole.OpenOdbcDatabase(sessionContexts.GetValue(sessionContext?.Index ?? 0, null)?.OdbcConfig);
|
||||
if (busMgrDatabase.HasErrorState())
|
||||
SaLogger.Warn($"{SysUtil.Fn} BusMgr Database: " + busMgrDatabase.DatabaseName + ". Initialisation error: " + busMgrDatabase.ErrorStateMessage);
|
||||
return busMgrDatabase;
|
||||
}
|
||||
// Instance configuration.
|
||||
public override SbmInstanceConfig GetInstanceConfig(SbmSessionContext sessionContext)
|
||||
@@ -271,29 +307,22 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
if (owner.IsStatusActive && repository.IsStatusActive)
|
||||
{
|
||||
// Configure Core database.
|
||||
SacsDatabaseConsole.OdbcConfig config = SbmCoreInstanceConsole_Dbas.GetRepositoryOdbcConfig(repository);
|
||||
SacsDatabase coreDatabase = SacsDatabaseConsole.OpenOdbcDatabase(config);
|
||||
|
||||
if (!coreDatabase.HasErrorState())
|
||||
// Create Session Context if not not currently populated.
|
||||
if (sessionContextData == null)
|
||||
{
|
||||
// Create Session Context if not not currently populated.
|
||||
if (sessionContextData == null)
|
||||
{
|
||||
// New Session context.
|
||||
ushort sessionContextIdx = sessionContextIdx_Next++;
|
||||
bool demoRepository = repositoryContext.EqualsCI(Sbm.RepositoryContext_Demo);
|
||||
sessionContextData = new SessionContextData_Control(new SbmSessionContext_Web(sessionContextIdx, demoRepository ? Sbm.Application.WebDemo : Sbm.Application.WebPortal), owner.Id, repository.Id);
|
||||
sessionContexts.Add(sessionContextData.SessionContext.Index, sessionContextData);
|
||||
SaLogger.Info($"{SysUtil.Fn} Control Instance initialised: Context: {repository.Context}. Database: {repository.DatabaseName}.");
|
||||
}
|
||||
else SaLogger.Info($"{SysUtil.Fn} Control Instance refreshed: Context: {repository.Context}. Database: {repository.DatabaseName}.");
|
||||
|
||||
// Refresh properties.
|
||||
sessionContextData.RepositoryContexts.Add(repository.Context);
|
||||
sessionContextData.BusMgrDatabase = coreDatabase;
|
||||
// New Session context.
|
||||
ushort sessionContextIdx = sessionContextIdx_Next++;
|
||||
bool demoRepository = repositoryContext.EqualsCI(Sbm.RepositoryContext_Demo);
|
||||
sessionContextData = new SessionContextData_Control(new SbmSessionContext_Web(sessionContextIdx, demoRepository ? Sbm.Application.WebDemo : Sbm.Application.WebPortal), repository);
|
||||
sessionContexts.Add(sessionContextData.SessionContext.Index, sessionContextData);
|
||||
SaLogger.Info($"{SysUtil.Fn} Control Instance initialised: Context: {repository.Context}. Database: {repository.DatabaseName}.");
|
||||
}
|
||||
else SaLogger.Warn($"{SysUtil.Fn} Database: {coreDatabase.DatabaseName}. Initialisation error: {coreDatabase.ErrorStateMessage}");
|
||||
else SaLogger.Info($"{SysUtil.Fn} Control Instance refreshed: Context: {repository.Context}. Database: {repository.DatabaseName}.");
|
||||
|
||||
// Refresh properties.
|
||||
sessionContextData.ControlOwnerId = owner.Id;
|
||||
sessionContextData.RepositoryContexts.Add(repository.Context);
|
||||
sessionContextData.OdbcConfig = SbmCoreInstanceConsole_Dbas.GetRepositoryOdbcConfig(repository);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -304,6 +333,70 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
return sessionContextData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Housekeeping.
|
||||
// NB Housekeeping triggered every 60 mins.
|
||||
|
||||
private class HousekeepingConfig
|
||||
{
|
||||
public TimeSpan RefreshInstanceSessionPropertiesInterval { get; set; } = TimeSpan.FromMinutes(50);
|
||||
public DateTime RefreshInstanceSessionPropertiesLastRun { get; set; } = DateTime.Now;
|
||||
}
|
||||
private HousekeepingConfig housekeepingConfig = new HousekeepingConfig();
|
||||
|
||||
/// <summary>
|
||||
/// Perform periodic application housekeeping.
|
||||
/// </summary>
|
||||
public override void DoHousekeeping(CancellationToken ct)
|
||||
{
|
||||
SaLogger.Info($"{SysUtil.Fn} Doing housekeeping.", true);
|
||||
if (DateTime.Now.Subtract(housekeepingConfig.RefreshInstanceSessionPropertiesLastRun) >= housekeepingConfig.RefreshInstanceSessionPropertiesInterval)
|
||||
{
|
||||
RefreshInstanceSessionProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Periodicallly refresh Instance Session properties - e.g. ODBC configuration etc.
|
||||
/// </summary>
|
||||
private void RefreshInstanceSessionProperties()
|
||||
{
|
||||
housekeepingConfig.RefreshInstanceSessionPropertiesLastRun = DateTime.Now;
|
||||
using (DisposableCollection<IDisposable> disposables = new DisposableCollection<IDisposable>())
|
||||
{
|
||||
SbmcInstanceMgr controlInstanceMgr = SbmGlobals_Web.System.CreateControlInstanceMgr();
|
||||
if (controlInstanceMgr == null) return;
|
||||
disposables.Add(controlInstanceMgr);
|
||||
|
||||
foreach (SessionContextData_Control sessionContextData in sessionContexts.Values)
|
||||
{
|
||||
// Retrieve repository for session context.
|
||||
SbmcRepository repository = controlInstanceMgr.GetRepositoryById(sessionContextData.ControlRepositoryId);
|
||||
if (repository == null) continue;
|
||||
|
||||
// Owner.
|
||||
if (!sessionContextData.ControlOwnerId.Equals(repository.OwnerId))
|
||||
{
|
||||
sessionContextData.ControlOwnerId = repository.OwnerId;
|
||||
}
|
||||
|
||||
// Contexts.
|
||||
if (!sessionContextData.RepositoryContexts.ContainsCI(repository.Context))
|
||||
{
|
||||
sessionContextData.RepositoryContexts.Clear();
|
||||
sessionContextData.RepositoryContexts.Add(repository.Context);
|
||||
}
|
||||
|
||||
// Database configuration.
|
||||
SacsDatabaseConsole.OdbcConfig odbcConfig = SbmCoreInstanceConsole_Dbas.GetRepositoryOdbcConfig(repository);
|
||||
if (!sessionContextData.OdbcConfig.ConnectionString.EqualsCI(SacsDatabaseConsole.GenerateConnectionString(sessionContextData.OdbcConfig)))
|
||||
{
|
||||
sessionContextData.OdbcConfig = odbcConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Sarand.BusinessMgr.Net.Core.Web.App;
|
||||
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
{
|
||||
@@ -28,7 +23,14 @@ namespace Sarand.BusinessMgr.Web.Portal.App
|
||||
// Initialise application.
|
||||
application = new SbmApplication_Portal(Configuration);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
application.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Security
|
||||
if (sessionContext == null) return false;
|
||||
|
||||
SbmSessionData_Portal sessionDataForUser = new SbmSessionData_Portal(sessionContext, model.RepositoryContext, null, null, null, null);
|
||||
ISacsDatabase busMgrDatabase = App.GetBusMgrDatabase(sessionContext);
|
||||
ISacsDatabase busMgrDatabase = Internals.BusMgrDatabase;
|
||||
if (busMgrDatabase == null) return false;
|
||||
|
||||
using (DisposableCollection<IDisposable> disposables = new DisposableCollection<IDisposable>())
|
||||
|
||||
Reference in New Issue
Block a user