Example #1
0
        public void OnAction(Hashtable parameters)
        {
            ServiceController svcc = GameServerService.GetDOLService();

            if (svcc == null)
            {
                Console.WriteLine("You have to install the service first!");
                return;
            }
            if (svcc.Status == ServiceControllerStatus.StartPending)
            {
                Console.WriteLine("Server is still starting, please check the logfile for progress information!");
                return;
            }
            if (svcc.Status != ServiceControllerStatus.Running)
            {
                Console.WriteLine("The DOL service is not running");
                return;
            }
            try
            {
                Console.WriteLine("Stopping the DOL service...");
                svcc.Stop();
                svcc.WaitForStatus(ServiceControllerStatus.Stopped);
                Console.WriteLine("Finished!");
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine("Could not stop the DOL service!");
                Console.WriteLine(e.Message);
                return;
            }
        }
Example #2
0
        public void OnAction(Hashtable parameters)
        {
            AssemblyInstaller assemblyInstaller = new AssemblyInstaller(Assembly.GetExecutingAssembly(), new string[]
            {
                "/LogToConsole=false"
            });
            Hashtable savedState = new Hashtable();

            if (GameServerService.GetDOLService() == null)
            {
                Console.WriteLine("No service named \"DOL\" found!");
                return;
            }
            Console.WriteLine("Uninstalling DOL system service...");
            try
            {
                assemblyInstaller.Uninstall(savedState);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error uninstalling system service");
                Console.WriteLine(ex.Message);
                return;
            }
            Console.WriteLine("Finished!");
        }
Example #3
0
        public void OnAction(Hashtable parameters)
        {
            ArrayList temp = new ArrayList();

            temp.Add("/LogToConsole=false");
            StringBuilder tempString = new StringBuilder();

            foreach (DictionaryEntry entry in parameters)
            {
                if (tempString.Length > 0)
                {
                    tempString.Append(" ");
                }

                tempString.Append(entry.Key);
                tempString.Append("=");
                tempString.Append(entry.Value);
            }

            temp.Add("commandline=" + tempString.ToString());

            string[] commandLine = (string[])temp.ToArray(typeof(string));

            System.Configuration.Install.AssemblyInstaller asmInstaller = new AssemblyInstaller(Assembly.GetExecutingAssembly(), commandLine);
            Hashtable rollback = new Hashtable();

            if (GameServerService.GetDOLService() != null)
            {
                Console.WriteLine("DOL service is already installed!");
                return;
            }

            Console.WriteLine("Installing DOL as system service...");
            try
            {
                asmInstaller.Install(rollback);
                asmInstaller.Commit(rollback);
            }
            catch (Exception e)
            {
                asmInstaller.Rollback(rollback);
                Console.WriteLine("Error installing as system service");
                Console.WriteLine(e.Message);
                return;
            }

            Console.WriteLine("Finished!");
        }
Example #4
0
        public void OnAction(Hashtable parameters)
        {
            ArrayList arrayList = new ArrayList();

            arrayList.Add("/LogToConsole=false");
            StringBuilder stringBuilder = new StringBuilder();

            foreach (DictionaryEntry dictionaryEntry in parameters)
            {
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Append(" ");
                }
                stringBuilder.Append(dictionaryEntry.Key);
                stringBuilder.Append("=");
                stringBuilder.Append(dictionaryEntry.Value);
            }
            arrayList.Add("commandline=" + stringBuilder.ToString());
            string[]          commandLine       = (string[])arrayList.ToArray(typeof(string));
            AssemblyInstaller assemblyInstaller = new AssemblyInstaller(Assembly.GetExecutingAssembly(), commandLine);
            Hashtable         hashtable         = new Hashtable();

            if (GameServerService.GetDOLService() != null)
            {
                Console.WriteLine("DOL service is already installed!");
                return;
            }
            Console.WriteLine("Installing Road as system service...");
            try
            {
                assemblyInstaller.Install(hashtable);
                assemblyInstaller.Commit(hashtable);
            }
            catch (Exception ex)
            {
                assemblyInstaller.Rollback(hashtable);
                Console.WriteLine("Error installing as system service");
                Console.WriteLine(ex.Message);
                return;
            }
            Console.WriteLine("Finished!");
        }
Example #5
0
        public void OnAction(Hashtable parameters)
        {
            ServiceController svcc = GameServerService.GetDOLService();

            if (svcc == null)
            {
                Console.WriteLine("You have to install the service first!");
                return;
            }

            if (svcc.Status == ServiceControllerStatus.StartPending)
            {
                Console.WriteLine("Server is still starting, please check the logfile for progress information!");
                return;
            }

            if (svcc.Status != ServiceControllerStatus.Stopped)
            {
                Console.WriteLine("The DOL service is not stopped");
                return;
            }

            try
            {
                Console.WriteLine("Starting the DOL service...");
                svcc.Start();
                svcc.WaitForStatus(ServiceControllerStatus.StartPending, TimeSpan.FromSeconds(10));
                Console.WriteLine("Starting can take some time, please check the logfile for progress information!");
                Console.WriteLine("Finished!");
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine("Could not start the DOL service!");
                Console.WriteLine(e.Message);
            }
            catch (System.ServiceProcess.TimeoutException)
            {
                Console.WriteLine("Error starting the service, please check the logfile for further info!");
            }
        }