Beispiel #1
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());
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        /// <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"));
        }
Beispiel #4
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 "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());
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="columnId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlList(string count, string columnId)
        {
            //分页查询
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top (CONVERT(int,@count)) * from htmlPara where columnId !='@columnId' order by addTime desc",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@count", count));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.userId   = row["userId"].ToString();
                hPara.title    = (string)row["title"];
                hPara.titleImg = (string)row["titleImg"];
                hPara.titleURL = (string)row["titleURL"];
                hPara.columnId = (string)row["columnId"];                                //栏目Id
                string content = (string)row["articlecontent"];
                hPara.articlecontent = ReplaceHtmlTag(content, 60);                      //产品简介
                hPara.city           = (string)row["city"];                              //生产城市
                hPara.smallCount     = (string)row["smallCount"];                        //起订
                hPara.companyName    = (string)SqlHelper.FromDBNull(row["companyName"]); //公司名字
                hPara.ten_qq         = (string)SqlHelper.FromDBNull(row["ten_qq"]);
                hPara.com_web        = (string)SqlHelper.FromDBNull(row["com_web"]);     //网址
                hPara.addTime        = ((DateTime)row["addTime"]).ToString("yyyy-MM-dd");
                hList.Add(hPara);
            }
            return(hList);
        }
Beispiel #6
0
        /// <summary>
        /// 获取目录主页内容
        /// </summary>
        /// <param name="sqlstr"></param>
        /// <returns></returns>
        public List <htmlInfo> GetMainHtmlList()
        {
            List <htmlInfo> hList = new List <htmlInfo>();
            //            DataTable dt = SqlHelper.ExecuteDataSet(@"select title,titleImg,titleURL,addTime,columnId,columnName from
            //( select
            //RANK()OVER(PARTITION BY columnInfo.Id ORDER BY htmlInfo.addTime DESC) AS
            //RANK2, title,titleImg,titleURL,addTime,htmlInfo.columnId,columnName from
            //htmlInfo left join columnInfo On htmlInfo.columnId = columnInfo.Id) T
            //where RANK2<=10 ").Tables[0];
            DataTable dt = SqlHelperCatalog.ExecuteDataSet(@"select  title,titleURL,titleImg,addTime,columnId from 
( select 
RANK()OVER(PARTITION BY columnId ORDER BY addTime DESC) AS
RANK2, title,titleImg,titleURL,addTime,columnId from 
htmlPara ) T
where RANK2<=10").Tables[0];

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlInfo hInfo = new htmlInfo();
                hInfo.title    = (string)row["title"];
                hInfo.titleImg = (string)row["titleImg"];
                hInfo.titleURL = (string)row["titleURL"];
                hInfo.columnId = (string)row["columnId"];//栏目Id
                hInfo.addTime  = row["addTime"].ToString();
                //hInfo.realmNameId = (string)row["realmNameId"];//目录名
                hList.Add(hInfo);
            }
            return(hList);
        }
Beispiel #7
0
        /// <summary>
        /// 标题存储成功后返回titleUrl
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string GetTitleUrl(string userId)
        {
            object tUrl = SqlHelperCatalog.ExecuteScalar("select top 1 titleURL from htmlPara where userId=@userId order by Id desc",
                                                         new SqlParameter("@userId", SqlHelper.ToDBNull(userId)));

            return(tUrl.ToString());
        }
Beispiel #8
0
        /// <summary>
        /// 获取栏目页网页
        /// </summary>
        /// <param name="columnId">行业类别</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页条数</param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlList(string columnId, int pageIndex, int pageSize)
        {
            //分页查询
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select * from 
                (select *, ROW_NUMBER() OVER(order by addTime desc) AS RowId from htmlPara where columnId=@columnId) as b where b.RowId between @startNum and @endNum",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@startNum", (pageIndex - 1) * pageSize + 1),
                                                                      new SqlParameter("@endNum", pageIndex * pageSize));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.userId   = row["userId"].ToString();
                hPara.title    = (string)row["title"];
                hPara.titleImg = (string)row["titleImg"];
                hPara.titleURL = (string)row["titleURL"];
                hPara.columnId = (string)row["columnId"];                                //栏目Id
                string content = (string)row["articlecontent"];
                hPara.articlecontent = ReplaceHtmlTag(content, 60);                      //产品简介
                hPara.city           = (string)row["city"];                              //生产城市
                hPara.smallCount     = (string)row["smallCount"];                        //起订
                hPara.companyName    = (string)SqlHelper.FromDBNull(row["companyName"]); //公司名字
                hPara.ten_qq         = (string)SqlHelper.FromDBNull(row["ten_qq"]);
                hPara.com_web        = (string)SqlHelper.FromDBNull(row["com_web"]);     //网址
                hPara.addTime        = ((DateTime)row["addTime"]).ToString("yyyy-MM-dd");
                hList.Add(hPara);
            }
            return(hList);
        }
Beispiel #9
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 { }));
            }
        }
