示例#1
0
        public static void MainMethod(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            settings = new Settings();
            settings.Load(SettingsPath);
            settings.SaveIfNoExist(SettingsPath);

            BPUtil.SimpleHttp.SimpleHttpLogger.RegisterLogger(BPUtil.Logger.httpLogger, settings.logVerbose);
            //bool gotServiceArg = (args.Length > 0 && args[0] == "svc");
            bool gotCmdArg = (args.Length > 0 && args[0] == "cmd");

            if (Environment.UserInteractive || gotCmdArg
                //&& (Environment.OSVersion.Platform == PlatformID.Win32NT
                //	|| Environment.OSVersion.Platform == PlatformID.Win32S
                //	|| Environment.OSVersion.Platform == PlatformID.Win32Windows
                //	|| Environment.OSVersion.Platform == PlatformID.WinCE)
                )
            {
                MainSvc svc = new MainSvc();
                svc.DoStart();
                do
                {
                    Console.WriteLine("Type \"exit\" to close.");
                }while (Console.ReadLine().Trim().ToLower() != "exit");
                svc.DoStop();
            }
            else
            {
                ServiceBase.Run(new MainSvc());
            }
        }
示例#2
0
        public static void MainMethod()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            settings = new Settings();
            settings.Load(SettingsPath);
            settings.SaveIfNoExist(SettingsPath);

            BPUtil.SimpleHttp.SimpleHttpLogger.RegisterLogger(BPUtil.Logger.httpLogger);

            if (!Environment.UserInteractive
                //&& (Environment.OSVersion.Platform == PlatformID.Win32NT
                //	|| Environment.OSVersion.Platform == PlatformID.Win32S
                //	|| Environment.OSVersion.Platform == PlatformID.Win32Windows
                //	|| Environment.OSVersion.Platform == PlatformID.WinCE)
                )
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new MainSvc()
                };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                MainSvc svc = new MainSvc();
                svc.DoStart();
                do
                {
                    Console.WriteLine("Type \"exit\" to close.");
                }while (Console.ReadLine().Trim().ToLower() != "exit");
                svc.DoStop();
            }
        }