예제 #1
0
        // GET: Article/Edit/5
        public ActionResult Edit(int id)
        {
            SystemFail error   = new SystemFail();
            Article    article = ArticleBLL.GetArticleById(id, error);


            return(View(article));
        }
예제 #2
0
        public ArticleSetting(decimal MerId)
        {
            BLL.ArticleBLL bll = new ArticleBLL();
            CheckMerBind(MerId);


            ds_Article = bll.GetArticleById("0", MerId);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["articleid"] != "" || Request["articleid"] != null)
            {
                string id = Context.Request["articleid"];

                model = bll.GetArticleById(id);
                if (model.ArticleCategory == 0)
                {
                    Response.Redirect("error.html");
                }

                if (model.ArticleAnnexAddr != "")
                {
                    string[] pathUrl = bll.GetAnnexAddrByAnnex(model.ArticleAnnexAddr);
                    string[] sp      = null;
                    if (model.ArticleAnnexAddr.IndexOf(',') > 0)
                    {
                        sp = model.ArticleAnnexAddr.Split(',');
                    }
                    else
                    {
                        sp = new string[] { model.ArticleAnnexAddr }
                    };
                    aAnnex = GenerateATagByAnnex(pathUrl, sp);
                }

                //上下篇
                List <T_Article> lastArticleList = bll.GetLastArticle(id, model.ArticleCategory);
                List <T_Article> nextArticleList = bll.GetNextArticle(id, model.ArticleCategory);
                if (lastArticleList.Count > 0)
                {
                    lastArticleHref  = "articleDetail.aspx?articleId=" + lastArticleList[0].ArticleId;
                    lastArticleTitle = lastArticleList[0].ArticleTitle;
                }
                else
                {
                    lastArticleHref  = "";
                    lastArticleTitle = "没有了";
                }
                if (nextArticleList.Count > 0)
                {
                    nextArticleHref  = "articleDetail.aspx?articleId=" + nextArticleList[0].ArticleId;
                    nextArticleTitle = nextArticleList[0].ArticleTitle;
                }
                else
                {
                    nextArticleHref  = "";
                    nextArticleTitle = "没有了";
                }
            }
            else
            {
                Response.Redirect("error.html");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request["id"] ?? "00000000";
                model = bll.GetArticleById(id);//直接绑定

                txtid.Text      = model.ArticleId;
                title.Text      = model.ArticleTitle;
                writer.Text     = model.ArticlePostStaff;
                time.Text       = model.ArticleTime;
                resourse.Text   = model.ArticleSector;
                txtcontent.Text = model.ArticleContent;


                //绑定类别下拉菜单
                category.SelectedIndex = model.ArticleCategory - 1;
            }
        }
예제 #5
0
        //中心动态,搜的都是要有图片的新闻
        public string LoadToutiaoNews()
        {
            List <T_Article> list = bll.GetListByContent(5, 2);
            StringBuilder    sb   = new StringBuilder();
            int i = 0;

            foreach (var model in list)
            {
                //获得文章内容的简介
                T_Article first = new T_Article();
                first = bll.GetArticleById(model.ArticleId);

                string ab = Regex.Replace(first.ArticleContent, @"<.*?>", "");
                //如果文字没有超过100个字
                if (ab.Length > 70)
                {
                    ab = ab.Substring(0, 70);
                }
                ab = ab + "...";


                if (i == 0)
                {
                    //第一张提取图片
                    //精简文章主题内容
                    string imgurl = ImgHelper.getImgUrl(first.ArticleContent, @"<img[^>]+src=\s*(?:'(?<src>[^']+)'|""(?<src>[^""]+)""|(?<src>[^>\s]+))\s*[^>]*>", "src")[0].ToString();
                    sb.AppendFormat("<a href='articleDetail.aspx?articleId={0}'><img src='{1}'/></a><h3>{2}</h3><p>{3}</p>", model.ArticleId, imgurl, model.ArticleTitle, ab);
                    sb.AppendFormat("</div><div class='newsright'>");
                }
                else
                {
                    sb.AppendFormat("<a href='articleDetail.aspx?articleId={0}'> <p class='nrtitle'>{1}</p></a><p class='nrtxt' style='font-size:0.84vw;'>{2}</p>", model.ArticleId, model.ArticleTitle, ab);
                }
                i++;
            }
            return(sb.ToString());
        }