/// <summary> /// 查看玩家身上道具 /// </summary> /// <returns></returns> public Message itemShop_Owner_Query(int index, int pageSize) { string serverIP = null; int userIndexID = 0; DataSet ds = null; try { serverIP = Encoding.Default.GetString(msg.m_packet.m_Body.getTLVByTag(TagName.SDO_ServerIP).m_bValueBuffer); TLV_Structure tlvStrut = new TLV_Structure(TagName.SDO_UserIndexID, 4, msg.m_packet.m_Body.getTLVByTag(TagName.SDO_UserIndexID).m_bValueBuffer); userIndexID = (int)tlvStrut.toInteger(); Console.WriteLine(DateTime.Now + " - " + lg.API_Display + lg.SDOAPI_SDO + "+>" + lg.API_CommonAPI_ServerIP + CommonInfo.serverIP_Query(serverIP) + lg.SDOAPI_SDOItemLogInfoAPI_Account + userIndexID + lg.SDOAPI_SDOItemShopAPI_PersonalItem + "!"); //请求玩家身上的道具 ds = ItemShopInfo.itemShop_Query(serverIP, userIndexID); if (ds != null && ds.Tables[0].Rows.Count > 0) { //总页数 int pageCount = 0; pageCount = ds.Tables[0].Rows.Count % pageSize; if (pageCount > 0) { pageCount = ds.Tables[0].Rows.Count / pageSize + 1; } else { pageCount = ds.Tables[0].Rows.Count / pageSize; } if (index + pageSize > ds.Tables[0].Rows.Count) { pageSize = ds.Tables[0].Rows.Count - index; } Query_Structure[] structList = new Query_Structure[pageSize]; for (int i = index; i < index + pageSize; i++) { Query_Structure strut = new Query_Structure((uint)ds.Tables[0].Rows[i].ItemArray.Length + 1); //道具编号 byte[] bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[0]); strut.AddTagKey(TagName.SDO_ItemCode, TagFormat.TLV_INTEGER, (uint)bytes.Length, bytes); //道具名 bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, UserValidate.validData(ds.Tables[0].Rows[i].ItemArray[1])); strut.AddTagKey(TagName.SDO_ItemName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); //最小等级 bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[2]); strut.AddTagKey(TagName.SDO_MinLevel, TagFormat.TLV_INTEGER, (uint)bytes.Length, bytes); //道具位置 bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[3]); strut.AddTagKey(TagName.SDO_Postion, TagFormat.TLV_INTEGER, (uint)bytes.Length, bytes); //道具使用次数 int timelimits = Convert.ToInt32(ds.Tables[0].Rows[i].ItemArray[4]); if (timelimits == -1) { timelimits = 0; } bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, timelimits); strut.AddTagKey(TagName.SDO_TimesLimit, TagFormat.TLV_INTEGER, (uint)bytes.Length, bytes); //道具时间限制 bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_TIMESTAMP, ds.Tables[0].Rows[i].ItemArray[5]); strut.AddTagKey(TagName.SDO_DateLimit, TagFormat.TLV_TIMESTAMP, (uint)bytes.Length, bytes); //总页数 strut.AddTagKey(TagName.PageCount, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, pageCount)); structList[i - index] = strut; } return(Message.COMMON_MES_RESP(structList, Msg_Category.SDO_ADMIN, ServiceKey.SDO_ITEMSHOP_BYOWNER_QUERY_RESP, 7)); } else { return(Message.COMMON_MES_RESP(lg.SDOAPI_SDOItemShopAPI_NoItemOnPlayer, Msg_Category.SDO_ADMIN, ServiceKey.SDO_ITEMSHOP_BYOWNER_QUERY_RESP, TagName.ERROR_Msg, TagFormat.TLV_STRING)); } } catch (Common.Logic.Exception ex) { Console.WriteLine(ex.Message); return(Message.COMMON_MES_RESP(lg.SDOAPI_SDOItemShopAPI_NoItemOnPlayer, Msg_Category.SDO_ADMIN, ServiceKey.SDO_ITEMSHOP_BYOWNER_QUERY_RESP, TagName.ERROR_Msg, TagFormat.TLV_STRING)); } }