예제 #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));
        }
예제 #2
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());
        }
예제 #3
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());
        }
예제 #4
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));
        }
예제 #5
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));
        }
예제 #6
0
        public ActionResult ArticleCategorySelect()
        {
            object area;

            Request.RequestContext.RouteData.DataTokens.TryGetValue("area", out area);

            ArticleCategoryBLL           articleCategoryBLL = new ArticleCategoryBLL();
            List <SqlDbParameter>        parms           = new List <SqlDbParameter>();
            List <ArticleCategoryEntity> articleCategory = articleCategoryBLL.GetAllArticleCategory(parms, "Id");

            return(PartialView(articleCategory));
        }
예제 #7
0
        public string Edit(ArticleCategoryEntity articleCategoryUpdate)
        {
            ArticleCategoryBLL    articleCategoryBLL    = new ArticleCategoryBLL();
            ArticleCategoryEntity articleCategoryEntity = articleCategoryBLL.GetArticleCategoryEntityById(articleCategoryUpdate.Id);

            articleCategoryEntity.CategoryName = articleCategoryUpdate.CategoryName.UrlDecode(); //分类名
            articleCategoryEntity.Order        = articleCategoryUpdate.Order;
            articleCategoryBLL.UpdateArticleCategoryEntity(articleCategoryEntity);

            return(JsonConvert.SerializeObject(new { result = true, message = "", returnUrl = "/Admin/Journal/Index" }));

            return(JsonConvert.SerializeObject(new { result = false, message = "" }));
        }
예제 #8
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));
        }
예제 #9
0
        public string GetList()
        {
            ArticleCategoryBLL    articleCategoryBLL = new ArticleCategoryBLL();
            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"]);
            //length = length == 0 ? 100 : length;
            //int page = length > 0 ? start / length : 1; //start 初始值0
            //DataTable dataTable = articleCategoryBLL.GetArticleCategoryDataTablePage(parms, "PId,[Order] ASC", length, page, out recordCount);

            DataTable   dataTable = articleCategoryBLL.GetArticleCategoryDataTable(parms, "PId,[Order] ASC");
            IDictionary info      = new Hashtable();

            info.Add("draw", draw);
            //info.Add("recordsTotal", recordCount);
            //info.Add("recordsFiltered", recordCount);
            info.Add("data", dataTable);
            return(JsonConvert.SerializeObject(info));
        }
예제 #10
0
        public string GetCategory()
        {
            ArticleCategoryBLL           articleCategoryBLL = new ArticleCategoryBLL();
            List <SqlDbParameter>        parms = new List <SqlDbParameter>();
            List <ArticleCategoryEntity> articleCategoryList = articleCategoryBLL.GetAllArticleCategory(parms, "Id");
            //info.Add("data", articleCategoryList);

            IDictionary info             = new Hashtable();
            ArrayList   selectOptionList = new ArrayList()
            {
            };

            selectOptionList.Add(new SelectOption {
                text = "请选择类别"
            });
            foreach (ArticleCategoryEntity articleCategory in articleCategoryList)
            {
                if (articleCategory.Level == 1)
                {
                    SelectOption option = new SelectOption {
                        id = articleCategory.Id, text = articleCategory.CategoryName
                    };
                    List <ArticleCategoryEntity> subCategory = articleCategoryList.Where(t => t.PId == articleCategory.Id && t.Level.Value == 2).OrderBy(t => t.Order).ToList();
                    if (subCategory.Count > 0)
                    {
                        List <SelectOption> children = new List <SelectOption>();
                        foreach (var item in subCategory)
                        {
                            SelectOption subOption = new SelectOption {
                                id = item.Id, text = item.CategoryName
                            };
                            children.Add(subOption);
                        }
                        option.children = children;
                    }
                    selectOptionList.Add(option);
                }
            }

            /*
             * List<SelectOption> children = new List<SelectOption>();
             * SelectOption option = new SelectOption { id = 11, text = "Grapefruit" };
             * children.Add(option);
             * option = new SelectOption { id = 12, text = "Orange" };
             * children.Add(option);
             * option = new SelectOption { id = 13, text = "Lemon" };
             * children.Add(option);
             * option = new SelectOption { id = 14, text = "Lime" };
             * children.Add(option);
             * selectOptionList.Add(new SelectOption { id = 1, text = "Citrus" , children= children });
             *
             * children = new List<SelectOption>();
             * option = new SelectOption { id = 21, text = "Apple" };
             * children.Add(option);
             * option = new SelectOption { id = 22, text = "Mango" };
             * children.Add(option);
             * option = new SelectOption { id = 23, text = "Banana" };
             * children.Add(option);
             * selectOptionList.Add(new SelectOption { id = 2, text = "Other", children = children });
             *
             * selectOptionList.Add(new SelectOption { id = 3, text = "Demo" });
             */
            info.Add("data", selectOptionList);
            return(JsonConvert.SerializeObject(info));
        }
예제 #11
0
        public ActionResult ListIndex(string type)
        {
            List <ArticleCategoryEntity> categoryList = new List <ArticleCategoryEntity>();  //文章分类信息
            Dictionary <string, string>  listImage    = new Dictionary <string, string>
            {
                { "jt", "tx_25.png" }, //集团新闻
                { "gs", "tx_33.png" }, //公司新闻
                { "yw", "tx_35.png" }, //业务动态
                { "jiaojuguoqi", "jujiaoguoqi.png" }//聚焦国企
            };

            ViewBag.ListIndexImg = listImage[type];//类别图片
            List <SqlDbParameter> parms;
            SqlDbParameter        parm;

            //获取某一期的首页文章列表
            parms                  = new List <SqlDbParameter>();
            parm                   = new SqlDbParameter();
            parm.ColumnName        = "JournalId";
            parm.ParameterName     = "JournalId";
            parm.ParameterValue    = currentJournalEntity.JournalId;//当前期刊Id
            parm.QualificationType = SqlDbParameter.QualificationSymbol.Equal;
            parms.Add(parm);

            //默认条件IsDelete!=1,软删标准
            parm                   = new SqlDbParameter();
            parm.ColumnName        = "IsDelete";
            parm.ParameterName     = "IsDelete";
            parm.QualificationType = SqlDbParameter.QualificationSymbol.IsNull;
            parm.ColumnType        = DbType.Int32;
            parms.Add(parm);

            List <ArticleEntity> resultList = new List <ArticleEntity>();
            ArticleBLL           articleBLL = new ArticleBLL();

            int       categoryId = Constants.ChannelToCategory[type];
            string    top        = "20";
            DataTable dt         = null;

            if (categoryId == 1 || categoryId == 2) //根据类别获取对应文章,集团新闻-1;公司新闻-2;
            {
                ArticleCategoryBLL    articleCategoryBLL = new ArticleCategoryBLL();
                List <SqlDbParameter> categoryParam      = new List <SqlDbParameter>();
                parm                   = new SqlDbParameter();
                parm.ColumnName        = "Id";
                parm.ParameterName     = "Id";
                parm.ColumnType        = DbType.Int32;
                parm.QualificationType = SqlDbParameter.QualificationSymbol.Equal;
                parm.ParameterValue    = categoryId;
                categoryParam.Add(parm);
                categoryList = articleCategoryBLL.GetAllArticleCategory(categoryParam);  //集团新闻无子类别,目前就一条分类记录

                parm                   = new SqlDbParameter();
                parm.ColumnName        = "CategoryId";
                parm.ParameterName     = "CategoryId";
                parm.QualificationType = SqlDbParameter.QualificationSymbol.Equal;
                parm.ParameterValue    = categoryId;
                parms.Add(parm);
                dt = articleBLL.GetArticleDataTable(parms, "NoOfJournal", top);
            }
            else if (categoryId == 3) //业务动态
            {
                //int[] categoryArray = { 6, 7, 8, 9,12,13,14,15};  //外企服务公司-6;关爱通公司-7,培训部-8,工会联合会-9;人才顾问公司-12//TODO 增加文章类别,13:科创公司,14党委,15法律事务部
                //获取"业务动态"子类别,即根据PId获取类别记录
                ArticleCategoryBLL articleCategoryBLL = new ArticleCategoryBLL();
                categoryList = articleCategoryBLL.GetArticleCategoryEntitiesByPId(3, "[Order]");  //获取业务动态下的子类别,3表示业务动态

                List <SqlDbParameter> orParms = new List <SqlDbParameter>();
                for (int i = 0; i < categoryList.Count; i++)
                {
                    SqlDbParameter orParameter = new SqlDbParameter();
                    orParameter.ColumnName     = "CategoryId";
                    orParameter.ParameterName  = "CategoryId_" + i;
                    orParameter.ColumnType     = DbType.Int32;
                    orParameter.ParameterValue = categoryList[i].Id;
                    orParms.Add(orParameter);
                }
                parm = new SqlDbParameter();
                parm.QualificationType = SqlDbParameter.QualificationSymbol.Or;
                parm.SqlDbParameters   = orParms;
                parm.ParameterName     = "CategoryId";
                parm.ParameterValue    = 0; //必须设置
                parms.Add(parm);
                dt = articleBLL.GetArticleDataTable(parms, "NoOfJournal", top);
            }
            else if (categoryId == 4)//聚焦国企  逻辑和"业务动态"一样
            {
                //int[] categoryArray = {10, 11 };  //国资要闻-10; 改革前沿-11
                ArticleCategoryBLL articleCategoryBLL = new ArticleCategoryBLL();
                categoryList = articleCategoryBLL.GetArticleCategoryEntitiesByPId(4, "Id");  //聚焦国企有2个子类别

                List <SqlDbParameter> orParms = new List <SqlDbParameter>();
                for (int i = 0; i < categoryList.Count; i++)
                {
                    SqlDbParameter orParameter = new SqlDbParameter();
                    orParameter.ColumnName     = "CategoryId";
                    orParameter.ParameterName  = "CategoryId_" + i;
                    orParameter.ColumnType     = DbType.Int32;
                    orParameter.ParameterValue = categoryList[i].Id;
                    orParms.Add(orParameter);
                }
                parm = new SqlDbParameter();
                parm.QualificationType = SqlDbParameter.QualificationSymbol.Or;
                parm.SqlDbParameters   = orParms;
                parm.ParameterName     = "CategoryId";
                parm.ParameterValue    = 0;                                     //必须设置
                parms.Add(parm);
                dt = articleBLL.GetArticleDataTable(parms, "NoOfJournal", top); //文章类别信息中包含文章静态URL模板
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ArticleEntity article = new ArticleEntity();
                article.Id           = int.Parse(dt.Rows[i]["Id"].ToString());
                article.ArticleTitle = dt.Rows[i]["ArticleTitle"].ToString();
                article.CategoryId   = int.Parse(dt.Rows[i]["CategoryId"].ToString());
                article.NoOfCategory = short.Parse(dt.Rows[i]["NoOfCategory"].ToString());
                article.HrefTpl      = dt.Rows[i]["HrefTpl"].ToString();
                ArticleCategoryEntity categoryEntity = categoryList.First(t => t.Id == article.CategoryId);//拼接文章分类信息
                article.CategoryName = categoryEntity == null ? "未分类" : categoryEntity.CategoryName;
                //article.Href = string.Format(dt.Rows[i]["HrefTpl"].ToString(), dt.Rows[i]["NoOfCategory"].ToString().PadLeft(2, '0'));
                resultList.Add(article);
            }

            //静态持久化
            string viewPath = @"~/Views/Home/ListIndex.cshtml"; //其它频道文章列表页

            if (type == "yw" || type == "jiaojuguoqi")
            {
                viewPath = "~/Views/Home/ListIndexYW.cshtml";
            }
            if (Request.QueryString["static"] == "1")
            {
                string html      = CommentHelper.RenderViewToString(this.ControllerContext, viewPath, new ChannlModel(categoryList, resultList));
                string outputDir = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["HtmlOutput"]) + "\\" + currentJournalEntity.JournalName + "\\";
                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
                System.IO.File.WriteAllText(outputDir + base.currentURL, html);
            }
            if (type == "yw" || type == "jiaojuguoqi")
            {
                return(View(viewPath, new ChannlModel(categoryList, resultList)));
            }
            return(View(new ChannlModel(categoryList, resultList)));

            return(View(resultList));
        }