private NewsCateInfo getNewsCateInfo(IDataReader reader) { NewsCateInfo obj = new NewsCateInfo(); obj.cat_id = (int)reader["cat_id"]; obj.cat_uid = reader["cat_uid"].ToString(); obj.cat_path = reader["cat_path"].ToString(); obj.cat_name = reader["cat_name"].ToString(); obj.cat_brief = reader["cat_brief"].ToString(); obj.cat_url = reader["cat_url"].ToString(); obj.cat_manager = reader["cat_manager"].ToString(); obj.cat_status = (int)reader["cat_status"]; obj.cat_totalNews = (int)reader["cat_totalNews"]; obj.cat_inheritAll = (bool)reader["cat_inheritAll"]; obj.cat_createUser = reader["cat_createUser"].ToString(); obj.cat_createTime = (DateTime)reader["cat_createTime"]; obj.cat_tableIndex = (int)reader["cat_tableIndex"]; obj.cat_isLast = (bool)reader["cat_isLast"]; obj.cat_totalUnchecked = (int)reader["cat_totalUnchecked"]; obj.cat_listType = (int)reader["cat_listType"]; obj.cat_ctrl = reader["cat_ctrl"].ToString(); obj.cat_lang = reader["cat_lang"].ToString(); obj.cat_tradeInList = reader["cat_tradeInList"].ToString(); obj.cat_title = reader["cat_title"].ToString(); return(obj); }
/// <summary> /// 根据cat_ctrl,cat_id获得新闻列表 /// </summary> /// <returns></returns> public static List <NewsInfo> News_SelectPaged(string cat_ctrl, string cat_id, string page, string pagesize) { page = (int.Parse(page) < 1) ? "1" : page; pagesize = (int.Parse(pagesize) > 30) ? "30" : pagesize; NewsCateInfo cate = CacheMarker.GetNewsCatesBycat_id(cat_id); NewsSearchInfo search = new NewsSearchInfo(); int rowcount = 0; using (var access = new DataAccess_QzNews(Constants.QZNewSite_News_Db_Key)) { search.n_state = 1; if (cate != null && cate.cat_inheritAll && !cate.cat_isLast) { search.cat_inheritPath = cate.cat_path; } else { search.n_cat_id = cate.cat_id; } string whereString = search.ToWhereString(); // 图集 if ("photo" == cat_ctrl) { whereString += " and n_type='images'"; } return(access.News_SelectPaged(GetNewsTable(cate.cat_tableIndex), "*", whereString, search.DefOrder, int.Parse(page), int.Parse(pagesize), out rowcount)); } }
/// <summary> /// 获得某条新闻的详细内容 /// </summary> /// <param name="rData"></param> /// <returns></returns> public Stream NewsContent_Selectbync_n_gid(NewsContentInfo_RD rData) { WebOperationContext context = WebOperationContext.Current; context.OutgoingResponse.ContentType = "application/json;charset=utf-8"; string json = ""; // 获取某条新闻的详细内容 List <NewsContentInfo> list = DataAccess_News.GetNewsContent(rData.n_gid); if (list.Count == 0) { json = string.Format("{{\"contents\":{0},\"shareUrl\":\"{1}\",\"imgs\":{2}}}", string.Empty, string.Empty, string.Empty); } else { string shareUrl = ""; // 分享文章的地址 NewsCateInfo cateInfo = null; string n_gid = ""; // 获取文章分类的相关字段信息,并拼接得到文章分享地址 if (list != null && list.Count > 0) { // 分类ID string cat_id = rData.vl_cateId.ToSafety(); // 根据分类ID获取分类信息 cateInfo = CacheMarker.GetNewsCatesBycat_id(cat_id); string cat_ctrl = (cateInfo != null) ? cateInfo.cat_ctrl : ""; n_gid = list[0].nc_n_gid; shareUrl = "http://qiye.qianzhan.com/show/detail/" + rData.n_gid + ".html"; //ServiceHandler.GetDetailURL(cat_ctrl, cat_id, n_gid, 1, false); } // 存放图片数据 List <ImgsInfo> imgs = new List <ImgsInfo>(); // 自定义文章内容 list = CustomContent(list, n_gid, "News_" + cateInfo.cat_tableIndex, out imgs, rData.vl_screenSize); // 插入浏览记录 int logIndex = VisitLog_Insert(rData, shareUrl); if (logIndex == -1) { return(null); } var jsonSerialiser = new JavaScriptSerializer(); json = string.Format("{{\"contents\":{0},\"shareUrl\":\"{1}\",\"imgs\":{2}}}", jsonSerialiser.Serialize(list), shareUrl, jsonSerialiser.Serialize(imgs)); } return(new MemoryStream(Encoding.UTF8.GetBytes(json))); }
/// <summary> /// 根据cat_ctrl获得新闻列表 /// 指定某一个新闻分类,然后获取这个分类下的处于正常状态的新闻列表 /// </summary> /// <returns></returns> public static List <NewsInfo> News_SelectPaged(string cat_ctrl, string page, string pagesize) { page = (int.Parse(page) < 1) ? "1" : page; pagesize = (int.Parse(pagesize) > 30) ? "30" : pagesize; // 根据指定的cat_ctrl获取某一新闻分类信息 NewsCateInfo cate = CacheMarker.GetNewsCateByCtrl(cat_ctrl); if (cate == null) { return(new List <NewsInfo>()); } NewsSearchInfo search = new NewsSearchInfo(); int rowcount = 0; using (var access = new DataAccess_QzNews(Constants.QZNewSite_News_Db_Key)) { try { search.n_state = 1; if (cate.cat_inheritAll && !cate.cat_isLast) { search.cat_inheritPath = cate.cat_path; } else { search.n_cat_id = cate.cat_id; } string whereString = search.ToWhereString(); // 图集 if ("photo" == cat_ctrl) { whereString += " and n_type='images'"; } return(access.News_SelectPaged(GetNewsTable(cate.cat_tableIndex), "*", whereString, search.DefOrder, int.Parse(page), int.Parse(pagesize), out rowcount)); } catch (Exception e) { #region debug Util.Log_Info(nameof(News_SelectPaged), Location.Internal, e.Message, "database error"); #endregion return(new List <NewsInfo>()); } } }
public static List <NewsInfo> News_Page_Select(string catId, string page, string pagesize) { page = (int.Parse(page) < 1) ? "1" : page; pagesize = (int.Parse(pagesize) > 30) ? "30" : pagesize; // 根据指定的cat_ctrl获取某一新闻分类信息 NewsCateInfo cate = CacheMarker.NewsCates_FromId_Get(catId); if (cate == null) { return(new List <NewsInfo>()); } NewsSearchInfo search = new NewsSearchInfo(); int rowcount = 0; using (var access = new DataAccess_QzNews(Constants.QZNewSite_News_Db_Key)) { try { search.n_state = 1; if (cate.cat_inheritAll && !cate.cat_isLast) { search.cat_inheritPath = cate.cat_path; } else { search.n_cat_id = cate.cat_id; } string whereString = search.ToWhereString(); //// 图集 //if ("photo" == cat_ctrl) //{ // whereString += " and n_type='images'"; //} var res = access.News_SelectPaged(GetNewsTable(cate.cat_tableIndex), "*", whereString, search.DefOrder, int.Parse(page), int.Parse(pagesize), out rowcount); return(res); } catch (Exception e) { return(new List <NewsInfo>()); } } }
/// <summary> /// 获取某一分类下最新新闻 /// </summary> /// <param name="cat_ctrl"></param> /// <returns></returns> public static NewsInfo LastNews_Select(string cat_ctrl) { // 根据指定的cat_ctrl获取某一新闻分类信息 NewsCateInfo cate = CacheMarker.GetNewsCateByCtrl(cat_ctrl); if (cate == null) { return(null); } NewsSearchInfo search = new NewsSearchInfo(); int rowcount = 0; using (var access = new DataAccess_QzNews(Constants.QZNewSite_News_Db_Key)) { search.n_state = 1; if (cate.cat_inheritAll && !cate.cat_isLast) { search.cat_inheritPath = cate.cat_path; } else { search.n_cat_id = cate.cat_id; } string whereString = search.ToWhereString(); // 图集 if ("photo" == cat_ctrl) { whereString += " and n_type='images'"; } var list = access.News_SelectPaged(GetNewsTable(cate.cat_tableIndex), "*", whereString, search.DefOrder, 1, 1, out rowcount); if (list != null && list.Count > 0) { return(list[0]); } return(null); } }
public static NewsCateInfo NewsCates_FromId_Get(string catId) { string cacheName = "NewsCates_" + catId; object o = CacheHelper.Cache_Get(cacheName); if (o != null) { return((NewsCateInfo)o); } NewsCateInfo cate = DataAccess_News.NewsCates_Selectbycat_id(int.Parse(catId)); if (cate != null) { CacheHelper.Cache_Store(cacheName, cate, TimeSpan.FromMinutes(10)); } return(cate); }
/// <summary> /// 选择信息分类 /// </summary> /// <param name="cat_id">The cat_id.</param> /// <returns></returns> public NewsCateInfo NewsCates_Selectbycat_id(int cat_id) { DbCommand dbCommandWrapper = Db_0.GetStoredProcCommand("Proc_NewsCates_Selectbycat_id"); Db_0.AddInParameter(dbCommandWrapper, "@cat_id", DbType.Int32, cat_id); try { NewsCateInfo obj = null; using (IDataReader reader = Db_0.ExecuteReader(dbCommandWrapper)) { if (reader.Read()) { obj = getNewsCateInfo(reader); } } return(obj); } catch (Exception e) { throw new Exception(e.Message); } }