3.0.0.1 Demo repository registration
This commit is contained in:
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -18,64 +19,52 @@ using System.Linq;
|
||||
namespace Sarand.BusinessMgr.Web.Control.Consoles
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmCoreInstanceConsole_Control : SbmCoreInstanceConsole_Base
|
||||
public class SbmCoreInstanceConsole_Control : SbmCoreInstanceConsole_Dbas
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SacsDatabase coreDatabase;
|
||||
private readonly SysId ownerId;
|
||||
private readonly SysId repositoryId;
|
||||
private SbmInternals internals;
|
||||
private class DataMembers
|
||||
{
|
||||
public SysId OwnerId { get; set; }
|
||||
public SysId RepositoryId { get; set; }
|
||||
public SbmInternals Internals { get; set; }
|
||||
}
|
||||
private DataMembers mbr { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCoreInstanceConsole_Control(SbmSessionData_Control sessionData_Control, SbmcRepository repository)
|
||||
{
|
||||
ownerId = repository.OwnerId;
|
||||
repositoryId = repository.Id;
|
||||
mbr = new DataMembers();
|
||||
mbr.OwnerId = repository.OwnerId;
|
||||
mbr.RepositoryId = repository.Id;
|
||||
this.SessionData_Control = sessionData_Control;
|
||||
|
||||
// Repository connection.
|
||||
SacsDatabaseConsole.OdbcConfig config = GetRepositoryOdbcConfig(repository);
|
||||
coreDatabase = SacsDatabaseConsole.OpenOdbcDatabase(config);
|
||||
if (coreDatabase.HasErrorState())
|
||||
SetErrorState(coreDatabase.ErrorStateMessage);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (mbr.Internals != null) mbr.Internals.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public static SbmApplication_Control App_Control { get { return SbmApplication_Control.Instance; } }
|
||||
public SbmSessionData_Control SessionData_Control { get; }
|
||||
public override ISacsDatabase Database_Core { get { return coreDatabase; } }
|
||||
public override SbmInternals Internals_Core { get { if (internals == null) { internals = CreateCoreInternals(); } return internals; } }
|
||||
public override DbUpdateInfo DbUpdateInfo_Core { get { return Internals_Core.DbUpdateInfo; } }
|
||||
private static SbmApplication_Control App_Control { get { return SbmApplication_Control.Instance; } }
|
||||
private SbmSessionData_Control SessionData_Control { get; }
|
||||
public override SbmInternals Internals { get { if (mbr.Internals == null) { mbr.Internals = CreateCoreInternals(); } return mbr.Internals; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
|
||||
public static SacsDatabaseConsole.OdbcConfig GetRepositoryOdbcConfig(SbmcRepository repository)
|
||||
{
|
||||
SacsDatabaseConsole.OdbcConfig config = new SacsDatabaseConsole.OdbcConfig();
|
||||
config.Location = $"MsSql:{repository.ServerName}\\{repository.InstanceName}.{repository.DatabaseName}";
|
||||
config.User = repository.UserName;
|
||||
config.Password = repository.Password;
|
||||
return config;
|
||||
}
|
||||
|
||||
/// <summary>Core internals for accessing core managers etc.</summary>
|
||||
protected SbmInternals CreateCoreInternals()
|
||||
{
|
||||
ushort sessionIndex = App_Control.GetCoreSessionIndexForControlRepository(ownerId, repositoryId);
|
||||
ushort sessionIndex = App_Control.GetCoreSessionIndexForControlRepository(mbr.OwnerId, mbr.RepositoryId);
|
||||
SbmSessionContext sessionContext = App_Control.GetSessionContextByIndex(sessionIndex);
|
||||
return new SbmInternals(sessionContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user