Exemple #1
0
        // Token: 0x060000F0 RID: 240 RVA: 0x000170E4 File Offset: 0x000152E4
        public async Task <bool> Load()
        {
            bool result2;

            using (MySqlConnection result = SQL.GetConnection().GetAwaiter().GetResult())
            {
                using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT * FROM clans WHERE ID = '" + this.ID.ToString() + "'", result).ExecuteReader())
                {
                    if (!mySqlDataReader.HasRows)
                    {
                        mySqlDataReader.Close();
                        result2 = false;
                    }
                    else
                    {
                        mySqlDataReader.Read();
                        this.ID           = mySqlDataReader.GetInt64(0);
                        this.Name         = mySqlDataReader.GetString(1);
                        this.Description  = mySqlDataReader.GetString(2);
                        this.CreationTime = mySqlDataReader.GetInt64(3);
                        this.Points       = mySqlDataReader.GetInt32(4);
                        this.ClanMembers  = XElement.Parse(mySqlDataReader.GetString(5));
                        this.LeaderName   = mySqlDataReader.GetString(6);
                        mySqlDataReader.Close();
                        result2 = true;
                    }
                }
            }
            return(result2);
        }
Exemple #2
0
        internal static void FixClans()
        {
            List <Player> playerList = new List <Player>();

            using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT * FROM players;", SQL.Handler).ExecuteReader())
            {
                while (mySqlDataReader.Read())
                {
                    Clan clan = new Clan()
                    {
                        ID = mySqlDataReader.GetInt64(0)
                    };
                    clan.Load();
                    foreach (long profileId in clan.ProfileIds)
                    {
                        Player player = new Player()
                        {
                            UserID = profileId
                        };
                        player.Load(false);
                        player.ClanPlayer.Clan = clan;
                        playerList.Add(player);
                    }
                }
            }
        }
        /// <summary>
        /// Hakee tietokannassa olevat varaukset. Palauttaa listan Varaus-objekteja.
        /// </summary>
        /// <returns></returns>
        public List <Varaus> HaeKaikkiVaraukset()
        {
            try
            {
                const string sqlLause = "SELECT varaukset.id, varaukset.asiakasID, asiakkaat.etunimi, asiakkaat.sukunimi, asiakkaat.sahkoposti, asiakkaat.puh, asiakkaat.katuosoite, asiakkaat.postinumero, asiakkaat.paikkakunta, varaukset.tilaID, tilat.nimi, tilat.katuosoite, tilat.paikkakunta, tilat.rakennus, tilat.varustus, tilat.kapasiteetti, tilat.hinta, varaukset.aloituspvm, varaukset.lopetuspvm, varaukset.maksutapa, varaukset.summa, varaukset.henkilomaara, varaukset.lisapalvelut FROM varaukset JOIN asiakkaat ON varaukset.asiakasID = asiakkaat.id JOIN tilat ON varaukset.tilaID = tilat.id ORDER BY varaukset.aloituspvm DESC;";

                var tulokset = new MySqlCommand(sqlLause, Yhteys).ExecuteReader();

                var varaukset = new List <Varaus>();

                while (tulokset.Read())
                {
                    varaukset.Add(new Varaus(
                                      tulokset.GetInt32("id"),
                                      new Asiakas(tulokset.GetString("etunimi"),
                                                  tulokset.GetString("sukunimi"),
                                                  tulokset.GetString("sahkoposti"),
                                                  tulokset.GetString("puh"),
                                                  tulokset.GetString("katuosoite"),
                                                  tulokset.GetInt32("postinumero"),
                                                  tulokset.GetString("paikkakunta")),
                                      new Tila(tulokset.GetInt32("tilaID"),
                                               tulokset.GetString("nimi"),
                                               tulokset.GetString("katuosoite"),
                                               tulokset.GetString("paikkakunta"),
                                               tulokset.GetString("rakennus"),
                                               tulokset.GetString("varustus"),
                                               tulokset.GetInt32("kapasiteetti"),
                                               tulokset.GetInt32("hinta")),
                                      tulokset.GetInt64("aloituspvm"),
                                      tulokset.GetInt64("lopetuspvm"),
                                      tulokset.GetString("maksutapa"),
                                      tulokset.GetInt32("summa"),
                                      tulokset.GetInt32("henkilomaara"),
                                      tulokset.GetString("lisapalvelut")));
                }

                tulokset.Close();

                return(varaukset);
            }
            catch (Exception e)
            {
                throw new Exception("Virhe varausten hakemisessa. ", e);
            }
        }
