public BuildSite() { ToHtmlHelper siteHelper = new ToHtmlHelper("", @"D:\_abc\myabc"); TmpltXmlDocument tmpltDoc = null; tmpltDoc.SaveXhtml(siteHelper); tmpltDoc.DeleteXhtml(siteHelper); PageXmlDocument pageDoc = null; pageDoc.SaveXhtml(siteHelper); pageDoc.DeleteXhtml(siteHelper); foreach (var item in tmpltDoc.GetSnipElementList()) { SnipXmlElement snip = (SnipXmlElement)item; snip.SaveXhtml(siteHelper); snip.DeleteXhtml(siteHelper); } }
/// <summary> /// 初始化一个SD项目以供测试 /// </summary> private void InitSdSite() { PageAttributeService.Initialize(); ToHtmlHelper htmlhelper = new ToHtmlHelper(_SdFile, @"d:\_abc\myabc"); this._htmlHelper = htmlhelper; this.InnerDoc = htmlhelper.SdsiteXmlDocument; string[] pageIds = this.InnerDoc.GetAllPageId(); foreach (var item in pageIds) { this.pageComboBox.Items.Add(new PageObject(item, htmlhelper)); } string[] tmpltIds = this.InnerDoc.GetAllTmpltId(); foreach (string id in tmpltIds) { this.tmpltComboBox.Items.Add(new TmpltObject(id, htmlhelper)); } this.sdsiteLabel.Text = _SdFile; }
/// <summary> /// 通过频道的url返回频道的GUID,没有则返回空 /// </summary> internal static string GetChannelRequestGuid(string index, ToHtmlHelper thh) { //如果为空返回根节点的Guid if (string.IsNullOrEmpty(index) || index == "//") { return("00000000"); } try { FolderXmlElement folderXmlEle = (FolderXmlElement)thh.SdsiteXmlDocument.GetElementById("00000000"); //url = DelFirstPath(url.Substring(1)); index = index.Substring(0, index.Length - 1); string channelName = GetLastPath(index); string url = DelLastPathName(index); //遍历所有要得到频道的父频道,找到其真实的父频道 while (!string.IsNullOrEmpty(url)) { string folder = GetFirstPath(url); folderXmlEle = (FolderXmlElement)folderXmlEle.SelectSingleNode(string.Format("child::*[@fileName='{0}']", folder)); url = DelFirstPath(url); } //通过父频道返回所求频道的id SimpleExIndexXmlElement xmlEle = (SimpleExIndexXmlElement)folderXmlEle.SelectSingleNode(string.Format("child::channel[@fileName='{0}']|child::folder[@fileName='{0}']", channelName)); if (xmlEle != null) { return(xmlEle.Id); } else { return(null); } } catch (Exception e) { ExceptionService.CreateException(e); return(null); } }
//SdsiteXmlDocument sdsiteDocument; /// <summary> /// 开始生成网站 /// </summary> /// <returns></returns> public bool StartBuild(string partPath, string projName) { string sdPath = AnyFilePath.GetSdsitesFolderAbsolutePath(partPath); string buildPath = AnyFilePath.GetWebAbsolutePath(partPath); toHtmlHelperObj = new ToHtmlHelper(sdPath, buildPath); resStartPath = sdPath + @"Root\" + @"Resource"; resToPath = buildPath + @"\Resource"; buildFile = new BuildFile(); buildFile.SdsiteDocument = toHtmlHelperObj.SdsiteXmlDocument; buildFile.ToHtmlHelperObj = toHtmlHelperObj; FolderXmlElement channelRootEle = toHtmlHelperObj.SdsiteXmlDocument.RootChannel; //string sdPath = AnyFilePath.GetSdsitesFolderAbsolutePath(partPath) + projName + ".sdsite"; ////打开网站 //this.sdsiteDocument = new SdsiteXmlDocument(sdPath); //this.sdsiteDocument.Load(); //buildFile = new BuildFile(); //buildFile.SdsiteDocument = this.sdsiteDocument; //buildFile.BuildFilePath = partPath; //FolderXmlElement channelRootEle = this.sdsiteDocument.RootChannel; try { SearchAndProcess(channelRootEle); return(true); } catch (Exception Ex) { ExceptionService.WriteExceptionLog(Ex); return(false); } }
public PageObject(string id, ToHtmlHelper htmlhelper) { this._ToHtmlHelper = htmlhelper; this.Id = id; }