示例#1
0
        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 }));
        }
示例#2
0
        public ActionResult StarNewBee(Guid id)
        {
            NewBee newBee  = NewBeeDataSvc.GetByID(id);
            string starKey = MyRedisKeys.Pre_UserStarCache + CurrentUser.ID;
            IEnumerable <UserStarCache> userStarCaches = MyRedisDB.GetSet <UserStarCache>(starKey);

            bool add = false;

            if (userStarCaches.Count() == 0)
            {
                IEnumerable <UserStar> userStars = UserStarDataSvc.GetByCondition(s => s.OwnerID == CurrentUser.ID);
                if (userStars.Count() > 0)
                {
                    //添加收藏缓存
                    foreach (UserStar star in userStars)
                    {
                        MyRedisDB.SetAdd(starKey, new UserStarCache()
                        {
                            ObjID = newBee.ID, ObjType = star.ObjType
                        });
                    }
                    MyRedisDB.RedisDB.KeyExpire(starKey, DateTime.Now.AddHours(3));
                    //添加收藏
                    if (userStars.Where(s => s.ObjID == newBee.ID).Count() == 0)
                    {
                        add = true;
                    }
                }
                else
                {
                    add = true;
                }
            }
            else if (userStarCaches.Where(s => s.ObjID == newBee.ID).Count() == 0)
            {
                add = true;
            }

            if (add)
            {
                //添加收藏
                UserStar star = new UserStar();
                star.OwnerID = CurrentUser.ID;
                star.ObjID   = newBee.ID;
                star.Title   = newBee.Title;
                star.ObjType = (int)EnumObjectType.NewBee;
                UserStarDataSvc.Add(star);
                MyRedisDB.SetAdd(starKey, new UserStarCache()
                {
                    ObjID = newBee.ID, ObjType = star.ObjType
                });
                MyRedisDB.RedisDB.KeyExpire(starKey, DateTime.Now.AddHours(3));
            }
            return(Json(new { msg = "done" }));
        }
示例#3
0
        public ActionResult NewBeeDelete(Guid id)
        {
            NewBee newBee = NewBeeDataSvc.GetByID(id);

            if (newBee.OwnerID != CurrentUser.ID)
            {
                return(Json(new { msg = "小伙子你想干嘛" }));
            }
            NewBeeDataSvc.DeleteByID(id);
            return(Json(new { msg = "done" }));
        }
示例#4
0
        //NewBee详情
        public ActionResult NewBeeView(Guid id, int co = 0, int ro = 0)
        {
            NewBee newBee = NewBeeDataSvc.GetByID(id);

            ViewBag.NewBee = newBee;
            ViewBag.Login  = CurrentUser != null;
            ViewBag.Owner  = CurrentUser != null ? CurrentUser.ID == newBee.OwnerID : false;
            ViewBag.COrder = co;
            ViewBag.ROrder = ro;

            newBee.ViewCount += 1;
            NewBeeDataSvc.Update(newBee);
            if (CurrentUser != null)
            {
                //查看次数 暂时不用户统计
                //string key = MyRedisKeys.Pre_UserRecord + CurrentUser.ID;
                //IEnumerable<UserRecord> userRecords = MyRedisDB.GetSet<UserRecord>(key);
                //if (userRecords.Count() == 0)
                //{
                //    MyRedisDB.SetAdd(key, new UserRecord() { ObjID = newBee.ID, type = (int)EnumRecordType.查看 });
                //    MyRedisDB.RedisDB.KeyExpire(key, DateTime.Now.AddDays(1));
                //    newBee.ViewCount += 1;
                //    NewBeeDataSvc.Update(newBee);
                //}
                //else if (userRecords.Where(r => r.ObjID == newBee.ID && r.type == (int)EnumRecordType.查看).Count() == 0)
                //{
                //    MyRedisDB.SetAdd(key, new UserRecord() { ObjID = newBee.ID, type = (int)EnumRecordType.查看 });
                //    newBee.ViewCount += 1;
                //    NewBeeDataSvc.Update(newBee);
                //}

                //收藏
                ViewBag.ShowStar = true;
                string starKey = MyRedisKeys.Pre_UserStarCache + CurrentUser.ID;
                IEnumerable <UserStarCache> userStarCaches = MyRedisDB.GetSet <UserStarCache>(starKey);
                if (userStarCaches.Count() == 0)
                {
                    IEnumerable <UserStar> userStars = UserStarDataSvc.GetByCondition(s => s.OwnerID == CurrentUser.ID);
                    if (userStars.Count() > 0)
                    {
                        if (userStars.Where(s => s.ObjID == newBee.ID).Count() > 0)
                        {
                            ViewBag.ShowStar = false;
                        }
                        //添加收藏缓存
                        foreach (UserStar star in userStars)
                        {
                            MyRedisDB.SetAdd(starKey, new UserStarCache()
                            {
                                ObjID = newBee.ID, ObjType = star.ObjType
                            });
                        }
                        MyRedisDB.RedisDB.KeyExpire(starKey, DateTime.Now.AddHours(3));
                    }
                }
                else if (userStarCaches.Where(s => s.ObjID == newBee.ID).Count() > 0)
                {
                    ViewBag.ShowStar = false;
                }

                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");
                }
            }

            return(View());
        }