public ActionResult UserMsgPage(string type, int pageSize, int pageNum = 1) { int totalCount = 0; switch (type) { case "Breply": ViewBag.Breplys = BlogCommentReplyDataSvc.GetPagedEntitys(ref pageNum, pageSize, b => (b.OwnerID != CurrentUser.ID && b.ToUserID == CurrentUser.ID) || (b.OwnerID == CurrentUser.ID && b.ToUserID != CurrentUser.ID), b => b.InsertDate, true, out totalCount).ToList(); break; case "Bcomment": ViewBag.Bcomments = BlogCommentDataSvc.GetPagedEntitys(ref pageNum, pageSize, b => b.OwnerID == CurrentUser.ID, b => b.InsertDate, true, out totalCount).ToList(); break; case "Nreply": ViewBag.Nreplys = NewBeeFloorReplyDataSvc.GetPagedEntitys(ref pageNum, pageSize, n => (n.OwnerID != CurrentUser.ID && n.ToUserID == CurrentUser.ID) || (n.OwnerID == CurrentUser.ID && n.ToUserID != CurrentUser.ID), n => n.InsertDate, true, out totalCount).ToList(); break; case "Ncomment": ViewBag.Ncomments = NewBeeFloorDataSvc.GetPagedEntitys(ref pageNum, pageSize, n => n.OwnerID == CurrentUser.ID, n => n.InsertDate, true, out totalCount).ToList(); break; } ViewBag.TotalCount = totalCount; ViewBag.CurrentPage = pageNum; ViewBag.Type = type; ViewBag.CUserID = CurrentUser.ID; return(View()); }
public ActionResult AddNewBeeFloor(Guid NewBeeID, string mdTxt, string mdValue) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(mdTxt) || string.IsNullOrEmpty(mdValue)) { return(Json(new { msg = "参数错误" })); } if (mdTxt.GetByteCount() > 2500 || mdValue.GetByteCount() > 5000) { return(Json(new { msg = "参数太长" })); } NewBee newBee = NewBeeDataSvc.GetByID(NewBeeID); newBee.FloorCount += 1; newBee.LastFloorDate = DateTime.Now; NewBeeFloor floor = new NewBeeFloor(); floor.NewBeeID = NewBeeID; floor.MDText = mdTxt; floor.MDValue = HtmlST.Sanitize(mdValue); floor.OwnerID = CurrentUser.ID; floor.Order = newBee.FloorCount; NewBeeFloorDataSvc.Add(floor); NewBeeDataSvc.Update(newBee); if (newBee.OwnerID != CurrentUser.ID) { string key = MyRedisKeys.Pre_CMsg + newBee.OwnerID; CMsg bcmsg = MyRedisDB.GetSet <CMsg>(key).Where(m => m.ObjID == NewBeeID).FirstOrDefault(); if (bcmsg != null) { MyRedisDB.SetRemove(key, bcmsg); bcmsg.Count += 1; MyRedisDB.SetAdd(key, bcmsg); } else { bcmsg = new CMsg(); bcmsg.ObjType = (int)EnumObjectType.NewBee; bcmsg.ObjID = NewBeeID; bcmsg.Count = 1; bcmsg.Date = DateTime.Now; bcmsg.Order = floor.Order; bcmsg.Title = newBee.Title.MaxByteLength(32); MyRedisDB.SetAdd(key, bcmsg); } } return(Json(new { msg = "done", count = newBee.FloorCount })); }
public ActionResult NewBeeFloorDelete(Guid id) { NewBeeFloor floor = NewBeeFloorDataSvc.GetByID(id); if (floor.OwnerID != CurrentUser.ID) { return(Json(new { msg = "错误" })); } floor.Delete = true; NewBeeFloorDataSvc.Update(floor); return(Json(new { msg = "done" })); }
public ActionResult AddNewBeeFloorReply(Guid floorID, Guid toUserID, string txt) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(txt)) { return(Json(new { msg = "参数错误" })); } if (txt.GetByteCount() > 400) { return(Json(new { msg = "参数太长" })); } NewBeeFloor floor = NewBeeFloorDataSvc.GetByID(floorID); floor.ReplyCount += 1; NewBeeFloorReply reply = new NewBeeFloorReply(); reply.NewBeeFloorID = floorID; reply.Content = HttpUtility.HtmlEncode(txt); reply.ToUserID = toUserID; reply.OwnerID = CurrentUser.ID; reply.Order = floor.ReplyCount; NewBeeFloorReplyDataSvc.Add(reply); NewBeeFloorDataSvc.Update(floor); if (toUserID != CurrentUser.ID) { string key = MyRedisKeys.Pre_RMsg + toUserID; RMsg bcrmsg = new RMsg(); bcrmsg.ObjType = (int)EnumObjectType.NewBee; bcrmsg.ObjID = floor.NewBeeID; bcrmsg.Date = DateTime.Now; bcrmsg.From = CurrentUser.UserName; bcrmsg.COrder = floor.Order; bcrmsg.ROrder = reply.Order; bcrmsg.Title = txt.MaxByteLength(32); MyRedisDB.SetAdd(key, bcrmsg); } return(Json(new { msg = "done" })); }
public ActionResult NewBeePage(int pageSize, int pageNum = 1) { int totalCount = 0; List <NewBee> newBeeList = NewBeeDataSvc.GetPagedEntitys(ref pageNum, pageSize, it => !it.Top, it => it.LastFloorDate, true, out totalCount).ToList(); if (pageNum == 1) { List <NewBee> topNewBee = NewBeeDataSvc.GetByCondition(n => n.Top).ToList(); newBeeList = topNewBee.Concat(newBeeList).OrderByDescending(n => n.Top).ThenByDescending(n => n.LastFloorDate).ToList(); } ViewBag.NewBeeList = newBeeList; ViewBag.TotalCount = totalCount; ViewBag.CurrentPage = pageNum; ViewBag.ShowPager = totalCount > pageSize; IEnumerable <Guid> NewBeeIDs = newBeeList.Select(n => n.ID); ViewBag.FirstFloors = NewBeeFloorDataSvc.GetByCondition(f => NewBeeIDs.Contains(f.NewBeeID) && f.Order == 1).ToList(); return(View()); }
public ActionResult NewBeeFloorPage(Guid nbID, int pageSize, int pageNum = 1) { int totalCount = 0; ViewBag.Login = CurrentUser != null; ViewBag.NewBeeFloorList = NewBeeFloorDataSvc.GetPagedEntitys(ref pageNum, pageSize, it => it.NewBeeID == nbID, it => it.InsertDate, false, out totalCount).ToList(); ViewBag.TotalCount = totalCount; ViewBag.CurrentPage = pageNum; ViewBag.ShowPager = totalCount > pageSize; if (ViewBag.Login) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { ViewBag.DisableMsg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss"); } ViewBag.CUID = CurrentUser.ID; } return(View()); }
public ActionResult NewNewBee(string title, string mdTxt, string mdValue) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(mdTxt) || string.IsNullOrEmpty(mdValue)) { return(Json(new { msg = "参数错误" })); } if (title.GetByteCount() > 100 || mdTxt.GetByteCount() > 2500 || mdValue.GetByteCount() > 5000) { return(Json(new { msg = "参数太长" })); } NewBee nb = new NewBee(); nb.OwnerID = CurrentUser.ID; nb.Title = title; nb.FloorCount = 1; nb.LastFloorDate = DateTime.Now; nb.Top = false; NewBeeDataSvc.Add(nb); NewBeeFloor nbf = new NewBeeFloor(); nbf.MDText = mdTxt; nbf.MDValue = HtmlST.Sanitize(mdValue); nbf.NewBeeID = nb.ID; nbf.Order = 1; nbf.OwnerID = CurrentUser.ID; NewBeeFloorDataSvc.Add(nbf); return(Json(new { msg = "done" })); }