kmCustomReportsNET/Program.cs

45 lines
1.2 KiB
C#

using log4net;
using log4net.Config;
using System.Reflection;
using Topshelf;
using kmCustomReportsNET.ClassObj;
using System.Diagnostics;
namespace kmCustomReportsNET;
internal class Program
{
internal static string AppPath = AppDomain.CurrentDomain.BaseDirectory.Trim();
internal static string AppName = AppDomain.CurrentDomain.FriendlyName.Trim();
internal static string MachineName = Environment.MachineName.Trim();
public static bool isExiting = false;
static void Main(string[] args)
{
var logRepo = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.Configure(logRepo, new FileInfo(Path.Combine(AppPath, "log4net.config")));
GlobalContext.Properties["Application"] = AppName;
if (Debugger.IsAttached)
{
using (var obj = new ClsDobbsEmail_T1439())
{
obj.Go();
}
}
else
{
var rc = HostFactory.Run(x =>
{
x.Service<ServiceMain>();
x.EnableServiceRecovery(r => r.RestartService(TimeSpan.FromSeconds(15)));
x.SetServiceName("kmAtomicTime2");
x.StartAutomaticallyDelayed();
x.SetDescription("Will run some custom reports occasionally for KeyMotive's customers.");
x.UseLog4Net();
});
}
}
}