/// <summary> /// 得到所有模块信息 /// </summary> /// <returns>模块数据集</returns> public Message GM_QueryAll(int index, int pageSize) { GMLogAPI logAPI = new GMLogAPI(); DataSet ds = null; try { logAPI.writeTitle(LanguageAPI.API_Display + LanguageAPI.API_ModuleInfoAPI_ModuleList, LanguageAPI.API_Display + LanguageAPI.API_ModuleInfoAPI_ModuleList); logAPI.writeContent(LanguageAPI.API_GameInfoAPI_ModuleID, LanguageAPI.API_GameInfoAPI_ModuleTitle, LanguageAPI.API_GameInfoAPI_ModuleClass, LanguageAPI.API_GameInfoAPI_ModuleDesp); ds = GMModuleInfo.SelectAll(); if (ds.Tables[0].Rows.Count <= 0) { return(Message.COMMON_MES_RESP(LanguageAPI.API_ModuleInfoAPI_NoModuleList, Msg_Category.MODULE_ADMIN, ServiceKey.MODULE_QUERY_RESP, TagName.ERROR_Msg, TagFormat.TLV_STRING)); } else { //总页数 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(7); strut.AddTagKey(TagName.GameID, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[0])); strut.AddTagKey(TagName.Module_ID, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[1])); byte[] bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[2]); strut.AddTagKey(TagName.GameName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[3]); strut.AddTagKey(TagName.ModuleName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[4]); strut.AddTagKey(TagName.ModuleClass, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[5]); strut.AddTagKey(TagName.ModuleContent, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); //总页数 strut.AddTagKey(TagName.PageCount, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, pageCount)); structList[i - index] = strut; logAPI.writeData(ds.Tables[0].Rows[i].ItemArray[1].ToString(), ds.Tables[0].Rows[i].ItemArray[2].ToString(), ds.Tables[0].Rows[i].ItemArray[3].ToString(), ds.Tables[0].Rows[i].ItemArray[4].ToString()); } Console.Write(logAPI.Buffer.ToString()); return(Message.COMMON_MES_RESP(structList, Msg_Category.MODULE_ADMIN, ServiceKey.MODULE_QUERY_RESP, 7)); } } catch (SqlException ex) { Console.WriteLine(ex.Message); return(Message.COMMON_MES_RESP(ex.Message, Msg_Category.MODULE_ADMIN, ServiceKey.MODULE_QUERY_RESP, TagName.ERROR_Msg, TagFormat.TLV_STRING)); } }
/// <summary> /// 得到游戏信息类 /// </summary> /// <param name="gameID">游戏ID</param> /// <returns>游戏信息类</returns> public Message GM_QueryModuleInfo(int gameID) { System.Data.DataSet ds = null; GMLogAPI logAPI = new GMLogAPI(); try { ds = GMModuleInfo.SelectAll(); if (ds.Tables[0].Rows.Count <= 0) { return(Message.COMMON_MES_RESP("FAILURE", Msg_Category.GAME_ADMIN, ServiceKey.GAME_MODULE_QUERY_RESP)); } else { logAPI.writeTitle(LanguageAPI.API_Display + LanguageAPI.API_GameInfoAPI_GameModuleList, LanguageAPI.API_Display + LanguageAPI.API_GameInfoAPI_GameModuleList); logAPI.writeContent(LanguageAPI.API_GameInfoAPI_ModuleID, LanguageAPI.API_GameInfoAPI_ModuleTitle, LanguageAPI.API_GameInfoAPI_ModuleClass, LanguageAPI.API_GameInfoAPI_ModuleDesp); Query_Structure[] structList = new Query_Structure[ds.Tables[0].Rows.Count]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Query_Structure strut = new Query_Structure((uint)ds.Tables[0].Rows[i].ItemArray.Length); strut.AddTagKey(TagName.Module_ID, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[1])); strut.AddTagKey(TagName.GameID, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[0])); byte[] bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[2]); strut.AddTagKey(TagName.GameName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[3]); strut.AddTagKey(TagName.ModuleName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[4]); strut.AddTagKey(TagName.ModuleClass, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[5]); strut.AddTagKey(TagName.ModuleContent, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); structList[i] = strut; logAPI.writeData(ds.Tables[0].Rows[i].ItemArray[1].ToString(), ds.Tables[0].Rows[i].ItemArray[2].ToString(), ds.Tables[0].Rows[i].ItemArray[3].ToString(), ds.Tables[0].Rows[i].ItemArray[4].ToString()); } Console.Write(logAPI.Buffer.ToString()); return(Message.COMMON_MES_RESP(structList, Msg_Category.GAME_ADMIN, ServiceKey.GAME_MODULE_QUERY_RESP, 6)); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); return(null); } }
/// <summary> /// 根据得到模块信息类 /// </summary> /// <param name="userID">用户ID</param> /// <returns>模块类</returns> public Message GM_getModuleInfo() { GMLogAPI logAPI = new GMLogAPI(); System.Data.DataSet ds = null; try { //将模块信息存入DATASET ds = GMModuleInfo.SelectAll(); //构造一个模块信息类 Query_Structure[] structList = new Query_Structure[ds.Tables[0].Rows.Count]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Query_Structure strut = new Query_Structure((uint)ds.Tables[0].Rows[i].ItemArray.Length); strut.AddTagKey(TagName.GameID, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[0])); strut.AddTagKey(TagName.Module_ID, TagFormat.TLV_INTEGER, 4, TLV_Structure.ValueToByteArray(TagFormat.TLV_INTEGER, ds.Tables[0].Rows[i].ItemArray[1])); byte[] bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[2]); strut.AddTagKey(TagName.GameName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[3]); strut.AddTagKey(TagName.ModuleName, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[4]); strut.AddTagKey(TagName.ModuleClass, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); bytes = TLV_Structure.ValueToByteArray(TagFormat.TLV_STRING, ds.Tables[0].Rows[i].ItemArray[5]); strut.AddTagKey(TagName.ModuleContent, TagFormat.TLV_STRING, (uint)bytes.Length, bytes); structList[i] = strut; //打印具体信息 //logAPI.writeData(ds.Tables[0].Rows[i].ItemArray[1].ToString(),ds.Tables[0].Rows[i].ItemArray[2].ToString(),ds.Tables[0].Rows[i].ItemArray[3].ToString(),ds.Tables[0].Rows[i].ItemArray[4].ToString()); } //Console.Write(logAPI.Buffer.ToString()); return(Message.COMMON_MES_RESP(structList, Msg_Category.USER_MODULE_ADMIN, ServiceKey.USER_MODULE_QUERY_RESP, 6)); } catch (System.Exception) { return(Message.COMMON_MES_RESP(LanguageAPI.API_UserModuleAPI_NoRecord, Msg_Category.USER_MODULE_ADMIN, ServiceKey.USER_MODULE_QUERY_RESP, TagName.ERROR_Msg, TagFormat.TLV_STRING)); } }