23-08-23
This commit is contained in:
33
EnvelopeGenerator.Web/Services/DatabaseService.cs
Normal file
33
EnvelopeGenerator.Web/Services/DatabaseService.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using DigitalData.Modules.Database;
|
||||
using DigitalData.Modules.Logging;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Services
|
||||
{
|
||||
public class DatabaseService
|
||||
{
|
||||
public MSSQLServer MSSQL { get; set; }
|
||||
|
||||
private readonly LogConfig _logConfig;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DatabaseService(LoggingService Logging, IConfiguration Config)
|
||||
{
|
||||
_logConfig = Logging.LogConfig;
|
||||
_logger = Logging.LogConfig.GetLogger();
|
||||
|
||||
_logger.Debug("Establishing MSSQL Database connection..");
|
||||
MSSQL = new MSSQLServer(_logConfig, Config["Config:ConnectionString"]);
|
||||
|
||||
if (MSSQL.DBInitialized == true)
|
||||
{
|
||||
_logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn("Connection could not be established!");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
EnvelopeGenerator.Web/Services/LoggingService.cs
Normal file
25
EnvelopeGenerator.Web/Services/LoggingService.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using DigitalData.Modules.Logging;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Services
|
||||
{
|
||||
public class LoggingService
|
||||
{
|
||||
public LogConfig LogConfig { get; set; }
|
||||
|
||||
public LoggingService(IConfiguration Config)
|
||||
{
|
||||
LogConfig = new LogConfig(LogConfig.PathType.CustomPath, Config["Config:LogPath"], null, "Digital Data", "ECM.JobRunner.Web");
|
||||
|
||||
var logger = LogConfig.GetLogger();
|
||||
logger.Info("Logging initialized!");
|
||||
|
||||
var debugLog = bool.Parse(Config["Config:LogDebug"]);
|
||||
logger.Info("Setting DEBUG Logging to: [{0}]", debugLog);
|
||||
LogConfig.Debug = debugLog;
|
||||
|
||||
var jsonLog = bool.Parse(Config["Config:LogJson"]);
|
||||
logger.Info("Setting JSON Logging to: [{0}]", jsonLog);
|
||||
LogConfig.Debug = jsonLog;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user