/// <summary> /// 后台公告分布视图 /// </summary> /// <returns></returns> public ActionResult BackNoticePartial(int?pageindex, int?LookType) { int index = LookType ?? 0; List <NoticeTable> list = new List <NoticeTable>(); if (index == 0) { list = NoticeBll.SelectAllNotice().Where(p => p.UserID == null).ToList(); } else { list = NoticeBll.SelectAllNotice().Where(p => p.UserID != null).ToList(); } if (list != null && list.Count() > 0) { Session["noticecount"] = list.Count(); } else { Session["noticecount"] = 0; } ViewBag.LookType = index; ViewBag.pageindex = pageindex ?? 1; Session["noticepagecount"] = Math.Ceiling(list.Count() / 10.0); Session["allnotice"] = list.Skip(((pageindex ?? 1) - 1) * 10).Take(10).ToList(); return(PartialView("BackNoticePartial")); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { NoticeBll bll = new NoticeBll(); title = Request["navname"]; news = Request["navnews"]; if (title != "" && news != "") { DataTable dt = bll.showNotice(); foreach (DataRow item in dt.Rows) { if (item["title"].ToString() == title) { Response.Write("<script>alert('通知标题不能重复!!!');</script>"); title = ""; return; } } Notice model = new Notice(); model.Title = title; model.News = news; model.Time = Convert.ToString(DateTime.Now); int result = bll.AddNotice(model); if (result > 0) { Response.Write("<script>alert('添加成功!')window.location.href='InformList.aspx'</script>"); } } else { Response.Write("<script>alert('通知标题不能为空!!!');</script>"); } } }
/// <summary> /// 用户删除消息 /// </summary> /// <param name="NoticeID">消息id</param> /// <returns></returns> public JsonResult NoticeDel(string NoticeID) { if (NoticeBll.DeleteNotice(Convert.ToInt32(NoticeID))) { return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 我的消息分布视图 /// </summary> /// <returns></returns> public ActionResult MyNotice() { List <NoticeTable> list = NoticeBll.SelectUserNotice(Convert.ToInt32(Session["userid"])); if (list != null && list.Count() > 0) { list = list.OrderByDescending(p => p.NoticeID).ToList(); } //修改用户未查看的消息为已经查看 NoticeBll.UpdateUserNotice(Convert.ToInt32(Session["userid"])); return(PartialView("MyNotice", list)); }
/// <summary> /// 新增公告/消息 /// </summary> /// <param name="UserID">用户id</param> /// <param name="NoticeTitle">标题</param> /// <param name="NoticeConten">内容</param> /// <returns></returns> public JsonResult NoticeAdd(string UserID, string NoticeTitle, string NoticeConten) { NoticeTable notice = new NoticeTable() { UserID = Convert.ToInt32(UserID), NoticeTitle = NoticeTitle, NoticeContent = NoticeConten }; if (NoticeBll.AddNotice(notice)) { return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }
// GET: User public ActionResult UserIndex() { //查询用户的订单 Session["userorder"] = OrderBll.SelectUserOrder(Convert.ToInt32(Session["userid"])); //获取所有图片 Session["goodphotos"] = GoodsPhotoBll.SelectAllGoodsPhoto(); //获得用户未查看的消息 try { ViewBag.nolook = NoticeBll.SelectUserNotice(Convert.ToInt32(Session["userid"])).Where(p => p.IsLook == 0).ToList(); } catch (Exception) { ViewBag.nolook = null; } return(View(UserInfoBll.SelectUser(Convert.ToInt32(Session["userid"])))); }
/// <summary> /// 后台公告界面 /// </summary> /// <returns></returns> public ActionResult BackNoticeIndex() { Session["li_1"] = 4; Session["li_2"] = 0; //查询所有反馈 List <NoticeTable> list = NoticeBll.SelectAllNotice().Where(p => p.UserID == null).ToList(); if (list != null && list.Count() > 0) { Session["noticecount"] = list.Count(); } else { Session["noticecount"] = 0; } ViewBag.IsDealwith = 2; Session["noticepagecount"] = Math.Ceiling(list.Count() / 10.0); Session["allnotice"] = list.Take(10).ToList(); Session["noticeuserlist"] = UserInfoBll.SelectAllUser(); return(View()); }
public HomeController(NoticeBll noticeBll) { _noticeBll = noticeBll; }
/// <summary> /// 获取页面视图模型 /// </summary> /// <param name="page"></param> /// <param name="size"></param> /// <param name="orderBy"></param> /// <param name="user"></param> /// <returns></returns> private async Task <IndexPageViewModel> GetIndexPageViewModelAsync(int page, int size, OrderBy orderBy, UserInfoOutputDto user) { IQueryable <PostOutputDto> postList = PostBll.LoadEntitiesNoTracking <PostOutputDto>(p => (p.Status == Status.Pended || user.IsAdmin)); //准备文章的查询 var notices = NoticeBll.LoadPageEntitiesFromL2CacheNoTracking <DateTime, NoticeOutputDto>(1, 5, out int _, n => (n.Status == Status.Display || user.IsAdmin), n => n.ModifyDate, false).ToList(); //加载前5条公告 var cats = await CategoryBll.LoadEntitiesFromL2CacheNoTrackingAsync <string, CategoryOutputDto>(c => c.Status == Status.Available, c => c.Name).ConfigureAwait(true); //加载分类目录 var comments = CommentBll.LoadPageEntitiesFromL2CacheNoTracking <DateTime, CommentOutputDto>(1, 10, out int _, c => c.Status == Status.Pended && c.Post.Status == Status.Pended || user.IsAdmin, c => c.CommentDate, false).ToList(); //加在新评论 var start = DateTime.Today.AddDays(-7); var hotSearches = await SearchDetailsBll.LoadEntitiesNoTracking(s => s.SearchTime > start, s => s.SearchTime, false).GroupBy(s => s.KeyWords.ToLower()).OrderByDescending(g => g.Count()).Take(10).Select(g => new KeywordsRankOutputDto() { KeyWords = g.FirstOrDefault().KeyWords, SearchCount = g.Count() }).ToListAsync(); //热词统计 var hot6Post = await(new Random().Next() % 2 == 0 ? postList.OrderByDescending(p => p.ViewCount) : postList.OrderByDescending(p => p.VoteUpCount)).Skip(0).Take(5).Cacheable().ToListAsync(); //热门文章 var topPostWeek = await PostBll.SqlQuery <SimplePostModel>("SELECT [Id],[Title] from Post WHERE Id in (SELECT top 10 PostId FROM [dbo].[PostAccessRecord] where DATEDIFF(week,AccessTime,getdate())<=1 GROUP BY PostId ORDER BY sum(ClickCount) desc)").ToListAsync(); //文章周排行 var topPostMonth = await PostBll.SqlQuery <SimplePostModel>("SELECT [Id],[Title] from Post WHERE Id in (SELECT top 10 PostId FROM [dbo].[PostAccessRecord] where DATEDIFF(month,AccessTime,getdate())<=1 GROUP BY PostId ORDER BY sum(ClickCount) desc)").ToListAsync(); //文章月排行 var topPostYear = await PostBll.SqlQuery <SimplePostModel>("SELECT [Id],[Title] from Post WHERE Id in (SELECT top 10 PostId FROM [dbo].[PostAccessRecord] where DATEDIFF(year,AccessTime,getdate())<=1 GROUP BY PostId ORDER BY sum(ClickCount) desc)").ToListAsync(); //文章年度排行 var tags = new List <string>(); //标签云 var tagdic = new Dictionary <string, int>(); var newdic = new Dictionary <string, int>(); //标签云最终结果 postList.Select(p => p.Label).ToList().ForEach(m => { if (!string.IsNullOrEmpty(m)) { tags.AddRange(m.Split(',', ',')); } });//统计标签 tags.GroupBy(s => s).ForEach(g => { tagdic.Add(g.Key, g.Count()); }); //将标签分组 if (tagdic.Any()) { int min = tagdic.Values.Min(); tagdic.ForEach(kv => { var fontsize = (int)Math.Floor(kv.Value * 1.0 / (min * 1.0) + 12.0); newdic.Add(kv.Key, fontsize >= 36 ? 36 : fontsize); }); } IList <PostOutputDto> posts; switch (orderBy)//文章排序 { case OrderBy.CommentCount: posts = postList.OrderByDescending(p => p.IsFixedTop).ThenByDescending(p => p.Comment.Count).Skip(size * (page - 1)).Take(size).ToList(); break; case OrderBy.PostDate: posts = postList.OrderByDescending(p => p.IsFixedTop).ThenByDescending(p => p.PostDate).Skip(size * (page - 1)).Take(size).ToList(); break; case OrderBy.ViewCount: posts = postList.OrderByDescending(p => p.IsFixedTop).ThenByDescending(p => p.ViewCount).Skip(size * (page - 1)).Take(size).ToList(); break; case OrderBy.VoteCount: posts = postList.OrderByDescending(p => p.IsFixedTop).ThenByDescending(p => p.VoteUpCount).Skip(size * (page - 1)).Take(size).ToList(); break; default: posts = postList.OrderByDescending(p => p.IsFixedTop).ThenByDescending(p => p.ModifyDate).Skip(size * (page - 1)).Take(size).ToList(); break; } return(new IndexPageViewModel() { Categories = cats.ToList(), Comments = comments, HotSearch = hotSearches, Notices = notices, Posts = posts, Tags = newdic, Top6Post = hot6Post, TopPostByMonth = topPostMonth, TopPostByWeek = topPostWeek, TopPostByYear = topPostYear, PostsQueryable = postList }); }
protected void Page_Load(object sender, EventArgs e) { EntranceBll bll1 = new EntranceBll(); NavBLL bll2 = new NavBLL(); NoticeBll bll3 = new NoticeBll(); if (!IsPostBack) { //加载导航信息 DataTable dt2 = bll2.NavQuery(); StringBuilder str3 = new StringBuilder(); StringBuilder str4 = new StringBuilder(); if (dt2.Rows.Count > 0) { str3.Append("<li class='active'><a href='" + dt2.Rows[0]["url"].ToString() + "'>" + dt2.Rows[0]["name"] + "</a></li>"); str4.Append("<li><a href='" + dt2.Rows[0]["url"].ToString() + "'>" + dt2.Rows[0]["name"] + "</a>|</li>"); for (int i = 1; i < dt2.Rows.Count; i++) { str3.Append("<li><a href='" + dt2.Rows[i]["url"].ToString() + "'>" + dt2.Rows[i]["name"] + "</a></li>"); str4.Append("<li><a href='" + dt2.Rows[i]["url"].ToString() + "'>" + dt2.Rows[i]["name"] + "</a>|</li>"); } nav1.InnerHtml = str3.ToString(); nav2.InnerHtml = str4.ToString(); } //加载图标信息 DataTable dt1 = bll1.ShowEnter(); StringBuilder str1 = new StringBuilder(); StringBuilder str2 = new StringBuilder(); for (var i = 0; i < dt1.Rows.Count; i++) { string type = dt1.Rows[i]["Type"].ToString(); if (type == "1") { str1.Append("<div class='col-md-4'><div class='modal-content clearfix'><a href='Labrary_introduce.aspx?Id=" + dt1.Rows[i]["Id"] + "'><span class='icon icon0" + (i + 1) + "'></span><h3>" + dt1.Rows[i]["Cname"].ToString() + "<small>" + dt1.Rows[i]["Ename"].ToString() + "</small></h3><p> " + dt1.Rows[i]["News"].ToString() + "</p></a></div></div>"); enter1.InnerHtml = str1.ToString(); } else if (type == "2") { str2.Append("<div class='col-xs-12 col-md-4 clearfix'><a href='Labrary_introduce.aspx?Id=" + dt1.Rows[i]["Id"] + "' class='img-circle text-center'><img src='img/icon08.png' width='37' height='62'></a><h3><a href='Labrary_introduce.aspx?Id=" + dt1.Rows[i]["Id"] + "'>" + dt1.Rows[i]["Cname"] + "<small>" + dt1.Rows[i]["Ename"] + "</small></a></h3><p>" + dt1.Rows[i]["News"] + "</p><a href='Labrary_introduce.aspx?Id=" + dt1.Rows[i]["Id"] + "' class='btn btn-more'>MORE</a></div>"); enter2.InnerHtml = str2.ToString(); } } //加载通知信息 DataTable dt3 = bll3.showNotice(); StringBuilder str5 = new StringBuilder(); if (dt3.Rows.Count > 0) { for (int i = dt3.Rows.Count - 1; i > dt3.Rows.Count - 11; i--) { str5.Append("<li><a href='#'>" + dt3.Rows[i]["Title"].ToString() + "</a></li>"); inform.InnerHtml = str5.ToString(); } } else { inform.InnerHtml = "暂无通知数据!"; } } }
// GET: Notice public ActionResult NoticeIndex() { return(View(NoticeBll.SelectAllNotice().Where(p => p.UserID == null).ToList())); }
public HomeController(NoticeBll noticeBll, BoardBll boardBll) { _noticeBll = noticeBll; _boardBll = boardBll; }
public HomeController(ILogger <HomeController> logger, NoticeBll noticeBll) { _logger = logger; _noticeBll = noticeBll; }