public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BulletinBll bll = new BulletinBll(); if (context.Request.RequestType.ToUpper() == "GET") { int id = int.Parse(context.Request["Id"] ?? "0"); Bulletin model = bll.GetModelById(id); //根据Id 获取数据 System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string jsonStr = javaScriptSerializer.Serialize(model); //将对象序列化成json context.Response.Write(jsonStr); } else { Bulletin model = new Bulletin(); string title = context.Request["editTitle"]; string content = context.Request["editContent"]; string userName = context.Request["editUserName"]; model.Id = int.Parse(context.Request["EditId"] ?? "0"); model.State = context.Request["editselState"]; model.TypeId = int.Parse(context.Request["editTypeId"] ?? "0"); model.UserName = userName; model.Content = content; model.Title = title; if (title == "" || title.Length < 1 || content.Length < 1 || content == "" || userName.Length < 1 || userName == "") { context.Response.Write("No:内容或标题包或发布人不能为空!!!"); return; } SensitiveBll senstitiveBll = new SensitiveBll(); if (senstitiveBll.CheckBanned(content) || senstitiveBll.CheckBanned(title)) { context.Response.Write("No:内容或标题包含禁用词!!!"); return; } else if (senstitiveBll.CheckMod(content) || senstitiveBll.CheckMod(title)) { //model.State = "待审核"; if (bll.Update(model)) { context.Response.Write("Ok:内容或标题包含审核词,请等待审核!!!"); } } else { if (bll.Update(model)) { context.Response.Write("Ok:成功"); } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Bulletin model = new Bulletin(); SensitiveBll senstitiveBll = new SensitiveBll(); string title = context.Request["Title"]; string content = context.Request["content"]; string userName = context.Request["UserName"]; model.TypeId = int.Parse(context.Request["TypeId"] ?? "0"); model.UserName = userName; model.Content = content; model.Title = title; BulletinBll bll = new BulletinBll(); if (title == "" || title.Length < 1 || content.Length < 1 || content == "" || userName.Length < 1 || userName == "") { context.Response.Write("No:内容或标题包或发布人不能为空!!!"); return; } if (senstitiveBll.CheckBanned(content) || senstitiveBll.CheckBanned(title)) {//检查 内容中是否存在 禁用 敏感词 context.Response.Write("No:内容或标题包含禁用词!!!"); return; } else if (senstitiveBll.CheckMod(content) || senstitiveBll.CheckMod(title)) { //检查 内容中是否存在 审查 敏感词 model.State = "待审核"; if (bll.Add(model)) //调用 业务逻辑层 方法将数据保存到数据库 { context.Response.Write("Ok:内容或标题包含审核词,请等待审核!!!"); } } else { model.State = "审核通过"; if (bll.Add(model))//调用 业务逻辑层 方法将数据保存到数据库 { context.Response.Write("Ok:成功"); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Discuss model = new Discuss(); model.UserName = context.Request["userName"]; model.BulletinId = int.Parse(context.Request["bulletitsId"] ?? "0"); model.Content = context.Request["content"]; if (string.IsNullOrWhiteSpace(model.UserName)) //是否登录 { context.Response.Write("请登录后在评论!!!"); return; } SensitiveBll sensitiveBll = new SensitiveBll(); if (sensitiveBll.CheckBanned(model.Content)) //是否存在禁用词 { context.Response.Write("内容包含禁用词!!!"); return; } if (sensitiveBll.CheckMod(model.Content))//是否存在 审核词 { context.Response.Write("内容包含审核词,请等待审核!!!"); model.State = "待审核"; } DiscussBll bll = new DiscussBll(); model.State = "审核通过"; if (bll.Add(model))//添加到数据库 { context.Response.Write("Ok"); } else { context.Response.Write("No"); } }