Migrated the legacy VB.NET Windows Service to a modern C# Worker Service targeting .NET Framework 4.6.2. Key changes include: - Added `Microsoft.Extensions.Hosting.WindowsServices`, `NLog`, and `Quartz` for logging and scheduling. - Introduced `LogConfigFactory` to bridge `ServiceConfig` and `LogConfig` for Quartz jobs. - Rewrote `Worker` to handle the full service lifecycle, including database connection, temp file management, and scheduler initialization. - Implemented `SchedulerFinishEnvelope` and `SchedulerEnvelopeTaskApi` for Quartz job scheduling. - Created `TempFiles` for service-level temp file management. - Configured `NLog` for file and console logging. - Updated `appsettings.json` for connection strings and service-specific configuration. - Replaced legacy `ProjectInstaller` with `AddWindowsService()` for SCM integration.
29 lines
834 B
C#
29 lines
834 B
C#
using DigitalData.Modules.Logging;
|
|
|
|
namespace EnvelopeGenerator.Service;
|
|
|
|
/// <summary>
|
|
/// Builds a <see cref="LogConfig"/> from <see cref="ServiceConfig"/>.
|
|
/// Required because CommonServices jobs have a hard dependency on <see cref="LogConfig"/>
|
|
/// in their Quartz <c>JobDataMap</c>.
|
|
/// Log path mirrors the legacy behavior: <c><BaseDirectory>\Log</c>.
|
|
/// </summary>
|
|
internal static class LogConfigFactory
|
|
{
|
|
public static LogConfig Create(ServiceConfig config)
|
|
{
|
|
var logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log");
|
|
|
|
var logConfig = new LogConfig(
|
|
LogConfig.PathType.CustomPath,
|
|
logPath,
|
|
null,
|
|
"Digital Data",
|
|
"EnvelopeGenerator.Service");
|
|
|
|
logConfig.Debug = config.Debug;
|
|
|
|
return logConfig;
|
|
}
|
|
}
|