Exemple #1
0
        /// <summary>
        ///   集合的过滤
        /// </summary>
        /// <returns></returns>
        public ActionResult ListTest()
        {
            List <Article> list   = bllSession.IArticleBLL.GetList("").ToList();
            bool           result = false;

            list = WordFilterHelper <Article> .TextFilter(list, out result) as List <Article>;

            return(View(list));
        }
Exemple #2
0
        /// <summary>
        /// 单个对象过滤
        /// </summary>
        /// <returns></returns>
        public ActionResult ShowTest()
        {
            bllSession.IArticleBLL.GetEntity(3);
            bool    result  = false;
            Article article = bllSession.IArticleBLL.GetEntity(3);

            article = WordFilterHelper <Article> .TextFilter(article, out result) as Article;

            return(View(article));
        }
Exemple #3
0
        public ActionResult Save(string Title, string Text)
        {
            AjaxModel model = new AjaxModel();

            if (CurrentUser != null)
            {
                int             user_id = CurrentUser.Id;
                Demand          demand  = new Entity.Demand();
                IBLL.IDemandBLL bll     = BLLSessionFactory.GetBLLSession().IDemandBLL;
                User            user    = new Entity.User();
                user = bllSession.IUserBLL.GetEntity(user_id);
                if (Title.Length == 0)
                {
                    model.Statu = "title";
                    model.Data  = "请输入标题!";
                    model.Msg   = "请输入标题!";
                }
                else if (Title.Length > 25)
                {
                    model.Statu = "title";
                    model.Data  = "标题过长,请重新输入!";
                    model.Msg   = "标题过长,请重新输入!";
                }
                else if (Text.Length == 0)
                {
                    model.Statu = "text";
                    model.Data  = "请填写需求!";
                    model.Msg   = "请填写需求!";
                }
                bool isBanned = false;
                WordFilterHelper <Demand> .TextFilter(Text, out isBanned);

                if (isBanned)
                {
                    model.Statu = "isBanned";
                    model.Data  = "文章内容包含敏感词,请修改后重新提交!";
                }
                else
                {
                    try
                    {
                        demand.Title    = Title.Trim();
                        demand.Text     = Text.Trim();
                        demand.State    = 0;
                        demand.UserId   = user_id;
                        demand.DateTime = DateTime.Now;
                        bll.Insert(demand);
                        model.Statu   = "ok";
                        model.Msg     = "提交成功!";
                        model.BackUrl = "/Demand";
                        log.Info(new LogContent(user.Username + "用户提交需求", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
                    }
                    catch (Exception e)
                    {
                        model.Statu = "err";
                        model.Msg   = "提交出错请重试!";
                        log.Error(new LogContent(user.Username + "用户提交需求出错" + e.Message, LogType.异常.ToString(), HttpHelper.GetIPAddress()));
                    }
                }
            }
            else
            {
                model.Statu   = "go_login";
                model.Msg     = "请登录后再提交页面!";
                model.BackUrl = "/User/Login";
            }
            return(Json(model));
        }