/// <summary> /// 删除 /// </summary> /// <param name="id">主键</param> /// <returns>影响行数</returns> public int Delete(string id) { var result = 0; // 删除角色权限结构定义 // result = DbUtil.Delete(DbHelper, BaseRoleModuleOperationTable.TableName, BaseRoleModuleOperationTable.FieldRoleId, id); // 删除员工角色结构定义部分 var parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(BaseUserRoleEntity.FieldRoleId, id) }; result += DbUtil.Delete(DbHelper, BaseUserRoleEntity.CurrentTableName, parameters); // 删除角色的表结构定义部分 parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(BaseRoleEntity.FieldId, id), new KeyValuePair <string, object>(BaseRoleEntity.FieldAllowDelete, 1) }; result += DbUtil.Delete(DbHelper, CurrentTableName, parameters); return(result); }
public async Task ClubUnjoinReq2(GameSession session, ClubUnjoinReq2Message message) { var plr = session.Player; if (plr?.Club == null || plr.Club.Id != message.ClanId) { await session.SendAsync(new ClubUnjoinAck2Message(4)); return; } if (plr.Club.Players.Values.Any(x => x.Account?.Id == (int)plr.Account.Id && x.Rank != ClubRank.Master)) { using (var db = GameDatabase.Open()) { var club = (await DbUtil.FindAsync <ClubDto>(db, statement => statement .Where($"{nameof(ClubDto.Id):C} = @Id") .WithParameters(new { plr.Club.Id }))).FirstOrDefault(); if (club != null) { var player = (await DbUtil.FindAsync <ClubPlayerDto>(db, statement => statement .Where($"{nameof(ClubPlayerDto.ClubId):C} = @Id") .WithParameters(new { plr.Club.Id })) ).FirstOrDefault(x => x.PlayerId == (int)plr.Account.Id); if (player != null) { Club.LogOff(plr); ClubPlayerInfo clubPlayerInfo; plr.Club.Players.TryRemove(plr.Account.Id, out clubPlayerInfo); DbUtil.Delete(db, new ClubPlayerDto { PlayerId = player.PlayerId }); plr.Club = null; await session.SendAsync(new ClubMyInfoAckMessage(plr.Map <Player, ClubMyInfoDto>())); await session.SendAsync(new ClubUnjoinAck2Message()); } else { await session.SendAsync((object)new ServerResultAckMessage((ServerResult)31)); } player = (ClubPlayerDto)null; } else { await session.SendAsync((object)new ServerResultAckMessage((ServerResult)31)); } club = (ClubDto)null; } } else { await session.SendAsync((object)new ServerResultAckMessage((ServerResult)22)); } }
public async Task ClubCloseReq2(GameSession session, ClubCloseReq2Message message) { var plr = session.Player; if (plr?.Club == null || plr.Club.Id != message.ClanId) { await session.SendAsync(new ClubCloseAck2Message(1)); return; } if (plr.Club.Players.Any(x => x.Key == plr.Account.Id && x.Value.Rank == ClubRank.Master)) { using (var db = GameDatabase.Open()) { var club = (await DbUtil.FindAsync <ClubDto>(db, statement => statement .Where($"{nameof(ClubDto.Id):C} = @Id") .WithParameters(new { plr.Club.Id }))).FirstOrDefault(); if (club != null) { var players = await DbUtil.FindAsync <ClubPlayerDto>(db, statement => statement .Where($"{nameof(ClubPlayerDto.ClubId):C} = @Id") .WithParameters(new { plr.Club.Id })); foreach (var member in players) { await DbUtil.DeleteAsync(db, member); } DbUtil.Delete(db, club); foreach (var member in plr.Club.Players) { plr.Club.Players.TryRemove(member.Key, out _); } GameServer.Instance.ClubManager.Remove(plr.Club); await session.SendAsync(new ClubCloseAck2Message()); foreach (var member in GameServer.Instance.PlayerManager.Where(x => x.Club?.Id == club.Id)) { Club.LogOff(member); member.Club = null; member.Session?.SendAsync(new ClubMyInfoAckMessage(member.Map <Player, ClubMyInfoDto>())); } } } } }
/// <summary> /// 删除 /// </summary> /// <param name="parameters"></param> /// <returns></returns> private int MyDelete(List <KeyValuePair <string, object> > parameters) { parameters = GetDeleteExtParam(parameters); return(DbUtil.Delete(DbHelper, CurrentTableName, parameters)); }