Exemple #1
0
        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)
        {
            int    pageIndex  = int.Parse(context.Request["pageIndex"]);
            int    pageSize   = int.Parse(context.Request["pageSize"]);
            string userAutoId = context.Request["userAutoId"];
            string keyword    = context.Request["keyword"];  //昵称搜索
            string type       = context.Request["type"];     //昵称搜索
            string exchange   = context.Request["exchange"]; //1时mainId,relationId互换
            string isid       = context.Request["isid"];     //AutoID建立的关系

            BLLJIMP.Enums.CommRelationType nType = BLLJIMP.Enums.CommRelationType.FollowUser;
            if (!string.IsNullOrWhiteSpace(type))
            {
                if (!Enum.TryParse(type, out nType))
                {
                    apiResp.code = 1;
                    apiResp.msg  = "类型格式不能识别";
                    bLLCommRelation.ContextResponse(context, apiResp);
                    return;
                }
            }
            currentUserInfo = bLLCommRelation.GetCurrentUserInfo();

            string mainId     = "";
            string relationId = "";

            if (isid == "1")
            {
                relationId = userAutoId;
            }
            else
            {
                UserInfo user = bllUser.GetUserInfoByAutoID(int.Parse(userAutoId));
                relationId = user.UserID;
            }
            if (exchange == "1")
            {
                mainId     = relationId;
                relationId = "";
            }

            int             TCount = 0;
            List <UserInfo> users  = bllUser.GetRelationUserList(pageSize, pageIndex, nType, mainId, relationId, keyword, out TCount, isid == "1");

            var list = from p in users
                       select new
            {
                id              = p.AutoID,
                avatar          = bllUser.GetUserDispalyAvatar(p),
                userName        = bllUser.GetUserDispalyName(p),
                describe        = p.Description,
                phone           = p.ViewType == 1?"": p.Phone,
                score           = p.TotalScore,
                times           = p.OnlineTimes,
                userHasRelation = this.currentUserInfo == null ? false : (isid == "1" ? bLLCommRelation.ExistRelation(nType, p.AutoID.ToString(), this.currentUserInfo.AutoID.ToString()) : bLLCommRelation.ExistRelation(nType, p.UserID, this.currentUserInfo.UserID)),
                relationTime    = p.LastLoginDate.ToString("yyyy/MM/dd hh:mm:ss")
            };

            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            apiResp.msg    = "查询完成";
            apiResp.status = true;
            apiResp.result = new
            {
                totalcount = TCount,
                list       = list
            };
            bLLCommRelation.ContextResponse(context, apiResp);
        }
Exemple #3
0
        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);
        }