Exemple #4
0
 public static void GetRequests(long id)
 {
     using (var connection = new MySqlConnection(ConnectionDB.Connection))
     {
         connection.Open();
         using (var reader = new MySqlCommand($"SELECT * FROM Requests WHERE IDEmpl = {id}", connection).ExecuteReader())
         {
             while (reader.Read())
             {
                 Application.Current.Dispatcher.Invoke(() => RequestsList.Add(
                                                           new URequest(reader.GetInt64("ID"), reader.GetString("Text"), reader.GetDateTime("Date"), reader.GetInt64("State").ToString(), SetBackGround(reader.GetInt64("State")))));
             }
         }
         connection.Close();
     }
 }
Exemple #5
0
        internal static void RemoveItems(string[] Items)
        {
            List <Player> playerList = new List <Player>();

            using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT * FROM players;", SQL.Handler).ExecuteReader())
            {
                while (mySqlDataReader.Read())
                {
                    Player player = new Player()
                    {
                        UserID = mySqlDataReader.GetInt64(0)
                    };
                    if (player.Load(false) && player.Items.RemoveAll((Predicate <Item>)(Attribute => ((IEnumerable <string>)Items).Contains <string>(Attribute.Name))) > 0)
                    {
                        playerList.Add(player);
                    }
                }
            }
            foreach (Player player in playerList)
            {
                player.Save();
            }
        }
Exemple #6
0
        // Token: 0x060000E9 RID: 233 RVA: 0x0001695C File Offset: 0x00014B5C
        public XElement Serialize(Client User)
        {
            XElement result2;

            using (MySqlConnection result = SQL.GetConnection().GetAwaiter().GetResult())
            {
                int num = 0;
                using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT ID FROM clans ORDER BY Points DESC;", result).ExecuteReader())
                {
                    if (mySqlDataReader.HasRows)
                    {
                        mySqlDataReader.Read();
                        try
                        {
                            while (mySqlDataReader.Read())
                            {
                                num++;
                                if (mySqlDataReader.GetInt64(0) == this.ID)
                                {
                                    mySqlDataReader.Close();
                                    break;
                                }
                            }
                            mySqlDataReader.Close();
                        }
                        catch
                        {
                        }
                    }
                }
                this.Points = 0;
                XElement xelement = new XElement("clan");
                try
                {
                    xelement.Add(new XAttribute("name", this.Name));
                    xelement.Add(new XAttribute("description", Convert.ToBase64String(Encoding.UTF8.GetBytes(this.Description))));
                    xelement.Add(new XAttribute("clan_id", this.ID));
                    xelement.Add(new XAttribute("creation_date", this.CreationTime));
                    xelement.Add(new XAttribute("leaderboard_position", num));
                    Client client = ArrayList.OnlineUsers.Find((Client Attribute) => Attribute.Player.Nickname == this.LeaderName);
                    if (client != null)
                    {
                        xelement.Add(new XAttribute("master_badge", client.Player.BannerBadge));
                        xelement.Add(new XAttribute("master_stripe", client.Player.BannerStripe));
                        xelement.Add(new XAttribute("master_mark", client.Player.BannerMark));
                    }
                    else
                    {
                        Player player = new Player
                        {
                            Nickname = this.LeaderName
                        };
                        player.Clan.ID = this.ID;
                        if (player.Load(false).Result)
                        {
                            xelement.Add(new XAttribute("master_badge", player.BannerBadge));
                            xelement.Add(new XAttribute("master_stripe", player.BannerStripe));
                            xelement.Add(new XAttribute("master_mark", player.BannerMark));
                        }
                    }
                    foreach (XElement content in this.ClanMembers.Elements("clan_member_info"))
                    {
                        xelement.Add(content);
                    }
                    xelement.Add(new XAttribute("clan_points", User.Player.Clan.Points));
                    User.Player.Clan.ID = this.ID;
                    User.Player.Save();
                    result2 = xelement;
                }
                catch (Exception)
                {
                    result2 = xelement;
                }
            }
            return(result2);
        }
