示例#1
0
        public static void HandleCmd(string[] input)
        {
            Console.WriteLine();

            string[] data;

            switch (input[0])
            {
            case "cmds":
                Help();
                break;

            case "exit":
                Environment.Exit(0);
                break;

            case "getreg":
                data = GetReg();
                if (!bool.Parse(data[0]))
                {
                    Console.WriteLine("error: " + data[1]);
                    break;
                }

                data = Parsing.RemoveNulls(Parsing.RemoveTilIndex(data, 1));

                foreach (var name in data)
                {
                    Console.WriteLine(name);
                }
                break;

            case "remusr":
                data = RemoveUser(input[1]);
                if (!bool.Parse(data[0]))
                {
                    Console.WriteLine("error: " + data[1]);
                    break;
                }
                else
                {
                    Console.WriteLine("Success!");
                }
                break;

            case "addusr":
                data = AddUser(input[1], input[2]);
                if (!bool.Parse(data[0]))
                {
                    Console.WriteLine("error: " + data[1]);
                    break;
                }
                else
                {
                    Console.WriteLine("Success!");
                }
                break;

            case "change":
                data = ChangeProp(input[1], input[2], input[3]);
                if (!bool.Parse(data[0]))
                {
                    Console.WriteLine("error: " + data[1]);
                    break;
                }
                else
                {
                    Console.WriteLine("Success!");
                }
                break;

            case "getusr":
                data = GetUser(input[1]);
                if (!bool.Parse(data[0]))
                {
                    Console.WriteLine("error: " + data[1]);
                    break;
                }
                else
                {
                    Console.WriteLine($"Account information for {data[1]}:");
                    foreach (var info in Parsing.RemoveTilIndex(data, 1))
                    {
                        Console.WriteLine(info);
                    }
                }
                break;
            }

            Console.WriteLine();
        }
示例#2
0
        public static string[] AddUser(string username, string password)
        {
            Server.SendData($"addusr\\{username}\\{password}");

            return(Parsing.RemoveNulls(Server.Recieve()));
        }
示例#3
0
        public static string[] GetUser(string username)
        {
            Server.SendData($"getusr\\{username}");

            return(Parsing.RemoveNulls(Server.Recieve()));
        }
示例#4
0
        public static string[] RemoveUser(string username)
        {
            Server.SendData("remusr\\" + username);

            return(Parsing.RemoveNulls(Server.Recieve()));
        }