コード例 #1
0
ファイル: HtmlBuilder.cs プロジェクト: YellowTulipShow/CSharp
        /// <summary>
        /// 返回频道下首页所有的文章列表URL地址
        /// </summary>
        ///  <param name="lang">频道分类</param>
        /// <param name="channelname">频道Name</param>
        /// <returns>返回频道下所有的文章列表URL地址</returns>
        private string GetArticleIndexUrlList(string lang, string channelname, string page, string pattern, string path, string querystring, int pagesize)
        {
            StringBuilder sburl     = new StringBuilder();
            int           strLength = 0;

            if (!string.IsNullOrEmpty(querystring))
            {
                strLength = querystring.Split('&').Length;
            }

            int totalCount = objarticle.ArticleCount(channelname, 0, string.Empty);
            int pageindex  = GetPageSize(totalCount, pagesize);

            if (strLength == 1)
            {
                pageindex = 1;
            }
            for (int q = 1; q <= pageindex; q++)
            {
                string querystr    = Regex.Replace(string.Format(path, "0", q), pattern, querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                string linkurl     = string.Format("{0}/{1}/{2}?{3}", DTKeys.DIRECTORY_REWRITE_ASPX, lang, page, querystr);
                string HTMLPattern = string.Format("{0}/{1}/{2}", DTKeys.DIRECTORY_REWRITE_HTML, lang, Utils.GetUrlExtension(string.Format(path, "0", q), config.staticextension)); //替换扩展名
                if (!string.IsNullOrEmpty(sburl.ToString()))
                {
                    sburl.Append(",");
                }
                sburl.AppendFormat(urlstr, config.webpath, lang, linkurl.Replace("&", "^"), HTMLPattern);
            }

            return(sburl.ToString());
        }