46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.3 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();
 | 
						|
 | 
						|
  internal static bool isExiting = false;
 | 
						|
  internal static object objSync2 = new();    // used by the CanWeGo proc in Constants
 | 
						|
 | 
						|
  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() { DebugMode = true })
 | 
						|
      {
 | 
						|
        obj.Go();
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      var rc = HostFactory.Run(x =>
 | 
						|
      {
 | 
						|
        x.Service<ServiceMain>();
 | 
						|
        x.EnableServiceRecovery(r => r.RestartService(TimeSpan.FromSeconds(15)));
 | 
						|
        x.SetServiceName("kmCustomReportsNET");
 | 
						|
        x.StartAutomaticallyDelayed();
 | 
						|
        x.SetDescription("Will run some custom reports occasionally for KeyMotive's customers.");
 | 
						|
        x.UseLog4Net();
 | 
						|
      });
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 |