/// <summary> /// The main entry point for the application /// <para>Основная точка входа для приложения</para> /// </summary> static void Main(string[] args) { // запуск агента Console.WriteLine("Starting Agent..."); AgentManager agentManager = new AgentManager(); if (agentManager.StartAgent()) { Console.WriteLine("Agent is started successfully"); } else { Console.WriteLine("Agent is started with errors"); } Console.WriteLine("Press 'x' or create 'agentstop' file to stop Agent"); // остановка службы при нажатии 'x' или обнаружении файла остановки FileListener stopFileListener = new FileListener(AppData.GetInstance().AppDirs.ConfigDir + "serverstop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.X || stopFileListener.FileFound)) { Thread.Sleep(ScadaUtils.ThreadDelay); } agentManager.StopAgent(); stopFileListener.DeleteFile(); stopFileListener.Abort(); Console.WriteLine("Agent is stopped"); }
static void Main(string[] args) { // start the service Console.WriteLine("Starting Communicator..."); Manager manager = new Manager(); if (manager.StartService()) { Console.WriteLine("Communicator is started successfully"); } else { Console.WriteLine("Communicator is started with errors"); } // stop the service if 'x' is pressed or a stop file exists Console.WriteLine("Press 'x' or create 'commstop' file to stop Communicator"); FileListener stopFileListener = new FileListener(Path.Combine(manager.AppDirs.CmdDir, "commstop")); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.X || stopFileListener.FileFound)) { Thread.Sleep(ScadaUtils.ThreadDelay); } manager.StopService(); stopFileListener.Terminate(); stopFileListener.DeleteFile(); Console.WriteLine("Communicator is stopped"); }
private static void Main(string[] args) { // service start Console.WriteLine("Starting SCADA-Server..."); var manager = new Manager(); manager.StartService(); Console.WriteLine("SCADA-Server is started"); Console.WriteLine("Press 'x' or create 'serverstop' file to stop SCADA-Server"); // stopping the service when you press 'x' or find the file stop FileListener stopFileListener = new FileListener("Cmd" + Path.DirectorySeparatorChar + "serverstop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.X || stopFileListener.FileFound)) { Thread.Sleep(ScadaUtils.ThreadDelay); } manager.StopService(); stopFileListener.DeleteFile(); stopFileListener.Abort(); Console.WriteLine("SCADA-Server is stopped"); }
/// <summary> /// The main entry point for the application /// <para>The main entry point for the application</para> /// </summary> static void Main(string[] args) { // agent start Console.WriteLine("Starting Agent..."); var agentManager = new AgentManager(); if (agentManager.StartAgent()) { Console.WriteLine("Agent is started successfully"); } else { Console.WriteLine("Agent is started with errors"); } Console.WriteLine("Press 'x' or create 'agentstop' file to stop Agent"); // stopping the service when you press 'x' or find the file stop FileListener stopFileListener = new FileListener(AppData.GetInstance().AppDirs.ConfigDir + "serverstop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.X || stopFileListener.FileFound)) { Thread.Sleep(ScadaUtils.ThreadDelay); } agentManager.StopAgent(); stopFileListener.DeleteFile(); stopFileListener.Abort(); Console.WriteLine("Agent is stopped"); }
static void Main(string[] args) { // запуск службы Console.WriteLine("Starting SCADA-Server..."); Manager manager = new Manager(); manager.StartService(); Console.WriteLine("SCADA-Server is started"); Console.WriteLine("Press 'x' or create 'serverstop' file to stop SCADA-Server"); // остановка службы при нажатии 'x' или обнаружении файла остановки FileListener stopFileListener = new FileListener("Cmd" + Path.DirectorySeparatorChar + "serverstop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.X || stopFileListener.FileFound)) Thread.Sleep(ScadaUtils.ThreadDelay); manager.StopService(); stopFileListener.DeleteFile(); stopFileListener.Abort(); Console.WriteLine("SCADA-Server is stopped"); }
static void Main(string[] args) { // запуск службы Console.WriteLine("Starting SCADA-Server..."); Manager manager = new Manager(); manager.StartService(); Console.WriteLine("SCADA-Server is started"); Console.WriteLine("Press 'x' or create 'serverstop' file to stop SCADA-Server"); // остановка службы при нажатии 'x' или обнаружении файла остановки FileListener stopFileListener = new FileListener("Cmd" + Path.DirectorySeparatorChar + "serverstop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.X || stopFileListener.FileFound)) { Thread.Sleep(ScadaUtils.ThreadDelay); } manager.StopService(); stopFileListener.DeleteFile(); stopFileListener.Abort(); Console.WriteLine("SCADA-Server is stopped"); }