Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int init;

            Console.WriteLine("Choose one of the variant: \r\n" +
                              "1: Start server.\r\n" +
                              "2: Exit.\r\n");

            while (int.TryParse(Console.ReadLine(), out init) && (init == 1 || init == 2))
            {
                // Main loop.
                switch (init)
                {
                case 1:
                    Core.Start();
                    Environment.Exit(0);
                    break;

                case 2:
                    Environment.Exit(0);
                    break;

                default:
                    Environment.Exit(0);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 static void StartService()
 {
     SQL.Init();
     Core CoreInSer = new Core();
     AsServer Server = new AsServer(IPAddress.Any, 5000);
     ComPortListener ComPotrList = new ComPortListener();
     WinLog.Init();
     CoreInSer.Start();
     Thread ServerThread = new Thread(Server.Start);
     ServerThread.IsBackground = true;
     ServerThread.Start();
     Thread CPList = new Thread(ComPotrList.OpenCom);
     CPList.IsBackground = true;
     CPList.Start();
     CoreInSer.UpdateClient();
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            SQL.Init();
            Core CoreInSer = new Core();

            // TODO: Настройки вынести в отдельный конфигурационный файл

            AsServer Server = new AsServer(IPAddress.Any, 5000);
            ComPortListener ComPotrList = new ComPortListener();
            WinLog.Init();
            CoreInSer.Start();
            Thread ServerThread = new Thread(Server.Start);
            ServerThread.IsBackground = true;
            ServerThread.Start();
            Thread CPList = new Thread(ComPotrList.OpenCom);
            CPList.IsBackground = true;
            CPList.Start();
            CoreInSer.UpdateClient();
            Console.WriteLine("Server started");
            Console.WriteLine("OK");
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            /* print a banner */
            Version ver = Assembly.GetEntryAssembly().GetName().Version;

            Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/",
                              ver.Major, ver.Minor, ver.Revision);
            Console.WriteLine("  on {0}, runtime {1}",
                              Environment.OSVersion, Environment.Version);

            Console.WriteLine();

                        #if MONO
            if ((int)Environment.OSVersion.Platform != 128)
            {
                Console.WriteLine("WARNING: This is the Mono optimized binary, and it will probably crash on Windows!");
                Console.WriteLine();
            }
                        #else
            if ((int)Environment.OSVersion.Platform == 128)
            {
                Console.WriteLine("WARNING: This is the Windows optimized binary, and you're running Mono.");
                Console.WriteLine();
            }
                        #endif

            /* parse command line */

            bool repair = false, service = false, profiling = false;

            string baseDirectory = null;
            string configFile    = null;

            for (int i = 0; i < args.Length; ++i)
            {
                switch (args[i])
                {
                case "-debug":
                case "--debug":
                    /* deprecated, debug is always on */
                    break;

                case "--repair":
                    repair = true;
                    break;

                case "-service":
                case "--service":
                    service = true;
                    break;

                case "-profile":
                case "--profile":
                    profiling = true;
                    break;

                case "-c":
                case "--config":
                    if (i == args.Length - 1)
                    {
                        Console.Error.WriteLine("file name expected after {0}",
                                                args[i]);
                        return;
                    }

                    configFile = args[++i];

                    if (!File.Exists(configFile))
                    {
                        Console.Error.WriteLine("{0} does not exist", configFile);
                        return;
                    }

                    break;

                case "-b":
                case "--base":
                    if (i == args.Length - 1)
                    {
                        Console.Error.WriteLine("directory name expected after {0}",
                                                args[i]);
                        return;
                    }

                    baseDirectory = args[++i];

                    if (!Directory.Exists(baseDirectory))
                    {
                        Console.Error.WriteLine("{0} does not exist", baseDirectory);
                        return;
                    }

                    break;

                default:
                    Console.Error.WriteLine("Unrecognized command line argument: {0}",
                                            args[i]);
                    return;
                }
            }

            if (baseDirectory == null)
            {
                baseDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
            }

            if (configFile == null)
            {
                string confDirectory = new DirectoryInfo(baseDirectory)
                                       .CreateSubdirectory("etc").FullName;
                configFile = Path.Combine(confDirectory, "sunuo.xml");
            }

            /* prepare environment */

            Directory.SetCurrentDirectory(baseDirectory);

            /* load configuration */

            Config.Root config = new Config.Root(baseDirectory, configFile);

            /* enter stage II */

            Core.Initialize(config, service, profiling);

            Core.Start(repair);
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            /* print a banner */
            Version ver = Assembly.GetEntryAssembly().GetName().Version;

            Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/",
                              ver.Major, ver.Minor, ver.Revision);
            Console.WriteLine("  on {0}, runtime {1}",
                              Environment.OSVersion, Environment.Version);

            if ((int)Environment.OSVersion.Platform == 128)
            {
                Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)");
            }

            Console.WriteLine();

            /* parse command line */

            bool debug = false, service = false, profiling = false;

            string baseDirectory = null;
            string configFile    = null;

            for (int i = 0; i < args.Length; ++i)
            {
                switch (args[i])
                {
                case "-debug":
                case "--debug":
                    debug = true;
                    break;

                case "-service":
                case "--service":
                    service = true;
                    break;

                case "-profile":
                case "--profile":
                    profiling = true;
                    break;

                case "-c":
                case "--config":
                    if (i == args.Length - 1)
                    {
                        Console.Error.WriteLine("file name expected after {0}",
                                                args[i]);
                        return;
                    }

                    configFile = args[++i];

                    if (!File.Exists(configFile))
                    {
                        Console.Error.WriteLine("{0} does not exist", configFile);
                        return;
                    }

                    break;

                case "-b":
                case "--base":
                    if (i == args.Length - 1)
                    {
                        Console.Error.WriteLine("directory name expected after {0}",
                                                args[i]);
                        return;
                    }

                    baseDirectory = args[++i];

                    if (!Directory.Exists(baseDirectory))
                    {
                        Console.Error.WriteLine("{0} does not exist", baseDirectory);
                        return;
                    }

                    break;

                default:
                    Console.Error.WriteLine("Unrecognized command line argument: {0}",
                                            args[i]);
                    return;
                }
            }

            if (baseDirectory == null)
            {
                baseDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
            }

            if (configFile == null)
            {
                string confDirectory = new DirectoryInfo(baseDirectory)
                                       .CreateSubdirectory("etc").FullName;
                configFile = Path.Combine(confDirectory, "sunuo.xml");
            }

            /* prepare environment */

            Directory.SetCurrentDirectory(baseDirectory);

            /* load configuration */

            Config.Root config = new Config.Root(baseDirectory, configFile);

            /* enter stage II */

            Core.Start(config, debug, service, profiling);
        }