예제 #1
0
        public ActionResult AdminAdd(ArticleModel model)
        {
            if (ModelState.IsValid)
            {
                var cateid = model.CateId;
                if (cateid == 0)
                {
                    var newcate = new CategoryModel
                    {
                        CateName    = "syscreate",
                        IsIndex     = true,
                        IsNav       = false,
                        ListNum     = 0,
                        ParentId    = 0,
                        ReName      = string.Empty,
                        CustomView  = string.Empty,
                        ReplyPermit = 2,
                        Status      = 1,
                        Type        = model.TypeId,
                        Description = string.Empty,
                        SubCount    = 0
                    };

                    cateid = AddNewCategory(newcate);
                }
                blog_varticle obj      = InitialArticleModel.VArticle();
                CategoryModel category = MyService.GetCategoryById(cateid);
                obj.typeid         = category.Type;
                obj.cateid         = model.CateId;
                obj.catepath       = category.Path;
                obj.title          = Utils.FileterStr(model.Title);
                obj.summary        = string.IsNullOrWhiteSpace(model.Summary) ? "" : model.Summary;
                obj.content        = Utils.DownloadImages(model.Content, "~/upload/article/", GetRootPath());
                obj.tags           = (string.IsNullOrWhiteSpace(model.Tags) ? "" : model.Tags).Trim();
                obj.replypermit    = model.ReplyPermit;
                obj.seodescription = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoDescription) ? "" : model.SeoDescription)).Trim();
                obj.seokeywords    = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.Seokeywords) ? "" : model.Seokeywords)).Trim();
                obj.seometas       = string.IsNullOrWhiteSpace(model.SeoMetas) ? "" : model.SeoMetas;
                obj.seotitle       = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoTitle) ? "" : model.SeoTitle)).Trim();
                obj.rename         = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.ReName) ? "" : model.ReName)).Trim();
                obj.status         = model.Status;
                obj.userid         = MyService.GetUserInfo(UserInfo.username).UserId;
                obj.username       = UserInfo.username;
                obj.iscommend      = model.IsCommend;
                obj.istop          = model.IsTop;
                obj.isindextop     = model.IsIndexTop;
                var re         = MyService.AddArticle(obj);
                var createHtml = Configinfo.IfHtmlCreated == 1 || Configinfo.IfWebStatic == 1;
                if (createHtml && category.Type == 1 && obj.status == 1)
                {
                    new CreatePageDelegate(WebUtils.CreateHtml).BeginInvoke(obj.typeid, re, obj.rename, obj.createdate, GetRootPath(), null, null);
                }

                return(RedirectToAction("AdminArticle", new { tid = obj.typeid, cid = obj.cateid }));
            }
            return(View(model));
        }
예제 #2
0
        public ActionResult AdminEdit(ArticleModel model)
        {
            if (ModelState.IsValid)
            {
                var isResetThumbnail = Request["IsResetThumbnail"];
                var obj      = InitialArticleModel.VArticle();
                var category = MyService.GetCategoryById(model.CateId);
                obj.id             = model.Id;
                obj.typeid         = category.Type;
                obj.cateid         = model.CateId;
                obj.catepath       = category.Path;
                obj.title          = Utils.FileterStr(model.Title);
                obj.summary        = Utils.FileterStr(model.Summary);
                obj.content        = Utils.FileterStr(Utils.DownloadImages(model.Content, "~/upload/article/", GetRootPath()));
                obj.tags           = (string.IsNullOrWhiteSpace(model.Tags) ? "" : model.Tags).Trim();
                obj.replypermit    = model.ReplyPermit;
                obj.seodescription = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoDescription) ? "" : model.SeoDescription)).Trim();
                obj.seokeywords    = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.Seokeywords) ? "" : model.Seokeywords)).Trim();
                obj.seometas       = string.IsNullOrWhiteSpace(model.SeoMetas) ? "" : model.SeoMetas;
                obj.seotitle       = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoTitle) ? "" : model.SeoTitle)).Trim();
                obj.rename         = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.ReName) ? "" : model.ReName)).Trim();
                obj.status         = model.Status;
                obj.userid         = MyService.GetUserInfo(UserInfo.username).UserId;
                obj.username       = UserInfo.username;
                obj.iscommend      = model.IsCommend;
                obj.istop          = model.IsTop;
                obj.isindextop     = model.IsIndexTop;

                if (obj.typeid == 1 && obj.status == 2)
                {
                    var varticle = MyService.GetArticleById(obj.id);
                    if (varticle.status == 1)
                    {
                        WebUtils.DeleteHtml(obj.id, varticle.rename, varticle.createdate);
                    }
                }

                MyService.UpdateVArticle(obj);
                var createHtml = Configinfo.IfHtmlCreated == 1 || Configinfo.IfWebStatic == 1;
                if (createHtml && category.Type == 1 && obj.status == 1)
                {
                    new CreatePageDelegate(WebUtils.CreateHtml).BeginInvoke(obj.typeid, obj.id, obj.rename, model.CreateDate, GetRootPath(), null, null);
                }

                if (isResetThumbnail != null && isResetThumbnail == "true")
                {
                    ResetThumbnails(obj.content);
                }

                return(RedirectToAction("AdminArticle", new { tid = obj.typeid, cid = obj.cateid }));
            }
            return(View(model));
        }
예제 #3
0
        public ActionResult AjaxComment(CommentModel model)
        {
            if (Configinfo.UserPermission && UserInfo == null)
            {
                return(JsonReturn("error.userpermission", string.Empty, string.Empty));
            }

            if (ModelState.IsValid)
            {
                if (Configinfo.IfValidateCode && model.ValidationCode != HttpContext.Session["validationCode"].ToString())
                {
                    return(JsonReturn("error.validationcode", string.Empty, string.Empty));
                }

                if (UserInfo != null && (model.CommentId > 0 && UserInfo.userid == model.UserId))
                {
                    var item = MyService.GetArticleById(model.CommentId);
                    item.title   = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Email) ? "" : model.Email);
                    item.summary = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Url) ? "" : model.Url);
                    item.content = WebUtils.FileterData(model.Content, model.DataType);
                    MyService.UpdateArticle(item);
                    return(JsonReturn(string.Empty, string.Empty, item.orderid.ToString()));
                }

                if (model.CommentId == 0)
                {
                    var obj     = InitialArticleModel.VArticle();
                    var article = MyService.GetArticleById(model.CommentArticleId);
                    obj.title     = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Email) ? "" : model.Email).Trim();
                    obj.summary   = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Url) ? "" : model.Url).Trim();
                    obj.content   = WebUtils.FileterData(model.Content, model.DataType);
                    obj.articleid = model.CommentArticleId;
                    obj.layer     = 1;
                    obj.parentid  = model.ParentId;
                    obj.userid    = model.UserId;
                    obj.username  = model.UserName.Trim();
                    obj.typeid    = article.typeid;
                    obj.cateid    = article.cateid;
                    var re         = MyService.AddArticle(obj);
                    var newComment = MyService.GetArticleById(re);
                    SendCommentReplyEmail(newComment);
                    return(JsonReturn(string.Empty, string.Empty, newComment.orderid.ToString()));
                }
            }
            return(JsonReturn("error.modelvalid", string.Empty, string.Empty));
        }