Esempio n. 1
0
        /// 添加留言
        /// </summary>
        public void message(HttpContext context)
        {
            string outmsg       = "{\"status\":1,\"msg\":\"留言成功!\"}";
            string messagename  = _Request.GetString("messagename");
            string messagmodile = _Request.GetString("messagmodile");
            string messageemail = _Request.GetString("messageemail");
            string messageliu   = _Request.GetString("messageliu");

            Model.article_comment model = new Model.article_comment();
            BLL.article_comment   bll   = new BLL.article_comment();
            model.user_name     = messagename;
            model.channel_id    = 1;
            model.user_ip       = messagmodile;
            model.content       = messageemail;
            model.reply_content = messageliu;
            model.add_time      = DateTime.Now;
            int id = bll.Add(model);

            if (id > 0)
            {
                context.Response.Clear();
                context.Response.Write(outmsg);
                context.Response.End();
            }
            else
            {
                context.Response.Clear();
                context.Response.Write("{\"status\":0,\"msg\":\"留言失败请稍候再试!\"}");
                context.Response.End();
            }
        }
Esempio n. 2
0
        public async Task <StatusModel> CommentAdd(CommentAddModel amodel)
        {
            StringBuilder strTxt = new StringBuilder();

            BLL.article_comment   bll   = new BLL.article_comment();
            Model.article_comment model = new Model.article_comment();

            if (amodel.articleId == 0)
            {
                return(new StatusModel {
                    status = 0, msg = "对不起,参数传输有误!"
                });
            }
            if (string.IsNullOrEmpty(amodel.content))
            {
                return(new StatusModel()
                {
                    status = 0, msg = "对不起,请输入评论的内容!"
                });
            }
            //检查该文章是否存在
            Model.article artModel = new BLL.article().GetModel(amodel.articleId);
            if (artModel == null)
            {
                return(new StatusModel()
                {
                    status = 0, msg = "对不起,主题不存在或已删除!"
                });
            }
            //检查用户是否登录
            int    user_id   = 0;
            string user_name = "匿名用户";
            var    user      = await UserManager.FindByIdAsync(int.Parse(User.Identity.GetUserId()));

            if (user != null)
            {
                user_id   = user.id;
                user_name = user.user_name;
            }
            model.channel_id = artModel.channel_id;
            model.article_id = artModel.id;
            model.content    = Utils.ToHtml(amodel.content);
            model.user_id    = user_id;
            model.user_name  = user_name;
            model.user_ip    = DTRequest.GetIP();
            model.is_lock    = siteConfig.commentstatus; //审核开关
            model.add_time   = DateTime.Now;
            model.is_reply   = 0;
            if (bll.Add(model) > 0)
            {
                return(new StatusModel()
                {
                    status = 1, msg = "留言提交成功!"
                });
            }
            return(new StatusModel()
            {
                status = 0, msg = "对不起,保存过程中发生错误!"
            });
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.article_comment model = new Model.article_comment();
            //HttpCookie cook = Request.Cookies["WEBUSERID"];
            string cook = Utils.GetCookie("WEBUSERID").ToString();

            if (cook == null)
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('請先登入');window.location.href='login_vip.aspx'</script>");
            }
            else
            {
                //ids = cook.Value;
            }
            string Content = Request.Form["txtContent"];

            model.content    = DTcms.Common.Utils.ToHtml(Content);
            model.article_id = id;
            model.user_ip    = DTcms.Common.DTRequest.GetIP();
            BLL.article_comment bll = new BLL.article_comment();
            bll.Add(model);
            this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('送出成功');window.location.href='productview.aspx?id=" + id + "&mid=2'</script>");
        }
Esempio n. 4
0
        private void comment_add(HttpContext context)
        {
            StringBuilder strTxt = new StringBuilder();
            BLL.article_comment bll = new BLL.article_comment();
            Model.article_comment model = new Model.article_comment();

            string code = DTRequest.GetFormString("txtCode");
            int article_id = DTRequest.GetQueryInt("article_id");
            string _content = DTRequest.GetFormString("txtContent");
            //校检验证码
            string result =verify_code(context, code);
            if (result != "success")
            {
                context.Response.Write(result);
                return;
            }
            if (article_id == 0)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,参数传输有误!\"}");
                return;
            }
            if (string.IsNullOrEmpty(_content))
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,请输入评论的内容!\"}");
                return;
            }
            //检查用户是否登录
            int user_id = 0;
            string user_name = "匿名用户";
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel != null)
            {
                user_id = userModel.id;
                user_name = userModel.user_name;
            }
            model.article_id = article_id;
            model.content = Utils.ToHtml(_content);
            model.user_id = user_id;
            model.user_name = user_name;
            model.user_ip = DTRequest.GetIP();
            model.is_lock = siteConfig.commentstatus; //审核开关
            model.add_time = DateTime.Now;
            model.is_reply = 0;
            if (bll.Add(model) > 0)
            {
                context.Response.Write("{\"msg\": 1, \"msgbox\": \"恭喜您,留言提交成功啦!\"}");
                return;
            }
            context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,保存过程中发生错误!\"}");
            return;
        }