Esempio n. 1
0
        /// <summary>
        /// 处理举报
        /// </summary>
        /// <param name="reportId"></param>
        /// <returns></returns>
        public ActionResult DealReport(int reportId)
        {
            // 设置为done
            var report = PrivateDb.One((Report r) => r.Id == reportId);
            if (report == null || report.IsDone)
            {
                return null;
            }
            PrivateDb.DoneReport(reportId);
            //发给举报人 说信息已经处理 如果已经处理或者不存在就返回
            var id = CheckValid();
            var msg = new Message
            {
                ActionTime = DateTime.Now,
                Content = string.Format("你在{0}举报{1}的信息,管理员已经处理,谢谢你的监督!", report.ActionTime, report.ReportedUserName),
                FromUserId = id,
                FromUserName = "******",
                IsReaded = false,
                ToUserId = report.UserId,
                MegType = MegType.System,
                StateType = StateType.None,
            };
            PrivateDb.Add(msg);

            //记录管理员 处理的情况
            var log = new ReportLog
            {
                ActionTime = DateTime.Now,
                AdminId = id,
                ReportId = reportId,

            };
            PrivateDb.Add(log);

            return Json("1");
        }
Esempio n. 2
0
        /// <summary>
        /// 解封
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public JsonResult UnForbidUser(int userid)
        {
            if (PrivateDb.One((User e) => e.UserId == userid).Enable == 1)
            {
                return Json(0);//已经被封禁过
            }

            PrivateDb.UnForbidUser(userid);
            //通知此人
            var msg = new Message
            {
                ActionTime = DateTime.Now,
                Content = string.Format("你的账户已经解封,祝你愉快。"),
                FromUserId = CheckValid(),
                FromUserName = "******",
                IsReaded = false,
                ToUserId = userid,
                MegType = MegType.System,
                StateType = StateType.None,
            };
            PrivateDb.Add(msg);

            Logger.Trace(GetUserNameById(userid) + "被管理员:" + GetUserNameById(CheckValid()) + "解封");
            return Json(1);//操作成功
        }
        public ActionResult CreateComment(Comment model)
        {
            try
            {
                //产生评论
                var id = CheckValid();
                var name = GetUserNameById(id);

                var com = new Comment
                {
                    ActionTime = DateTime.Now,
                    Content = model.Content,
                    TopicId = model.TopicId,
                    ReplyId = model.ReplyId,
                    UserId = id,
                    UserName = name
                };
                //修复第一次评论时,ActionName出现null的bug

                //var mm = string.IsNullOrEmpty(LoveDb.LastOne((Comment c) => c.UserId == id).ActionTime);
                var mm = PrivateDb.LastOne((Comment c) => c.Id == id);
                if (string.IsNullOrEmpty(mm.ActionTime.ToString()))
                {

                var min = PrivateDb.DiffMinute(mm.ActionTime, DateTime.Now);
                if (min<=1)
                {
                    return Json(0);
                }
                }
                PrivateDb.Add(com);

                var topic = PrivateDb.One((Topic t) => t.Id == model.TopicId);
                if (topic != null)
                {

                    if (topic.UserId != id)//回复这个话题不是楼主本人就通知楼主。
                    {
                        var msg = new Message
                        {
                            ActionTime = DateTime.Now,
                            Content =
                                string.Format(
                                    "<a href='/User/Index?id={0}'>{1}</a>回复了你的话题:<a href='/Interactive/Detail?topicId={2}'>{3}</a>"
                                    , id, name, topic.Id, topic.Title),
                            FromUserId = 1,
                            FromUserName = "******",
                            IsReaded = false,
                            MegType = MegType.System,
                            StateId = topic.Id,
                            StateType = StateType.Topic,
                            ToUserId = topic.UserId,
                        };
                        PrivateDb.Add(msg);
                    }

                    if (com.ReplyId != 0)
                    {
                        var recom = PrivateDb.One((Comment c) => c.Id == com.ReplyId);
                        if (recom != null)
                        {
                            var msg = new Message
                            {
                                ActionTime = DateTime.Now,
                                Content =
                                    string.Format(
                                        "<a href='/User/Index?id={0}'>{1}</a>回复了你的,话题:<a href='/Interactive/Detail?topicId={2}'>{3}</a>"
                                        , id, name, topic.Id, topic.Title),
                                FromUserId = 1,
                                FromUserName = "******",
                                IsReaded = false,
                                MegType = MegType.System,
                                StateId = recom.Id,
                                StateType = StateType.Comment,
                                ToUserId = recom.UserId,
                            };
                            PrivateDb.Add(msg);
                        }
                    }

                }
                return Json(1);
            }
            catch (Exception)
            {

                return Json(0);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 封号
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public JsonResult ForbidUser(int userid)
        {
            if (PrivateDb.One((User e) => e.UserId == userid).Enable == 0)
            {
                return Json(0);//已经被封禁过
            }

            PrivateDb.ForbidUser(userid);
            //通知此人
            var msg = new Message
            {
                ActionTime = DateTime.Now,
                Content = string.Format("由于你的非法操作和举报信息,你的号已经被系统封禁,该账户功能会被大量削弱!如有问题请联系管理员"),
                FromUserId = CheckValid(),
                FromUserName = "******",
                IsReaded = false,
                ToUserId = userid,
                MegType = MegType.System,
                StateType = StateType.None,
            };
            PrivateDb.Add(msg);

            Logger.Trace(GetUserNameById(userid) + "被管理员:" + GetUserNameById(CheckValid()) + "封号");

            return Json(1);//操作成功
        }
        public JsonResult EnjoyTopic(int topicid)
        {
            var id = CheckValid();
            var name = GetUserNameById(id);
            var topic = PrivateDb.One((Topic t) => t.Id == topicid);
            if (topic != null)
            {
                if (id==topic.UserId)
                {
                    return Json(0);
                }

            var love = PrivateDb.One((EnjoyTopic m) => m.TopicId == topicid && m.UserId == id);

            if (love != null)//存在 就删除
            {
                PrivateDb.Delete<EnjoyTopic>(love.Id);
                var msg1 =
                    PrivateDb.One(
                        (Message m) =>
                            m.StateType == StateType.Topic && m.StateId == topicid && m.Content.Contains(name));
                if (msg1 != null)
                {
                    PrivateDb.Delete<Message>(msg1.Id);
                }

                return Json(0);//已经取消喜欢
            }

            love = new EnjoyTopic
            {
                TopicId = topicid,
                UserId = id,
                ActionTime = DateTime.Now,
                IsRead = false,
            };
            PrivateDb.Add(love);

            //系统消息通知下

                var msg = new Message
                {
                    ActionTime = DateTime.Now,
                    Content =
                        string.Format(
                            "<a href='/User/Index?id={0}'>{1}</a>赞了你的话题:<a href='/Interactive/Detail?topicId={2}'>{3}</a>"
                            , id,name , topicid, topic.Title),
                    FromUserId = 1,
                    FromUserName = "******",
                    IsReaded = false,
                    MegType = MegType.System,
                    StateId = topicid,
                    StateType = StateType.Topic,
                    ToUserId = topic.UserId,
                };
                PrivateDb.Add(msg);
                return Json(1);
            }
            return Json(0);
        }