创建文章静态页面

 

#region 创建静态页面(播放页)
        /// <summary>
        /// 创建静态页面(播放页)
        /// </summary>
        /// <param name="CH_HtmlFileName">静态页文件名</param>
        /// <param name="CH_TypeId">栏目ID</param>
        /// <param name="CH_TypeName">栏目名称</param>
        /// <param name="CH_Title">标题</param>
        /// <param name="CH_AddUsr">发布人</param>
        /// <param name="CH_AddTime">发布时间</param>
        /// <param name="CH_Content_Short">简介_短</param>
        /// <param name="CH_Content_detail">简介_长</param>
        /// <param name="CH_KeyWord">关键字</param>
        /// <param name="CH_Vid">记录ID(根据ID更新点击量)</param>
        /// <param name="CH_Player">播放器</param>
        /// <param name="CH_AboutVideo">相关视频</param>
        /// <param name="CH_RecommendVideo">推荐视频</param>
        public void CreateHtmlShowPage(string CH_HtmlFileName, string CH_TypeId, string CH_TypeName, string CH_Title, string CH_AddUsr, string CH_AddTime, string CH_Content_Short, string CH_Content_detail, string CH_KeyWord, string CH_Vid, string CH_Player, string CH_AboutVideo, string CH_RecommendVideo)
        {
            StringBuilder s = new StringBuilder();
            string line = string.Empty;
            //模板文件内容
            string TemplateContent = string.Empty;
            //模板文件路径
            string TemplateFilePath = System.Web.HttpContext.Current.Server.MapPath("/Video/Template/Tmp_VideoShow.htm");
            //静态页存放的文件夹路径
            string HtmlFolderPath = System.Web.HttpContext.Current.Server.MapPath("/Video/Html/");
            //静态页文件路径
            string HtmlFilePath = HtmlFolderPath + CH_HtmlFileName;
            try
            {
                //--------------读取模板中的内容--------------//
                using (StreamReader sr = new StreamReader(TemplateFilePath, System.Text.Encoding.GetEncoding("utf-8")))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        s.AppendLine(line);
                        //s.AppendLine("/n");
                    }
                    sr.Close();
                }
                TemplateContent = s.ToString();
                //-------判断静态页文件夹路径是否存在--------//
                if (!Directory.Exists(HtmlFolderPath))
                {
                    Directory.CreateDirectory(HtmlFolderPath);
                }
                //---------------生成静态页----------------//
                using (StreamWriter sw = new StreamWriter(HtmlFilePath, false, System.Text.Encoding.GetEncoding("utf-8")))
                {
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[TypeName]", CH_TypeName);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[TypeId]", CH_TypeId);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[Title]", CH_Title);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[AddUsr]", CH_AddUsr);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[AddTime]", CH_AddTime);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[Content_Short]", CH_Content_Short);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[Content_detail]", CH_Content_detail);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[KeyWord]", CH_KeyWord);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[Vid]", CH_Vid);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[Player]", CH_Player);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[AboutVideo]", CH_AboutVideo);
                    TemplateContent = TemplateContent.Replace("$HtmlFormat[RecommendVideo]", CH_RecommendVideo);
                    sw.WriteLine(TemplateContent);
                    sw.Close();
                }
                //----------------------END------------//
            }
            catch (Exception ex)
            {
                throw new Exception("BLL.AudiovisualBLL.CreateHtmlShowPage:" + ex.Message);
            }
        }
        #endregion

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值