96 lines
4.1 KiB
C#
96 lines
4.1 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Dbas;
|
|
using Sarand.Net.Standard.Base.Email;
|
|
using Sarand.Net.Standard.Base.IO;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using Sarand.Net.Standard.Dbas.Data;
|
|
using Saxonite.Net.Core.Web.Base.Consoles;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
using Saxonite.Net.Standard.Base.Consoles;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Saxonite.Net.Core.Web.Base.App
|
|
{
|
|
//=======================================================================
|
|
public abstract class SaxApplication_Web : SaxApplication_Base
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
protected Sax.InstanceType instanceType;
|
|
protected String environmentName = "";
|
|
|
|
//-------------------------------------------------------------------
|
|
// Protected construction.
|
|
protected SaxApplication_Web()
|
|
{
|
|
WebApp = this;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public override SaxSystem System { get { return System_Web; } }
|
|
public SaxSystem_Web System_Web { get; protected set; }
|
|
public static SaxApplication_Web WebApp { get; private set; }
|
|
// Application instance.
|
|
public override Sax.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 String SessionCookieName { get; }
|
|
public virtual SaxSessionContext SessionContext { get; protected set; }
|
|
public abstract SaxSessionConfig SessionConfig { get; }
|
|
public override SaxConsoleHelper ConsoleHelper { get { return ConsoleHelper_Web; } }
|
|
public SaxConsoleHelper_Web ConsoleHelper_Web { get; protected set; }
|
|
public override IDatabaseInfo CreateCoreDbInfo(SaxSessionContext sessionContext) { return new DbDataItem.DatabaseInfo(GetCoreDatabase(sessionContext)); }
|
|
// Configuration.
|
|
public IConfiguration Configuration { get; protected set; }
|
|
public IConfiguration SaxConfiguration { get; protected set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Logging.
|
|
protected void LogApplicationStart(String fn)
|
|
{
|
|
// Log application start.
|
|
List<StringPair> applicationParams = new List<StringPair>();
|
|
applicationParams.Add("Host", SaxSystem.ComputerName);
|
|
applicationParams.Add("Version", Sax.Version.GetFullVersion());
|
|
applicationParams.Add("Instance", InstanceType.ToString() + (!StringUtil.IsEmpty(SessionConfig.Instance) ? " [" + SessionConfig.Instance + "]" : ""));
|
|
applicationParams.Add("Configuration", SaxSystem.DebugMode ? "Debug" : "Release");
|
|
applicationParams.Add("Environment", EnvironmentName);
|
|
applicationParams.Add("Database", SessionConfig.CoreDatabase.Location);
|
|
applicationParams.Add("Application root", SaxSystem.ApplicationFolder);
|
|
if (!StringUtil.IsEmpty(SessionConfig.Documents.RootFolder))
|
|
applicationParams.Add("Documents root", SessionConfig.Documents.RootFolder);
|
|
applicationParams.Add("Email context", SessionConfig.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\Saxonite\Logs" })
|
|
{
|
|
if (DirectoryUtil.DirectoryExists(folder))
|
|
{
|
|
SaLogger.LogFolder = folder;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|