示例#1
0
 /// <summary>
 /// Updates friendship status for contact 1.
 /// </summary>
 /// <param name="contactId"></param>
 /// <returns></returns>
 public void SetFriendshipStatusOneSided(int contactId1, int contactId2, FriendshipStatus status)
 {
     using (var conn = this.Connection)
         using (var cmd = new UpdateCommand("UPDATE `friends` SET {0} WHERE (`userId1` = @userId1 AND `userId2` = @userId2)", conn))
         {
             cmd.Set("status", (byte)status);
             cmd.AddParameter("@userId1", contactId1);
             cmd.AddParameter("@userId2", contactId2);
             cmd.Execute();
         }
 }
示例#2
0
        /// <summary>
        /// Changes group the friend is in in the database.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="friendContactId"></param>
        /// <param name="groupId"></param>
        public void ChangeGroup(User user, int friendContactId, int groupId)
        {
            using (var conn = this.Connection)
                using (var cmd = new UpdateCommand("UPDATE `friends` SET {0} WHERE `userId1` = @userId1 AND `userId2` = @userId2", conn))
                {
                    cmd.Set("groupId", groupId);
                    cmd.AddParameter("@userId1", user.Id);
                    cmd.AddParameter("@userId2", friendContactId);

                    cmd.Execute();
                }
        }
示例#3
0
        /// <summary>
        /// Renames group in database.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="groupId"></param>
        /// <param name="groupName"></param>
        public void RenameGroup(User user, int groupId, string groupName)
        {
            using (var conn = this.Connection)
                using (var cmd = new UpdateCommand("UPDATE `groups` SET {0} WHERE `groupId` = @groupId AND `contactId` = @contactId", conn))
                {
                    cmd.Set("name", groupName);
                    cmd.AddParameter("@groupId", groupId);
                    cmd.AddParameter("@contactId", user.Id);

                    cmd.Execute();
                }
        }
示例#4
0
        public static void Update(MySqlConnection dbconn, int serverId, ulong characterId, uint questId, int state)
        {
            using (var cmd =
                       new UpdateCommand("UPDATE Quests SET {0} WHERE CID=@charId AND QuestId=@questId AND ServerId=@serverId",
                                         dbconn))
            {
                cmd.AddParameter("@serverId", serverId);
                cmd.AddParameter("@charId", characterId);
                cmd.AddParameter("@questId", questId);

                cmd.Set("State", state);
                cmd.Execute();
            }
        }
示例#5
0
        /// <summary>
        /// Saves account.
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public bool SaveAccount(Account account)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }

            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `accounts` SET {0} WHERE `accountId` = @accountId", conn))
                {
                    cmd.AddParameter("@accountId", account.Id);
                    cmd.Set("settings", account.Settings.ToString());

                    if (cmd.Execute() == 0)
                    {
                        return(false);
                    }
                }

            this.SaveVariables("account:" + account.Id, account.Variables.Perm);
            this.SaveChatMacros(account);
            this.SaveRevealedMaps(account);

            return(true);
        }
示例#6
0
        public static void Update(MySqlConnection dbconn, int serverId, ulong characterId, uint questId, Quest quest)
        {
            using (var cmd =
                       new UpdateCommand("UPDATE Quests SET {0} WHERE CID=@charId AND QuestId=@questId AND ServerId=@serverId",
                                         dbconn))
            {
                cmd.AddParameter("@serverId", serverId);
                cmd.AddParameter("@charId", characterId);
                cmd.AddParameter("@questId", questId);

                cmd.Set("ServerId", quest.ServerId);
                cmd.Set("CNAME", quest.CharacterName);
                cmd.Set("State", quest.State);
                cmd.Set("FailNum", quest.FailNum);
                cmd.Set("PlaceIdx", quest.PlaceIdx);
                cmd.Execute();
            }
        }
示例#7
0
 /// <summary>
 /// Writes the vehicle to the database
 /// </summary>
 /// <param name="dbconn">The mysql connection</param>
 /// <param name="vehicle">The vehicle that should be written</param>
 public static void Update(MySqlConnection dbconn, Vehicle vehicle)
 {
     using (var cmd = new UpdateCommand("UPDATE vehicles SET {0} WHERE CID=@vehId", dbconn))
     {
         cmd.AddParameter("@vehId", vehicle.CarId);
         var updateCommand = cmd;
         vehicle.WriteToDb(ref updateCommand);
     }
 }
