Beispiel #1
0
        public ActionResult ArtReplyMsg(int artreplyid, string artreplymsg)
        {
            JsonResult <string>     result          = new JsonResult <string>();
            ArticleCommentServicese commnetServices = new ArticleCommentServicese();

            if (artreplyid > 0)
            {
                article_comment add = new article_comment();
                add.add_time   = DateTime.Now;
                add.is_del     = false;
                add.is_reply   = false;
                add.content    = artreplymsg;
                add.reply_id   = null;
                add.article_id = artreplyid;
                if (commnetServices.Add(add) > 0)
                {
                    result.Success();
                }
                else
                {
                    result.Fail("无法进行回复");
                }
            }
            else
            {
                result.Fail("该文章不存在,无法回复");
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            this.ChkAdminLevel("channel_" + this.channel_name + "_comment", DTEnums.ActionEnum.Delete.ToString());
            int             num1           = 0;
            int             num2           = 0;
            article_comment articleComment = new article_comment();

            for (int index = 0; index < this.rptList.Items.Count; ++index)
            {
                int int32 = Convert.ToInt32(((HiddenField)this.rptList.Items[index].FindControl("hidId")).Value);
                if (((CheckBox)this.rptList.Items[index].FindControl("chkId")).Checked)
                {
                    if (articleComment.Delete(int32))
                    {
                        ++num1;
                    }
                    else
                    {
                        ++num2;
                    }
                }
            }
            this.AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除" + this.channel_name + "频道评论成功" + (object)num1 + "条,失败" + (object)num2 + "条");
            this.JscriptMsg("删除成功" + (object)num1 + "条,失败" + (object)num2 + "条!", Utils.CombUrlTxt("comment_list.aspx", "channel_id={0}&keywords={1}&property={2}", this.channel_id.ToString(), this.keywords, this.property));
        }
Beispiel #3
0
        /// <summary>
        /// 评论回复
        /// </summary>
        /// <param name="msgid"></param>
        /// <param name="replymsg"></param>
        /// <returns></returns>
        public ActionResult ReplyMsg(int msgid, string replymsg)
        {
            JsonResult <string>     result          = new JsonResult <string>();
            ArticleCommentServicese commnetServices = new ArticleCommentServicese();
            var msg = commnetServices.query.Where(q => q.id == msgid).Where(q => q.is_del != true).FirstOrDefault();

            if (msg != null)
            {
                article_comment add = new article_comment();
                add.add_time   = DateTime.Now;
                add.is_del     = false;
                add.is_reply   = true;
                add.content    = replymsg;
                add.reply_id   = msgid;
                add.article_id = msg.article_id;
                if (commnetServices.Add(add) > 0)
                {
                    result.Success();
                }
                else
                {
                    result.Fail("无法进行回复");
                }
            }
            else
            {
                result.Fail("该评论不存在,无法回复");
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
 public static ArticleComment ToModel(this article_comment row)
 {
     return(new ArticleComment()
     {
         comment = row.comment.ToHtmlParagraph(),
         id = row.id,
         creator_name = row.name,
         creator_email = row.email,
         posted_time = row.created.ToString(GeneralConstants.DATEFORMAT_TIME),
         isReviewed = row.isApproved || row.isSpam,
         isSpam = row.isSpam
     });
 }
Beispiel #5
0
        private static string ToStatus(this article_comment row)
        {
            if (row.isSpam)
            {
                return("spam");
            }

            if (row.isApproved)
            {
                return("published");
            }

            return("unapproved");
        }
Beispiel #6
0
        protected void btnAudit_Click(object sender, EventArgs e)
        {
            this.ChkAdminLevel("channel_" + this.channel_name + "_comment", DTEnums.ActionEnum.Audit.ToString());
            article_comment articleComment = new article_comment();

            for (int index = 0; index < this.rptList.Items.Count; ++index)
            {
                int int32 = Convert.ToInt32(((HiddenField)this.rptList.Items[index].FindControl("hidId")).Value);
                if (((CheckBox)this.rptList.Items[index].FindControl("chkId")).Checked)
                {
                    articleComment.UpdateField(int32, "is_lock=0");
                }
            }
            this.AddAdminLog(DTEnums.ActionEnum.Audit.ToString(), "审核" + this.channel_name + "频道评论信息");
            this.JscriptMsg("审核通过成功!", Utils.CombUrlTxt("comment_list.aspx", "channel_id={0}&keywords={1}&property={2}", this.channel_id.ToString(), this.keywords, this.property));
        }
        public ActionResult Comments(string blogid, string aid, string name, string email, string body)
        {
            // verify form fields
            var form = new Form()
            {
                name   = name,
                email  = email,
                body   = body,
                errors = new FormErrors()                 // init MUST be done here because liquid uses this to detect if there are errors
            };

            if (string.IsNullOrEmpty(name))
            {
                form.errors.Add("author");
            }
            if (string.IsNullOrEmpty(email))
            {
                form.errors.Add("email");
            }
            if (string.IsNullOrEmpty(body))
            {
                form.errors.Add("body");
            }

            if (form.errors.Count != 0)
            {
                TempData["form"] = form;
                return(RedirectToAction("Index"));
            }


            var articleid_idx = aid.IndexOf("-");

            if (articleid_idx == -1)
            {
                return(RedirectToAction("Index"));
            }
            var articleid = aid.Substring(0, articleid_idx);

            var blog = MASTERdomain.blogs.Where(x => string.Equals(x.permalink, blogid, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault();

            if (blog == null)
            {
                return(RedirectToAction("Index"));
            }
            var commentType = (Commenting)blog.comments;

            var article =
                blog.articles.Where(y => y.id.ToString() == articleid).SingleOrDefault();

            if (article == null)
            {
                return(RedirectToAction("Index"));
            }

            var c = new article_comment
            {
                comment    = body,
                email      = email,
                name       = name,
                created    = DateTime.UtcNow,
                isApproved = commentType == Commenting.ON
            };

            article.article_comments.Add(c);

            repository.Save();
            form = new Form
            {
                posted_successfully = true
            };

            TempData["form"] = form;

            return(RedirectToAction("Index"));
        }
        public ActionResult Article(HttpPostedFileBase file)
        {
            HttpCookie cook      = Request.Cookies["temp"];
            String     cookie    = cook["userid"];
            int        studentID = int.Parse(cookie);
            Model1     head      = new Model1();
            var        headquery = (from s in head.student where s.StudentID == studentID select s).FirstOrDefault();

            ViewBag.head = headquery.Head;
            //新帖子
            string newtitle     = Request["newtitle"];
            string newbrief     = Request["newbrief"];
            string newcontent   = Request["newcontent"];
            int    newarticleid = 0;

            if (newtitle != null)
            {
                Model1      newData      = new Model1();
                var         articleCount = from s in newData.article select s;
                var         newarticle   = new article();
                FirstComObj temp         = new FirstComObj();
                newarticle.articleID = temp.AddOne_COM(articleCount.Count());
                //newarticle.articleID = addOne(articleCount.Count());
                newarticleid       = newarticle.articleID;
                newarticle.Content = newcontent;
                newarticle.Brief   = newbrief;
                newarticle.Title   = newtitle;

                HttpPostedFileBase f        = Request.Files["imgPicker"];
                string             new_path = Server.MapPath("~/Content/images/");
                f.SaveAs(new_path + f.FileName);
                string store_path = "/Content/images/";
                newarticle.Picture = store_path + f.FileName;

                newData.article.Add(newarticle);
                newData.SaveChanges();
            }


            //
            //新评论
            string newComment = Request["comment"];
            string articleID  = Request["articleID"];
            int    ArticleID  = 0;

            if (articleID != null)
            {
                ArticleID = int.Parse(articleID);
            }
            else
            {
                ArticleID = newarticleid;
            }

            if (newComment != null)
            {
                Model1 commentData  = new Model1();
                var    commentCount = from s in commentData.comment select s;
                var    comment      = new comment();
                comment.commentID = addOne(commentCount.Count());
                comment.Content   = newComment;
                DateTime dt  = DateTime.Now;
                string   str = dt.ToString("yyyy-MM-dd HH:mm:ss");
                comment.date      = str;
                comment.StudentID = studentID;
                commentData.comment.Add(comment);


                var comment_article = new article_comment();
                comment_article.commentID = addOne(commentCount.Count());
                comment_article.articleID = ArticleID;
                commentData.article_comment.Add(comment_article);
                commentData.SaveChanges();
            }


            //显示文章
            Model1 ctx   = new Model1();
            var    query = (from s in ctx.article where s.articleID == ArticleID select s).FirstOrDefault();

            ViewBag.content = query.Content;
            ViewBag.brief   = query.Brief;
            ViewBag.theme   = query.Title;
            ViewBag.Title   = query.Title;
            ViewBag.picture = query.Picture;

            //显示评论
            Model1 ctxx        = new Model1();
            var    comments    = from s in ctxx.article_comment where s.articleID == ArticleID select new { s.commentID };
            var    commentHome = new List <Comment>();

            foreach (var item in comments.ToList())
            {
                var commentContent = (from s in ctx.comment where s.commentID == item.commentID select s).FirstOrDefault();
                var commentUser    = (from s in ctx.student where s.StudentID == commentContent.StudentID select s).FirstOrDefault();

                commentHome.Add(new Comment {
                    Content = commentContent.Content, datetime = commentContent.date, name = commentUser.Name, Picture = commentUser.Head
                });
            }
            ViewBag.commentHome   = commentHome;
            ViewBag.commentNumber = commentHome.Count();
            ViewBag.htmlHref      = "Article?articleID=" + articleID + "";

            return(View());
        }
        public ActionResult Article()
        {
            HttpCookie cook      = Request.Cookies["temp"];
            String     cookie    = cook["userid"];
            int        studentID = int.Parse(cookie);
            Model1     head      = new Model1();
            var        headquery = (from s in head.student where s.StudentID == studentID select s).FirstOrDefault();

            ViewBag.head = headquery.Head;
            //新帖子
            string newtitle     = Request["newtitle"];
            string newbrief     = Request["newbrief"];
            string newcontent   = Request["newcontent"];
            int    newarticleid = 0;

            if (newtitle != null)
            {
                Model1 newData      = new Model1();
                var    articleCount = from s in newData.article select s;
                var    newarticle   = new article();
                newarticle.articleID = addOne(articleCount.Count());
                newarticleid         = newarticle.articleID;
                newarticle.Content   = newcontent;
                newarticle.Brief     = newbrief;
                newarticle.Title     = newtitle;
                newData.article.Add(newarticle);
                newData.SaveChanges();
            }


            //
            //新评论
            string newComment = Request["comment"];
            string articleID  = Request["articleID"];
            int    ArticleID  = 0;

            if (articleID != null)
            {
                ArticleID = int.Parse(articleID);
            }
            else
            {
                ArticleID = newarticleid;
            }

            if (newComment != null)
            {
                Model1 commentData  = new Model1();
                var    commentCount = from s in commentData.comment select s;
                var    comment      = new comment();
                comment.commentID = addOne(commentCount.Count());
                comment.Content   = newComment;
                DateTime dt  = DateTime.Now;
                string   str = dt.ToString("yyyy-MM-dd HH:mm:ss");
                comment.date      = str;
                comment.StudentID = studentID;
                commentData.comment.Add(comment);
                ;

                var comment_article = new article_comment();
                comment_article.commentID = addOne(commentCount.Count());
                comment_article.articleID = ArticleID;
                commentData.article_comment.Add(comment_article);
                commentData.SaveChanges();
            }

            MyDelegate dele = new MyDelegate(Task1);

            //dele.BeginInvoke(ArticleID,backcall,"我是异步调用的parameter");
            dele += new MyDelegate(Task2);
            dele(ArticleID);

            //显示文章
            //Model1 ctx = new Model1();
            //var query = (from s in ctx.article where s.articleID == ArticleID select s).FirstOrDefault();
            //ViewBag.content = query.Content;
            //ViewBag.brief = query.Brief;
            //ViewBag.theme = query.Title;
            //ViewBag.Title = query.Title;
            //ViewBag.picture = query.Picture;

            ////显示评论
            //Model1 ctxx = new Model1();
            //var comments = from s in ctxx.article_comment where s.articleID == ArticleID select new { s.commentID };
            //var commentHome = new List<Comment>();
            //foreach (var item in comments.ToList())
            //{

            //    var commentContent = (from s in ctx.comment where s.commentID == item.commentID select s).FirstOrDefault();
            //    var commentUser = (from s in ctx.student where s.StudentID == commentContent.StudentID select s).FirstOrDefault();

            //    commentHome.Add(new Comment { Content = commentContent.Content, datetime = commentContent.date, name = commentUser.Name, Picture = commentUser.Head});
            //}
            //ViewBag.commentHome = commentHome;
            //ViewBag.commentNumber = commentHome.Count();
            ViewBag.htmlHref = "Article?articleID=" + articleID + "";

            return(View());
        }