148 lines
5.6 KiB
C#
148 lines
5.6 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Sarand.BusinessMgr.Net.Core.Web.Consoles;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
|
|
using Sarand.BusinessMgr.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.CodeTypes;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
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 System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Core.Web.App
|
|
{
|
|
//=======================================================================
|
|
public abstract class SbmApplication_Web : SbmApplication
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
protected Sbm.InstanceType instanceType;
|
|
protected String environmentName = "";
|
|
|
|
//-------------------------------------------------------------------
|
|
// Protected construction.
|
|
protected SbmApplication_Web() : base(new PropertySet())
|
|
{
|
|
SbmGlobals_Web.Application = this;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public override SbmSystem System { get { return System_Web; } }
|
|
public SbmSystem_Web System_Web { get; protected set; }
|
|
// Application instance.
|
|
public override Sbm.InstanceType InstanceType { get { return instanceType; } }
|
|
public override String EnvironmentName { get { return environmentName; } }
|
|
public bool Development { get; protected set; }
|
|
public String LoggingRootFolder { get; protected set; } = "";
|
|
// Application components.
|
|
public abstract SbmAppConfig AppConfig { get; }
|
|
public abstract String SessionCookieName { get; }
|
|
public abstract List<ushort> GetSessionContextIdxs();
|
|
public abstract SbmSessionContext GetSessionContext(ushort index);
|
|
// Configuration.
|
|
public IConfiguration Configuration { get; protected set; }
|
|
public IConfiguration SbmConfiguration { get; protected set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Logging.
|
|
protected void LogApplicationStart(String fn)
|
|
{
|
|
// Log application start.
|
|
List<StringPair> applicationParams = new List<StringPair>();
|
|
applicationParams.Add("Host", SbmSystem.ComputerName);
|
|
applicationParams.Add("Version", Sbm.Version.GetFullVersion());
|
|
applicationParams.Add("Instance", InstanceType.ToString() + (!StringUtil.IsEmpty(AppConfig.Instance) ? " [" + AppConfig.Instance + "]" : ""));
|
|
applicationParams.Add("Configuration", SbmSystem.DebugMode ? "Debug" : "Release");
|
|
applicationParams.Add("Environment", EnvironmentName);
|
|
applicationParams.Add("Control database", AppConfig.ControlDatabase.Location);
|
|
applicationParams.Add("BusMgr database", AppConfig.BusMgrDatabase.Location);
|
|
applicationParams.Add("Application root", SbmSystem.ApplicationFolder);
|
|
if (!StringUtil.IsEmpty(AppConfig.Documents.RootFolder))
|
|
applicationParams.Add("Documents root", AppConfig.Documents.RootFolder);
|
|
applicationParams.Add("Email context", AppConfig.Email.Context + (!StringUtil.IsEmpty(EmailConfig.SMTP.Server) ? " [" + EmailConfig.SMTP.Server + "]" : ""));
|
|
SaLogger.Info(fn + " Application start." + applicationParams.Select(item => StringUtil.PadRight(item.Item1 + ":", 20, ' ') + item.Item2).Concat("", "\n\t"), true);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
protected void InitialiseTemporaryLoggingFolder()
|
|
{
|
|
// Default logging folder - in case of startup failure.
|
|
try
|
|
{
|
|
foreach (String folder in new String[] { @"D:\Sarand\Projects\User\AHoward\VS2017\Sbmonite\Logs" })
|
|
{
|
|
if (DirectoryUtil.DirectoryExists(folder))
|
|
{
|
|
SaLogger.LogFolder = folder;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Create consoles.
|
|
public override SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext)
|
|
{
|
|
return SbmConfigConsole.CreateConsole(sessionContext);
|
|
}
|
|
public override SaDiaryConsole CreateDiaryConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaSecurityConsole CreateSecurityConsole(ISbmUserContext userContext)
|
|
{
|
|
return new SbmSecurityConsole_Web(userContext);
|
|
}
|
|
public override SaCodeTypeConsole CreateCodeTypeConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaReferenceDataConsole CreateReferenceDataConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaItemDataConsole CreateItemDataConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaItemDocConsole CreateItemDocConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaItemOptionConsole CreateItemOptionConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaInterfaceConsole CreateInterfaceConsole(ISbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaUpdateLogConsole CreateUpdateLogConsole(ISbmUserContext userContext)
|
|
{
|
|
return new SbmUpdateLogConsole_Web(userContext);
|
|
}
|
|
public override SbmEmailConsole CreateEmailConsole(ISbmUserContext userContext)
|
|
{
|
|
return new SbmEmailConsole_Web(EmailConfig);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|