Example #1
0
        public bool GetPlayerID(WowRealm _Realm, string _PlayerName, out SQLPlayerID _ResultPlayerID)
        {
            var conn = OpenConnection();

            try
            {
                using (var cmd = new NpgsqlCommand("SELECT id FROM playertable WHERE name=:Name AND realm=:Realm", conn))
                {
                    {
                        var nameParam = new NpgsqlParameter("Name", NpgsqlDbType.Text);
                        nameParam.Value = _PlayerName;
                        cmd.Parameters.Add(nameParam);
                    }
                    {
                        var realmParam = new NpgsqlParameter("Realm", NpgsqlDbType.Integer);
                        realmParam.Value = (int)_Realm;
                        cmd.Parameters.Add(realmParam);
                    }
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read() == true)
                        {
                            _ResultPlayerID = new SQLPlayerID(reader.GetInt32(0));
                            return(true);
                        }
                    }
                }
            }
            finally
            {
                CloseConnection();
            }
            _ResultPlayerID = SQLPlayerID.Invalid();
            return(false);
        }
Example #2
0
        public SQLPlayerID UpdateLatestPlayerDataEntry(SQLPlayerID _PlayerID, SQLUploadID _UploadID, PlayerData.Player _PlayerData)
        {
            WowVersionEnum wowVersion = VF_RealmPlayersDatabase.StaticValues.GetWowVersion(_PlayerData.Realm);
            SQLPlayerData  playerData = new SQLPlayerData();

            playerData.PlayerID        = _PlayerID;
            playerData.UploadID        = _UploadID;
            playerData.UpdateTime      = _PlayerData.LastSeen;
            playerData.PlayerCharacter = _PlayerData.Character;
            playerData.PlayerGuildID   = GenerateNewPlayerGuildDataEntry(_PlayerData.Guild);
            playerData.PlayerHonorID   = GenerateNewPlayerHonorDataEntry(_PlayerData.Honor, wowVersion);
            playerData.PlayerGearID    = GenerateNewPlayerGearDataEntry(_PlayerData.Gear, wowVersion);
            if (wowVersion != WowVersionEnum.Vanilla)
            {
                playerData.PlayerArenaID   = GenerateNewPlayerArenaInfoEntry(_PlayerData.Arena);
                playerData.PlayerTalentsID = GenerateNewPlayerTalentsDataEntry(_PlayerData.TalentPointsData);
            }
            else
            {
                playerData.PlayerArenaID   = 0;
                playerData.PlayerTalentsID = 0;
            }
            if (GenerateNewPlayerDataEntry(playerData) == true)
            {
                if (UpdatePlayerEntry(playerData.PlayerID, playerData.UploadID) == false)
                {
                    VF_RealmPlayersDatabase.Logger.ConsoleWriteLine("Error in UpdateLatestPlayerDataEntry, could not UpdatePlayerEntry!!!");
                    return(SQLPlayerID.Invalid());
                }
            }
            else
            {
                VF_RealmPlayersDatabase.Logger.ConsoleWriteLine("Error in UpdateLatestPlayerDataEntry, could not GenerateNewPlayerDataEntry!!!");
                return(SQLPlayerID.Invalid());
            }
            return(_PlayerID);
        }