Beispiel #10
0
    /// <summary>
    /// 将html内容参数存入数据库
    /// </summary>
    /// <param name="info"></param>
    public void AddHtml(htmlPara info)
    {
        int a = SqlHelperCatalog.ExecuteNonQuery(@"INSERT INTO htmlPara
     ([title]
       ,[titleURL]
       ,[articlecontent]
       ,[columnId]
       ,[pinpai]
       ,[xinghao]
       ,[price]
       ,[smallCount]
       ,[sumCount]
       ,[unit]
       ,[city]
       ,[titleImg]
       ,[addTime]
       ,[ten_qq]
       ,[companyName]
       ,[com_web]
       ,[userId]
       ,[userName])
 VALUES
       (@title
       ,@titleURL+CONVERT(varchar(10), IDENT_CURRENT('htmlPara'))+'.html'
       ,@articlecontent
       ,@columnId
       ,@pinpai
       ,@xinghao
       ,@price
       ,@smallCount
       ,@sumCount
       ,@unit
       ,@city
       ,@titleImg
       ,@addTime
       ,@ten_qq
       ,@companyName
       ,@com_web
       ,@userId
       ,@userName)",
                                                 new SqlParameter("@title", SqlHelper.ToDBNull(info.title)),
                                                 new SqlParameter("@titleURL", SqlHelper.ToDBNull(info.titleURL)),
                                                 new SqlParameter("@articlecontent", SqlHelper.ToDBNull(info.articlecontent)),
                                                 new SqlParameter("@columnId", SqlHelper.ToDBNull(info.columnId)),
                                                 new SqlParameter("@pinpai", SqlHelper.ToDBNull(info.pinpai)),
                                                 new SqlParameter("@xinghao", SqlHelper.ToDBNull(info.xinghao)),
                                                 new SqlParameter("@price", SqlHelper.ToDBNull(info.price)),
                                                 new SqlParameter("@smallCount", SqlHelper.ToDBNull(info.smallCount)),
                                                 new SqlParameter("@sumCount", SqlHelper.ToDBNull(info.sumCount)),
                                                 new SqlParameter("@unit", SqlHelper.ToDBNull(info.unit)),
                                                 new SqlParameter("@city", SqlHelper.ToDBNull(info.city)),
                                                 new SqlParameter("@titleImg", SqlHelper.ToDBNull(info.titleImg)),
                                                 new SqlParameter("@addTime", SqlHelper.ToDBNull(info.addTime)),
                                                 new SqlParameter("@ten_qq", SqlHelper.ToDBNull(info.ten_qq)),
                                                 new SqlParameter("@companyName", SqlHelper.ToDBNull(info.companyName)),
                                                 new SqlParameter("@com_web", SqlHelper.ToDBNull(info.com_web)),
                                                 new SqlParameter("@userId", SqlHelper.ToDBNull(info.userId)),
                                                 new SqlParameter("@userName", SqlHelper.ToDBNull(info.username)));
    }
Beispiel #11
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);
        }
Beispiel #12
0
        /// <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"));
        }
Beispiel #13
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"));
        }
Beispiel #14
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"));
        }
Beispiel #15
0
        /// <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"));
        }
Beispiel #16
0
        /// <summary>
        /// 获取当前表最大Id
        /// </summary>
        /// <returns></returns>
        public int GetMaxId()
        {
            object ob = "";

            try
            {
                ob = SqlHelperCatalog.ExecuteScalar("select Id  from htmlPara order by Id desc");
                if (ob == null)
                {
                    ob = 0;
                }
            }
            catch (Exception ex)
            { return(1); }
            return(int.Parse(ob.ToString()));
        }
Beispiel #17
0
        /// <summary>
        /// 获取栏目信息
        /// </summary>
        /// <param name="sqlstr"></param>
        /// <returns></returns>
        public List <columnInfo> GetColumns(string sqlstr)
        {
            List <columnInfo> cList = new List <columnInfo>();
            DataTable         dt    = SqlHelperCatalog.ExecuteDataTable("select * from columnInfo " + sqlstr);

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                columnInfo cInfo = new columnInfo();
                cInfo.Id         = (int)row["Id"];
                cInfo.columnName = (string)row["columnName"];
                cList.Add(cInfo);
            }
            return(cList);
        }
Beispiel #18
0
        /// <summary>
        /// XML
        /// </summary>
        /// <returns></returns>
        public List <htmlPara> GetXML()
        {
            List <htmlPara> hParaList = new List <htmlPara>();
            DataTable       dt        = SqlHelperCatalog.ExecuteDataTable("select top 1000 Id, title,titleURL,addTime from htmlPara order by Id desc");

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
                hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
                hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
                hPara.addTime  = ((DateTime)SqlHelper.FromDBNull(row["addTime"])).ToString("yyyy-MM-dd");
                hParaList.Add(hPara);
            }
            return(hParaList);
        }
Beispiel #19
0
        /// <summary>
        /// 右侧浮动栏,前十条新闻
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <htmlPara> GetNewsFloat(string userId)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top 10 * from htmlPara where userId=1 and columnId=20 order by addTime desc",
                                                                      new SqlParameter("@userId", userId));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.title    = (string)row["title"];
                hPara.titleURL = row["titleURL"].ToString();
                hList.Add(hPara);
            }
            return(hList);
        }
