Exemple #1
0
        public ActionResult MessageIng(string msg)
        {
            MessageServices     msgServices = new MessageServices();
            JsonResult <string> result      = new JsonResult <string>();
            string userip = UserAddress.GetUserAddress();
            //10分钟内,同一ip只可留言一次
            var newMsg = msgServices.query.Where(q => q.user_ip == userip).OrderByDescending(q => q.msg_time).FirstOrDefault();

            if (newMsg != null && ((TimeSpan)(DateTime.Now - newMsg.msg_time)).TotalMinutes < 10)
            {
                result.Fail("已留言," + (10 - ((TimeSpan)(DateTime.Now - newMsg.msg_time)).TotalMinutes).ToString("F0") + "分钟内无法再次留言");
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            message add = new message();

            add.is_del   = false;
            add.msg_time = DateTime.Now;
            add.content  = msg;
            add.user_ip  = userip;
            if (msgServices.Add(add) > 0)
            {
                result.Success();
            }
            else
            {
                result.Fail("留言失败");
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #2
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));
        }
Exemple #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));
        }
Exemple #4
0
        public ActionResult GetMoreArticle(int skip, int num)
        {
            JsonResult <List <ArticlListModel> > result = new JsonResult <List <ArticlListModel> >();
            List <ArticlListModel> articls = new List <ArticlListModel>();
            var list = articleDB.query.Where(q => q.is_show == true).OrderByDescending(q => q.add_time).Skip(skip).Take(num).ToList();

            if (list.Count() > 0)
            {
                foreach (var item in list)
                {
                    articls.Add(new ArticlListModel()
                    {
                        ID         = item.id,
                        AddTime    = item.add_time.Value.ToString("yyyy-MM-dd"),
                        Abstract   = item.@abstract,
                        BrowseNum  = (int)item.browse_num,
                        Title      = item.title,
                        TypeName   = item.article_type.type_name,
                        CommentNum = item.article_comment.Where(q => q.is_del != true).Count(),
                        Image      = item.image,
                    });
                }
                result.Success(articls);
            }
            else
            {
                result.Fail("没有更多的文章啦!");
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult OCRImg(string imgPath = null)
        {
            //"img/{size}/t{imageType}t{yearMonth}-{id}.{format}"
            var result = new JsonResult <object>();

            if (string.IsNullOrEmpty(imgPath))
            {
                result.Fail();
            }
            else
            {
                var         physicalPath = Server.MapPath("~/storage/images/2017/");
                var         pj           = imgPath.Split('/');
                var         p3           = pj[3];
                var         pDate        = p3.Split('-')[0];
                var         imgKey       = p3.Substring(p3.IndexOf('-') + 1);
                var         imgFix       = imgKey.Substring(imgKey.IndexOf('.') + 1).ToLower();
                ImageFormat imageFormat  = imgFix == "jpg" ? ImageFormat.Jpeg : ImageFormat.Png;
                physicalPath = physicalPath + pDate.Substring(pDate.Length - 2) + "/" + imgKey.Substring(0, imgKey.IndexOf('.')) + "/" + "Full" + imgKey.Substring(imgKey.IndexOf('.'));

                var imgDatas = OcrImgToDataServer.GetData(physicalPath);

                result.Succeed();
                result.Value = new { Data = imgDatas.Item1, ListData = imgDatas.Item2 };
            }

            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 点赞、踩
        /// </summary>
        /// <param name="msgid"></param>
        /// <param name="is_up"></param>
        /// <returns></returns>
        public ActionResult LikeMsg(int msgid, bool is_up)
        {
            JsonResult <string> result       = new JsonResult <string>();
            CommentLikeServices likeservices = new CommentLikeServices();
            var userAddress = UserAddress.GetUserAddress();
            var lieks       = likeservices.query.Where(q => q.comment_id == msgid).ToList();
            var like        = likeservices.query.Where(q => q.comment_id == msgid).Where(q => q.user_ip == userAddress).FirstOrDefault();

            if (like != null)
            {
                if (like.is_like == is_up)
                {
                    result.Fail("");
                }
                else
                {
                    like.is_like = is_up;
                    if (likeservices.Update(like) > 0)
                    {
                        result.Success();
                    }
                    else
                    {
                        result.Fail("");
                    }
                }
            }
            else
            {
                comment_like add = new comment_like();
                add.is_like = is_up;
                //add.user_id
                add.user_ip    = userAddress;
                add.add_time   = DateTime.Now;
                add.comment_id = msgid;
                if (likeservices.Add(add) > 0)
                {
                    result.Success();
                }
                else
                {
                    result.Fail("");
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }