Exemplo n.º 1
0
        // GET: Admin/Demo
        public ActionResult Index()
        {
            return(View("~/Areas/Admin/Views/Demo/ValidateDemo4.cshtml"));

            //当前期刊
            string journalId = "5";
            var    model     = new ArticleJournalEntity();

            if (journalId != null)
            {
                ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();
                model = articleJournalBLL.GetArticleJournalEntityById(journalId);
            }

            //select options => 文章分类
            ArticleCategoryBLL           articleCategoryBLL = new ArticleCategoryBLL();
            List <SqlDbParameter>        parms           = new List <SqlDbParameter>();
            List <ArticleCategoryEntity> articleCategory = articleCategoryBLL.GetAllArticleCategory(parms, "Id");

            articleCategory.Insert(0, new ArticleCategoryEntity()
            {
                CategoryName = "请选择"
            });
            var selectList = new SelectList(articleCategory, "Id", "CategoryName");

            ViewBag.ArticleCategory = selectList;
            return(View(model));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 后台的文章静态处理
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult StaticHtml(int id)
        {
            ArticleBLL    articleBLL    = new ArticleBLL();
            ArticleEntity articleEntity = articleBLL.GetArticleEntityById(id);
            string        staticURL     = "/";

            //生成文章静态URL
            ArticleCategoryBLL    articleCategoryBLL = new ArticleCategoryBLL();
            ArticleCategoryEntity categoryEntity     = articleCategoryBLL.GetArticleCategoryEntityById(articleEntity.CategoryId);

            articleEntity.HrefTpl = categoryEntity.HrefTpl;

            if (!string.IsNullOrEmpty(categoryEntity.HrefTpl))
            {
                //查文章对应的期刊
                if (articleEntity.ArticlePropertyId.HasValue)
                {
                    JournalArticleRelationBLL    journalArticleRelationBLL    = new JournalArticleRelationBLL();
                    JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(articleEntity.ArticlePropertyId);
                    ArticleJournalBLL            articleJournalBLL            = new ArticleJournalBLL();
                    ArticleJournalEntity         articleJournalEntity         = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId);
                    articleEntity.JournalId    = articleJournalEntity.JournalId;    //期刊Id
                    articleEntity.JournalName  = articleJournalEntity.JournalName;  //期刊名
                    articleEntity.PropertyName = articleJournalEntity.PropertyName; //期刊总序号
                    staticURL += articleEntity.Href + "?JournalId=" + articleEntity.JournalId + "&static=1";
                    return(Redirect(staticURL));
                }
                staticURL += articleEntity.Href + "&static=1";
                return(Redirect(staticURL));
            }
            return(new EmptyResult());
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            ArticleJournalBLL    articleJournalBLL = new ArticleJournalBLL();
            ArticleJournalEntity journalEntity     = articleJournalBLL.GetArticleJournalEntityById(id);

            return(View(journalEntity));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 文章预览
        /// </summary>
        /// <param name="id">文章Id</param>
        /// <returns></returns>
        public ActionResult Perview(int id)
        {
            ArticleBLL    articleBLL    = new ArticleBLL();
            ArticleEntity articleEntity = articleBLL.GetArticleEntityById(id);
            string        staticURL     = "/";

            //生成文章静态URL
            ArticleCategoryBLL    articleCategoryBLL = new ArticleCategoryBLL();
            ArticleCategoryEntity categoryEntity     = articleCategoryBLL.GetArticleCategoryEntityById(articleEntity.CategoryId);

            //TODO 判断文章没有任何分类的情况
            articleEntity.HrefTpl = categoryEntity != null ? categoryEntity.HrefTpl : "nocategory{0}.html";//文章没有类别时,详细页URL

            if (!string.IsNullOrEmpty(articleEntity.HrefTpl))
            {
                //查文章对应的期刊
                if (articleEntity.ArticlePropertyId.HasValue)
                {
                    JournalArticleRelationBLL    journalArticleRelationBLL    = new JournalArticleRelationBLL();
                    JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(articleEntity.ArticlePropertyId);
                    ArticleJournalBLL            articleJournalBLL            = new ArticleJournalBLL();
                    ArticleJournalEntity         articleJournalEntity         = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId);
                    articleEntity.JournalId    = articleJournalEntity.JournalId;    //期刊Id
                    articleEntity.JournalName  = articleJournalEntity.JournalName;  //期刊名
                    articleEntity.PropertyName = articleJournalEntity.PropertyName; //期刊总序号
                    staticURL += articleEntity.Href + "?JournalId=" + articleEntity.JournalId;
                    return(Redirect(staticURL));
                }
                staticURL += articleEntity.Href;
                return(Redirect(staticURL));
            }
            return(new EmptyResult());
        }
Exemplo n.º 5
0
        // GET: Article
        public ActionResult Index()
        {
            //当前期刊
            string journalId = Request.QueryString["JournalId"];
            var    model     = new ArticleJournalEntity();

            if (journalId != null)
            {
                ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();
                model = articleJournalBLL.GetArticleJournalEntityById(journalId);
            }
            //ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();//1.获取期刊
            //List<SqlDbParameter> parms = new List<SqlDbParameter>();
            //SqlDbParameter para = new SqlDbParameter();
            //List<ArticleJournalEntity> journalList = articleJournalBLL.GetAllArticleJournal(parms);
            //journalList.Insert(0, new ArticleJournalEntity() { JournalName ="请选择"});
            //ViewBag.ArticleProperty = new SelectList(journalList, "JournalId", "JournalName"); //期刊ID

            //文章分类
            ArticleCategoryBLL           articleCategoryBLL = new ArticleCategoryBLL();
            List <SqlDbParameter>        parms           = new List <SqlDbParameter>();
            List <ArticleCategoryEntity> articleCategory = articleCategoryBLL.GetAllArticleCategory(parms, "Id");

            articleCategory.Insert(0, new ArticleCategoryEntity()
            {
                CategoryName = "请选择"
            });
            var selectList = new SelectList(articleCategory, "Id", "CategoryName");

            ViewBag.ArticleCategory = selectList;
            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Create()
        {
            //当前期刊
            string journalId = Request.QueryString["JournalId"];//期刊Id
            var    model     = new ArticleJournalEntity();

            if (journalId != null)
            {
                ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();
                model = articleJournalBLL.GetArticleJournalEntityById(journalId);
            }

            //ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();//1.获取期刊
            //List<SqlDbParameter> parms = new List<SqlDbParameter>();
            //SqlDbParameter para = new SqlDbParameter();
            //List<ArticleJournalEntity> journalList = articleJournalBLL.GetAllArticleJournal(parms);
            //ViewBag.ArticleProperty = new SelectList(journalList, "JournalId", "JournalName");
            //EnumDescription[] articleCategory = EnumDescription.GetFieldTexts(typeof(Enumerator.ArticleType)); //文章分类
            //文章分类 TODO
            ArticleCategoryBLL           articleCategoryBLL = new ArticleCategoryBLL();
            List <SqlDbParameter>        parms           = new List <SqlDbParameter>();
            List <ArticleCategoryEntity> articleCategory = articleCategoryBLL.GetAllArticleCategory(parms, "Id");

            articleCategory.Insert(0, new ArticleCategoryEntity()
            {
                CategoryName = "请选择"
            });
            var selectList = new SelectList(articleCategory, "Id", "CategoryName");

            ViewBag.ArticleCategory = selectList;// articleCategoryList;
            //ViewBag.ArticleCategory = new SelectList(articleCategory, "EnumValue", "CNText");
            return(View(model));
        }
Exemplo n.º 7
0
 public string Create(ArticleJournalEntity journal)
 {
     if (ModelState.IsValid)
     {
         ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();
         journal.JournalName = journal.JournalName.UrlDecode();//期刊名
         //journal.ArticleContent = article.ArticleContent.UrlDecode();//文章内容
         articleJournalBLL.AddArticleJournalEntity(journal);
         return(JsonConvert.SerializeObject(new { result = true, message = "", returnUrl = "Index" }));
     }
     return(JsonConvert.SerializeObject(new { result = false, message = "" }));
 }
Exemplo n.º 8
0
        public string Edit(ArticleJournalEntity journalUpdate)
        {
            if (ModelState.IsValid)
            {
                ArticleJournalBLL    articleJournalBLL = new ArticleJournalBLL();
                ArticleJournalEntity journalEntity     = articleJournalBLL.GetArticleJournalEntityById(journalUpdate.JournalId);

                journalEntity.JournalName  = journalUpdate.JournalName.UrlDecode();  //期刊名称
                journalEntity.PropertyName = journalUpdate.PropertyName.UrlDecode(); //期刊编号
                articleJournalBLL.UpdateArticleJournalEntity(journalEntity);

                return(JsonConvert.SerializeObject(new { result = true, message = "", returnUrl = "/Admin/Journal/Index" }));
            }
            return(JsonConvert.SerializeObject(new { result = false, message = "" }));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 期刊列表
        /// </summary>
        /// <returns></returns>
        public string GetList()
        {
            ArticleJournalBLL     articleJournalBLL = new ArticleJournalBLL();
            List <SqlDbParameter> parms             = new List <SqlDbParameter>();
            SqlDbParameter        parm = null;


            int         recordCount;
            int         draw      = Convert.ToInt32(Request["draw"]);
            int         start     = Convert.ToInt32(Request["start"]);
            int         length    = Convert.ToInt32(Request["length"]);
            int         page      = start / length; //start 初始值0
            DataTable   dataTable = articleJournalBLL.GetJournalDataTablePage(parms, "JournalId DESC", length, page, out recordCount);
            IDictionary info      = new Hashtable();

            info.Add("draw", draw);
            info.Add("recordsTotal", recordCount);
            info.Add("recordsFiltered", recordCount);
            info.Add("data", dataTable);
            return(JsonConvert.SerializeObject(info));
        }
Exemplo n.º 10
0
        // GET: Base
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);

            //TO DO
            string controller = (string)requestContext.RouteData.Values["controller"];
            string action     = (string)requestContext.RouteData.Values["action"];

            currentURL = System.Web.HttpContext.Current.Request.Url.AbsolutePath; //获取当前url,以/开头

            string JournalId = Request.QueryString["JournalId"];                  //期刊ID

            //默认获取最新期刊
            //TODO Cache
            ArticleJournalBLL     articleJournalBLL = new ArticleJournalBLL();
            List <SqlDbParameter> parms             = new List <SqlDbParameter>();
            SqlDbParameter        parm;

            if (!string.IsNullOrEmpty(JournalId))
            {
                parm                = new SqlDbParameter();
                parm.ColumnName     = "JournalId";
                parm.ParameterName  = "JournalId";
                parm.ParameterValue = JournalId;
                parm.ColumnType     = DbType.Int32;
                parms.Add(parm);
                currentJournalEntity = articleJournalBLL.GetArticleJournalEntity(parms);
            }
            else
            {
                DataTable dt = articleJournalBLL.GetJournalDataTable(parms, "JournalId DESC", "1"); //返回最新的期刊
                currentJournalEntity              = new ArticleJournalEntity();
                currentJournalEntity.JournalId    = int.Parse(dt.Rows[0]["JournalId"].ToString());
                currentJournalEntity.JournalName  = dt.Rows[0]["JournalName"].ToString();
                currentJournalEntity.PropertyName = dt.Rows[0]["PropertyName"].ToString();
            }

            ViewBag.JournalName = currentJournalEntity.JournalName;
            ViewBag.JournalNo   = currentJournalEntity.PropertyName;
        }
Exemplo n.º 11
0
        public string Edit(ArticleEntity articleUpdate)
        {
            var errors = ModelState.Values.SelectMany(v => v.Errors).ToList();//查找具体出错的模型字段

            //ModelState.Remove("Id");

            if (ModelState.IsValid)
            {
                ArticleBLL    articleBLL = new ArticleBLL();
                ArticleEntity article    = articleBLL.GetArticleEntityById(articleUpdate.Id);

                article.ArticleTitle      = articleUpdate.ArticleTitle.UrlDecode();   //文章标题
                article.ArticleTitleAlias = articleUpdate.ArticleTitleAlias.UrlDecode();
                article.ArticleContent    = articleUpdate.ArticleContent.UrlDecode(); //文章内容
                article.CategoryId        = articleUpdate.CategoryId;
                article.NoOfJournal       = articleUpdate.NoOfJournal;
                article.NoOfCategory      = articleUpdate.NoOfCategory;
                article.IsPublic          = articleUpdate.IsPublic;
                //article.IsTop = articleUpdate.IsTop;

                if (article.ArticlePropertyId.HasValue)
                {
                    JournalArticleRelationBLL    journalArticleRelationBLL    = new JournalArticleRelationBLL();
                    JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(article.ArticlePropertyId);
                    ArticleJournalBLL            articleJournalBLL            = new ArticleJournalBLL();
                    ArticleJournalEntity         articleJournalEntity         = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId);
                    article.JournalId = articleJournalEntity.JournalId;
                }

                articleBLL.UpdateArticleEntity(article);
                //TODO Step3 维护照片关系
                this.ArticleImageSave(articleUpdate);

                string returnUrl = article.JournalId.HasValue ? "/Admin/Article/Index?JournalId=" + article.JournalId : "/Admin/Article/Index";
                return(JsonConvert.SerializeObject(new { result = true, message = "", returnUrl = returnUrl }));
            }
            return(JsonConvert.SerializeObject(new { result = false, message = "" }));
        }
Exemplo n.º 12
0
        public ActionResult Edit(int id)
        {
            ArticleBLL    articleBLL    = new ArticleBLL();
            ArticleEntity articleEntity = articleBLL.GetArticleEntityById(id);

            //查文章对应的期刊
            if (articleEntity.ArticlePropertyId.HasValue)
            {
                JournalArticleRelationBLL    journalArticleRelationBLL    = new JournalArticleRelationBLL();
                JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(articleEntity.ArticlePropertyId);
                ArticleJournalBLL            articleJournalBLL            = new ArticleJournalBLL();
                ArticleJournalEntity         articleJournalEntity         = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId);
                articleEntity.JournalName  = articleJournalEntity.JournalName;
                articleEntity.PropertyName = articleJournalEntity.PropertyName;
                articleEntity.JournalId    = articleJournalEntity.JournalId;//文章所属期刊Id
            }

            /*
             * ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();//1.获取期刊
             * List<SqlDbParameter> parms = new List<SqlDbParameter>();
             * SqlDbParameter para = new SqlDbParameter();
             * List<ArticleJournalEntity> journalList = articleJournalBLL.GetAllArticleJournal(parms);
             * ViewBag.ArticleProperty = new SelectList(journalList, "JournalId", "JournalName", articleEntity.JournalId);
             */
            //文章分类 TODO
            ArticleCategoryBLL           articleCategoryBLL = new ArticleCategoryBLL();
            List <SqlDbParameter>        parms           = new List <SqlDbParameter>();
            List <ArticleCategoryEntity> articleCategory = articleCategoryBLL.GetAllArticleCategory(parms, "Id");

            articleCategory.Insert(0, new ArticleCategoryEntity()
            {
                CategoryName = "请选择"
            });
            var selectList = new SelectList(articleCategory, "Id", "CategoryName", articleEntity.CategoryId);

            ViewBag.ArticleCategory = selectList;
            return(View(articleEntity));
        }