コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string columnId = context.Request["cId"];
            string Id       = context.Request["Id"];

            if (!string.IsNullOrEmpty(columnId) && !string.IsNullOrEmpty(Id))
            {
                List <htmlPara> pList = bll.GetHtmlBAPage(columnId, Id);//上一篇,下一篇
                object          BPage = null, APage = null;
                if (pList.Count == 2)
                {
                    BPage = new { Href = pList[0].titleURL, Title = pList[0].title };
                    APage = new { Href = pList[1].titleURL, Title = pList[1].title };
                }
                else
                {
                    BPage = new { Href = pList[0].titleURL, Title = pList[0].title };
                    APage = new { Href = "javascript:alert('没有了');", Title = "没有了" };
                }
                var data = new
                {
                    BPage,
                    APage
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "BAPage.html");
                context.Response.Write(html);
            }
        }
コード例 #2
0
ファイル: TestHandler.ashx.cs プロジェクト: fbkc/fist_site
        /// <summary>
        /// 更多产品页
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string MoreProduct(HttpContext context)
        {
            string cId  = "21";
            var    data = new
            {
                htmlTitle = "产品栏目",
                hostName,
                hostUrl,
                cId,
                c1Title  = GetParaByCId("1", 1, 10),
                c2Title  = GetParaByCId("2", 1, 10),
                c3Title  = GetParaByCId("3", 1, 10),
                c4Title  = GetParaByCId("4", 1, 10),//工具量具,不显示
                c5Title  = GetParaByCId("5", 1, 10),
                c6Title  = GetParaByCId("6", 1, 10),
                c7Title  = GetParaByCId("7", 1, 10),
                c8Title  = GetParaByCId("8", 1, 10),
                c9Title  = GetParaByCId("9", 1, 10),
                c10Title = GetParaByCId("10", 1, 10),
                c11Title = GetParaByCId("11", 1, 10),
                c12Title = GetParaByCId("12", 1, 10),
                c13Title = GetParaByCId("13", 1, 10),
                c14Title = GetParaByCId("14", 1, 10),
                c15Title = GetParaByCId("15", 1, 10),
                c16Title = GetParaByCId("16", 1, 10),
                c17Title = GetParaByCId("17", 1, 10),
                c18Title = GetParaByCId("18", 1, 10),
                c19Title = GetParaByCId("19", 1, 10)
            };

            return(SqlHelperCatalog.WriteTemplate(data, "MoreProduct.html"));
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            StringBuilder _strContent = new StringBuilder();

            if (_strContent.Length == 0)
            {
                string _strAction = context.Request.Params["action"];
                if (string.IsNullOrEmpty(_strAction))
                {
                    _strContent.Append(_strContent.Append(SqlHelperCatalog.WriteTemplate("", "404.html")));
                }
                else
                {
                    switch (_strAction.Trim())
                    {
                    case "MainPage": _strContent.Append(MainPage(context)); break;        //主页

                    case "GetProduct": _strContent.Append(GetProduct(context)); break;    //栏目,产品列表页

                    case "DetailPage": _strContent.Append(DetailPage(context)); break;    //渲染动态详情页,伪静态可用

                    case "sitemap": _strContent.Append(SiteMapXML(context)); break;       //站点地图XML

                    case "sitemap.html": _strContent.Append(SiteMapHtml(context)); break; //站点地图Html

                    default: break;
                    }
                }
            }
            context.Response.Write(_strContent.ToString());
        }
コード例 #4
0
ファイル: TestHandler.ashx.cs プロジェクト: fbkc/fist_site
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            StringBuilder _strContent = new StringBuilder();

            if (_strContent.Length == 0)
            {
                string _strAction = context.Request.Params["action"];
                if (string.IsNullOrEmpty(_strAction))
                {
                    _strContent.Append(_strContent.Append(SqlHelperCatalog.WriteTemplate("", "404.html")));
                }
                else
                {
                    switch (_strAction.Trim())
                    {
                    case "MainPage": _strContent.Append(MainPage(context)); break;

                    case "GetProduct": _strContent.Append(GetProduct(context)); break;   //产品列表

                    case "GetNews": _strContent.Append(GetNews(context)); break;         //新闻列表

                    case "MoreProduct": _strContent.Append(MoreProduct(context)); break; //更多产品

                    case "MoreNews": _strContent.Append(MoreNews(context)); break;       //更多新闻

                    case "DetailPage": _strContent.Append(DetailPage(context)); break;   //渲染详情页

                    default: break;
                    }
                }
            }
            context.Response.Write(_strContent.ToString());
        }