Exemple #7
0
            internal static Dictionary <string, object> Get(int CharacterID)
            {
                Dictionary <string, object> CharacterData = new Dictionary <string, object>();

                MySqlDataReader ResultReader;

                ResultReader = new MySqlCommand($"select * FROM usercharacter WHERE UserCharacterID = {CharacterID}")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();

                CharacterData.Add("CharacterID", ResultReader.GetInt64(0));
                CharacterData.Add("Name", ResultReader.GetString(2)); //The 0 here is an Ordinal
                CharacterData.Add("GuildID", ResultReader.GetInt64(3));
                CharacterData.Add("Credits", ResultReader.GetInt64(4));
                CharacterData.Add("LastInInstanceID", ResultReader.GetInt16(5));
                CharacterData.Add("LastInInstance", ResultReader.GetInt64(6));
                CharacterData.Add("PositionX", ResultReader.GetFloat(7));
                CharacterData.Add("PositionY", ResultReader.GetFloat(8));
                CharacterData.Add("Deleted", ResultReader.GetBoolean(10));

                ResultReader.Close();

                ResultReader = new MySqlCommand($"select * FROM usercharacterxp WHERE UserCharacterID = {CharacterID}")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();
                CharacterData.Add("MageXP", ResultReader.GetInt64(1));
                CharacterData.Add("HealerXP", ResultReader.GetInt64(2));
                CharacterData.Add("AttackerXP", ResultReader.GetInt64(3));
                CharacterData.Add("TankXP", ResultReader.GetInt64(4));
                CharacterData.Add("WoodcuttingXP", ResultReader.GetInt64(5));
                CharacterData.Add("CombatXP", ResultReader.GetInt64(6));

                ResultReader.Close();

                ResultReader = new MySqlCommand($"select * FROM usercharacteroutfit WHERE CharacterID = {CharacterID} AND IsEquipped = 1")
                {
                    Connection = Connection
                }.ExecuteReader();

                ResultReader.Read();
                CharacterData.Add("HeadIndex", ResultReader.GetInt16(3));
                CharacterData.Add("HeadColor", ResultReader.GetString(4));
                CharacterData.Add("HairIndex", ResultReader.GetInt16(5));
                CharacterData.Add("HairColor", ResultReader.GetString(6));
                CharacterData.Add("EyesIndex", ResultReader.GetInt16(7));
                CharacterData.Add("EyesColor", ResultReader.GetString(8));
                CharacterData.Add("TorsoIndex", ResultReader.GetInt16(9));
                CharacterData.Add("TorsoColor", ResultReader.GetString(10));
                CharacterData.Add("ArmsIndex", ResultReader.GetInt16(11));
                CharacterData.Add("ArmsColor", ResultReader.GetString(12));
                CharacterData.Add("HandsIndex", ResultReader.GetInt16(13));
                CharacterData.Add("HandsColor", ResultReader.GetString(14));
                CharacterData.Add("LegsIndex", ResultReader.GetInt16(15));
                CharacterData.Add("LegsColor", ResultReader.GetString(16));
                CharacterData.Add("FeetIndex", ResultReader.GetInt16(17));
                CharacterData.Add("FeetColor", ResultReader.GetString(18));

                ResultReader.Close();

                return(CharacterData);
            }
