public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; int id = packet.ReadInt(); bool upGrade = packet.ReadBoolean(); bool result = false; string msg = "ConsortiaUserGradeUpdateHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { string tempUserName = ""; ConsortiaDutyInfo info = new ConsortiaDutyInfo(); if (db.UpdateConsortiaUserGrade(id, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, upGrade, ref msg, ref info, ref tempUserName)) { msg = "ConsortiaUserGradeUpdateHandler.Success"; result = true; GameServer.Instance.LoginServer.SendConsortiaDuty(info, upGrade ? 6 : 7, client.Player.PlayerCharacter.ConsortiaID,id, tempUserName,client.Player.PlayerCharacter.ID,client.Player.PlayerCharacter.NickName); } } packet.WriteBoolean(result); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; int dutyID = packet.ReadInt(); int updateType = packet.ReadByte(); //int level = packet.ReadInt(); bool result = false; string msg = "ConsortiaDutyUpdateHandler.Failed"; using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaDutyInfo info = new ConsortiaDutyInfo(); info.ConsortiaID = client.Player.PlayerCharacter.ConsortiaID; info.DutyID = dutyID; info.IsExist = true; info.DutyName = ""; switch (updateType) { case 1: return 1; case 2: info.DutyName = packet.ReadString(); if (string.IsNullOrEmpty(info.DutyName) || System.Text.Encoding.Default.GetByteCount(info.DutyName) > 10) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaDutyUpdateHandler.Long")); return 1; } info.Right = packet.ReadInt(); break; case 3: break; case 4: break; } if (db.UpdateConsortiaDuty(info, client.Player.PlayerCharacter.ID, updateType, ref msg)) { dutyID = info.DutyID; msg = "ConsortiaDutyUpdateHandler.Success"; result = true; GameServer.Instance.LoginServer.SendConsortiaDuty(info, updateType, client.Player.PlayerCharacter.ConsortiaID); } } packet.WriteBoolean(result); packet.WriteInt(dutyID); packet.WriteString(LanguageMgr.GetTranslation(msg)); client.Out.SendTCP(packet); return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID == 0) return 0; //int id = packet.ReadInt(); string nickName = packet.ReadString(); bool result = false; string msg = "ConsortiaChangeChairmanHandler.Failed"; if (string.IsNullOrEmpty(nickName)) { msg = "ConsortiaChangeChairmanHandler.NoName"; } else if( nickName == client.Player.PlayerCharacter.NickName) { msg = "ConsortiaChangeChairmanHandler.Self"; } else { using (ConsortiaBussiness db = new ConsortiaBussiness()) { string tempUserName = ""; int tempUserID = 0; ConsortiaDutyInfo info = new ConsortiaDutyInfo(); if (db.UpdateConsortiaChairman(nickName, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, ref msg, ref info,ref tempUserID, ref tempUserName)) { ConsortiaDutyInfo orderInfo = new ConsortiaDutyInfo(); orderInfo.Level = client.Player.PlayerCharacter.DutyLevel; orderInfo.DutyName = client.Player.PlayerCharacter.DutyName; orderInfo.Right = client.Player.PlayerCharacter.Right; msg = "ConsortiaChangeChairmanHandler.Success1"; result = true; GameServer.Instance.LoginServer.SendConsortiaDuty(orderInfo, 9, client.Player.PlayerCharacter.ConsortiaID, tempUserID, tempUserName, 0, ""); GameServer.Instance.LoginServer.SendConsortiaDuty(info, 8, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, 0, ""); } } } string temp = LanguageMgr.GetTranslation(msg); if (msg == "ConsortiaChangeChairmanHandler.Success1") { temp += nickName + LanguageMgr.GetTranslation("ConsortiaChangeChairmanHandler.Success2"); } packet.WriteBoolean(result); packet.WriteString(temp); client.Out.SendTCP(packet); return 0; }
public bool AddConsortia(ConsortiaInfo info, ref string msg, ref ConsortiaDutyInfo dutyInfo) { bool result = false; try { SqlParameter[] para = new SqlParameter[23]; para[0] = new SqlParameter("@ConsortiaID", info.ConsortiaID); para[0].Direction = ParameterDirection.InputOutput; para[1] = new SqlParameter("@BuildDate", info.BuildDate); para[2] = new SqlParameter("@CelebCount", info.CelebCount); para[3] = new SqlParameter("@ChairmanID", info.ChairmanID); para[4] = new SqlParameter("@ChairmanName", info.ChairmanName == null ? "" : info.ChairmanName); para[5] = new SqlParameter("@ConsortiaName", info.ConsortiaName == null ? "" : info.ConsortiaName); para[6] = new SqlParameter("@CreatorID", info.CreatorID); para[7] = new SqlParameter("@CreatorName", info.CreatorName == null ? "" : info.CreatorName); para[8] = new SqlParameter("@Description", info.Description); para[9] = new SqlParameter("@Honor", info.Honor); para[10] = new SqlParameter("@IP", info.IP); para[11] = new SqlParameter("@IsExist", info.IsExist); para[12] = new SqlParameter("@Level", info.Level); para[13] = new SqlParameter("@MaxCount", info.MaxCount); para[14] = new SqlParameter("@Placard", info.Placard); para[15] = new SqlParameter("@Port", info.Port); para[16] = new SqlParameter("@Repute", info.Repute); para[17] = new SqlParameter("@Count", info.Count); para[18] = new SqlParameter("@Riches", info.Riches); para[19] = new SqlParameter("@Result", System.Data.SqlDbType.Int); para[19].Direction = ParameterDirection.ReturnValue; para[20] = new SqlParameter("@tempDutyLevel", System.Data.SqlDbType.Int); para[20].Direction = ParameterDirection.InputOutput; para[20].Value = dutyInfo.Level; para[21] = new SqlParameter("@tempDutyName", System.Data.SqlDbType.VarChar, 100); para[21].Direction = ParameterDirection.InputOutput; para[21].Value = ""; para[22] = new SqlParameter("@tempRight", System.Data.SqlDbType.Int); para[22].Direction = ParameterDirection.InputOutput; para[22].Value = dutyInfo.Right; result = db.RunProcedure("SP_Consortia_Add", para); int returnValue = (int)para[19].Value; result = returnValue == 0; if (result) { info.ConsortiaID = (int)para[0].Value; dutyInfo.Level = (int)para[20].Value; dutyInfo.DutyName = para[21].Value.ToString(); dutyInfo.Right = (int)para[22].Value; } switch (returnValue) { case 2: msg = "ConsortiaBussiness.AddConsortia.Msg2"; break; } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public bool AddConsortiaDuty(ConsortiaDutyInfo info, int userID, ref string msg) { bool result = false; try { SqlParameter[] para = new SqlParameter[7]; para[0] = new SqlParameter("@DutyID", info.DutyID); para[0].Direction = ParameterDirection.InputOutput; para[1] = new SqlParameter("@ConsortiaID", info.ConsortiaID); para[2] = new SqlParameter("@DutyName", info.DutyName); para[3] = new SqlParameter("@Level", info.Level); para[4] = new SqlParameter("@UserID", userID); para[5] = new SqlParameter("@Right", info.Right); para[6] = new SqlParameter("@Result", System.Data.SqlDbType.Int); para[6].Direction = ParameterDirection.ReturnValue; result = db.RunProcedure("SP_ConsortiaDuty_Add", para); info.DutyID = (int)para[0].Value; int returnValue = (int)para[6].Value; result = returnValue == 0; switch (returnValue) { case 2: msg = "ConsortiaBussiness.AddConsortiaDuty.Msg2"; break; case 3: msg = "ConsortiaBussiness.AddConsortiaDuty.Msg3"; break; } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public bool UpdateConsortiaUserGrade(int id, int consortiaID, int userID, bool upGrade, ref string msg, ref ConsortiaDutyInfo info, ref string tempUserName) { bool result = false; try { SqlParameter[] para = new SqlParameter[9]; para[0] = new SqlParameter("@ID", id); para[1] = new SqlParameter("@ConsortiaID", consortiaID); para[2] = new SqlParameter("@UserID", userID); para[3] = new SqlParameter("@UpGrade", upGrade); para[4] = new SqlParameter("@Result", System.Data.SqlDbType.Int); para[4].Direction = ParameterDirection.ReturnValue; para[5] = new SqlParameter("@tempUserName", System.Data.SqlDbType.VarChar, 100); para[5].Direction = ParameterDirection.InputOutput; para[5].Value = tempUserName; para[6] = new SqlParameter("@tempDutyLevel", System.Data.SqlDbType.Int); para[6].Direction = ParameterDirection.InputOutput; para[6].Value = info.Level; para[7] = new SqlParameter("@tempDutyName", System.Data.SqlDbType.VarChar, 100); para[7].Direction = ParameterDirection.InputOutput; para[7].Value = ""; para[8] = new SqlParameter("@tempRight", System.Data.SqlDbType.Int); para[8].Direction = ParameterDirection.InputOutput; para[8].Value = info.Right; result = db.RunProcedure("SP_ConsortiaUserGrade_Update", para); int returnValue = (int)para[4].Value; result = returnValue == 0; if (result) { tempUserName = para[5].Value.ToString(); info.Level = (int)para[6].Value; info.DutyName = para[7].Value.ToString(); info.Right = (int)para[8].Value; } switch (returnValue) { case 2: msg = "ConsortiaBussiness.UpdateConsortiaUserGrade.Msg2"; break; case 3: msg = upGrade ? "ConsortiaBussiness.UpdateConsortiaUserGrade.Msg3" : "ConsortiaBussiness.UpdateConsortiaUserGrade.Msg10"; break; case 4: msg = "ConsortiaBussiness.UpdateConsortiaUserGrade.Msg4"; break; case 5: msg = "ConsortiaBussiness.UpdateConsortiaUserGrade.Msg5"; break; } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public bool UpdateConsortiaDuty(ConsortiaDutyInfo info, int userID, int updateType, ref string msg) { bool result = false; try { SqlParameter[] para = new SqlParameter[8]; para[0] = new SqlParameter("@DutyID", info.DutyID); para[0].Direction = ParameterDirection.InputOutput; para[1] = new SqlParameter("@ConsortiaID", info.ConsortiaID); para[2] = new SqlParameter("@DutyName", System.Data.SqlDbType.NVarChar, 100); para[2].Direction = ParameterDirection.InputOutput; para[2].Value = info.DutyName; para[3] = new SqlParameter("@Right", System.Data.SqlDbType.Int); para[3].Direction = ParameterDirection.InputOutput; para[3].Value = info.Right; para[4] = new SqlParameter("@Level", System.Data.SqlDbType.Int); para[4].Direction = ParameterDirection.InputOutput; para[4].Value = info.Level; para[5] = new SqlParameter("@UserID", userID); para[6] = new SqlParameter("@UpdateType", updateType); para[7] = new SqlParameter("@Result", System.Data.SqlDbType.Int); para[7].Direction = ParameterDirection.ReturnValue; result = db.RunProcedure("SP_ConsortiaDuty_Update", para); int returnValue = (int)para[7].Value; result = returnValue == 0; if (result) { info.DutyID = (int)para[0].Value; info.DutyName = para[2].Value == null ? "" : para[2].Value.ToString(); info.Right = (int)para[3].Value; info.Level = (int)para[4].Value; } switch (returnValue) { case 2: msg = "ConsortiaBussiness.UpdateConsortiaDuty.Msg2"; break; case 3: case 4: msg = "ConsortiaBussiness.UpdateConsortiaDuty.Msg3"; break; case 5: msg = "ConsortiaBussiness.DeleteConsortiaDuty.Msg5"; break; } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public ConsortiaDutyInfo[] GetConsortiaDutyPage(int page, int size, ref int total, int order, int consortiaID, int dutyID) { List<ConsortiaDutyInfo> infos = new List<ConsortiaDutyInfo>(); try { string sWhere = " IsExist=1 "; if (consortiaID != -1) { sWhere += " and ConsortiaID =" + consortiaID + " "; } if (dutyID != -1) { sWhere += " and DutyID =" + dutyID + " "; } string sOrder = "Level"; switch (order) { case 1: sOrder = "DutyName"; break; } sOrder += ",DutyID "; DataTable dt = GetPage("Consortia_Duty", sWhere, page, size, "*", sOrder, "DutyID", ref total); foreach (DataRow dr in dt.Rows) { ConsortiaDutyInfo info = new ConsortiaDutyInfo(); info.DutyID = (int)dr["DutyID"]; info.ConsortiaID = (int)dr["ConsortiaID"]; info.DutyID = (int)dr["DutyID"]; info.DutyName = dr["DutyName"].ToString(); info.IsExist = (bool)dr["IsExist"]; info.Right = (int)dr["Right"]; info.Level = (int)dr["Level"]; infos.Add(info); } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return infos.ToArray(); }
//updateType:1.添加责务,2.更改责务,3.职务升级,4.职务降级,5.个人改变,6.个人升级,7.个人降级,8.会长转让,9.升会长。 public void SendConsortiaDuty(ConsortiaDutyInfo info, int updateType, int consortiaID, int playerID, string playerName, int handleID, string handleName) { GSPacketIn pkg = new GSPacketIn((byte)eChatServerPacket.CONSORTIA_RESPONSE); pkg.WriteByte(8); pkg.WriteByte((byte)updateType); pkg.WriteInt(consortiaID); pkg.WriteInt(playerID); pkg.WriteString(playerName); pkg.WriteInt(info.Level); pkg.WriteString(info.DutyName); pkg.WriteInt(info.Right); pkg.WriteInt(handleID); pkg.WriteString(handleName); SendTCP(pkg); }
public void SendConsortiaDuty(ConsortiaDutyInfo info, int updateType, int consortiaID) { SendConsortiaDuty(info, updateType, consortiaID, 0, "", 0, ""); }
public static XElement CreateConsortiaDutyInfo(ConsortiaDutyInfo info) { return new XElement("Item", new XAttribute("DutyID", info.DutyID), new XAttribute("ConsortiaID", info.ConsortiaID), new XAttribute("DutyName", info.DutyName == null ? "" : info.DutyName), new XAttribute("Right", info.Right), new XAttribute("Level", info.Level)); }
public int HandlePacket(GameClient client, GSPacketIn packet) { var consortiaCmd = packet.ReadInt(); bool result = false; string msg = "Packet Error!"; ConsortiaLevelInfo levelInfo = null; GamePlayer[] players = WorldMgr.GetAllPlayers(); switch (consortiaCmd) { case (int)ConsortiaPackageType.CONSORTIA_TRYIN: HandleCONSORTIA_TRYIN(packet); break; case (int)ConsortiaPackageType.CONSORTIA_CREATE: //Create Guild { if (client.Player.PlayerCharacter.ConsortiaID != 0) return 0; levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1); string name = packet.ReadString(); //if (string.IsNullOrEmpty(name) || System.Text.Encoding.Default.GetByteCount(name) > 12) //{ // client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long")); // return 1; //} //result = false; int id = 0; int mustGold = levelInfo.NeedGold; int mustLevel = 5; msg = "ConsortiaCreateHandler.Failed"; ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo(); if (!string.IsNullOrEmpty(name) && client.Player.PlayerCharacter.Gold >= mustGold && client.Player.PlayerCharacter.Grade >= mustLevel) { using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = new ConsortiaInfo(); info.BuildDate = DateTime.Now; info.CelebCount = 0; info.ChairmanID = client.Player.PlayerCharacter.ID; info.ChairmanName = client.Player.PlayerCharacter.NickName; info.ConsortiaName = name; info.CreatorID = info.ChairmanID; info.CreatorName = info.ChairmanName; info.Description = ""; info.Honor = 0; info.IP = ""; info.IsExist = true; info.Level = levelInfo.Level; info.MaxCount = levelInfo.Count; info.Riches = levelInfo.Riches; info.Placard = ""; info.Port = 0; info.Repute = 0; info.Count = 1; if (db.AddConsortia(info, ref msg, ref dutyInfo)) { client.Player.PlayerCharacter.ConsortiaID = info.ConsortiaID; client.Player.PlayerCharacter.ConsortiaName = info.ConsortiaName; client.Player.PlayerCharacter.DutyLevel = dutyInfo.Level; client.Player.PlayerCharacter.DutyName = dutyInfo.DutyName; client.Player.PlayerCharacter.Right = dutyInfo.Right; client.Player.PlayerCharacter.ConsortiaLevel = levelInfo.Level; client.Player.RemoveGold(mustGold); msg = "ConsortiaCreateHandler.Success"; result = true; id = info.ConsortiaID; GameServer.Instance.LoginServer.SendConsortiaCreate(id, client.Player.PlayerCharacter.Offer, info.ConsortiaName); } else { client.Player.SendMessage("db.AddConsortia Error "); } } } //Send package create Guild client.Out.SendConsortiaCreate(name, result, id, name, LanguageMgr.GetTranslation(msg), dutyInfo.Level, dutyInfo.DutyName, dutyInfo.Right, client.Player.PlayerCharacter.ID); } break; case (int)ConsortiaPackageType.CONSORTIA_DISBAND: HandleCONSORTIA_DISBAND(packet); break; case (int)ConsortiaPackageType.CONSORTIA_RENEGADE: HandleCONSORTIA_RENEGADE(packet); break; case (int)ConsortiaPackageType.CONSORTIA_TRYIN_PASS: HandleCONSORTIA_TRYIN_PASS(packet); break; case (int)ConsortiaPackageType.CONSORTIA_TRYIN_DEL: HandleCONSORTIA_TRYIN_DEL(packet); break; case (int)ConsortiaPackageType.CONSORTIA_RICHES_OFFER: break; case (int)ConsortiaPackageType.CONSORTIA_APPLY_STATE: break; case (int)ConsortiaPackageType.CONSORTIA_DUTY_DELETE: break; case (int)ConsortiaPackageType.CONSORTIA_DUTY_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_INVITE: break; case (int)ConsortiaPackageType.CONSORTIA_INVITE_PASS: break; case (int)ConsortiaPackageType.CONSORTIA_INVITE_DELETE: break; case (int)ConsortiaPackageType.CONSORTIA_DESCRIPTION_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_PLACARD_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_BANCHAT_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_USER_REMARK_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_USER_GRADE_UPDATE: break; case (int)ConsortiaPackageType.CONSORTIA_CHAIRMAN_CHAHGE: break; case (int)ConsortiaPackageType.CONSORTIA_CHAT: break; case (int)ConsortiaPackageType.CONSORTIA_LEVEL_UP: break; case (int)ConsortiaPackageType.CONSORTIA_TASK_RELEASE: break; case (int)ConsortiaPackageType.DONATE: break; case (int)ConsortiaPackageType.CONSORTIA_EQUIP_CONTROL: break; case (int)ConsortiaPackageType.POLL_CANDIDATE: break; case (int)ConsortiaPackageType.SKILL_SOCKET: break; case (int)ConsortiaPackageType.CONSORTION_MAIL: break; case (int)ConsortiaPackageType.BUY_BADGE: break; } return 0; }
public int HandlePacket(GameClient client, GSPacketIn packet) { if (client.Player.PlayerCharacter.ConsortiaID != 0) return 0; ConsortiaLevelInfo levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1); string name = packet.ReadString(); if (string.IsNullOrEmpty(name) || System.Text.Encoding.Default.GetByteCount(name) > 12) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long")); return 1; } bool result = false; int id = 0; int mustGold = levelInfo.NeedGold; int mustLevel = 5; string msg = "ConsortiaCreateHandler.Failed"; ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo(); if (!string.IsNullOrEmpty(name) && client.Player.PlayerCharacter.Gold >= mustGold && client.Player.PlayerCharacter.Grade >= mustLevel) { using (ConsortiaBussiness db = new ConsortiaBussiness()) { ConsortiaInfo info = new ConsortiaInfo(); info.BuildDate = DateTime.Now; info.CelebCount = 0; info.ChairmanID = client.Player.PlayerCharacter.ID; info.ChairmanName = client.Player.PlayerCharacter.NickName; info.ConsortiaName = name; info.CreatorID = info.ChairmanID; info.CreatorName = info.ChairmanName; info.Description = ""; info.Honor = 0; info.IP = ""; info.IsExist = true; info.Level = levelInfo.Level; info.MaxCount = levelInfo.Count; info.Riches = levelInfo.Riches; info.Placard = ""; info.Port = 0; info.Repute = 0; info.Count = 1; if (db.AddConsortia(info, ref msg, ref dutyInfo)) { client.Player.PlayerCharacter.ConsortiaID = info.ConsortiaID; client.Player.PlayerCharacter.ConsortiaName = info.ConsortiaName; client.Player.PlayerCharacter.DutyLevel = dutyInfo.Level; client.Player.PlayerCharacter.DutyName = dutyInfo.DutyName; client.Player.PlayerCharacter.Right = dutyInfo.Right; client.Player.PlayerCharacter.ConsortiaLevel = levelInfo.Level; client.Player.RemoveGold(mustGold); msg = "ConsortiaCreateHandler.Success"; result = true; id = info.ConsortiaID; GameServer.Instance.LoginServer.SendConsortiaCreate(id, client.Player.PlayerCharacter.Offer,info.ConsortiaName); } } } packet.WriteBoolean(result); packet.WriteInt(id); packet.WriteString(name); packet.WriteString(LanguageMgr.GetTranslation(msg)); packet.WriteInt(dutyInfo.Level); packet.WriteString(dutyInfo.DutyName == null ? "" : dutyInfo.DutyName); packet.WriteInt(dutyInfo.Right); client.Out.SendTCP(packet); //client.Out.SendMessage(eMessageType.Normal, msg); return 0; }