Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string type = "全部新闻";
            string temp = File.ReadAllText(context.Server.MapPath("drugstore_news.html"));

            //
            List <NewsModel> newsList = new List <NewsModel>();

            if (context.Request.QueryString["type"] != null)
            {
                int newsType = Int32.Parse(context.Request.QueryString["type"].ToString());
                newsList = NewsBLL.GetNewsListByType(newsType);
            }
            else
            {
                newsList = NewsBLL.GetHotNewsList();
            }

            StringBuilder sb = new StringBuilder();

            int count = 1;

            if (newsList != null)
            {
                foreach (NewsModel item in newsList)
                {
                    //item["News_newstype"]

                    string newsTypeName = NewsTypeBLL.GetNameById(item.NewsType);
                    sb.AppendFormat("<tr><td>{0}</td><td><a href='ProcessNewsDetail.ashx?news_id={1}'>{2}</a></td><td>{3}</td><td>{4}</td></tr>", count, item.NewsId, item.NewsTitle, item.NewsViewCount.ToString(), newsTypeName);
                    count++;
                }
            }


            List <NewsTypeModel> newsTypeList = NewsTypeBLL.GetNewsList();
            StringBuilder        sb3          = new StringBuilder();

            foreach (NewsTypeModel item in newsTypeList)
            {
                sb3.AppendFormat("<a href='ProcessNews.ashx?type={0}' class='list-group-item'>{1}</a>", item.NewsTypeid, item.NewsTypename);
            }


            temp = temp.Replace("@news_type", sb3.ToString());
            temp = temp.Replace("@type", type);
            temp = temp.Replace("@content", sb.ToString());
            if (context.Session["users_id"] != null)
            {
                temp = temp.Replace("@user_name", context.Session["user_name"].ToString());
            }
            else
            {
                temp = temp.Replace("@user_name", "游客");
            }
            context.Response.Write(temp);
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            if (context.Session["id"] != null)
            {
                string temp = File.ReadAllText(context.Server.MapPath("drugstore_admin_news.html"));

                List <NewsModel> newsList = NewsBLL.GetNewsList();
                StringBuilder    sb       = new StringBuilder();
                foreach (NewsModel item in newsList)
                {
                    string newsTypeName = NewsTypeBLL.GetNameById(item.NewsType);
                    sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='ProcessAdminDeleteNews.ashx?news_id={0}' class='btn btn-danger'>删除</a>&nbsp;<a href='ProcessAdminNewsSaveIndex.ashx?news_id={0}' class='btn btn-primary'>修改</a>&nbsp;<a href='ProcessAdminNewsPreview.ashx?news_id={0}' class='btn btn-warning'>预览</a></td></tr>", item.NewsId, item.NewsTitle, item.NewsViewCount, item.NewsSource, newsTypeName);
                }
                temp = temp.Replace("@content", sb.ToString());
                temp = temp.Replace("@admin", context.Session["admin_name"].ToString());
                context.Response.Write(temp);
            }
            else
            {
                context.Response.Redirect("~/admin_login.html");
            }
        }