Esempio n. 1
0
        /// <summary>
        /// 保存当前模板生成的CSS代码为一个文件
        /// </summary>
        public virtual bool SaveCss(ToHtmlHelper htmlHelper)
        {
            this.ToHtmlHelper = htmlHelper;

            #region 临时效果

            string str = this.Id + "\r\n" + this.Title + "\r\nTmpltXmlDocument.SaveCss() Test!\r\n" + DateTime.Now.ToString(Utility.Const.TimeFormat);

            Directory.CreateDirectory(Path.GetDirectoryName(this.ToHtmlHelper.CSSPath));///创建目录

            string     file   = Path.Combine(this.ToHtmlHelper.CSSPath, this.Id + Utility.Const.CssFileExt);
            FileStream fs     = File.Open(file, FileMode.Create, FileAccess.Write);
            byte[]     buffer = Encoding.UTF8.GetBytes(str);
            fs.Write(buffer, 0, buffer.Length);
            fs.Close();
            fs.Dispose();

            string     fileUser   = Path.Combine(this.ToHtmlHelper.CSSPath, this.Id + "_custom" + Utility.Const.CssFileExt);
            FileStream fsUser     = File.Open(fileUser, FileMode.Create, FileAccess.Write);
            byte[]     bufferUser = Encoding.UTF8.GetBytes(str + "\r\n\r\nThis is User custom css!");
            fsUser.Write(bufferUser, 0, bufferUser.Length);
            fsUser.Close();
            fsUser.Dispose();

            return(true);

            #endregion
        }
Esempio n. 2
0
 public virtual bool DeleteXhtml(ToHtmlHelper htmlhelper)
 {
     this.ToHtmlHelper = htmlhelper;
     File.Delete(this.HtmlFile);
     Directory.Delete(this.TmpltToHtmlPath, true);
     return(true);
 }
Esempio n. 3
0
        /// <summary>
        /// 保存当前节点生成的Xhtml代码为一个文件。成功时返回一个Bool值为True。
        /// 调用时建议判断一下是否保存成功。
        /// </summary>
        public virtual bool SaveXhtml(ToHtmlHelper htmlHelper)
        {
            this.ToHtmlHelper = htmlHelper;
            TmpltXmlDocument doc  = (TmpltXmlDocument)this.OwnerAnyDocument;
            string           path = Path.Combine(doc.TmpltToHtmlPath, this.Id + Utility.Const.IncludeFileExt);

            return(this.SaveXhtml(path));
        }
Esempio n. 4
0
 /// <summary>
 /// 生成頁面的三个文件(MainPage,Head,Content)到默認目錄。成功时返回一个Bool值为True。
 /// 调用时建议判断一下是否保存成功。
 /// </summary>
 /// <returns>返回保存是否成功,不成功有两种情况,1文件系统导致,2该类型不支持存储成文件</returns>
 public virtual bool SaveXhtml(ToHtmlHelper htmlhelper)
 {
     this.ToHtmlHelper = htmlhelper;
     return
         (this.SaveXhtml(htmlhelper, PageSection.MainPage) &
          this.SaveXhtml(htmlhelper, PageSection.Head) &
          this.SaveXhtml(htmlhelper, PageSection.Content));
 }
Esempio n. 5
0
 /// <summary>
 /// 删除页面的所有生成的子文件(MainPage,Head,Content)
 /// </summary>
 /// <param name="pageId">将要生成的页面的Id</param>
 public virtual bool DeleteXhtml(ToHtmlHelper htmlhelper)
 {
     this.ToHtmlHelper = htmlhelper;
     try
     {
         File.Delete(this.HtmlFile);
         File.Delete(this.HtmlContentFile);
         File.Delete(this.HtmlHeadFile);
         return(true);
     }
     catch (Exception ex)
     {
         Debug.Fail(ex.Message);
         return(false);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 生成頁面的单个子文件到默認目錄。成功时返回一个Bool值为True。
        /// 调用时建议判断一下是否保存成功。
        /// </summary>
        /// <param name="section">正在生成的子文件类型,枚举</param>
        /// <returns>返回保存是否成功,不成功有两种情况,1文件系统导致,2该类型不支持存储成文件</returns>
        public virtual bool SaveXhtml(ToHtmlHelper htmlhelper, PageSection section)
        {
            switch (section)
            {
            case PageSection.MainPage:
                return(ToHtmlHelper.FileSave(this.HtmlFile, this.ToHtml(section)));

            case PageSection.Head:
                return(ToHtmlHelper.FileSave(this.HtmlHeadFile, this.ToHtml(section)));

            case PageSection.Content:
                return(ToHtmlHelper.FileSave(this.HtmlContentFile, this.ToHtml(section)));

            case PageSection.None:
            default:
                Debug.Fail("PageSection is Error!");
                return(ToHtmlHelper.FileSave(this.HtmlFile, this.ToHtml(section)));
            }
        }
Esempio n. 7
0
 public virtual bool DeleteXhtml(ToHtmlHelper htmlHelper)
 {
     this.ToHtmlHelper = htmlHelper;
     File.Delete(this.HtmlFile);
     return(true);
 }
Esempio n. 8
0
 /// <summary>
 /// 删除移动前服务器端生成的Xhtml文件
 /// </summary>
 /// <param name="htmlhelper"></param>
 /// <returns></returns>
 public virtual bool DeleteOldXhtml(ToHtmlHelper htmlhelper)
 {
     return(true);
 }
Esempio n. 9
0
 /// <summary>
 /// 保存当前模板生成的Xhtml代码为一个文件
 /// </summary>
 public virtual bool SaveXhtml(ToHtmlHelper htmlHelper)
 {
     this.ToHtmlHelper = htmlHelper;
     this.SaveCss(htmlHelper);
     return(ToHtmlHelper.FileSave(Path.Combine(this.ToHtmlHelper.TmpltPath, this.Id + Utility.Const.ShtmlFileExt), this.ToHtml()));
 }
Esempio n. 10
0
 /// <summary>
 /// 清理可能已不存在的Snip对应的生成文件,一般在模板的isModify为真时调用
 /// </summary>
 public virtual bool ClearSnipXhtml(ToHtmlHelper htmlhelper)
 {
     return(true);
 }