コード例 #5
0
        /// <summary>
        /// 渲染详情页,伪静态
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string DetailPage(HttpContext context)
        {
            string columnId = context.Request["cId"];
            string Id       = context.Request["Id"];

            if (string.IsNullOrEmpty(columnId) || string.IsNullOrEmpty(Id))
            {
                return(SqlHelperCatalog.WriteTemplate("", "404.html"));
            }
            try
            {
                htmlPara hInfo       = bll.GetHtmlPara(columnId, Id);
                string   keyword     = ""; //关键词
                string   description = ""; //描述
                if (hInfo.title.Length > 6)
                {
                    keyword = hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2);
                }
                else
                {
                    keyword = hInfo.title;
                }
                description = hInfo.title + "," + BLL.ReplaceHtmlTag(hInfo.articlecontent, 80)
                              .Replace("\r\n", "").Replace("<br/>", "").Replace("\r", "").Replace("\n", "").Replace("&nbsp;", "") + "...";//产品简介;//产品简介
                #region  一篇,下一篇
                List <string>   BAPage = new List <string>();
                List <htmlPara> pList  = bll.GetHtmlBAPage(columnId, Id);//上一篇,下一篇
                if (pList.Count == 1)
                {
                    BAPage.Add("上一篇:<a href = '" + pList[0].titleURL + "' >" + pList[0].title + "</a> <br />");//上一篇
                }
                if (pList.Count == 2)
                {
                    BAPage.Add("上一篇:<a href = '" + pList[0].titleURL + "' >" + pList[0].title + "</a> <br />");
                    BAPage.Add("下一篇:<a href = '" + pList[1].titleURL + "' >" + pList[1].title + "</a> <br />");//下一篇
                }
                #endregion
                var data = new
                {
                    htmlTitle = hInfo.title + "_" + hInfo.companyName,
                    hInfo,
                    keyword,
                    description,
                    hostUrl,
                    hostName,
                    columnName  = bll.GetColumns(" where Id=" + columnId)[0].columnName,
                    columnsList = bll.GetColumns(""),                   //导航
                    BAPage,
                    ProductFloat = bll.GetProFloat(hInfo.userId, "22"), //右侧浮动10条产品
                    NewsFloat    = bll.GetNewsFloat(hInfo.userId, "22") //右侧浮动10条新闻
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "DetailModel.html");
                return(html);
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
        }
コード例 #6
0
        /// <summary>
        /// siteMap XML
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string SiteMapXML(HttpContext context)
        {
            context.Response.ContentType = "application/xml;charset=utf-8";
            List <htmlPara> hInfo = bll.GetXML();
            var             data  = new
            {
                hInfo
            };
            string html = SqlHelperCatalog.WriteTemplate(data, "sitemap.xml");

            return(html);
        }
コード例 #7
0
        /// <summary>
        /// 主页
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string MainPage(HttpContext context)
        {
            var data = new
            {
                htmlTitle = hostName,
                hostName,
                hostUrl,
                columnsList  = bll.GetColumns(""),          //导航
                productTitle = bll.GetHtmlList("50", "22"), //最新产品,无分类
                newsTitle    = bll.GetHtmlList("22", 1, 50) //最新新闻
            };

            return(SqlHelperCatalog.WriteTemplate(data, "MainPage.html"));
        }
コード例 #8
0
        /// <summary>
        /// siteMap Html
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string SiteMapHtml(HttpContext context)
        {
            List <htmlPara> hInfo = bll.GetXML();
            var             data  = new
            {
                hInfo,
                htmlTitle = hostName,
                hostName,
                hostUrl,
                columnsList = bll.GetColumns(""),//导航
            };

            return(SqlHelperCatalog.WriteTemplate(data, "sitemap.html"));
        }
コード例 #9
0
ファイル: TestHandler.ashx.cs プロジェクト: fbkc/fist_site
        /// <summary>
        /// 更多新闻页
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string MoreNews(HttpContext context)
        {
            string cId  = "22";
            var    data = new
            {
                htmlTitle = "新闻栏目",
                hostName,
                hostUrl,
                cId,
                newsTitle = GetParaByCId("20", 1, 30)
            };

            return(SqlHelperCatalog.WriteTemplate(data, "MoreNews.html"));
        }
コード例 #10
0
ファイル: TestHandler.ashx.cs プロジェクト: fbkc/fist_site
        /// <summary>
        /// 主页
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string MainPage(HttpContext context)
        {
            var data = new
            {
                htmlTitle = hostName,
                hostName,
                hostUrl,
                columnsList  = bll.GetColumns(""),         //导航
                lunboTitle   = GetParaByCId("20", 1, 6),   //轮播标题,推荐新闻
                tuijianTitle = GetNoNewsByCId("12", "20"), //推荐产品
                productTitle = GetNoNewsByCId("30", "20"), //最新产品,无分类
                newsTitle    = GetParaByCId("20", 1, 30)   //最新新闻
            };

            return(SqlHelperCatalog.WriteTemplate(data, "MainPage.html"));
        }
コード例 #11
0
ファイル: TestHandler.ashx.cs プロジェクト: fbkc/fist_site
        /// <summary>
        /// 新闻列表页
        /// </summary>
        /// <param name="context"></param>
        /// <param name="cId"></param>
        /// <returns></returns>
        public string GetNews(HttpContext context)
        {
            int pageIndex = 1;

            if (context.Request["pageIndex"] != null)
            {
                try
                {
                    pageIndex = int.Parse(context.Request["pageIndex"]);
                }
                catch
                {
                }
            }
            string cId       = context.Request["cId"];
            int    paraTotal = bll.GetPageTotal(cId);               //此行业总条数
            int    pageCount = (int)Math.Ceiling(paraTotal / 20.0); //总页数(每页20条)

            object[] pageData = new object[pageCount];
            for (int i = 0; i < pageCount; i++)
            {
                pageData[i] = new { Href = "http://hyzx.100dh.cn/handler/TestHandler.ashx?action=GetNews&cId=" + cId + "&pageIndex=" + (i + 1), Title = i + 1 };
            }
            var data = new
            {
                htmlTitle = "新闻栏目",
                hostName,
                hostUrl,
                cId,
                columnsList = bll.GetColumns(""), //导航
                columnName  = bll.GetColumns("where Id=" + cId)[0].columnName,
                paraTotal,                        //总条数
                pageIndex,                        //当前页
                pageData,                         //页码渲染
                pageCount,                        //总页数
                newsList    = GetParaByCId("20", pageIndex, 20),
                productList = GetNoNewsByCId("20", "20")
            };

            return(SqlHelperCatalog.WriteTemplate(data, "News.html"));
        }
コード例 #12
0
ファイル: TestHandler.ashx.cs プロジェクト: fbkc/fist_site
        public string DetailPage(HttpContext context)
        {
            string columnId = context.Request["cId"];
            string Id       = context.Request["Id"];

            if (string.IsNullOrEmpty(columnId) || string.IsNullOrEmpty(Id))
            {
                return(SqlHelperCatalog.WriteTemplate("", "404.html"));
            }
            try
            {
                htmlPara hInfo   = bll.GetHtmlPara(columnId, Id);
                string   keyword = "";//关键词
                if (hInfo.title.Length > 6)
                {
                    keyword = hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2);
                }
                else
                {
                    keyword = hInfo.title;
                }
                var data = new
                {
                    title = hInfo.title + "_" + hInfo.companyName,
                    hInfo,
                    keyword,
                    description  = BLL.ReplaceHtmlTag(hInfo.articlecontent, 80),//产品简介
                    host         = hostUrl,
                    ProductFloat = bll.GetProFloat(hInfo.userId),
                    NewsFloat    = bll.GetNewsFloat(hInfo.userId)
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "DetailModel.html");
                return(html);
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
        }
コード例 #13
0
        /// <summary>
        /// 产品列表页
        /// </summary>
        /// <param name="context"></param>
        /// <param name="cId"></param>
        /// <returns></returns>
        public string GetProduct(HttpContext context)
        {
            int pageIndex = 1;

            if (context.Request["pageIndex"] != null)
            {
                try
                {
                    pageIndex = int.Parse(context.Request["pageIndex"]);
                }
                catch
                {
                }
            }
            string        cId       = context.Request["cId"];
            int           paraTotal = bll.GetPageTotal(cId);               //此行业总条数
            int           pageCount = (int)Math.Ceiling(paraTotal / 20.0); //总页数(每页20条)
            List <object> pageData  = new List <object>();

            if (pageCount > 8)
            {
                if (pageIndex > 4)
                {
                    int maxIndex = pageIndex + 4;
                    if (maxIndex > pageCount)
                    {
                        maxIndex = pageCount;
                    }
                    for (int i = pageIndex - 5; i < maxIndex; i++)
                    {
                        pageData.Add(new { Href = "list-" + cId + "-" + (i + 1), Title = i + 1 });
                    }
                }
                else
                {
                    for (int i = 0; i < 9; i++)
                    {
                        pageData.Add(new { Href = "list-" + cId + "-" + (i + 1), Title = i + 1 });
                    }
                }
            }
            else
            {
                for (int i = 0; i < pageCount; i++)
                {
                    pageData.Add(new { Href = "list-" + cId + "-" + (i + 1), Title = i + 1 });
                }
            }
            string            columnName  = "";
            List <columnInfo> columnsList = bll.GetColumns("");//导航

            foreach (columnInfo c in columnsList)
            {
                if (c.Id.ToString() == cId)
                {
                    columnName = c.columnName;
                }
            }
            var data = new
            {
                htmlTitle = columnName + "_" + hostName,
                hostName,
                hostUrl,
                cId,
                columnsList,                                     //导航
                columnName,                                      //栏目名称
                paraTotal,                                       //总条数
                pageIndex,                                       //当前页
                pageData,                                        //页码渲染
                pageCount,                                       //总页数
                productList      = bll.GetHtmlList(cId, pageIndex, 20),
                newsList         = bll.GetHtmlList("22", 1, 20), //右侧浮动栏新闻20条
                productListNocId = bll.GetHtmlList("20", "22")   //右侧浮动栏产品20条(非新闻,cId!=22)
            };

            return(SqlHelperCatalog.WriteTemplate(data, "Product.html"));
        }
コード例 #14
0
        public string ModuleHtml(HttpContext context)
        {
            //需要做一个时间,每隔多长时间才允许访问一次
            string keyValue = NetHelper.GetMD5("liu" + "100dh888");
            string url      = "";
            string key      = context.Request["key"];

            if (key != keyValue)
            {
                return(json.WriteJson(0, "key值错误", new { }));
            }
            string username = context.Request["username"];

            if (string.IsNullOrEmpty(username))
            {
                return(json.WriteJson(0, "用户名不能为空", new { }));
            }
            try
            {
                htmlPara hInfo = new htmlPara();
                hInfo.userId = bll.GetUserId(username);//用户名
                hInfo.title  = context.Request["title"];
                string cid = context.Request["catid"];
                if (string.IsNullOrEmpty(cid))
                {
                    return(json.WriteJson(0, "行业或栏目不能为空", new { }));
                }
                hInfo.columnId = cid;//行业id,行业新闻id=20
                string content = context.Request["content"];
                if (string.IsNullOrEmpty(content) || content.Length < 500)
                {
                    return(json.WriteJson(0, "文章不能少于500字,请丰富文章内容", new { }));
                }
                hInfo.articlecontent = content;
                //hInfo.articlecontent = HttpUtility.UrlDecode(jo["content"].ToString(), Encoding.UTF8);//内容,UrlDecode解码
                //命名规则:ip/目录/用户名/show_行业id+(五位数id)
                long htmlId = (bll.GetMaxId() + 1);
                hInfo.Id = htmlId;
                string showName = "show_" + cid + "_" + htmlId + ".html";
                url            = host + username + "/" + showName;
                hInfo.titleURL = url;
                //hInfo.titleURL = string.Format("handler/TestHandler.ashx?action=DetailPage&cId={0}&Id={1}", cid, htmlId);
                //url = host + hInfo.titleURL;
                hInfo.pinpai     = context.Request["pinpai"];
                hInfo.xinghao    = context.Request["xinghao"];
                hInfo.price      = context.Request["price"];
                hInfo.smallCount = context.Request["qiding"];
                hInfo.sumCount   = context.Request["gonghuo"];
                hInfo.unit       = context.Request["unit"];
                hInfo.city       = context.Request["city"];
                hInfo.titleImg   = context.Request["thumb"];
                hInfo.addTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                hInfo.username   = username;
                //公司 / 会员信息
                cmUserInfo uInfo = bll.GetUser(string.Format("where username='******'", username));
                hInfo.companyName = uInfo.companyName;
                hInfo.com_web     = uInfo.com_web;
                //hInfo.realmNameId = "1";//发到哪个站
                bll.AddHtml(hInfo);      //存入数据库

                string keyword     = ""; //关键词
                string description = ""; //描述
                if (hInfo.title.Length > 6)
                {
                    keyword = hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2);
                }
                else
                {
                    keyword = hInfo.title;
                }
                description = BLL.ReplaceHtmlTag(hInfo.articlecontent, 80);//产品简介
                var data = new
                {
                    title = hInfo.title + "_" + hInfo.companyName,
                    hInfo,
                    keyword,
                    description,
                    host,
                    columnName   = bll.GetColumns(" where Id=" + cid)[0].columnName,
                    ProductFloat = bll.GetProFloat(hInfo.userId),
                    NewsFloat    = bll.GetNewsFloat(hInfo.userId)
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "DetailModel.html");
                WriteFile(html, showName, username);//写模板
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
            return(json.WriteJson(1, "发布成功", new { url, username }));
        }