public static void UserFromGroup(Packet packet)
        {
            Packet sendPacket;

            try
            {
                string[] combine  = packet.Argument.Split(char.Parse("|"));
                string   username = combine[0];
                string   group    = combine[1];
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Remove user from group {1} [{2}]", packet.ClientIP, group, packet.Username));

                UserInfoInserter.RemoveUserFromGroup(username, group);
                MySQLAccountParsing.RemoveUserFromGroup(username, group);

                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Success, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Removing user from group success: {1} [{2}]", packet.ClientIP, username, packet.Username));
            }
            catch (Exception e)
            {
                ConsoleUtils.Print(string.Format("User From Group Error: [{0}] {1}", e.GetType().ToString(), e.Message));
                sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.Failure, packet.Token);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                return;
            }
        }
Esempio n. 2
0
        public static void RemoveUserInEveryGroup(string username)
        {
            string[] groupstack = new string[0];
            using (var dbCon = new MySQLDatabaseConnection(System.Net.IPAddress.Parse("127.0.0.1"), "exceeddb"))
            {
                dbCon.Username = "******";
                dbCon.Password = "******";
                dbCon.Connect();

                string command = "SELECT `groupname` FROM `groupDB`";
                groupstack = dbCon.GetListCollumnValue(command, "groupname");

                command = string.Empty;
                dbCon.Close();
            }

            if (groupstack.Length == 0)
            {
                return;
            }

            foreach (string group in groupstack)
            {
                try
                {
                    MySQLAccountParsing.RemoveUserFromGroup(username, group);
                }
                catch (Exception ex)
                {
                    if (!(ex is MissingMemberException))
                    {
                        throw;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }