Esempio n. 1
0
        public static string SaveContentPic(string content, string title)
        {
            var folder = string.Format("{0}.{1}", DateTime.Now.ToString("yyyy.MM.dd"), title);
            var root   = Config.Path.REMOTE_PICTURE_FOLDER;

            if (root.Substring(0, 1) == "/")
            {
                root = root.Substring(1);
            }
            folder = Path.Combine(root, folder);
            var cdata = SaveRemoteFileHelper.SavePic(content, Config.Path.PHYSICAL_ROOT_PATH, folder);

            return(cdata.Content);
        }
Esempio n. 2
0
        public ActionResult SavePic(int utype)
        {
            string result = "";

            if (this.IsPostFile())
            {
                result = SaveRemoteFileHelper.SaveRequestFiles("imgFile", utype);
            }
            else
            {
                result = "{\"error\":1,\"message\":\"没有传文件\"}";
            }

            return(Content(result));
        }
Esempio n. 3
0
        public ActionResult ArticleSave(BlogArticle model, FormCollection form)
        {
            int hID    = Convert.ToInt32(form["hID"]);
            int CateID = Convert.ToInt32(form["CateID"]);

            bool DownMeta       = Convert.ToBoolean(form["DownMeta"]);
            bool AutoMark       = Convert.ToBoolean(form["AutoMark"]);
            bool TopAsThumbnail = Convert.ToBoolean(form["TopAsThumbnail"]);

            bool IsEdit = hID > 0;

            if (IsEdit)
            {
                //编辑
                model = _articleService.GetByCondition(new DirectSpecification <BlogArticle>(x => x.ArticleID == hID));
                model.BlogCategory = _categoryService.GetByCondition(new DirectSpecification <BlogCategory>(x => x.CateID == CateID));
            }

            model.ImageUrl = RequestHelper.GetInputString(form["hImageUrl"], "", true, true);

            ShowResultModel ShowMsg = new ShowResultModel();

            model.Content = RequestHelper.GetInputString(form["Content"], "", false, false);

            //下载远程图片
            if (DownMeta)
            {
                ContentData cdata = SaveRemoteFileHelper.SavePic(model.Content, AutoMark);
                model.Content = cdata.Content;
                if (cdata.FileList.Count > 0 && TopAsThumbnail)
                {
                    model.ImageUrl = cdata.FileList[0];
                }
            }

            if (IsEdit)
            {
                //编辑

                model.Title = RequestHelper.GetInputString(form["Title"], "", true, true);
                model.IsTop = RequestHelper.GetInputBoolean(form["IsTop"].Split(',')[0], false);

                model.Tag         = RequestHelper.GetInputString(form["Tag"], "", true, true);
                model.Description = RequestHelper.GetInputString(form["Description"], "", true, true);

                model.State       = RequestHelper.GetInputInt32(form["State"], 0);
                model.PublishTime = RequestHelper.GetInputDateTime(form["PublishTime"], DateTime.Now);
                model.Hits        = RequestHelper.GetInputInt32(form["Hits"], 0);

                _articleService.Modify(model);


                ShowMsg.PageTitle   = string.Format("{0} 提示信息", "博文编辑");
                ShowMsg.ReDirectUrl = Url.Action("ArticleList");
                ShowMsg.TipMsg      = string.Format("标题为:{0} 编辑成功", model.Title);
                ShowMsg.Delay       = 3000;
            }
            else
            {
                //新增
                model.BlogCategory = _categoryService.GetByCondition(new DirectSpecification <BlogCategory>(x => x.CateID == CateID));

                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                model.UserID     = 0;
                model.UserName   = "";
                model.UserIP     = RequestHelper.GetIP();

                ShowMsg.PageTitle   = string.Format("{0} 提示信息", "博文发布");
                ShowMsg.ReDirectUrl = Url.Action("ArticleList");
                ShowMsg.TipMsg      = string.Format("标题为:{0} 发布成功", model.Title);
                ShowMsg.Delay       = 3000;

                _articleService.NewSave(model);
            }

            ViewData["ShowMsg"] = ShowMsg;
            return(View("ShowResult"));
        }