149 lines
5.6 KiB
C#
149 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.Net.Standard.Base.App;
|
|
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.Data;
|
|
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())
|
|
{
|
|
WebApp = this;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public override SbmSystem System { get { return System_Web; } }
|
|
public SbmSystem_Web System_Web { get; protected set; }
|
|
public static SbmApplication_Web WebApp { get; private 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 String SessionCookieName { get; }
|
|
public virtual SbmSessionContext SessionContext { get; protected set; }
|
|
public abstract SbmSessionConfig SessionConfig { get; }
|
|
public override IDatabaseInfo CreateBusMgrDbInfo(SbmSessionContext sessionContext) { return new DbDataItem.DatabaseInfo(GetBusMgrDatabase(sessionContext)); }
|
|
// 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(SessionConfig.Instance) ? " [" + SessionConfig.Instance + "]" : ""));
|
|
applicationParams.Add("Configuration", SbmSystem.DebugMode ? "Debug" : "Release");
|
|
applicationParams.Add("Environment", EnvironmentName);
|
|
applicationParams.Add("Database", SessionConfig.BusMgrDatabase.Location);
|
|
applicationParams.Add("Application root", SbmSystem.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\Sbmonite\Logs" })
|
|
{
|
|
if (DirectoryUtil.DirectoryExists(folder))
|
|
{
|
|
SaLogger.LogFolder = folder;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Create consoles.
|
|
public override SbmConfigConsole CreateConfigConsole(SbmSessionContext sessionContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaDiaryConsole CreateDiaryConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaSecurityConsole CreateSecurityConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaCodeTypeConsole CreateCodeTypeConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaReferenceDataConsole CreateReferenceDataConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaItemDataConsole CreateItemDataConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaItemDocConsole CreateItemDocConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaItemOptionConsole CreateItemOptionConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaInterfaceConsole CreateInterfaceConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SaUpdateLogConsole CreateUpdateLogConsole(SbmUserContext userContext)
|
|
{
|
|
return null;
|
|
}
|
|
public override SbmEmailConsole CreateEmailConsole(SbmUserContext userContext)
|
|
{
|
|
return new SbmEmailConsole_Web(EmailConfig);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|