示例#8
0
 public static void Update(MySqlConnection dbconn, InventoryItem inventoryItem)
 {
     using (var cmd = new UpdateCommand("UPDATE items SET {0} WHERE Id=@id", dbconn))
     {
         cmd.AddParameter("@id", inventoryItem.DbId);
         var updateCommand = cmd;
         inventoryItem.WriteToDb(ref updateCommand);
         cmd.Execute();
     }
 }
示例#9
0
        public static bool Update(MySqlConnection dbconn, User user)
        {
            using (var cmd = new UpdateCommand("UPDATE `Users` SET {0} WHERE `UID` = @userId", dbconn))
            {
                cmd.AddParameter("@userId", user.Id);

                //var updateCommand = cmd;
                return(Write(user, cmd) == 1);
            }
        }
示例#10
0
        /// <summary>
        /// Changes the given account's auth level.
        /// </summary>
        /// <param name="accountName"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public bool ChangeAuth(string accountName, int level)
        {
            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `accounts` SET {0} WHERE `name` = @accountName", conn))
                {
                    cmd.AddParameter("@accountName", accountName);
                    cmd.Set("authority", level);

                    return(cmd.Execute() > 0);
                }
        }
示例#11
0
文件: MsgrDb.cs 项目: xKamuna/aura-1
        /// <summary>
        /// Updates contact's last login time.
        /// </summary>
        /// <param name="contact"></param>
        private void UpdateLastLogin(Contact contact)
        {
            using (var conn = this.Connection)
                using (var cmd = new UpdateCommand("UPDATE `contacts` SET {0} WHERE `contactId` = @contactId", conn))
                {
                    cmd.AddParameter("@contactId", contact.Id);
                    cmd.Set("lastLogin", contact.LastLogin);

                    cmd.Execute();
                }
        }
示例#12
0
        /// <summary>
        /// Sets read flag for given note.
        /// </summary>
        /// <param name="noteId"></param>
        public void SetNoteRead(long noteId)
        {
            using (var conn = this.Connection)
                using (var cmd = new UpdateCommand("UPDATE `notes` SET {0} WHERE `noteId` = @noteId", conn))
                {
                    cmd.Set("read", true);
                    cmd.AddParameter("@noteId", noteId);

                    cmd.Execute();
                }
        }
示例#13
0
        public static bool Update(MySqlConnection dbconn, Character character)
        {
            using (var cmd = new UpdateCommand("UPDATE `Characters` SET {0} WHERE `CID` = @charId", dbconn))
            {
                cmd.AddParameter("@charId", character.Id);

                //var updateCommand = cmd;
                return(WriteCharacter(character, cmd) == 1);
                //character.WriteToDb(ref updateCommand);
                //cmd.Execute();
            }
        }
示例#14
0
        /// <summary>
        /// Saves user's options to database.
        /// </summary>
        /// <param name="user"></param>
        public void SaveOptions(User user)
        {
            using (var conn = this.Connection)
                using (var cmd = new UpdateCommand("UPDATE `contacts` SET {0} WHERE `contactId` = @contactId", conn))
                {
                    cmd.Set("status", (byte)user.Status);
                    cmd.Set("chatOptions", (uint)user.ChatOptions);
                    cmd.Set("nickname", user.Nickname ?? "");
                    cmd.AddParameter("@contactId", user.Id);

                    cmd.Execute();
                }
        }
示例#15
0
        /// <summary>
        /// Saves character information.
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public bool SaveCharacter(Character character)
        {
            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `characters` SET {0} WHERE `characterId` = @characterId", conn))
                {
                    cmd.AddParameter("@characterId", character.Id);
                    cmd.Set("name", character.Name);
                    cmd.Set("job", (short)character.JobId);
                    cmd.Set("gender", (byte)character.Gender);
                    cmd.Set("hair", character.Hair);
                    cmd.Set("level", character.Level);
                    cmd.Set("zone", character.MapId);
                    cmd.Set("x", character.Position.X);
                    cmd.Set("y", character.Position.Y);
                    cmd.Set("z", character.Position.Z);
                    cmd.Set("exp", character.Exp);
                    cmd.Set("maxExp", character.MaxExp);
                    cmd.Set("totalExp", character.TotalExp);
                    cmd.Set("hp", character.Hp);
                    cmd.Set("hpRate", character.HpRateByJob);
                    cmd.Set("sp", character.Sp);
                    cmd.Set("spRate", character.SpRateByJob);
                    cmd.Set("stamina", character.Stamina);
                    cmd.Set("staminaByJob", character.StaminaByJob);
                    cmd.Set("str", character.StrInvested);
                    cmd.Set("strByJob", character.StrByJob);
                    cmd.Set("con", character.ConInvested);
                    cmd.Set("conByJob", character.ConByJob);
                    cmd.Set("int", character.IntInvested);
                    cmd.Set("intByJob", character.IntByJob);
                    cmd.Set("spr", character.SprInvested);
                    cmd.Set("sprByJob", character.SprByJob);
                    cmd.Set("dex", character.DexInvested);
                    cmd.Set("dexByJob", character.DexByJob);
                    cmd.Set("statByLevel", character.StatByLevel);
                    cmd.Set("statByBonus", character.StatByBonus);
                    cmd.Set("usedStat", character.UsedStat);
                    cmd.Set("abilityPoints", character.AbilityPoints);

                    cmd.Execute();
                }

            this.SaveCharacterItems(character);
            this.SaveVariables("character:" + character.Id, character.Variables.Perm);
            this.SaveSessionObjects(character);
            this.SaveJobs(character);
            this.SaveSkills(character);
            this.SaveAbilities(character);

            return(false);
        }
示例#16
0
        /// <summary>
        /// Deletes group from database and moves friends in that group to ETC.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="groupId"></param>
        public void DeleteGroup(User user, int groupId)
        {
            using (var conn = this.Connection)
            {
                // Move friends
                using (var cmd = new UpdateCommand("UPDATE `friends` SET {0} WHERE `userId1` = @userId1 AND `groupId` = @oldGroupId", conn))
                {
                    cmd.Set("groupId", -1);
                    cmd.AddParameter("@userId1", user.Id);
                    cmd.AddParameter("@oldGroupId", groupId);

                    cmd.Execute();
                }

                // Delete group
                using (var mc = new MySqlCommand("DELETE FROM `groups` WHERE `contactId` = @contactId AND `groupId` = @groupId", conn))
                {
                    mc.Parameters.AddWithValue("@contactId", user.Id);
                    mc.Parameters.AddWithValue("@groupId", groupId);
                    mc.ExecuteNonQuery();
                }
            }
        }
示例#17
0
        /// <summary>
        /// Saves character information.
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public void SaveCharacter(Character character)
        {
            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `characters` SET {0} WHERE `characterId` = @characterId", conn))
                {
                    cmd.AddParameter("@characterId", character.Id);
                    cmd.Set("teamName", character.TeamName);
                    cmd.Set("zone", character.MapId);
                    cmd.Set("bx", character.BarrackPosition.X);
                    cmd.Set("by", character.BarrackPosition.Y);
                    cmd.Set("bz", character.BarrackPosition.Z);

                    cmd.Execute();
                }
        }
示例#18
0
 public static void UpdatePosition(MySqlConnection dbconn, ulong charId,
                                   int channelId, float x, float y, float z, float w, int cityId, int posState)
 {
     using (var cmd = new UpdateCommand("UPDATE characters SET {0} WHERE CID=@charId", dbconn))
     {
         cmd.AddParameter("@charId", charId);
         cmd.Set("posX", x);
         cmd.Set("posY", y);
         cmd.Set("posZ", z);
         cmd.Set("posW", w);
         cmd.Set("City", cityId);
         cmd.Set("channelId", channelId);
         cmd.Set("posState", posState);
         cmd.Execute();
     }
 }
示例#19
0
        /// <summary>
        /// Saves account.
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public bool SaveAccount(Account account)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }

            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `accounts` SET {0} WHERE `accountId` = @accountId", conn))
                {
                    cmd.AddParameter("@accountId", account.Id);
                    cmd.Set("settings", account.Settings.ToString());

                    return(cmd.Execute() > 0);
                }
        }
示例#20
0
        /// <summary>
        /// Saves account data.
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public bool SaveAccount(Account account)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }

            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `accounts` SET {0} WHERE `accountId` = @accountId", conn))
                {
                    cmd.AddParameter("@accountId", account.Id);
                    cmd.Set("teamName", account.TeamName);
                    cmd.Set("password", account.Password);
                    cmd.Set("medals", account.Medals);
                    cmd.Set("giftMedals", account.GiftMedals);
                    cmd.Set("premiumMedals", account.PremiumMedals);

                    return(cmd.Execute() > 0);
                }
        }
