Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            ConsoleHandler.SetConsoleCtrlHandler(ConsoleHandler.GoodHandler, true);

            var service = new CollectorService();

            if ((args.Length == 5 && args[0] == "-d"))
            {
                service.SaveMessage(args[1], Convert.ToInt32(args[2]), args[3], args[4]);

                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
            else if (Environment.UserInteractive)
            {
                service.StartDaemon();
            }
            else
            {
                ServiceBase.Run(service);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            ConsoleHandler.SetConsoleCtrlHandler(ConsoleHandler.GoodHandler, true);

            if (Environment.UserInteractive)
            {
                var options = new Options();

                if (CommandLine.Parser.Default.ParseArgumentsStrict(args, options,
                                                                    () =>
                                                                    Console.WriteLine("Bad command line parameters.")))
                {
                    var service = new CollectorService(options.OnlyUsers);
                    service.StartDaemon();
                }
                Console.ReadKey();
            }
            else
            {
                ServiceBase.Run(new CollectorService());
            }
        }