示例#1
0
        public static Enums.AccountStatus Authenticate(Client.AuthClient client, string Account, string Password)
        {
            try
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("AuthConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, true))
                    {
                        cmd.AddWhereValue("AccountName", Account);
                        cmd.AddWhereValue("AccountPassword", Password);

                        cmd.Finish("DB_Accounts");
                    }

                    if (!sql.Read())
                    {
                        return(Enums.AccountStatus.Invalid_AccountID_Or_Password);
                    }
                    client.DatabaseUID = sql.ReadInt32("AccountID");
                    client.Server      = sql.ReadByte("AccountServer");
                    client.Account     = Account;
                    client.Password    = Password;
                    using (var sql2 = new SqlHandler(Program.Config.ReadString("AuthConnectionString")))
                    {
                        using (var cmd2 = new SqlCommandBuilder(sql2, SqlCommandType.UPDATE, true))
                        {
                            cmd2.AddWhereValue("AccountID", client.DatabaseUID);
                            if (sql.ReadBoolean("AccountBanned"))
                            {
                                DateTime banexpire = sql.ReadDateTime("AccountBanExpire");
                                if (DateTime.Now < banexpire)
                                {
                                    return(Enums.AccountStatus.Account_Banned);
                                }

                                cmd2.AddUpdateValue("AccountBanned", false);
                            }

                            cmd2.AddUpdateValue("AccountLastLoginIP", client.NetworkClient.IP);
                            cmd2.Finish("DB_Accounts");
                        }
                        sql2.Execute();
                    }
                }
                return(Enums.AccountStatus.Ready);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(Enums.AccountStatus.Datebase_Error);
            }
        }
示例#2
0
 public static void UpdateGuildInfo(Data.Guild guild, string Column, object Value)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("GuildID", guild.DatabaseID);
             cmd.AddUpdateValue(Column, Value);
             cmd.Finish("DB_Guilds");
         }
         sql.Execute();
     }
 }
示例#3
0
 public static void UpdateNobilityDonation(int Identifier, string Column, object Value)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("PlayerID", Identifier);
             cmd.AddUpdateValue(Column, Value);
             cmd.Finish("DB_NobilityBoard");
         }
         sql.Execute();
     }
 }
示例#4
0
 public static void SaveArenaInfo(Data.ArenaInfo arena)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("PlayerID", arena.DatabaseID);
             cmd.AddUpdateValue("PlayerName", arena.Name);
             cmd.AddUpdateValue("ArenaLevel", arena.Level);
             cmd.AddUpdateValue("ArenaClass", arena.Class);
             cmd.AddUpdateValue("Mesh", arena.Mesh);
             cmd.AddUpdateValue("HonorPoints", arena.DatabaseID);
             cmd.AddUpdateValue("ArenaPoints", arena.ArenaPoints);
             cmd.AddUpdateValue("TotalWins", arena.ArenaTotalWins);
             cmd.AddUpdateValue("TotalWinsToday", arena.ArenaWinsToday);
             cmd.AddUpdateValue("TotalLoss", arena.ArenaTotalLoss);
             cmd.AddUpdateValue("TotalLossToday", arena.ArenaLossToday);
             cmd.Finish("DB_ArenaQualifier");
         }
         sql.Execute();
     }
 }
示例#5
0
        public static void UpdateAuthentication(Client.AuthClient client)
        {
            if (PlayerExists(client.DatabaseUID))
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddUpdateValue("PlayerLastEntityUID", client.EntityUID);
                        cmd.AddUpdateValue("PlayerLoginOK", true);

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
            else
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("PlayerNew", true);
                        cmd.AddInsertValue("PlayerAccount", client.Account);
                        cmd.AddInsertValue("PlayerLastEntityUID", client.EntityUID);
                        cmd.AddInsertValue("PlayerLoginOK", true);
                        cmd.AddInsertValue("PlayerServer", client.Server);

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
        }