Beispiel #20
0
        /// <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"));
        }
Beispiel #21
0
        /// <summary>
        /// 右侧浮动栏,前十条公司产品
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <htmlPara> GetProFloat(string userId, string cId)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top 10 Id,title,titleURL from htmlPara where userId=@userId and columnId!=@columnId order by addTime desc",
                                                                      new SqlParameter("@userId", userId),
                                                                      new SqlParameter("@columnId", cId));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
                hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
                hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
                hList.Add(hPara);
            }
            return(hList);
        }
Beispiel #22
0
        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 { }));
            }
        }
Beispiel #23
0
        /// <summary>
        /// 获取前多少条数据
        /// </summary>
        /// <param name="count">条数</param>
        /// <param name="columnId">栏目Id</param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlList(string count, string columnId)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top (CONVERT(int,@count)) Id,title,titleURL,addTime from htmlPara where columnId !='@columnId' order by addTime desc",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@count", count));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
                hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
                hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
                hPara.addTime  = ((DateTime)SqlHelper.FromDBNull(row["addTime"])).ToString("yyyy-MM-dd");
                hList.Add(hPara);
            }
            return(hList);
        }
Beispiel #24
0
        /// <summary>
        /// 获取单条信息
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="columnId"></param>
        /// <returns></returns>
        public htmlPara GetHtmlPara(string columnId, string Id)
        {
            htmlPara  hPara = new htmlPara();
            DataTable dt    = SqlHelperCatalog.ExecuteDataTable(@"select * from htmlPara h left join columnInfo c on h.columnId=c.Id  where columnId =@columnId and h.Id=@Id",
                                                                new SqlParameter("@columnId", columnId),
                                                                new SqlParameter("@Id", Id));

            if (dt.Rows.Count != 1)
            {
                return(null);
            }
            DataRow row = dt.Rows[0];

            hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
            hPara.userId   = SqlHelper.FromDBNull(row["userId"]).ToString();
            hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
            hPara.titleImg = (string)SqlHelper.FromDBNull(row["titleImg"]);
            hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
            hPara.columnId = (string)SqlHelper.FromDBNull(row["columnId"]);//栏目Id
            string content = (string)SqlHelper.FromDBNull(row["articlecontent"]);

            //hPara.articlecontent = ReplaceHtmlTag(content, 60);//产品简介
            hPara.articlecontent = content;
            hPara.city           = (string)SqlHelper.FromDBNull(row["city"]);        //生产城市
            hPara.smallCount     = (string)SqlHelper.FromDBNull(row["smallCount"]);  //起订
            hPara.xinghao        = (string)SqlHelper.FromDBNull(row["xinghao"]);     //型号
            hPara.unit           = (string)SqlHelper.FromDBNull(row["unit"]);        //单位
            hPara.sumCount       = (string)SqlHelper.FromDBNull(row["sumCount"]);    //供货总量
            hPara.price          = (string)SqlHelper.FromDBNull(row["price"]);       //单价
            hPara.pinpai         = (string)SqlHelper.FromDBNull(row["pinpai"]);      //品牌
            hPara.companyName    = (string)SqlHelper.FromDBNull(row["companyName"]); //公司名字
            hPara.ten_qq         = (string)SqlHelper.FromDBNull(row["ten_qq"]);
            hPara.com_web        = (string)SqlHelper.FromDBNull(row["com_web"]);     //网址
            hPara.addTime        = ((DateTime)SqlHelper.FromDBNull(row["addTime"])).ToString("yyyy-MM-dd");
            hPara.columnName     = (string)SqlHelper.FromDBNull(row["columnName"]);  //栏目名
            hPara.username       = (string)SqlHelper.FromDBNull(row["username"]);    //用户名
            return(hPara);
        }
Beispiel #25
0
        /// <summary>
        /// 查询上一条下一条
        /// </summary>
        /// <param name="columnId"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlBAPage(string columnId, string Id)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top 1 -1 as [Sort],Id,title,columnId,titleURL from (select top 1 Id,title,columnId,titleURL from htmlPara where columnId=@columnId and Id<@Id order by Id desc) as tab_up 
                 union select top 1 1 as [Sort],Id,title,columnId,titleURL from (select top 1 Id,title,columnId,titleURL from htmlPara where columnId=@columnId and Id>@Id order by Id) as tab_up",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@Id", Id));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.title    = (string)row["title"];
                hPara.titleURL = row["titleURL"].ToString();
                hPara.columnId = (string)row["columnId"];
                hList.Add(hPara);
            }
            return(hList);
        }
Beispiel #26
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 }));
        }
Beispiel #27
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"));
        }
Beispiel #28
0
 public int GetPageTotal(string columnId)
 {
     return((int)SqlHelperCatalog.ExecuteScalar("select count(*)  from htmlPara where columnId=@columnId",
                                                new SqlParameter("@columnId", columnId)));
 }