public void ProcessRequest(HttpContext context) { string articleId = context.Request["activity_id"]; string content = context.Request["content"]; var replyId = Convert.ToInt32(context.Request["reply_id"]);//评论了文章里的哪个评论 int isHideUserName = Convert.ToInt32(context.Request["is_hide_user_name"]); resp.isSuccess = false; if (string.IsNullOrWhiteSpace(articleId) || string.IsNullOrWhiteSpace(content)) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "activity_id、content 为必填项,请检查"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } if (bllJuActivity.GetCount <JuActivityInfo>(string.Format(" WebsiteOwner='{0}' AND JuActivityID = {1} ", bllJuActivity.WebsiteOwner, articleId)) == 0) { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; resp.errmsg = "不存在活动"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } //敏感词检查 string errmsg = ""; if (!bllFilterWord.CheckFilterWord(content, this.bllJuActivity.WebsiteOwner, out errmsg, "0")) { resp.errmsg = errmsg; resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); return; } //添加评论 int reviewId = 0; JuActivityInfo article = bllJuActivity.GetJuActivity(int.Parse(articleId), true); BLLJIMP.Enums.ReviewTypeKey reviewType = BLLJIMP.Enums.ReviewTypeKey.ArticleComment; if (article.ArticleType == "Question") { reviewType = BLLJIMP.Enums.ReviewTypeKey.Answer; } if (article.ArticleType == "Appointment") { reviewType = BLLJIMP.Enums.ReviewTypeKey.AppointmentComment; } var addResult = bllReview.AddReview(reviewType, articleId, replyId, this.CurrentUserInfo.UserID, "评论", content, this.bllJuActivity.WebsiteOwner, out reviewId, isHideUserName); if (addResult) { if (reviewType == BLLJIMP.Enums.ReviewTypeKey.Answer) { bllUser.AddUserScoreDetail(this.CurrentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.AnswerQuestions), this.bllJuActivity.WebsiteOwner, null, null); } resp.isSuccess = true; resp.returnValue = reviewId.ToString(); if (article.ArticleType == "Question") { bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.QuestionIsAnswered, this.CurrentUserInfo, article, article.UserID, content); List <UserInfo> users = bllUser.GetRelationUserList(BLLJIMP.Enums.CommRelationType.JuActivityFollow, articleId); bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.FollowQuestionIsAnswered, this.CurrentUserInfo, article, users, content); } } else { resp.errcode = (int)BLLJIMP.Enums.APIErrCode.OperateFail; resp.isSuccess = false; } context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
public void ProcessRequest(HttpContext context) { var articleId = context.Request["articleid"]; var content = context.Request["content"]; var replyId = Convert.ToInt32(context.Request["replyid"]);//评论了文章里的哪个评论 int isHideUserName = Convert.ToInt32(context.Request["ishideusername"]); currentUserInfo = bllUser.GetCurrentUserInfo(); if (this.currentUserInfo == null) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.UserIsNotLogin; apiResp.msg = "请先登录"; bllUser.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(articleId) || string.IsNullOrWhiteSpace(content)) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete; bllUser.ContextResponse(context, apiResp); return; } if (bllUser.GetCount <JuActivityInfo>(string.Format(" JuActivityID = {0} ", articleId)) == 0) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.ContentNotFound; bllUser.ContextResponse(context, apiResp); return; } //敏感词检查 BLLFilterWord bllFilterWord = new BLLFilterWord(); string errmsg = ""; if (!bllFilterWord.CheckFilterWord(content, this.bllUser.WebsiteOwner, out errmsg, "0")) { apiResp.msg = errmsg; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } //添加评论 int reviewId = 0; JuActivityInfo article = bll.GetJuActivity(int.Parse(articleId), true); BLLJIMP.Enums.ReviewTypeKey reviewType = BLLJIMP.Enums.ReviewTypeKey.ArticleComment; if (article.ArticleType == "Question") { reviewType = BLLJIMP.Enums.ReviewTypeKey.Answer; } var addResult = bllReview.AddReview(reviewType, articleId, replyId, this.currentUserInfo.UserID, "评论", content, this.bll.WebsiteOwner, out reviewId, isHideUserName); if (addResult) { if (reviewType == BLLJIMP.Enums.ReviewTypeKey.Answer) { bllUser.AddUserScoreDetail(this.currentUserInfo.UserID, EnumStringHelper.ToString(ScoreDefineType.AnswerQuestions), this.bll.WebsiteOwner, null, null); } if (article.ArticleType == "Question") { bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.QuestionIsAnswered, this.currentUserInfo, article, article.UserID, content); List <UserInfo> users = bllUser.GetRelationUserList(BLLJIMP.Enums.CommRelationType.JuActivityFollow, articleId); bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.FollowQuestionIsAnswered, this.currentUserInfo, article, users, content); } apiResp.status = true; apiResp.msg = "评论完成"; apiResp.result = reviewId.ToString(); apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsSuccess; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "评论出错"; } bllReview.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int pageIndex = Convert.ToInt32(context.Request["pageindex"]), pageSize = Convert.ToInt32(context.Request["pagesize"]); var articleId = context.Request["articleid"]; var userAutoId = context.Request["user_autoid"]; var reviewType = context.Request["review_type"]; currentUserInfo = bllUser.GetCurrentUserInfo(); var totalCount = 0; BLLJIMP.Enums.ReviewTypeKey nType = BLLJIMP.Enums.ReviewTypeKey.ArticleComment; if (string.IsNullOrWhiteSpace(reviewType) && !string.IsNullOrWhiteSpace(articleId)) { int artId = Convert.ToInt32(articleId); JuActivityInfo juArtcle = bll.GetJuActivity(artId); if (juArtcle.ArticleType.ToLower() == "question") { nType = BLLJIMP.Enums.ReviewTypeKey.Answer; } } else { Enum.TryParse(reviewType, out nType); } string userId = ""; if (!string.IsNullOrWhiteSpace(userAutoId)) { UserInfo user = bllUser.GetUserInfoByAutoID(int.Parse(userAutoId)); if (user != null) { userId = user.UserID; } else { userId = "-1"; } } //仅显示审核通过的 var sourceData = this.bllReview.GetReviewList(nType, out totalCount, pageIndex, pageSize, articleId, this.bll.WebsiteOwner, this.currentUserInfo == null ? "" : this.currentUserInfo.UserID, "", userId); List <dynamic> returnList = new List <dynamic>(); foreach (var item in sourceData) { int actId = 0; int.TryParse(item.Expand1, out actId); JuActivityInfo actInfo = bll.GetJuActivity(actId); returnList.Add(new { id = item.ReviewMainId, content = item.ReviewContent, createDate = item.InsertDate.ToString(), replyCount = item.ReplyCount, //回复数 praiseCount = item.PraiseCount, //点赞数 pv = item.Pv, //浏览数 currUserIsPraise = item.CurrUserIsPraise, articleId = actInfo != null ? actInfo.JuActivityID : 0, articleName = actInfo != null ? actInfo.ActivityName : "", pubUser = new { id = item.PubUser == null ? 0 : item.PubUser.AutoID, userId = item.PubUser == null ? "" : item.PubUser.UserID, userName = item.PubUser == null ? "" : bllUser.GetUserDispalyName(item.PubUser), avatar = item.PubUser == null ? "" : bllUser.GetUserDispalyAvatar(item.PubUser), isTutor = item.PubUser == null ? false : bllUser.IsTutor(item.PubUser) }, replayToUser = new { id = item.ReplayToUser == null ? 0 : item.ReplayToUser.AutoID, userId = item.ReplayToUser == null ? "" : item.ReplayToUser.UserID, userName = item.ReplayToUser == null ? "" : bllUser.GetUserDispalyName(item.ReplayToUser), avatar = item.ReplayToUser == null ? "" : bllUser.GetUserDispalyAvatar(item.ReplayToUser), isTutor = item.ReplayToUser == null ? false : bllUser.IsTutor(item.ReplayToUser) } }); } dynamic result = new { totalcount = totalCount, list = returnList }; apiResp.status = true; apiResp.msg = "查询完成"; apiResp.result = result; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; int pageSize = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10; var articleId = context.Request["article_id"]; var userAutoId = context.Request["user_autoid"]; var reviewType = context.Request["review_type"]; var totalCount = 0; BLLJIMP.Enums.ReviewTypeKey nType = BLLJIMP.Enums.ReviewTypeKey.ArticleComment; if (string.IsNullOrWhiteSpace(reviewType) && !string.IsNullOrWhiteSpace(articleId)) { int artId = Convert.ToInt32(articleId); JuActivityInfo juArtcle = bllJuActivity.GetJuActivity(artId); if (juArtcle.ArticleType.ToLower() == "question") { nType = BLLJIMP.Enums.ReviewTypeKey.Answer; } if (juArtcle.ArticleType.ToLower() == "appointment") { nType = BLLJIMP.Enums.ReviewTypeKey.AppointmentComment; } } else { Enum.TryParse(reviewType, out nType); } string UserId = ""; if (!string.IsNullOrWhiteSpace(userAutoId)) { UserInfo user = bllUser.GetUserInfoByAutoID(int.Parse(userAutoId)); if (user != null) { UserId = user.UserID; } else { UserId = "-1"; } } var sourceData = this.bllReview.GetReviewList(nType, out totalCount, pageIndex, pageSize, articleId, this.bllJuActivity.WebsiteOwner, this.CurrentUserInfo == null ? "" : this.CurrentUserInfo.UserID, "", UserId); List <dynamic> returnList = new List <dynamic>(); resp.isSuccess = true; foreach (var item in sourceData) { int actId = 0; int.TryParse(item.Expand1, out actId); JuActivityInfo actInfo = bllJuActivity.GetJuActivity(actId); returnList.Add(new { id = item.ReviewMainId, content = item.ReviewContent, create_time = bllUser.GetTimeStamp(item.InsertDate), reply_count = item.ReplyCount, //回复数 praise_count = item.PraiseCount, //点赞数 pv = item.Pv, //浏览数 curruser_ispraise = item.CurrUserIsPraise, article_id = actInfo != null ? actInfo.JuActivityID : 0, article_name = actInfo != null ? actInfo.ActivityName : "", pub_user = new { id = item.PubUser == null ? 0 : item.PubUser.AutoID, user_id = item.PubUser == null ? "" : item.PubUser.UserID, user_name = item.PubUser == null ? "" : bllUser.GetUserDispalyName(item.PubUser), avatar = item.PubUser == null ? "" : bllUser.GetUserDispalyAvatar(item.PubUser), istutor = item.PubUser == null ? false : bllUser.IsTutor(item.PubUser) }, replay_touser = new { id = item.ReplayToUser == null ? 0 : item.ReplayToUser.AutoID, user_id = item.ReplayToUser == null ? "" : item.ReplayToUser.UserID, user_name = item.ReplayToUser == null ? "" : bllUser.GetUserDispalyName(item.ReplayToUser), avatar = item.ReplayToUser == null ? "" : bllUser.GetUserDispalyAvatar(item.ReplayToUser), istutor = item.ReplayToUser == null ? false : bllUser.IsTutor(item.ReplayToUser) } }); } resp.returnObj = new { totalcount = totalCount, list = returnList }; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }