Ejemplo n.º 1
0
        /// <summary>
        /// shut down the server
        /// </summary>
        /// <param name="TRemote"></param>
        /// <param name="AWithUserInteraction"></param>
        /// <returns>true if shutdown was completed</returns>
        public static bool ShutDown(IServerAdminInterface TRemote, bool AWithUserInteraction)
        {
            bool ReturnValue;
            bool ack;

            ack = false;

            if (AWithUserInteraction == true)
            {
                Console.WriteLine(Environment.NewLine + "-> UNCONDITIONAL SHUTDOWN   (force disconnection of all Clients) <-");
                Console.Write("     Enter YES to perform shutdown (anything else to leave command): ");

                if (Console.ReadLine() == "YES")
                {
                    Console.WriteLine();
                    ack = true;
                }
            }
            else
            {
                ack = true;
            }

            if (ack == true)
            {
                TLogging.Log("SHUTDOWN PROCEDURE INITIATED...");
                try
                {
                    TRemote.StopServer();
                }
                catch (SocketException)
                {
                    if (AWithUserInteraction == true)
                    {
                        Console.WriteLine();
                        TLogging.Log("SERVER STOPPED!");
                        Console.WriteLine();
                        Console.Write("Press ENTER to end PETRAServerADMIN...");
                        Console.ReadLine();
                    }
                }
                ReturnValue = true;
            }
            else
            {
                Console.WriteLine("     Shutdown cancelled!");
                Console.Write(ServerAdminPrompt);
                ReturnValue = false;
            }

            return(ReturnValue);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// shut down the server
    /// </summary>
    /// <param name="TRemote"></param>
    /// <param name="AWithUserInteraction"></param>
    /// <returns>true if shutdown was completed</returns>
    public static bool ShutDown(IServerAdminInterface TRemote, bool AWithUserInteraction)
    {
        bool ReturnValue;
        bool ack;

        ack = false;

        if (AWithUserInteraction == true)
        {
            Console.WriteLine(Environment.NewLine + "-> UNCONDITIONAL SHUTDOWN   (force disconnection of all Clients) <-");
            Console.Write("     Enter YES to perform shutdown (anything else to leave command): ");

            if (Console.ReadLine() == "YES")
            {
                Console.WriteLine();
                ack = true;
            }
        }
        else
        {
            ack = true;
        }

        if (ack == true)
        {
            TLogging.Log("SHUTDOWN PROCEDURE INITIATED...");
            try
            {
                TRemote.StopServer();
            }
            catch (SocketException)
            {
                if (AWithUserInteraction == true)
                {
                    Console.WriteLine();
                    TLogging.Log("SERVER STOPPED!");
                    Console.WriteLine();
                    Console.Write("Press ENTER to end PETRAServerADMIN...");
                    Console.ReadLine();
                }
            }
            ReturnValue = true;
        }
        else
        {
            Console.WriteLine("     Shutdown cancelled!");
            Console.Write(ServerAdminPrompt);
            ReturnValue = false;
        }

        return ReturnValue;
    }