public JsonResult Reply(int topicId, string reply) { if (B_StaticObject.swh.HasBadWord(string.Concat(reply))) { return(Json(new { status = "1", message = "标题或者内容中含有敏感词汇,不能提交!", value = 0 })); } T_Reply m = new T_Reply(); m.UserId = this.UserInfo.Id; m.TopicId = topicId; m.ReplyContent = processQuote(ProcessBigPic(reply, 900)); m.CreateDate = DateTime.Now; m.Deleted = false; m.Blocked = false; m.Ip = ClientUtil.Ip; m.Good = 0; int i = B_Topic.AddReply(m); if (i > 0) { B_Topic.AddTopicReplyCount(topicId); return(Json(new { status = "0", message = "", value = i })); } else { return(Json(new { status = "1", message = "发表回复失败!", value = 0 })); } }
public JsonResult AddTopic(string invites, string title, string topic, string topicText, int gradeId, int subjectId) { topic = HttpUtility.UrlDecode(topic); if (B_StaticObject.swh.HasBadWord(string.Concat(title, topic))) { return(Json(new { status = "1", message = "标题或者内容中含有敏感词汇,不能提交!", value = 0 })); } topicText = HttpUtility.HtmlDecode(HttpUtility.UrlDecode(topicText).Replace("\n", "").Replace("\t", "")).Trim(); T_Topic t = new T_Topic() { UserId = UserInfo.Id, Invites = invites, Title = title, TopicContent = ProcessBigPic(topic, 760), TopicText = topicText, Hit = 0, Good = 0, ReplyCount = 0, GradeId = gradeId, SubjectId = subjectId, Deleted = false, Blocked = false, CreateDate = DateTime.Now, Ip = ClientUtil.Ip }; int i = B_Topic.AddTopic(t); if (i > 0 && !string.IsNullOrEmpty(invites)) { B_Topic.AddTopicInvites(i, invites.Split(' ')); } return(Json(new { status = "0", message = "", value = i })); }
public JsonResult GetReplyById(int id) { dto_Reply r = B_Topic.GetReplyById(id); if (r != null) { T_User u = B_UserRedis.GetUser(r.UserId); r.UserName = u == null ? "" : u.UserName; } return(Json(r)); }
public ActionResult GetInvites() { List <int> invites = B_Topic.GetInvites(this.UserInfo.UserName); List <dto_Topic> tl = null; if (invites != null) { tl = B_Topic.GetTopics(invites.ToArray()); } B_Topic.ClearInvites(this.UserInfo.UserName); ViewBag.List = tl; return(PartialView()); }
public JsonResult GetTop5Topics() { DateTime FirstCycleDay = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).Date; List <dto_Topic> tl = B_Topic.GetTop5Topics(FirstCycleDay); if (tl != null) { foreach (var t in tl) { t.CreateDateString = t.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"); T_User u = B_UserRedis.GetUser(t.UserId); t.UserName = u == null ? "" : u.UserName; t.TrueName = u == null ? "" : u.TrueName; } } return(Json(tl)); }
public JsonResult AddReplyGoodCount(int replyId) { if (B_Topic.HasReplySetGood(replyId, this.UserInfo.Id)) { return(Json(new { status = "1", message = "已经点赞过!", value = 0 })); } bool isOK = B_Topic.AddReplyGoodCount(replyId, this.UserInfo.Id); if (isOK) { return(Json(new { status = "0", message = "", value = 0 })); } else { return(Json(new { status = "1", message = "点赞失败!", value = 0 })); } }
/// <summary> /// 查看详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult detail(int id) { dto_Topic t = B_Topic.GetTopic(id); if (t != null) { T_User u = B_UserRedis.GetUser(t.UserId); t.UserName = u == null ? "" : u.UserName; t.TrueName = u == null ? "" : u.TrueName; string GradeName = "", SubjectName = ""; Const.Grades.TryGetValue(t.GradeId, out GradeName); Const.Subjects.TryGetValue(t.SubjectId, out SubjectName); t.GradeName = GradeName; t.SubjectName = SubjectName; } ViewBag.TopicInfo = t; return(View()); }
public BaseController() { string DesUserModel = Util.GetCookie("easyzy.user", "useridentity"); string DesKey = Util.GetAppSetting("DesKey"); UserCookieHelper.UserCookieModel u = UserCookieHelper.DescryptUserCookie(DesUserModel, DesKey); UserId = u._id; int invites = 0; if (UserId != 0) { UserInfo = B_UserRedis.GetUser(UserId); invites = B_Topic.GetInviteCount(UserInfo.UserName); } ViewBag.UserInfo = UserInfo; ViewBag.Invites = invites; }
public JsonResult GetTop5Activities() { DateTime FirstCycleDay = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).Date; Dictionary <int, int> d = B_Topic.GetTop5Activities(FirstCycleDay); List <dto_KeyValue> d2 = new List <dto_KeyValue>(); if (d != null) { foreach (var s in d) { T_User t = B_UserRedis.GetUser(s.Key); d2.Add(new dto_KeyValue() { key = string.Concat(t == null ? "" : string.Concat(t.UserName, "【", t.TrueName, "】")), value = s.Value.ToString() }); } } return(Json(d2)); }
public ActionResult GetReplyList(int id, int pageIndex, int pageSize) { int totalCount = 0; var ReplyList = B_Topic.GetReplyList(id, pageSize, pageIndex, out totalCount); if (ReplyList != null) { foreach (var r in ReplyList) { T_User u = B_UserRedis.GetUser(r.UserId); r.UserName = u == null ? "" : u.UserName; r.TrueName = u == null ? "" : u.TrueName; } } ViewBag.pageIndex = pageIndex; ViewBag.PageCount = Util.GetTotalPageCount(totalCount, pageSize); ViewBag.ReplyList = ReplyList; return(PartialView()); }
public ActionResult gettopics(int gradeId, int subjectId, int pageIndex, int pageSize) { int totalCount = 0; List <dto_Topic> tl = B_Topic.GetTopics(gradeId, subjectId, pageIndex, pageSize, out totalCount); if (tl != null) { foreach (var t in tl) { T_User u = B_UserRedis.GetUser(t.UserId); t.UserName = u == null ? "" : u.UserName; t.TrueName = u == null ? "" : u.TrueName; string GradeName = "", SubjectName = ""; Const.Grades.TryGetValue(t.GradeId, out GradeName); Const.Subjects.TryGetValue(t.SubjectId, out SubjectName); t.GradeName = GradeName; t.SubjectName = SubjectName; } } ViewBag.List = tl; ViewBag.PageCount = Util.GetTotalPageCount(totalCount, pageSize); return(PartialView()); }
/// <summary> /// 如果登录,且control和action在计算activity的集合内,则添加活跃度 /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { string DesUserModel = Util.GetCookie("easyzy.user", "useridentity"); if (!string.IsNullOrEmpty(DesUserModel)) { string DesKey = Util.GetAppSetting("DesKey"); UserCookieHelper.UserCookieModel u = UserCookieHelper.DescryptUserCookie(DesUserModel, DesKey); int uId = u._id; var controllerName = (filterContext.RouteData.Values["controller"]).ToString().ToLower(); var actionName = (filterContext.RouteData.Values["action"]).ToString().ToLower(); string key = string.Concat(controllerName, "_", actionName); int value = 0; var aw = ActivityWeightConst.ActivityWeights.TryGetValue(key, out value); if (aw) { DateTime FirstCycleDay = DateTime.Now.AddDays(1 - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).Date; B_Topic.AddActivity(uId, key, value, FirstCycleDay); } } base.OnActionExecuting(filterContext); }