//获取所有的petlist public List<CVKnowledgePet> GetAllKnowledgePetPageList(int pageNumber, int NumberPerPage, out int howmanyPages) { SqlParameter[] adoptPetParams = null; adoptPetParams = new SqlParameter[] { new SqlParameter("@DescriptionLength",SqlDbType.Int), new SqlParameter("@PageNumber",SqlDbType.Int), new SqlParameter("@InfoPerPage",SqlDbType.Int), new SqlParameter("@HowManyInfo",SqlDbType.Int,65535,ParameterDirection.Output,true,0,0,"",DataRowVersion.Default,0), }; adoptPetParams[0].Value = CPetCareConfiguration.ArticleBreviaryNum; adoptPetParams[1].Value = pageNumber; adoptPetParams[2].Value = NumberPerPage; List<CVKnowledgePet> AdoptPetList = new List<CVKnowledgePet>(); try { using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "proGetKnowledgeInfo", adoptPetParams)) { while (reader.Read()) { CVKnowledgePet knowledgePet = new CVKnowledgePet(); knowledgePet.KnowledgeID = reader["KnowledgeID"].ToString(); knowledgePet.City = reader["City"].ToString(); knowledgePet.Province = reader["Province"].ToString(); knowledgePet.KnowledgeInfo = reader["KnowledgeInfo"].ToString(); knowledgePet.KnowledgeTitle = reader["KnowledgeTitle"].ToString(); knowledgePet.PetCategoryName = reader["PetCategoryName"].ToString(); knowledgePet.PriorityScore = int.Parse(reader["PriorityScore"].ToString()); knowledgePet.UserName = reader["UserName"].ToString(); knowledgePet.PicLocation = reader["PicLocation"].ToString(); knowledgePet.Portrait = reader["Portrait"].ToString(); knowledgePet.LinkUrl = reader["LinkUrl"].ToString(); knowledgePet.UserWeiBo = reader["UserWeiBo"].ToString(); knowledgePet.Status = reader["Status"].ToString(); bool tempIsRecommand = true; knowledgePet.IsRecommand = bool.TryParse(reader["IsRecommand"].ToString(), out tempIsRecommand) ? tempIsRecommand : true; bool tempIsEssence = true; knowledgePet.IsEssence = bool.TryParse(reader["IsEssence"].ToString(), out tempIsEssence) ? tempIsEssence : true; DateTime tempLastEditTime = DateTime.Now; tempLastEditTime = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now; knowledgePet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss"); DateTime tempKnowledgeTime = DateTime.Now; tempKnowledgeTime = DateTime.TryParse(reader["KnowledgeTime"].ToString(), out tempKnowledgeTime) ? tempKnowledgeTime : DateTime.Now; knowledgePet.KnowledgeTime = tempKnowledgeTime.ToString("yyyy/MM/dd hh:mm:ss"); knowledgePet.IP = reader["IP"].ToString(); int tempFocusNum = 0; knowledgePet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0; int tempCommentCount = 0; knowledgePet.CommentCount = int.TryParse(reader["CommentCount"].ToString(), out tempCommentCount) ? tempCommentCount : 0; AdoptPetList.Add(knowledgePet); } reader.Close(); reader.Dispose(); int tempHowmanyPages=0; howmanyPages = int.TryParse(adoptPetParams[3].Value.ToString(), out tempHowmanyPages) ? tempHowmanyPages : 0; } } catch (Exception ex) { throw; } return AdoptPetList; }
//获取所有的petlist public List <CVKnowledgePet> GetAllKnowledgePetPageList(int pageNumber, int NumberPerPage, out int howmanyPages) { SqlParameter[] adoptPetParams = null; adoptPetParams = new SqlParameter[] { new SqlParameter("@DescriptionLength", SqlDbType.Int), new SqlParameter("@PageNumber", SqlDbType.Int), new SqlParameter("@InfoPerPage", SqlDbType.Int), new SqlParameter("@HowManyInfo", SqlDbType.Int, 65535, ParameterDirection.Output, true, 0, 0, "", DataRowVersion.Default, 0), }; adoptPetParams[0].Value = CPetCareConfiguration.ArticleBreviaryNum; adoptPetParams[1].Value = pageNumber; adoptPetParams[2].Value = NumberPerPage; List <CVKnowledgePet> AdoptPetList = new List <CVKnowledgePet>(); try { using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "proGetKnowledgeInfo", adoptPetParams)) { while (reader.Read()) { CVKnowledgePet knowledgePet = new CVKnowledgePet(); knowledgePet.KnowledgeID = reader["KnowledgeID"].ToString(); knowledgePet.City = reader["City"].ToString(); knowledgePet.Province = reader["Province"].ToString(); knowledgePet.KnowledgeInfo = reader["KnowledgeInfo"].ToString(); knowledgePet.KnowledgeTitle = reader["KnowledgeTitle"].ToString(); knowledgePet.PetCategoryName = reader["PetCategoryName"].ToString(); knowledgePet.PriorityScore = int.Parse(reader["PriorityScore"].ToString()); knowledgePet.UserName = reader["UserName"].ToString(); knowledgePet.PicLocation = reader["PicLocation"].ToString(); knowledgePet.Portrait = reader["Portrait"].ToString(); knowledgePet.LinkUrl = reader["LinkUrl"].ToString(); knowledgePet.UserWeiBo = reader["UserWeiBo"].ToString(); knowledgePet.Status = reader["Status"].ToString(); bool tempIsRecommand = true; knowledgePet.IsRecommand = bool.TryParse(reader["IsRecommand"].ToString(), out tempIsRecommand) ? tempIsRecommand : true; bool tempIsEssence = true; knowledgePet.IsEssence = bool.TryParse(reader["IsEssence"].ToString(), out tempIsEssence) ? tempIsEssence : true; DateTime tempLastEditTime = DateTime.Now; tempLastEditTime = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now; knowledgePet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss"); DateTime tempKnowledgeTime = DateTime.Now; tempKnowledgeTime = DateTime.TryParse(reader["KnowledgeTime"].ToString(), out tempKnowledgeTime) ? tempKnowledgeTime : DateTime.Now; knowledgePet.KnowledgeTime = tempKnowledgeTime.ToString("yyyy/MM/dd hh:mm:ss"); knowledgePet.IP = reader["IP"].ToString(); int tempFocusNum = 0; knowledgePet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0; int tempCommentCount = 0; knowledgePet.CommentCount = int.TryParse(reader["CommentCount"].ToString(), out tempCommentCount) ? tempCommentCount : 0; AdoptPetList.Add(knowledgePet); } reader.Close(); reader.Dispose(); int tempHowmanyPages = 0; howmanyPages = int.TryParse(adoptPetParams[3].Value.ToString(), out tempHowmanyPages) ? tempHowmanyPages : 0; } } catch (Exception ex) { throw; } return(AdoptPetList); }