Beispiel #1
0
        /// <summary>
        /// 实现整个期刊静态化处理
        /// </summary>
        public void StaticHtml()
        {
            //var otherController = DependencyResolver.Current.GetService< typeof(CIIC.TongXun.Controllers.HomeController) > ();
            //var result = otherController.另一个动作方法();
            // Get a PostAuthenticateRequestProvider and use this to apply a
            // correctly configured principal to the current http request
            //var provider = (HomeController)DependencyResolver.Current.GetService(typeof(CIIC.TongXun.Controllers.HomeController));
            //provider.Index();
            string JournalId = Request.QueryString["JournalId"];//期刊ID

            string[] staticFileList =
            {
                "index.html",             //HomeController Index
                "news_list_jt.html",      //HomeController ListIndex
                "news_list_gs.html",
                "news_list_yw.html",
                "news_list_jiaojuguoqi.html"
            };
            //staticFileList = new string[] { };

            string url     = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; //AbsoluteUri = "http://localhost:58321/Journal/StaticHtml"
            int    start   = url.IndexOf("//");
            int    end     = url.IndexOf("/", start + 2);
            string urlHead = url.Substring(0, end + 1);
            string param   = "static=1&journalId=" + JournalId;

            for (int i = 0; i < staticFileList.Length; i++)
            {
                string reRewriteUrl = urlHead + staticFileList[i];
                CommentHelper.HttpWebRequestGet(reRewriteUrl, param);
                Response.Write(reRewriteUrl);
                Response.Write("<br />");
            }

            //获取期刊下的文章
            ArticleBLL            articleBLL = new ArticleBLL();
            List <SqlDbParameter> parms      = new List <SqlDbParameter>();
            SqlDbParameter        parm       = null;

            if (!string.IsNullOrEmpty(JournalId))
            {
                parm                = new SqlDbParameter();
                parm.ColumnName     = "JournalId";
                parm.ParameterName  = "JournalId";
                parm.ParameterValue = JournalId;
                parm.ColumnType     = DbType.Int32;
                parms.Add(parm);
            }
            DataTable dt = articleBLL.GetArticleDataTable(parms, "NoOfJournal");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ArticleEntity article = new ArticleEntity();
                article.Id           = int.Parse(dt.Rows[i]["Id"].ToString());
                article.CategoryId   = int.Parse(dt.Rows[i]["CategoryId"].ToString()); //列表ID
                article.NoOfCategory = short.Parse(dt.Rows[i]["NoOfCategory"].ToString());
                article.HrefTpl      = dt.Rows[i]["HrefTpl"].ToString();
                string reRewriteUrl = urlHead + article.Href;
                CommentHelper.HttpWebRequestGet(reRewriteUrl, param);
                Response.Write(reRewriteUrl);
                Response.Write("<br />");
            }
        }