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 AddBlogComment(Guid blogID, string mdTxt, string mdValue)
        {
            DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && 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() > 5000 || mdValue.GetByteCount() > 10000)
            {
                return(Json(new { msg = "参数太长" }));
            }

            Blog blog = BlogDataSvc.GetByID(blogID);

            blog.CommentCount += 1;

            BlogComment comment = new BlogComment();

            comment.BlogID  = blogID;
            comment.MDText  = mdTxt;
            comment.MDValue = HtmlST.Sanitize(mdValue);
            comment.OwnerID = CurrentUser.ID;
            comment.Order   = blog.CommentCount;
            BlogCommentDataSvc.Add(comment);

            BlogDataSvc.Update(blog);

            if (blog.OwnerID != CurrentUser.ID)
            {
                string key   = MyRedisKeys.Pre_CMsg + blog.OwnerID;
                CMsg   bcmsg = MyRedisDB.GetSet <CMsg>(key).Where(m => m.ObjID == blogID).FirstOrDefault();
                if (bcmsg != null)
                {
                    MyRedisDB.SetRemove(key, bcmsg);
                    bcmsg.Count += 1;
                    MyRedisDB.SetAdd(key, bcmsg);
                }
                else
                {
                    bcmsg         = new CMsg();
                    bcmsg.ObjType = (int)EnumObjectType.姿势;
                    bcmsg.ObjID   = blogID;
                    bcmsg.Count   = 1;
                    bcmsg.Date    = DateTime.Now;
                    bcmsg.Order   = comment.Order;
                    bcmsg.Title   = blog.Title.MaxByteLength(32);
                    MyRedisDB.SetAdd(key, bcmsg);
                }
            }

            return(Json(new { msg = "done", count = blog.CommentCount }));
        }
        public ActionResult BlogCommentDelete(Guid id)
        {
            BlogComment comment = BlogCommentDataSvc.GetByID(id);

            if (comment.OwnerID != CurrentUser.ID)
            {
                return(Json(new { msg = "错误" }));
            }
            comment.Delete = true;
            BlogCommentDataSvc.Update(comment);
            return(Json(new { msg = "done" }));
        }
        public ActionResult AddBlogCommentReply(Guid commentID, Guid toUserID, string txt)
        {
            DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && 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 = "参数太长" }));
            }

            BlogComment comment = BlogCommentDataSvc.GetByID(commentID);

            comment.ReplyCount += 1;

            BlogCommentReply reply = new BlogCommentReply();

            reply.BlogCommentID = commentID;
            reply.Content       = HttpUtility.HtmlEncode(txt);
            reply.ToUserID      = toUserID;
            reply.OwnerID       = CurrentUser.ID;
            reply.Order         = comment.ReplyCount;
            BlogCommentReplyDataSvc.Add(reply);

            BlogCommentDataSvc.Update(comment);

            if (toUserID != CurrentUser.ID)
            {
                string key    = MyRedisKeys.Pre_RMsg + toUserID;
                RMsg   bcrmsg = new RMsg();
                bcrmsg.ObjType = (int)EnumObjectType.姿势;
                bcrmsg.ObjID   = comment.BlogID;
                bcrmsg.Date    = DateTime.Now;
                bcrmsg.From    = CurrentUser.UserName;
                bcrmsg.COrder  = comment.Order;
                bcrmsg.ROrder  = reply.Order;
                bcrmsg.Title   = txt.MaxByteLength(32);
                MyRedisDB.SetAdd(key, bcrmsg);
            }

            return(Json(new { msg = "done" }));
        }
        public ActionResult BlogCommentPage(Guid blogID, int pageSize, int pageNum = 1)
        {
            int totalCount;

            ViewBag.Login           = CurrentUser != null;
            ViewBag.BlogCommentList = BlogCommentDataSvc.GetPagedEntitys(ref pageNum, pageSize, it => it.BlogID == blogID, it => it.InsertDate, false, out totalCount).ToList();
            ViewBag.TotalCount      = totalCount;
            ViewBag.CurrentPage     = pageNum;

            if (ViewBag.Login)
            {
                DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && d.AbleDate > DateTime.Now).FirstOrDefault();
                if (user != null)
                {
                    ViewBag.DisableMsg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss");
                }
                ViewBag.CUID = CurrentUser.ID;
            }

            return(View());
        }