Ejemplo n.º 1
0
        public static void CreateOneArticleHtml(int article_id)
        {
            ArtBll artBll = new ArtBll();

            if (article_id > 0)
            {
//                string sql = @"Select t_article.id as articleId,t_article.title,t_article.title1,t_article.source,t_article.keyword,t_article.daoyu,t_article.content,
//                            t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic as artPic,t_article.html,t_article.remark,
//                            t_article_type.id as type_id,t_article_type.type_name,tag,t_article.tag_id
//                            FROM t_article  LEFT JOIN t_article_type ON t_article.type=t_article_type.id
//                            WHERE t_article.id=" + article_id;

                string sql = @"Select t_article.id as articleId,t_article.title,t_article.title1,t_article.source,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic as artPic,t_article.html,t_article.remark,t_article.last_id,t_article.next_id,
                            t_article1.html AS last_html,t_article1.title AS last_title,t_article2.html AS next_html,t_article2.title AS next_title,
                            t_article_type.id as type_id,t_article_type.type_name,t_article.tag,t_article.tag_id,t_article.search_keyword
                            FROM (((t_article  
                            LEFT JOIN t_article_type ON (t_article.type=t_article_type.id) )
                            LEFT JOIN t_article t_article1 ON (t_article.last_id=t_article1.id) )
                            LEFT JOIN t_article t_article2 ON (t_article.next_id=t_article2.id))
                            WHERE t_article.id=" + article_id;

                DataTable dt = artBll.SelectToDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    //articleId = Convert.ToInt32(dt.Rows[i]["id"]);
                    //string article_html = dt.Rows[i]["html"].ToString();
                    //this.CteateHTML(url + "/article/content.aspx?pc=" + pc + "&a_id=" + articleId, staticPath, article_html);
                    int    articleId       = Convert.ToInt32(dt.Rows[0]["articleId"]);
                    string title           = dt.Rows[0]["title"].ToString();
                    string title1          = dt.Rows[0]["title1"].ToString();
                    string source          = dt.Rows[0]["source"].ToString();
                    int    articleType     = Convert.ToInt32(dt.Rows[0]["type_id"]);
                    string articleTypeName = dt.Rows[0]["type_name"].ToString();
                    string content         = dt.Rows[0]["content"].ToString();
                    string keyword         = dt.Rows[0]["keyword"].ToString();
                    string search_keyword  = dt.Rows[0]["search_keyword"].ToString();
                    string artPic          = dt.Rows[0]["artPic"].ToString();
                    string article_html    = dt.Rows[0]["html"].ToString();
                    string tagStr          = dt.Rows[0]["tag"].ToString();
                    string tagIdHtml       = dt.Rows[0]["tag_id"].ToString();
                    string update_date     = Convert.ToDateTime(dt.Rows[0]["update_date"]).ToString("yyyy年M月d日");
                    string tag_id          = dt.Rows[0]["tag_id"].ToString();

                    if (tagIdHtml.Trim() != "")
                    {
                        string[] tagArray = tagIdHtml.Split(',');
                        for (int j = 0; j < tagArray.Length; j++)
                        {
                            if (tagArray[j].Trim() != "" && tagArray[j].Trim() != ",")
                            {
                                tagIdHtml = tagArray[j].Trim();
                                break;
                            }
                        }
                    }

                    string last_title = "上一篇:" + dt.Rows[0]["last_title"].ToString();
                    string last_html  = dt.Rows[0]["last_html"].ToString();
                    string next_title = "下一篇:" + dt.Rows[0]["next_title"].ToString();
                    string next_html  = dt.Rows[0]["next_html"].ToString();

                    //生成静态页
                    CommonMethod.CreateArticleHtml(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tag_id, tagIdHtml, update_date, last_html, last_title, next_html, next_title, search_keyword);
                }
            }
        }
Ejemplo n.º 2
0
        public static bool CreateArticleHtml(int art_id, string title, string title1, string source, int articleType, string articleTypeName, string content, string keyword, string imgUrl, string article_html, string tag, string tagId, string tagIdHtml, string update_date, string last_html, string last_title, string next_html, string next_title, string search_keyword)
        {
            Hashtable artHt = new Hashtable();

            artHt.Add("$title", title);    //
            artHt.Add("$titl_e1", title1); //
            if (source.Trim() == "")
            {
                //source = "<a href='http://www.up927.com/' target='_blank' title='好宝宝早教网_" + articleTypeName + "'>好宝宝早教网</a>";
                source = "毛豆妈咪";
            }
            artHt.Add("$source", source);                    //
            artHt.Add("$articleType", articleType);          //
            artHt.Add("$article_TypeName", articleTypeName); //articleTypeName
            artHt.Add("$content", content);                  //
            artHt.Add("$keyword", keyword);                  //
            //artHt.Add("$tag", tag);
            artHt.Add("$update_date", update_date);

            artHt.Add("$last_html", last_html);
            artHt.Add("$last_title", last_title);
            artHt.Add("$next_html", next_html);
            artHt.Add("$next_title", next_title);

            if (search_keyword.Trim() != "")
            {
                string   tagStr = "";
                string[] array  = search_keyword.Split(' ');
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i].Trim() != "")
                    {
                        tagStr += "<a href='/list.aspx?title=" + System.Web.HttpUtility.UrlEncode(array[i]) + "' target='_blank'>" + array[i] + "</a>&nbsp;&nbsp;";//<a href="#" target="_blank">温州人</a>
                    }
                }
                artHt.Add("$search_keyword", "<div class='zx_tag' align='left'>相关搜索:" + tagStr + "</div>");
                //artHt.Add("$search_keyword", search_keyword);
            }
            else
            {
                artHt.Add("$search_keyword", "");
            }

            if (tag.Trim() != "")
            {
                string   tagStr  = "";
                string[] array   = tag.Split(' ');
                string[] arrayId = CommonMethod.GetArrayNoEmpty(tagId.Split(','));
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i].Trim() != "")
                    {
                        tagStr += "<a href='/list.aspx?tag=" + arrayId[i] + "' target='_blank'>" + array[i] + "</a>&nbsp;";//<a href="#" target="_blank">温州人</a>
                    }
                }
                artHt.Add("$tag", "<div class='zx_tag' align='left'>标签:" + tagStr + "</div>");
                artHt.Add("$xiangguanShow", "");//显示相关文章
            }
            else
            {
                artHt.Add("$tag", "");
                artHt.Add("$xiangguanShow", "none");////隐藏相关文章
            }
            if (tagIdHtml.Trim() != "")
            {
                artHt.Add("$_tagUrl", "/tag/" + tagIdHtml + ".html");//<!--#include file="$_tagUrl"-->  "<!--#include file='/tag/" + tagIdHtml + ".html'-->"
            }
            else
            {
                artHt.Add("$_tagUrl", "/tag/0.html");//无相关文章,引用页为无内容
            }


            //if (imgUrl.Trim() != "")
            //{
            //    artHt.Add("$imgStr", "<img src='/Article_File/" + imgUrl + "'/>");//
            //}
            //else
            //{
            //    artHt.Add("$imgStr", "");//
            //}

            //模版文件 存放路径
            string sourceFilePath = HttpRuntime.AppDomainAppPath.ToString() + "/template/detail_2.html";

            //生成后文件 存放的 路径
            string spanFilePath = HttpRuntime.AppDomainAppPath.ToString();

            CommonMethod cm = new CommonMethod();

            return(cm.WriteHTML(artHt, sourceFilePath, spanFilePath, article_html));  //生成静态页
        }