protected override void LoadChildNodes(TmpltTreeNodeType NodeFilterType) { this.Nodes.Clear(); TmpltXmlDocument tmpltDoc = Service.Sdsite.CurrentDocument.GetTmpltDocumentById(ID); foreach (SnipXmlElement snipEle in tmpltDoc.GetSnipElementList()) { AddElementNode(snipEle, NodeFilterType); } SetNoChildNodesText(); }
private void TmpltTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) { e.Cancel = expandCollapse; //展开前的判断 if (!e.Cancel && e.Node is TmpltElementNode) { TmpltElementNode tmpltNode = e.Node as TmpltElementNode; TmpltXmlDocument tmpltDoc = Service.Sdsite.CurrentDocument.GetTmpltDocumentById(tmpltNode.ID); if (tmpltDoc.GetSnipElementList().Count <= 0) { tmpltNode.ClearTmpltNode(); } } }
private void TmpltTreeView_AfterExpand(object sender, TreeViewEventArgs e) { //生成树 if (e.Node is TmpltElementNode) { TmpltElementNode tmpltNode = e.Node as TmpltElementNode; TmpltXmlDocument tmpltDoc = Service.Sdsite.CurrentDocument.GetTmpltDocumentById(tmpltNode.ID); if (tmpltDoc.GetSnipElementList().Count <= 0 || tmpltNode.NodeExpand) { return; } tmpltNode.NodeExpand = true; tmpltNode.LoadData(SnipFilter); ResetDicNodeIndexs(); } }
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> /// 生成模板文件 /// </summary> /// <param name="simpleEle"></param> public void BuildTmpltFile(SimpleExIndexXmlElement simpleEle) { //添加模板到Dictionary字典中 AddElementToDictionary(simpleEle); /// tmpltFolderAbsPath ="Y:\zha\zhangling\projectname\TmpltRootFolder"; ///string tmpltFolderAbsPath = Path.Combine(sdsiteAbsPath, SdsiteDocument.TmpltFolder.FileName); TmpltSimpleExXmlElement tmpltEle = (TmpltSimpleExXmlElement)simpleEle; string tmpltId = tmpltEle.Id; TmpltXmlDocument tmpltDoc = ToHtmlHelperObj.SdsiteXmlDocument.GetTmpltDocumentById(tmpltId); if (tmpltEle.IsDeletedRecursive) { //删除模板本身的文件 //删除此模板文件对应的模板文件夹(内有多个snip文件) //删除相应的css文件 //string filePath = tmpltFolderAbsPath + @"\" + tmpltId + CommonService.Inc; //FileService.FileDelete(filePath); //string folderPath = tmpltFolderAbsPath + @"\" + tmpltId; //FolderService.FolderDelete(folderPath); //string cssPath = tmpltFolderAbsPath + @"\" + CommonService.Css + @"\" + tmpltId + CssDAT; //FileService.FileDelete(cssPath); tmpltDoc.DeleteXhtml(ToHtmlHelperObj); } else if (!tmpltEle.IsAlreadyPublished) //新建 { //打开相应的模板 //生成本身的文件.css //遍历生成相应的snip文件 //string tmpltPath = tmpltFolderAbsPath + @"\" + tmpltId + CommonService.Inc; //TmpltXmlDocument tmpltDoc = SdsiteDocument.GetTmpltDocumentById(tmpltId); //tmpltDoc.SaveXhtml(); //tmpltDoc.SaveXhtml(tmpltPath); //string tmpltCssPath = tmpltFolderAbsPath + @"\" + tmpltId + @"\" + CssDAT; //tmpltDoc.SaveCss(); tmpltDoc.SaveXhtml(ToHtmlHelperObj); //string folderPath = tmpltFolderAbsPath + @"\" + tmpltId; XmlNodeList snipList = tmpltDoc.GetSnipElementList(); foreach (var item in snipList) { SnipXmlElement snipEle = item as SnipXmlElement; //string snipfile = snipEle.Id + CommonService.Inc; //string snipFilePath = Path.Combine(folderPath, snipfile); //snipEle.SaveXhtml(); //snipEle.SaveXhtml(snipFilePath); snipEle.SaveXhtml(ToHtmlHelperObj); } } else { //此处没有路径改变的问题 if (tmpltEle.IsModified) { //打开相应的模板文件 //则需要重新生成本身的文件,及有改变过的snip的对应的文件 //tmpltDoc.SaveXhtml(); //方法内部在保存此文件时,还需要检查此文件是否存在,存在,则删除掉,然后将其在保存 //tmpltDoc.SaveCss(); tmpltDoc.SaveXhtml(ToHtmlHelperObj); Dictionary <string, string> dic = new Dictionary <string, string>(); XmlNodeList snipList = tmpltDoc.GetSnipElementList(); foreach (var item in snipList) { SnipXmlElement snipEle = item as SnipXmlElement; if (snipEle.IsModified) { //则需要重新生成 // snipEle.SaveXhtml(); snipEle.SaveXhtml(ToHtmlHelperObj); } string snipFileName = snipEle.Id + CommonService.Inc; dic.Add(snipFileName, ""); } //看是否存在多余的snip文件,并将其删除 string snipFolderPath = sdWebAbsPath + @"\" + SdsiteDocument.TmpltFolder.Name + @"\" + tmpltId; string[] allSnipFile = GetAllSnipFile(snipFolderPath); foreach (var file in allSnipFile) { if (!dic.ContainsKey(file)) { //删除此文件 string filePath = snipFolderPath + @"\" + file; FileService.FileDelete(filePath); } } } } }