protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string msg = Request["txtMsg"]; msg = msg.Trim(); string[] words = msg.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); BLL.Articel_WordsBLL articelWordManager = new BLL.Articel_WordsBLL(); foreach (var item in words) { string[] w = item.Split('='); Model.Articel_WordsModel articelWord = new Model.Articel_WordsModel(); articelWord.WordPattern = w[0]; switch (w[1]) { case "{BANNED}": articelWord.IsForbid = true; break; case "{MOD}": articelWord.IsMod = true; break; default: articelWord.ReplaceWord = w[1]; break; } articelWordManager.Add(articelWord); } } }
/// <summary> /// 添加评论 /// </summary> /// <param name="context"></param> private void AddComment(HttpContext context) { BLL.Articel_WordsBLL articelWordManger = new BLL.Articel_WordsBLL(); string msg = context.Request["msg"]; bool isPass = true; //判断是否含有禁用词 if (articelWordManger.CheckForbid(msg)) { context.Response.Write("no:评论中含有禁用词"); } // 判断是否含有敏感词 if (articelWordManger.CheckMod(msg)) { isPass = false; } Model.BookCommentModel bookComment = new Model.BookCommentModel(); bookComment.BookId = Convert.ToInt32(context.Request["bookId"]); bookComment.Msg = articelWordManger.CheckReplace(msg); bookComment.CreateDateTime = System.DateTime.Now; bookComment.IsPass = isPass; if (bookCommentManager.Add(bookComment) > 0) { if (bookComment.IsPass == true) { context.Response.Write("ok:评论成功"); } else { context.Response.Write("unaudit:评论中含有敏感词,审核后方可显示"); } } else { context.Response.Write("no:评论失败"); } }