Exemple #8
0
 internal Auth(Client User, XmlDocument Packet)
 {
     try
     {
         string[] strArray = Encoding.UTF8.GetString(Convert.FromBase64String(Packet["auth"].InnerText)).Split(new char[1], StringSplitOptions.RemoveEmptyEntries);
         if (strArray[0] != "dedicated" && strArray[1] != "dedicated")
         {
             Player player = new Player();
             using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT id,token,nickname,profileid FROM tickets WHERE nickname='" + strArray[1] + "';", AuroraServer.SQL.Handler).ExecuteReader())
             {
                 try
                 {
                     if (mySqlDataReader.HasRows)
                     {
                         mySqlDataReader.Read();
                         string str = mySqlDataReader.GetString(1);
                         player.TicketId = mySqlDataReader.GetInt64(0);
                         player.Nickname = mySqlDataReader.GetString(2);
                         player.UserID   = mySqlDataReader.GetInt64(3);
                         mySqlDataReader.Close();
                         if (player.Nickname == "")
                         {
                             player.Nickname = string.Format("user{0}", (object)player.UserID);
                         }
                         if (strArray[0].Replace("{:B:}row_emul", "").ToLower() == str.ToLower())
                         {
                             if (player.UserID != 0L && !player.Load(true))
                             {
                                 Program.WriteLine("Игрок " + strArray[1] + " не может авторизироваться!", ConsoleColor.Red);
                                 User.Send(new XDocument(new object[1]
                                 {
                                     (object)new XElement(this.NameSpace + "failure")
                                 }).ToString(SaveOptions.DisableFormatting));
                             }
                             else
                             {
                                 User.Authorized = true;
                                 if (player.BanType == BanType.ALL_PERMANENT)
                                 {
                                     Program.WriteLine("Игрок " + strArray[1] + " забанен навсегда!", ConsoleColor.Red);
                                     User.Send(new XDocument(new object[1]
                                     {
                                         (object)new XElement(this.NameSpace + "failure")
                                     }).ToString(SaveOptions.DisableFormatting));
                                 }
                                 else
                                 {
                                     if (player.BanType == BanType.ALL)
                                     {
                                         TimeSpan timeSpan = DateTimeOffset.FromUnixTimeSeconds(player.UnbanTime).Subtract(DateTimeOffset.UtcNow);
                                         if (timeSpan.TotalSeconds <= 0.0)
                                         {
                                             player.BanType = BanType.NO;
                                         }
                                         else
                                         {
                                             Program.WriteLine("Игрок " + strArray[1] + " забанен на " + timeSpan.ToString() + "!", ConsoleColor.Red);
                                             User.Send(new XDocument(new object[1]
                                             {
                                                 (object)new XElement(this.NameSpace + "failure")
                                             }).ToString(SaveOptions.DisableFormatting));
                                             return;
                                         }
                                     }
                                     if (player != null)
                                     {
                                         if (User.Player == null)
                                         {
                                             User.Player = player;
                                         }
                                         ArrayList.OnlineUsers.Add(User);
                                     }
                                     Program.WriteLine("Игрок " + strArray[1] + " присоединился к серверу!", ConsoleColor.Green);
                                     User.Send(new XDocument(new object[1]
                                     {
                                         (object)new XElement(this.NameSpace + "success")
                                     }).ToString(SaveOptions.DisableFormatting));
                                     Console.Title = string.Format("AURORA SERVER (Online: {0})", (object)ArrayList.OnlineUsers.FindAll((Predicate <Client>)(Attribute => !Attribute.Dedicated)).Count);
                                     MySqlCommand mySqlCommand = new MySqlCommand("UPDATE system SET value=@value WHERE system_cvar=@value2", AuroraServer.SQL.Handler);
                                     mySqlCommand.Parameters.AddWithValue("value2", (object)"online");
                                     mySqlCommand.Parameters.AddWithValue("value", (object)ArrayList.OnlineUsers.FindAll((Predicate <Client>)(Attribute => !Attribute.Dedicated)).Count);
                                     mySqlCommand.ExecuteNonQuery();
                                     User.Player = player;
                                 }
                             }
                         }
                         else
                         {
                             Program.WriteLine("Игрок " + strArray[1] + " не может авторизироваться. Неверный пароль!", ConsoleColor.Red);
                             User.Send(new XDocument(new object[1]
                             {
                                 (object)new XElement(this.NameSpace + "failure")
                             }).ToString(SaveOptions.DisableFormatting));
                         }
                     }
                     else
                     {
                         User.Send(new XDocument(new object[1]
                         {
                             (object)new XElement(this.NameSpace + "failure")
                         }).ToString(SaveOptions.DisableFormatting));
                     }
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine((object)ex);
                 }
             }
         }
         else if (!((IEnumerable <string>)System.IO.File.ReadAllLines("AuthorizedIPs.txt")).Contains <string>(User.IPAddress))
         {
             Console.ForegroundColor = ConsoleColor.Red;
             Console.WriteLine("[" + User.IPAddress + "] Нельзя запустить выделенный сервер с данного IP!");
             Console.ResetColor();
             User.Dispose();
         }
         else
         {
             Player player = new Player();
             User.Dedicated          = true;
             User.Player             = player;
             Console.ForegroundColor = ConsoleColor.Green;
             Console.WriteLine("[" + User.IPAddress + "] Выделенный сервер подключен!");
             Console.ResetColor();
             XDocument xdocument = new XDocument(new object[1]
             {
                 (object)new XElement(this.NameSpace + "success")
             });
             User.Authorized = true;
             ArrayList.OnlineUsers.Add(User);
             User.Send(xdocument.ToString(SaveOptions.DisableFormatting));
         }
     }
     catch (SqlException ex)
     {
         if (!ex.Message.Contains("Закрыто"))
         {
             return;
         }
         AuroraServer.SQL.Handler.Open();
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
 }
Exemple #9
0
        public XElement Serialize()
        {
            int num = 0;

            using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT ID FROM clans ORDER BY Points DESC;", SQL.Handler).ExecuteReader())
            {
                while (mySqlDataReader.Read())
                {
                    ++num;
                    if (mySqlDataReader.GetInt64(0) == this.ID)
                    {
                        mySqlDataReader.Close();
                        break;
                    }
                }
                mySqlDataReader.Close();
            }
            this.Points = 0;
            XElement xelement1 = new XElement((XName)"clan");

            try
            {
                xelement1.Add((object)new XAttribute((XName)"name", (object)this.Name));
                xelement1.Add((object)new XAttribute((XName)"description", (object)Convert.ToBase64String(Encoding.UTF8.GetBytes(this.Description))));
                xelement1.Add((object)new XAttribute((XName)"clan_id", (object)this.ID));
                xelement1.Add((object)new XAttribute((XName)"creation_date", (object)this.CreationTime));
                xelement1.Add((object)new XAttribute((XName)"leaderboard_position", (object)num));
                xelement1.Add((object)new XAttribute((XName)"master_badge", (object)this.MasterBadge));
                xelement1.Add((object)new XAttribute((XName)"master_stripe", (object)this.MasterStripe));
                xelement1.Add((object)new XAttribute((XName)"master_mark", (object)this.MasterMark));
                foreach (ClanProperties userProperty in this.UserProperties)
                {
                    try
                    {
                        if (userProperty.ClanRole == Clan.CLAN_ROLE.NOT_IN_CLAN)
                        {
                            this.ProfileIds.Remove(userProperty.ProfileId);
                        }
                        else
                        {
                            this.Points += userProperty.Points;
                            XElement xelement2 = new XElement((XName)"clan_member_info");
                            xelement2.Add((object)new XAttribute((XName)"nickname", (object)userProperty.Nickname));
                            xelement2.Add((object)new XAttribute((XName)"profile_id", (object)userProperty.ProfileId));
                            xelement2.Add((object)new XAttribute((XName)"experience", (object)userProperty.Experience));
                            xelement2.Add((object)new XAttribute((XName)"jid", userProperty.Online != null ? (object)userProperty.Online.JID : (object)""));
                            xelement2.Add((object)new XAttribute((XName)"clan_points", (object)userProperty.Points));
                            xelement2.Add((object)new XAttribute((XName)"invite_date", (object)userProperty.InvitationDate));
                            xelement2.Add((object)new XAttribute((XName)"clan_role", (object)(int)userProperty.ClanRole));
                            xelement2.Add((object)new XAttribute((XName)"status", (object)(userProperty.Online != null ? userProperty.Online.Status : 0)));
                            xelement1.Add((object)xelement2);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                xelement1.Add((object)new XAttribute((XName)"clan_points", (object)this.Points));
                this.Save();
                return(xelement1);
            }
            catch (Exception ex)
            {
                return(xelement1);
            }
        }
Exemple #10
0
            public static void Authorize(ulong _DiscordID, string _DiscordUser)
            {
                bool _ = false;

                if (_)
                {
                    GlobalVar._clientFm.Invoke(new MethodInvoker(delegate
                    {
                        GlobalVar.Discord.Details = $"User: {GlobalVar.Discord.Username} ({GlobalVar.Auth.ActType})";
                        GlobalVar.Discord.State   = "Currently Idle";
                        Discord.RPC.client.Deinitialize();
                        Discord.RPC.Init();

                        // Default clientFm properties
                        GlobalVar._clientFm.Size = new Size(716, 465);
                        GlobalVar._clientFm.homePnl.BringToFront();
                        GlobalVar._clientFm.barPnl.Show();
                        clientFm.loadPic.Dispose();
                        clientFm.loadLbl.Dispose();
                        clientFm.loadPnl.Dispose();
                        GlobalVar._clientFm.tagLbl.Text = GlobalVar.Discord.Details;
                    }));
                }
                else
                {
                    MySqlConnection Connection = new MySqlConnection(GlobalVar.Auth.ConnectionString);
                    Connection.Open();
                    MySqlDataReader ConnectionData = new MySqlCommand($"SELECT * FROM accounts WHERE accounts.id = {_DiscordID}", Connection).ExecuteReader();
                    while (ConnectionData.Read())
                    {
                        GlobalVar.Auth.ActLvl = ConnectionData.GetInt64(1);
                    }
                    GlobalVar.Auth.DiscordUser = _DiscordUser;
                    GlobalVar.Auth.DiscordID   = _DiscordID;
                    GlobalVar.Auth.ActType     = GlobalVar.Auth.ActLvl.ToString().Replace("-1", "None").Replace("0", "Guest").Replace("1", "Member");
                    if (GlobalVar.Auth.ActLvl >= 0 && GlobalVar.Auth.ActType != string.Empty)
                    {
                        GlobalVar._clientFm.Invoke(new MethodInvoker(delegate
                        {
                            GlobalVar.Discord.Details = $"User: {GlobalVar.Discord.Username} ({GlobalVar.Auth.ActType})";
                            GlobalVar.Discord.State   = "Currently Idle";
                            Discord.RPC.client.Deinitialize();
                            Discord.RPC.Init();

                            // Default clientFm properties
                            GlobalVar._clientFm.Size = new Size(716, 465);
                            GlobalVar._clientFm.homePnl.BringToFront();
                            GlobalVar._clientFm.barPnl.Show();
                            clientFm.loadPic.Dispose();
                            clientFm.loadLbl.Dispose();
                            clientFm.loadPnl.Dispose();
                            GlobalVar._clientFm.tagLbl.Text   = GlobalVar.Discord.Details;
                            GlobalVar._clientFm.StartPosition = FormStartPosition.CenterScreen;
                        }));

                        if (!Directory.Exists(GlobalVar.Client.Paths.ScriptsPath))
                        {
                            Directory.CreateDirectory(GlobalVar.Client.Paths.ScriptsPath);
                        }
                        new Thread(Handler.Client.Scan).Start();
                    }
                    else
                    {
                        GlobalVar._clientFm.Invoke(new MethodInvoker(async delegate
                        {
                            string loadString     = "You don\'t have permission\r\n    to access gSploit ";
                            clientFm.loadLbl.Text = loadString + "(5)";
                            await Task.Delay(1000);
                            clientFm.loadLbl.Text = loadString + "(4)";
                            await Task.Delay(1000);
                            clientFm.loadLbl.Text = loadString + "(3)";
                            await Task.Delay(1000);
                            clientFm.loadLbl.Text = loadString + "(2)";
                            await Task.Delay(1000);
                            clientFm.loadLbl.Text = loadString + "(1)";
                            await Task.Delay(1000);
                            Environment.Exit(0);
                        }));
                    }
                }
            }
Exemple #11
0
        internal override void Process()
        {
            XDocument xDocument = new XDocument();
            XElement  xelement1 = new XElement(Gateway.JabberNS + "iq");

            xelement1.Add((object)new XAttribute((XName)"type", (object)"result"));
            xelement1.Add((object)new XAttribute((XName)"from", (object)this.To));
            xelement1.Add((object)new XAttribute((XName)"to", (object)this.User.JID));
            xelement1.Add((object)new XAttribute((XName)"id", (object)this.Id));
            XElement xelement2 = new XElement(Stanza.NameSpace + "query");
            XElement xelement3 = new XElement((XName)"clan_list");
            XElement xelement4 = (XElement)null;

            if (this.User.Player.ClanPlayer.Clan == null)
            {
                xelement4 = new XElement((XName)"clan_performance", (object)new XAttribute((XName)"position", (object)0));
            }
            else
            {
                using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT ID FROM clans ORDER BY Points DESC;", SQL.Handler).ExecuteReader())
                {
                    try
                    {
                        int num = 0;
                        while (mySqlDataReader.Read())
                        {
                            ++num;
                            if (mySqlDataReader.GetInt64(0) == this.User.Player.ClanPlayer.Clan.ID)
                            {
                                xelement4 = new XElement((XName)"clan_performance", (object)new XAttribute((XName)"position", (object)num));
                                mySqlDataReader.Close();
                                break;
                            }
                        }
                        mySqlDataReader.Close();
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        mySqlDataReader.Close();
                    }
                }
            }
            using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT * FROM clans;", SQL.Handler).ExecuteReader())
            {
                try
                {
                    while (mySqlDataReader.Read())
                    {
                        XmlDocument xmlDocument1 = new XmlDocument();
                        XmlDocument xmlDocument2 = new XmlDocument();
                        XDocument   xdocument1   = XDocument.Parse(mySqlDataReader.GetString(5));
                        XDocument   xdocument2   = XDocument.Parse(mySqlDataReader.GetString(6));
                        xmlDocument2.LoadXml(xdocument1.ToString());
                        xmlDocument1.LoadXml(xdocument2.ToString());
                        xelement4.Add((object)new XElement((XName)"clan", new object[8]
                        {
                            (object)new XAttribute((XName)"name", (object)mySqlDataReader.GetString(1)),
                            (object)new XAttribute((XName)"clan_id", (object)mySqlDataReader.GetInt64(0)),
                            (object)new XAttribute((XName)"master", (object)xmlDocument1.FirstChild.Attributes["nick"].InnerText),
                            (object)new XAttribute((XName)"clan_points", (object)mySqlDataReader.GetInt32(4)),
                            (object)new XAttribute((XName)"members", (object)xmlDocument2.FirstChild.ChildNodes.Count),
                            (object)new XAttribute((XName)"master_badge", (object)xmlDocument1.FirstChild.Attributes["master_badge"].InnerText),
                            (object)new XAttribute((XName)"master_stripe", (object)xmlDocument1.FirstChild.Attributes["master_stripe"].InnerText),
                            (object)new XAttribute((XName)"master_mark", (object)xmlDocument1.FirstChild.Attributes["master_mark"].InnerText)
                        }));
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    mySqlDataReader.Close();
                }
            }
            xelement3.Add((object)xelement4);
            xelement2.Add((object)xelement3);
            xelement1.Add((object)xelement2);
            xDocument.Add((object)xelement1);
            this.Compress(ref xDocument);
            this.User.Send(xDocument.ToString(SaveOptions.DisableFormatting));
        }
Exemple #12
0
 public override void Process()
 {
     using (MySqlConnection result = SQL.GetConnection().GetAwaiter().GetResult())
     {
         try
         {
             XDocument xDocument = new XDocument();
             XElement  xelement1 = new XElement(Gateway.JabberNS + "iq");
             xelement1.Add((object)new XAttribute((XName)"type", (object)"result"));
             xelement1.Add((object)new XAttribute((XName)"from", (object)this.To));
             xelement1.Add((object)new XAttribute((XName)"to", (object)this.User.JID));
             xelement1.Add((object)new XAttribute((XName)"id", (object)this.Id));
             XElement xelement2 = new XElement(Stanza.NameSpace + "query");
             XElement xelement3 = new XElement((XName)"clan_list");
             XElement xelement4 = (XElement)null;
             if (this.User.Player.Clan.ID == 0L)
             {
                 xelement4 = new XElement((XName)"clan_performance", (object)new XAttribute((XName)"position", (object)0));
             }
             else
             {
                 using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT ID FROM clans ORDER BY Points DESC;", result).ExecuteReader())
                 {
                     try
                     {
                         int num = 0;
                         while (mySqlDataReader.Read())
                         {
                             ++num;
                             if (mySqlDataReader.GetInt64(0) == this.User.Player.Clan.ID)
                             {
                                 xelement4 = new XElement((XName)"clan_performance", (object)new XAttribute((XName)"position", (object)num));
                                 mySqlDataReader.Close();
                                 break;
                             }
                         }
                         mySqlDataReader.Close();
                     }
                     catch (Exception ex)
                     {
                     }
                     finally
                     {
                         mySqlDataReader.Close();
                     }
                 }
             }
             using (MySqlDataReader mySqlDataReader = new MySqlCommand("SELECT * FROM clans ORDER BY Points DESC LIMIT 10;", result).ExecuteReader())
             {
                 try
                 {
                     while (mySqlDataReader.Read())
                     {
                         XElement xelement5 = XElement.Parse(mySqlDataReader.GetString(5));
                         xelement4.Add((object)new XElement((XName)"clan", new object[8]
                         {
                             (object)new XAttribute((XName)"name", (object)mySqlDataReader.GetString(1)),
                             (object)new XAttribute((XName)"clan_id", (object)mySqlDataReader.GetInt64(0)),
                             (object)new XAttribute((XName)"master", (object)mySqlDataReader.GetString(6)),
                             (object)new XAttribute((XName)"clan_points", (object)mySqlDataReader.GetInt32(4)),
                             (object)new XAttribute((XName)"members", (object)xelement5.Elements((XName)"clan_member_info").ToList <XElement>().Count),
                             (object)new XAttribute((XName)"master_badge", (object)"0"),
                             (object)new XAttribute((XName)"master_stripe", (object)"0"),
                             (object)new XAttribute((XName)"master_mark", (object)"0")
                         }));
                     }
                 }
                 catch (Exception ex)
                 {
                 }
                 finally
                 {
                     mySqlDataReader.Close();
                 }
             }
             xelement3.Add((object)xelement4);
             xelement2.Add((object)xelement3);
             xelement1.Add((object)xelement2);
             xDocument.Add((object)xelement1);
             this.Compress(ref xDocument);
             this.User.Send(xDocument.ToString(SaveOptions.DisableFormatting));
         }
         catch
         {
         }
         result.Close();
     }
 }