示例#21
0
        /// <summary>
        /// Saves character information.
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public bool SaveCharacter(Character character)
        {
            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `characters` SET {0} WHERE `characterId` = @characterId", conn))
                {
                    cmd.AddParameter("@characterId", character.Id);
                    cmd.Set("name", character.Name);
                    cmd.Set("job", (short)character.Job);
                    cmd.Set("gender", (byte)character.Gender);
                    cmd.Set("hair", character.Hair);
                    cmd.Set("level", character.Level);
                    cmd.Set("zone", character.MapId);
                    cmd.Set("x", character.Position.X);
                    cmd.Set("y", character.Position.Y);
                    cmd.Set("z", character.Position.Z);
                    cmd.Set("exp", character.Exp);
                    cmd.Set("maxExp", character.MaxExp);
                    cmd.Set("hp", character.Hp);
                    cmd.Set("maxHp", character.MaxHp);
                    cmd.Set("sp", character.Sp);
                    cmd.Set("maxSp", character.MaxSp);
                    cmd.Set("stamina", character.Stamina);
                    cmd.Set("maxStamina", character.MaxStamina);
                    cmd.Set("str", character.Str);
                    cmd.Set("con", character.Con);
                    cmd.Set("int", character.Int);
                    cmd.Set("spr", character.Spr);
                    cmd.Set("dex", character.Dex);
                    cmd.Set("statByLevel", character.StatByLevel);
                    cmd.Set("statByBonus", character.StatByBonus);
                    cmd.Set("usedStat", character.UsedStat);

                    cmd.Execute();
                }

            this.SaveCharacterItems(character);
            this.SaveVariables("character:" + character.Id, character.Variables.Perm);

            return(false);
        }
示例#22
0
        /// <summary>
        /// Saves character information.
        /// </summary>
        /// <param name="character"></param>
        /// <returns></returns>
        public bool SaveCharacter(Character character)
        {
            using (var conn = this.GetConnection())
                using (var cmd = new UpdateCommand("UPDATE `characters` SET {0} WHERE `characterId` = @characterId", conn))
                {
                    var characterProperties = (CharacterProperties)character.Properties;

                    cmd.AddParameter("@characterId", character.Id);
                    cmd.Set("name", character.Name);
                    cmd.Set("job", (short)character.JobId);
                    cmd.Set("gender", (byte)character.Gender);
                    cmd.Set("hair", character.Hair);
                    cmd.Set("level", character.Level);
                    cmd.Set("zone", character.MapId);
                    cmd.Set("x", character.Position.X);
                    cmd.Set("y", character.Position.Y);
                    cmd.Set("z", character.Position.Z);
                    cmd.Set("exp", character.Exp);
                    cmd.Set("maxExp", character.MaxExp);
                    cmd.Set("totalExp", character.TotalExp);
                    cmd.Set("stamina", (character.Properties as CharacterProperties).Stamina);
                    cmd.Set("silver", character.Inventory.CountItem(ItemId.Silver));

                    cmd.Execute();
                }

            this.SaveCharacterItems(character);
            this.SaveVariables("character:" + character.Id, character.Variables.Perm);
            this.SaveSessionObjects(character);
            this.SaveProperties("character_properties", "characterId", character.Id, character.Properties);
            this.SaveJobs(character);
            this.SaveSkills(character);
            this.SaveAbilities(character);

            return(false);
        }
示例#23
0
        /// <summary>
        /// Updates deletion time for character, or deletes it.
        /// </summary>
        /// <param name="character"></param>
        public void UpdateDeletionTime(Character character)
        {
            using (var conn = this.Connection)
            {
                if (character.DeletionFlag == DeletionFlag.Delete)
                {
                    using (var mc = new MySqlCommand("DELETE FROM `creatures` WHERE `creatureId` = @creatureId", conn))
                    {
                        mc.Parameters.AddWithValue("@creatureId", character.CreatureId);
                        mc.ExecuteNonQuery();
                    }
                }
                else
                {
                    using (var cmd = new UpdateCommand("UPDATE `creatures` SET {0} WHERE `creatureId` = @creatureId", conn))
                    {
                        cmd.AddParameter("@creatureId", character.CreatureId);
                        cmd.Set("deletionTime", character.DeletionTime);

                        cmd.Execute();
                    }
                }
            }
        }