Example #1
0
        /// <summary>
        /// Главная функция программы
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                // Первый аргумент командной строки
                string cmd = (args.Count() > 0) ? args[0] : "";

                // Файл самого сервиса
                string s = Assembly.GetExecutingAssembly().Location;

                // Селектор команд
                switch (cmd)
                {
                case "console":
                    var bot = new CSharpBot();
                    bot.Start();
                    Console.WriteLine("Бот запущен, для завершения нажмите Enter");
                    Console.ReadLine();
                    break;

                case "install":
                    ManagedInstallerClass.InstallHelper(new string[] { s });
                    Console.ReadLine();
                    break;

                case "uninstall":
                    ManagedInstallerClass.InstallHelper(new string[] { "/u", s });
                    Console.ReadLine();
                    break;

                default:     // Запуск в виде сервиса
                    var svc = new BotService();
                    ServiceBase.Run(svc);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
Example #2
0
 /// <summary>
 /// Конструктор по умолчанию
 /// </summary>
 public BotService()
 {
     InitializeComponent();
     bot = new CSharpBot();
 }