/// <summary> /// 在线留言 /// </summary> /// <returns></returns> public ActionResult Index(int page = 1) { GuestbookQuery guestBookQuery = new GuestbookQuery(); guestBookQuery.JournalID = JournalID; guestBookQuery.CurrentPage = page; guestBookQuery.PageSize = 15; Pager<GuestbookEntity> pageGuestBook = new Pager<GuestbookEntity>(); try { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); pageGuestBook = service.GetSiteGuestBookPageList(guestBookQuery); if (pageGuestBook != null) { ViewBag.PagerInfo = Utils.GetPageNumbers(page, pageGuestBook.TotalPage, "/Message/", 5); } } catch (Exception ex) { WKT.Log.LogProvider.Instance.Error("获取留言列表出现异常:" + ex.Message); } return View(pageGuestBook); }
/// <summary> /// 将查询实体转换为Where语句 /// <param name="query">查询实体</param> /// <returns>获取Where语句,不包含Where</returns> /// </summary> public string GuestbookQueryToSQLWhere(GuestbookQuery query) { return string.Empty; }
/// <summary> /// 将查询实体转换为Order语句 /// <param name="query">查询实体</param> /// <returns>获取Order语句,不包含Order</returns> /// </summary> public string GuestbookQueryToSQLOrder(GuestbookQuery query) { return " MessageID DESC"; }
public Pager<GuestbookEntity> GetGuestbookPageList(GuestbookQuery query) { int recordCount=0; string whereSQL=GuestbookQueryToSQLWhere(query); string orderBy=GuestbookQueryToSQLOrder(query); DataSet ds=db.GetPagingData("Guestbook","MessageID,JournalID,PMessageID,UserName,Email,Tel,Title,MessageContent,IP,AddDate",orderBy,whereSQL,query.CurrentPage,query.PageSize,out recordCount); Pager<GuestbookEntity> pager=new Pager<GuestbookEntity>(); if(ds!=null && ds.Tables.Count>0) { pager.ItemList= MakeGuestbookList(ds.Tables[0]); } pager.CurrentPage=query.CurrentPage; pager.PageSize=query.PageSize; pager.TotalRecords=recordCount; return pager; }
public List<GuestbookEntity> GetGuestbookList(GuestbookQuery query) { List<GuestbookEntity> list = new List<GuestbookEntity>(); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("SELECT MessageID,JournalID,PMessageID,UserName,Email,Tel,Title,MessageContent,IP,AddDate FROM dbo.Guestbook WITH(NOLOCK)"); string whereSQL = GuestbookQueryToSQLWhere(query); string orderBy=GuestbookQueryToSQLOrder(query); if(!string.IsNullOrEmpty(whereSQL)) sqlCommandText.Append(" WHERE " + whereSQL); if(!string.IsNullOrEmpty(orderBy)) sqlCommandText.Append(" ORDER BY " + orderBy); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); using(IDataReader dr = db.ExecuteReader(cmd)) { list = MakeGuestbookList(dr); } return list; }
/// <summary> /// 分页获取符合查询条件的数据 /// </summary> /// <param name="guestbookQuery">GuestbookQuery查询实体对象</param> /// <returns>Pager<GuestbookEntity></returns> public Pager<GuestbookEntity> GetGuestbookPageList(GuestbookQuery guestbookQuery) { return GuestbookBusProvider.GetGuestbookPageList(guestbookQuery); }
/// <summary> /// 获取所有符合查询条件的数据 /// </summary> /// <param name="guestbookQuery">GuestbookQuery查询实体对象</param> /// <returns>List<GuestbookEntity></returns> public List<GuestbookEntity> GetGuestbookList(GuestbookQuery guestbookQuery) { return GuestbookBusProvider.GetGuestbookList(guestbookQuery); }
/// <summary> /// 获取所有符合查询条件的数据 /// </summary> /// <param name="guestbookQuery">GuestbookQuery查询实体对象</param> /// <returns>List<GuestbookEntity></returns> public List<GuestbookEntity> GetGuestbookList(GuestbookQuery guestbookQuery) { return GuestbookDataAccess.Instance.GetGuestbookList(guestbookQuery); }
/// <summary> /// 将查询实体转换为Where语句 /// <param name="query">查询实体</param> /// <returns>获取Where语句,不包含Where</returns> /// </summary> public string GuestbookQueryToSQLWhere(GuestbookQuery query) { StringBuilder strFilter = new StringBuilder("JournalID=" + query.JournalID); return strFilter.ToString(); }
public Pager<GuestbookEntity> GetGuestBookPageList(GuestbookQuery query) { IGuestbookService service = ServiceContainer.Instance.Container.Resolve<IGuestbookService>(); Pager<GuestbookEntity> pager = service.GetGuestbookPageList(query); return pager; }
/// <summary> /// 获取留言分页数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public Pager<GuestbookEntity> GetSiteGuestBookPageList(GuestbookQuery query) { HttpClientHelper clientHelper = new HttpClientHelper(); Pager<GuestbookEntity> pager = clientHelper.Post<Pager<GuestbookEntity>, GuestbookQuery>(GetAPIUrl(APIConstant.SITE_GUESTBOOKIE_GETPAGELIST), query); return pager; }