Example #1
0
        /// <summary>
        /// 编辑页面
        /// </summary>
        /// <param name="caId">栏目文章ID</param>
        /// <returns>用户编辑页面</returns>
        public virtual ActionResult Edit(int caId = 0)
        {
            var ca = (caId > 0) ? _article.GetById(caId) : _article.CreateByCatalog(CatalogId);

            _innerCatalogId = ca.CatalogId;
            Session["Editing_" + _innerCatalogId] = ca;
            //ViewBag.ShowSearchBox = false;
            ViewBag.ShowBreadCrumb = false;
            Base_Catalog cat     = SiteManager.Catalog.GetById(_innerCatalogId);
            string       catName = cat == null ? null : cat.Name;

            ca.CheckExts();
            BeforeShowEditForm(ca);
            return(View(ca.Article));
        }
        /// <summary>
        /// 保存查询对象,根据是否是新对象决定是插入还是改写
        /// </summary>
        /// <param name="item">查询对象</param>
        public void Save(AdvQueryItem item)
        {
            var ca = GetUserQueryArticle(item.ModelName).FirstOrDefault(ca1 => ca1.Article.Title.Equals(item.Name, StringComparison.OrdinalIgnoreCase));

            if (ca == null)
            {
                ca = _article.CreateByCatalog(AdvQuery.Query.Id);
                ca.Article.State = ArticleState.Published;
            }
            ca.Article.Title    = item.Name;
            ca.Article.Text     = JsonHelper.ToJson(item.Nodes);
            ca.Article.EditorId = CommOp.ToInt(AppManager.Instance.GetCurrentUserId());
            ca.SetExt(AdvQuery.Query.ModelName, item.ModelName);
            _article.Save(ca);
            item.Id = ca.Id;
        }
        /// <summary>
        /// 保存文件属性信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private ResourceFileInfo InnerSaveArticleInfo(ResourceFileInfo info)
        {
            //string fileKey = Guid.NewGuid().ToString();
            //文件Key,作为物理文件的文件名称,8位日期 + 年月日时分秒毫秒 by_zjf + 实际的上传文件名称
            string fileKey = DateTime.Now.ToString("yyyyMMdd") + "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-" + info.FileName;

            int catId = GetCatalogId(info.ContentType);
            //保存文件属性信息
            var a = _article.CreateByCatalog(catId);

            a.CreateTime       = DateTime.Now;
            a.Article.State    = ArticleState.Incomplete;
            a.Article.Title    = info.FileName;
            a.Article.EditorId = int.Parse((info.UserId));
            a.Article.Author   = info.UserId;
            a.Article.Text     = "";
            a.Article.Keywords = info.Keywords;
            a.Article.EditTime = info.CreateTime;
            a.Article.Abstract = info.Abstract;

            //查找扩展属性ID,对应ID赋值
            a.SetExt(SystemTypes.Root.Key, fileKey);
            a.SetExt(SystemTypes.Root.MD5Code, info.MD5Code);
            a.SetExt(SystemTypes.Root.ContentType, info.ContentType);
            a.SetExt(SystemTypes.Root.FileName, info.FileName);
            a.SetExt(SystemTypes.Root.FileSize, info.FileSize);


            SaveExtraExt(a, info);

            //保存文件信息到系统目录
            _article.Save(a);

            info.Id = a.Id;

            var saved = SaveCatalogArticleInfo(info);

            info.Id      = saved.Id;
            info.FileKey = fileKey;

            return(info);
        }