Esempio n. 1
0
        public static void ServiceMain(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();


            if (args.Length == 1)
            {
                switch (args[0].ToLower())
                {
                case "-install":
                    QuartzServiceInstaller.InstallService();
                    break;

                case "-uninstall":
                    StopIt();
                    QuartzServiceInstaller.UninstallService();
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            else
            {
                if (!Environment.UserInteractive)
                {
                    // running as service
                    using (var service = new Service())
                        ServiceBase.Run(service);
                }
                else
                {
                    // running as console app
                    try
                    {
                        Start(args);
                        Console.WriteLine("Press any key to stop...");
                        Console.ReadKey(true);
                        StopIt();
                    } catch (Exception ex)
                    {
                        _log.Error(ex);
                    }
                }
            }
        }
Esempio n. 2
0
 public void UnInstall()
 {
     StopIt();
     QuartzServiceInstaller.UninstallService();
 }