Example #1
0
        public StopServerResult StopServer(ServerModel server)
        {
            var serverProcess = GetServerProcess(server);

            StopServerResult stopServerResult;

            if (serverProcess != null)
            {
                var result = "";
                try
                {
                    _processLogic.StopProcess(serverProcess);
                }
                catch (Exception ex)
                {
                    result = $"{ex.Message} Process Id: {serverProcess.Id}";
                }

                if (result == string.Empty)
                {
                    stopServerResult = new StopServerResult(StopServerResultType.Success, string.Empty);
                }
                else
                {
                    stopServerResult = new StopServerResult(StopServerResultType.StopProcessFailed, result);
                }
            }
            else
            {
                stopServerResult = new StopServerResult(StopServerResultType.ProcessNotFound, string.Empty);
            }

            return(stopServerResult);
        }