static public WorkDocumentType GetWorkDocumentType(SimpleExIndexXmlElement ele) { switch (ele.DataType) { case DataType.Tmplt: return(WorkDocumentType.TmpltDesigner); case DataType.Page: { switch (((PageSimpleExXmlElement)ele).PageType) { case PageType.General: return(WorkDocumentType.HtmlDesigner); case PageType.Product: case PageType.Project: case PageType.InviteBidding: case PageType.Knowledge: case PageType.Hr: return(WorkDocumentType.Edit); case PageType.Home: return(WorkDocumentType.HomePage); default: Debug.Fail(""); break; } return(WorkDocumentType.HtmlDesigner); } } return(WorkDocumentType.None); }
/// <summary> /// 前进或者后退 /// </summary> /// <param name="next"></param> private void TranFolder(bool next) { SimpleExIndexXmlElement initFolder = null; if (next) { initFolder = filePaths[--pathNum]; } else { initFolder = filePaths[++pathNum]; } InitListView(initFolder); SetBackEnabled(); SetPreEnabled(); if (initFolder.AbsoluteFilePath != Service.Sdsite.CurrentDocument.Resources.AbsoluteFilePath) { upToolStripButton.Enabled = true; backToolStripButton.Enabled = true; } else { upToolStripButton.Enabled = false; backToolStripButton.Enabled = false; filePaths.Clear(); pathNum = 0; filePaths.Add(Service.Sdsite.CurrentDocument.Resources); } }
public void CodeToDesign() { if (idoc2 != null && idoc2.body != null) { //相对路径转绝对路径 string htmlCode = codeTextEditorControl.Text; string ostr = "${srs_"; while (htmlCode.IndexOf(ostr) > 0) { string mediaId = htmlCode.Substring(htmlCode.IndexOf(ostr) + 6, 32); SimpleExIndexXmlElement ele = Service.Sdsite.CurrentDocument.GetElementById(mediaId) as SimpleExIndexXmlElement; if (ele != null) { if (!ResourcesIdPaths.ContainsKey(ele.Id)) { ResourcesIdPaths.Add(ele.Id, ele.AbsoluteFilePath); } string PATH = SiteResourceService.ParseFormatId(ele.Id, true); htmlCode = htmlCode.Replace(htmlCode.Substring(htmlCode.IndexOf(ostr), 39), "file:///" + ele.AbsoluteFilePath.Replace("\\", "/")); } else { break; } } idoc2.body.innerHTML = htmlCode; } }
private void SearchAndProcess(FolderXmlElement channelRootEle) { foreach (AnyXmlElement anyXmlEle in channelRootEle) { SimpleExIndexXmlElement simpleEle = anyXmlEle as SimpleExIndexXmlElement; switch (simpleEle.DataType) { case DataType.Resources: //直接将资源文件移动与此; 还不够妥当todo: if (simpleEle.IsModified) { DirectoryInfo dic = new DirectoryInfo(resStartPath); dic.MoveTo(resToPath); } break; case DataType.TmpltFolder: case DataType.Folder: case DataType.Channel: SearchAndProcess((FolderXmlElement)simpleEle); break; case DataType.Tmplt: buildFile.BuildTmpltFile(simpleEle); break; case DataType.Page: buildFile.BuildPageFile(simpleEle); break; } } }//private
private ElementNode AddElementNode(SimpleExIndexXmlElement element) { ///找到新Element的父Element在树中的节点 BaseFolderElementNode folderNode = (BaseFolderElementNode)GetElementNode(element.OwnerFolderElement.Id); ///添加此SimpleExIndexXmlElement return(folderNode.AddElementNode(element)); }
/// <summary> /// 处理文件 /// </summary> /// <param name="simpleEle"></param> public void DealWithFile(SimpleExIndexXmlElement simpleEle) { /* * true 文件有移动;false文件无移动; * 为真时,表示此文件是已发布过的文件 * 为假时,或是新上传的文件或是已修改过的文件 * */ //上次发布后此文件的绝对路径 string fileAbsolutePathPrevious = Path.Combine(_sdsitesPath, simpleEle.OldRelativeFilePath); //临时文件下的此文件的路径 string fileAbsolutePathTemp = Path.Combine(_tempPath, simpleEle.RelativeFilePath); if (simpleEle.IsDeletedRecursive) { //直接找到此文件,然后删除 FileService.FileDelete(fileAbsolutePathPrevious); } else if (!simpleEle.IsAlreadyPublished) { FileService.FileMove(fileAbsolutePathTemp, fileAbsolutePathPrevious); } else { if (simpleEle.IsChangedPosition) { string fileAbsolutePathCurrent = Path.Combine(_sdsitesPath, simpleEle.RelativeFilePath); if (!simpleEle.IsModified) { //文件没有重命名,并且其内容没有修改,则直接移动文件到新的位置上 FileService.FileMove(fileAbsolutePathPrevious, fileAbsolutePathCurrent); } else { //则直接删除文件,然后,在从临时文件夹下将其文件移动到新的位置上 FileService.FileDelete(fileAbsolutePathPrevious); FileService.FileMove(fileAbsolutePathTemp, fileAbsolutePathCurrent); } } else { string fileAbsolutePathCurrent = Path.Combine(_sdsitesPath, simpleEle.RelativeFilePath); if (simpleEle.IsModified) { //修改 FileService.FileMove(fileAbsolutePathTemp, fileAbsolutePathCurrent); } } } }
private void FilterComboBox_SelectedIndexChanged(object sender, EventArgs e) { SimpleExIndexXmlElement FolderFullPath = filePaths[pathNum]; /* if (FilePathID.Value != null) * FolderFullPath = FilePathID.Value; * else * FolderFullPath = filePaths[pathNum];*/ if (FolderFullPath != null) { InitListView(FolderFullPath); } }
/// <summary> /// 当发送频道请求情况下,产生该频道下的列表(文件夹,频道,页面) /// </summary> internal static string GetChannelContent(string channelGuid) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<body></body>"); FolderXmlElement channeEle = ToHtmlSdsiteService.SdsiteXmlDocument.GetFolderElementById(channelGuid); if (string.IsNullOrEmpty(channeEle.DefaultPageId)) { foreach (AnyXmlElement anyEle in channeEle.ChildNodes) { if (anyEle.Name != "siteShowItem") { SimpleExIndexXmlElement pageEle = anyEle as SimpleExIndexXmlElement; if (pageEle.Name != "resources" && pageEle.Name != "tmpltRootFolder" && pageEle.IsDeleted == false) { //如果包含主页,则跳转到主页 XmlElement xmlEle = xmlDoc.CreateElement("div"); XmlElement linkEle = xmlDoc.CreateElement("a"); if (pageEle.Name == "channel" || pageEle.Name == "folder") { linkEle.SetAttribute("href", pageEle.OwnerFolderElement.RelativeUrl); } else { linkEle.SetAttribute("href", pageEle.RelativeUrl); } linkEle.InnerXml += pageEle.FileName; xmlEle.AppendChild(linkEle); xmlDoc.DocumentElement.AppendChild(xmlEle); return(string.Format(ConstService.HTMLUTF8Head, channeEle.Title) + xmlDoc.InnerXml + ConstService.HTMLUTF8END); } } } } else { return("<html><head>" + ConstService.UTF8 + "<meta http-equiv=\"refresh\" content=\"0;URL=http://127.0.0.1:" + Perviewer.Port + channeEle.RelativeUrl + "index.shtml\"></head></html>"); } } catch (Exception e) { ExceptionService.CreateException(e); return(ConstService.BAD); } return("该频道(文件夹)下无内容显示!"); }
/// <summary> /// 添加模板或页面元素到Dictionary字典中 /// </summary> /// <param name="simpleEle"></param> private void AddElementToDictionary(SimpleExIndexXmlElement simpleEle) { //循环遍历.sdsite文件时,将其模板(tmplt)元素添加到此字典中 if (simpleEle.DataType == DataType.Tmplt) { string _tmpltId = ((TmpltSimpleExXmlElement)simpleEle).Id; _FileDic.Add(_tmpltId, new List <PageSimpleExXmlElement>()); } else if (simpleEle.DataType == DataType.Page) { string _getTmpltId = ((PageSimpleExXmlElement)simpleEle).TmpltId; //找到字典中此模板id对应的list列表,直接添加进去//也会只会放一些更有用的页面//todo。。。 _FileDic[_getTmpltId].Add((PageSimpleExXmlElement)simpleEle); } }
/// <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); } }
/// <summary> /// 元素绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void designWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { IHTMLDocument3 pBody = ((IWebBrowser2)designWebBrowser.ActiveXInstance).Document as IHTMLDocument3; m_elemEvents.ConnectToHtmlEvents(pBody.documentElement); if (idoc2.body != null) { idoc2.body.innerHTML = _articleText; codeTextEditorControl.Text = GeneralMethods.tidy(idoc2.body.innerHTML); string htmlCode = codeTextEditorControl.Text; string ostr = "${srs_"; while (htmlCode.IndexOf(ostr) > 0) { string mediaId = htmlCode.Substring(htmlCode.IndexOf(ostr) + 6, 32); SimpleExIndexXmlElement ele = Service.Sdsite.CurrentDocument.GetElementById(mediaId) as SimpleExIndexXmlElement; if (ele != null) { if (!ResourcesIdPaths.ContainsKey(ele.Id)) { ResourcesIdPaths.Add(ele.Id, ele.AbsoluteFilePath); } string PATH = SiteResourceService.ParseFormatId(ele.Id, true); htmlCode = htmlCode.Replace(htmlCode.Substring(htmlCode.IndexOf(ostr), 39), "file:///" + ele.AbsoluteFilePath.Replace("\\", "/")); } else { break; } } } DesignToCode(); CodeToDesign(); }
/// <summary> /// 到上一级文件目录 /// </summary> private void UpFolder() { SimpleExIndexXmlElement FolderFullPath = filePaths[pathNum]; SimpleExIndexXmlElement parentEle = (SimpleExIndexXmlElement)FolderFullPath.ParentNode; if (FolderFullPath.AbsoluteFilePath != Service.Sdsite.CurrentDocument.Resources.AbsoluteFilePath) { InitListView(parentEle); filePaths.Add(parentEle); pathNum++; } if (parentEle.AbsoluteFilePath != Service.Sdsite.CurrentDocument.Resources.AbsoluteFilePath) { upToolStripButton.Enabled = true; } else { upToolStripButton.Enabled = false; filePaths.Clear(); pathNum = 0; filePaths.Add(Service.Sdsite.CurrentDocument.Resources); SetBackEnabled(); } }
/// <summary> /// 通过element添加ElementNode节点,并添加到树中 /// </summary> public virtual ElementNode AddElementNode(SimpleExIndexXmlElement element) { ///IsDeleted为true的,表示已经被删除,不显示 if (element.IsDeleted) { return(null); } ElementNode elementNode = null; switch (element.DataType) { case DataType.Channel: //右侧树或选择频道才加载频道 if (TreeView.TreeMode == TreeMode.General || TreeView.TreeMode == TreeMode.SelectChannel) { elementNode = new ChannelNode(element as ChannelSimpleExXmlElement); } break; case DataType.Tmplt: //选择模板文件夹的树不加载模板文件 if (TreeView.TreeMode == TreeMode.SelectTmplt || TreeView.TreeMode == TreeMode.General) { elementNode = new TmpltNode(element as TmpltSimpleExXmlElement); } break; case DataType.Page: //只有在右侧树中才显示页面 if (TreeView.TreeMode == TreeMode.General) { elementNode = new PageNode(element as PageSimpleExXmlElement); } break; case DataType.Resources: //只有在右侧树中才显示资源文件夹 if (TreeView.TreeMode == TreeMode.General) { elementNode = new ResourceRootNode(element as ResourcesXmlElement); } break; case DataType.Folder: { switch (((FolderXmlElement)element).FolderType) { case FolderType.ChannelFolder: //选择模板和选择模板文件夹的树不加载子频道 if (TreeView.TreeMode != TreeMode.SelectTmplt && TreeView.TreeMode != TreeMode.SelectTmpltFolder) { elementNode = new ChannelFolderNode(element as FolderXmlElement); } break; case FolderType.TmpltFolder: elementNode = new TmpltFolderNode(element as FolderXmlElement); break; case FolderType.ResourcesFolder: elementNode = new ResourceFolderNode(element as FolderXmlElement); break; default: Debug.Fail("未处理的FolderType类型:" + ((FolderXmlElement)element).FolderType); break; } break; } case DataType.File: elementNode = new ResourceFileNode(element as FileSimpleExXmlElement); break; case DataType.TmpltFolder: //选择频道的树不加载模板 if (TreeView.TreeMode != TreeMode.SelectChannel) { elementNode = new TmpltRootNode(element as TmpltFolderXmlElement); } break; default: Debug.Fail("未处理的Element的DataType:" + element.DataType); break; } if (elementNode == null) { return(null); } ///添加到树中 if (elementNode is ResourceRootNode) { ///资源文件夹的根,添加到第一个 this.AddChildNode(0, elementNode); ((RootChannelNode)this).ResourceRootNode = (ResourceRootNode)elementNode; } else if (elementNode is TmpltRootNode) { ///模板文件夹的根,添加到第二个 this.AddChildNode(1, elementNode); ((RootChannelNode)this).TmpltRootNode = (TmpltRootNode)elementNode; } else { this.AddChildNode(elementNode); } ///调用LoadData()加载本身的数据 elementNode.LoadData(); ///添加到收藏夹 if (elementNode.Element.IsFavorite) { if (TreeView.TreeMode == TreeMode.General) { TreeView.AddLinkNodeToFavorite(elementNode); } } return(elementNode); }
/// <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); } } } } }
/// <summary> /// 拖拽结束,将要移动节点的预处理。返回值:是否取消拖拽 /// </summary> /// <param name="srcNode"></param> /// <param name="e"></param> /// <returns></returns> void ProcessDragDropedNode(BaseTreeNode srcNode, DragDropNodeEventArgs e) { BaseTreeNode putNode = e.DragDropResult.DropPutNode as BaseTreeNode; SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; SimpleExIndexXmlElement dragEle = ((ElementNode)srcNode).Element; SimpleExIndexXmlElement targetEle = null; if (e.DragDropResult.DropPutNode is DataNode) { targetEle = ((ElementNode)e.DragDropResult.DropPutNode).Element; } ///将要拖放到此节点内 BaseTreeNode parentNode = null; if (e.DragDropResult.DropResultType == DragDropResultType.Into) { parentNode = (BaseTreeNode)e.DragDropResult.DropPutNode; } else { parentNode = (BaseTreeNode)e.DragDropResult.DropPutNode.Parent; } ///收藏夹的处理方式 if (parentNode.NodeType == TreeNodeType.Favorite) { doc.AddFavorite(dragEle); } /// else { ///移动 if ((e.DrgEvent.Effect & DragDropEffects.Move) != 0) { ///处理XmlElement bool result = doc.MoveNode(dragEle, targetEle, e.DragDropResult.DropResultType); if (result) { ///处理树节点 srcNode.Parent.RemoveChildNodeTemp(srcNode); switch (e.DragDropResult.DropResultType) { case DragDropResultType.Before: putNode.Parent.AddChildNodeTemp(putNode.Index, srcNode); break; case DragDropResultType.After: putNode.Parent.AddChildNodeTemp(putNode.Index + 1, srcNode); break; case DragDropResultType.Into: putNode.AddChildNodeTemp(srcNode); break; default: Debug.Assert(false); break; } } } ///拷贝 else if ((e.DrgEvent.Effect & DragDropEffects.Copy) != 0) { doc.CopyNode(dragEle.Id, ((ElementNode)parentNode).Element.Id); } } }
public MyFileItem(SimpleExIndexXmlElement element) : base(element) { _element = element; this.Text = _element.Title; }
public MyItem(SimpleExIndexXmlElement element) { _element = element; }
public ElementNode(SimpleExIndexXmlElement element, bool isFolder) : base(element.AbsoluteFilePath, isFolder) { this.Element = element; }
/// <summary> /// 加载项目 /// </summary> /// <param name="initPath"></param> void InitListView(SimpleExIndexXmlElement folderEle) { listView.Items.Clear(); SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; //加载子文件夹 foreach (XmlNode node in folderEle.ChildNodes) { if (node is FolderXmlElement) { FolderXmlElement folder = (FolderXmlElement)node; if (folder.IsDeleted) { continue; } MyFolderItem mylvi = new MyFolderItem(folder); string folderPath = folder.AbsoluteFilePath.Substring(0, folder.AbsoluteFilePath.Length - 1); mylvi.Text = Path.GetFileName(folderPath); mylvi.Text = folder.Title; listView.Items.Add(mylvi); } } //加载子文件 foreach (XmlNode node in folderEle.ChildNodes) { if (node is FileSimpleExXmlElement) { FileSimpleExXmlElement fileEle = (FileSimpleExXmlElement)node; MyFileItem myFileItem = new MyFileItem(fileEle); if (fileEle.IsDeleted) { continue; } myFileItem.Element = fileEle; myFileItem.Text = Path.GetFileName(fileEle.AbsoluteFilePath); myFileItem.Text = fileEle.Title; string exfile = Path.GetExtension(fileEle.AbsoluteFilePath).ToLower(); switch (FileType) { case MediaFileType.Pic: { if (exfile == ".jpg" || exfile == ".jpeg" /*|| exfile == ".png"*/ || exfile == ".gif") { myFileItem.ItemMediaType = MediaFileType.Pic; string valuestr = ""; if (!picFilter.TryGetValue(FilterComboBox.Text, out valuestr) || valuestr == "all") { listView.Items.Add(myFileItem); } else { if (exfile == valuestr) { listView.Items.Add(myFileItem); } } } break; } case MediaFileType.Flash: { if (exfile == ".swf") { myFileItem.ItemMediaType = MediaFileType.Flash; listView.Items.Add(myFileItem); } break; } case MediaFileType.Audio: { if (exfile == ".mp3" || exfile == ".mdi" || exfile == ".wma" || exfile == "*.wav") { myFileItem.ItemMediaType = MediaFileType.Audio; string valuestr = ""; if (!audioFilter.TryGetValue(FilterComboBox.Text, out valuestr) || valuestr == "all") { listView.Items.Add(myFileItem); } else { if (exfile == valuestr) { listView.Items.Add(myFileItem); } } } break; } case MediaFileType.Video: { if (exfile == ".rmvb" || exfile == ".rm" || exfile == ".avi" || exfile == ".wmv") { myFileItem.ItemMediaType = MediaFileType.Video; string valuestr = ""; if (!mediaFilter.TryGetValue(FilterComboBox.Text, out valuestr) || valuestr == "all") { listView.Items.Add(myFileItem); } else { if (exfile == valuestr) { listView.Items.Add(myFileItem); } } } break; } } } } //加载图标 foreach (MyItem lvitem in listView.Items) { string fullPath = lvitem.Element.AbsoluteFilePath; KeyValuePair <string, Image> keyImg = GetImageAndKey(fullPath); if (!listView.SmallImageList.Images.ContainsKey(keyImg.Key)) { listView.SmallImageList.Images.Add(keyImg.Key, keyImg.Value); } lvitem.ImageKey = keyImg.Key; } }
/// <summary> /// 导入资源文件方法 /// </summary> void ImportResources() { try { string newFilePath = string.Empty; SimpleExIndexXmlElement importFolder = null; SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; FormOpenFileDialog OpenFile = new FormOpenFileDialog(); #region 筛选处理 OpenFile.OpenDialog.Multiselect = true; string openfileFilter = ""; switch (fileType) { case MediaFileType.Pic: openfileFilter = "PIC files (*.jpg,*.gif)|*.jpg;*.gif;"; break; case MediaFileType.Flash: openfileFilter = "Flash files (.swf)|*.swf"; break; case MediaFileType.Video: openfileFilter = "Media files (*.rmvb,*.rm,*.avi,*.wmv)|*.rmvb;*.rm;*.avi;*.wmv"; break; case MediaFileType.Audio: openfileFilter = "Audio files (*.mp3,*.mdi,*.wma,*.wav)|*.mp3;*.mid;*.wma;*.wav"; break; } OpenFile.OpenDialog.Filter = openfileFilter; #endregion if (OpenFile.ShowDialog(this) == DialogResult.OK) { string[] fileNames = OpenFile.OpenDialog.FileNames; foreach (string srcFilePath in fileNames) { if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0] is MyFolderItem) { importFolder = (listView.SelectedItems[0] as MyItem)._element;// filePaths[pathNum].AbsoluteFilePath; filePaths.Add(importFolder); pathNum++; backToolStripButton.Enabled = upToolStripButton.Enabled = true; } else { importFolder = filePaths[pathNum]; if (importFolder is FileSimpleExXmlElement) { importFolder = filePaths[pathNum - 1]; } } FileSimpleExXmlElement fileEle = doc.CreateFileElement(importFolder as FolderXmlElement, srcFilePath); //#region 复制文件 /////将文件名翻译成拼音,生成一个不重名的文件名 //string fileName = Path.GetFileName(srcFilePath); //string pinyinFileName = Utility.File.FormatFileName(fileName); //string formatFileName = Utility.File.BuildFileName(importFolder.AbsoluteFilePath, pinyinFileName, false, true); //bool isNoIn = false;//标识是否已经加载的资源文件 //if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0] is MyFolderItem) //{ // importFolder = (listView.SelectedItems[0] as MyItem)._element;// filePaths[pathNum].AbsoluteFilePath; // filePaths.Add(importFolder); // pathNum++; // backToolStripButton.Enabled = upToolStripButton.Enabled = true; //} //else //{ // importFolder = filePaths[pathNum]; // if (importFolder is FileSimpleExXmlElement) // importFolder = filePaths[pathNum - 1]; //} //newFilePath = Path.Combine(importFolder.AbsoluteFilePath, formatFileName); //if (File.Exists(newFilePath)) //{ // if (MessageBox.Show("您确定要覆盖吗?", "确定", MessageBoxButtons.YesNo) == DialogResult.Yes) // { // isNoIn = false; // File.Copy(srcFilePath, newFilePath, true); // } //} //else //{ // isNoIn = true; // File.Copy(srcFilePath, newFilePath); //} //#endregion //#region 加入索引 //if (isNoIn) //{ // FileSimpleExXmlElement fileEle = doc.CreateFileElementNoCreateFile(importFolder as FolderXmlElement, formatFileName,fileName); //} //#endregion } if (importFolder != null) { InitListView(importFolder); } } } catch { } }
/// <summary> /// 获得节点的源父文件夹Url /// </summary> public static string GetElementSourceUrlPath(SimpleExIndexXmlElement simpleEle) { return(simpleEle.OldRelativeUrl); }
/// <summary> /// 生成页面文件 /// </summary> /// <param name="simpleEle"></param> public void BuildPageFile(SimpleExIndexXmlElement simpleEle) { //添加模板到Dictionary字典中 AddElementToDictionary(simpleEle); PageSimpleExXmlElement pageEle = (PageSimpleExXmlElement)simpleEle; string pageId = pageEle.Id; string channelId = pageEle.OwnerChannelElement.Id; //页面直属频道的Id PageXmlDocument pageDoc = SdsiteDocument.GetPageDocumentById(pageId); if (pageEle.IsDeletedRecursive) { //如果 是索引页面,删除本身的文件 filename.sdpage index.sdpage,其它页面则还要删除 //及一系列的关于页面的文件filename_head.inc filename_content.inc filename_list.inc pageDoc.DeleteXhtml(ToHtmlHelperObj); //此时就要看与此文件关联的其它文件 if (AsTmpltList(channelId)) { NewMethod(channelId); } //文件删除,则其它链接到此文件文件不做处理 } else if (!pageEle.IsAlreadyPublished) //新建 { //如果 是索引页面,新建本身的文件 filename.sdpage 及index.shtml //,其它类型页面则要新建一系列的关于页面的文件filename_head.inc filename_content.inc //todo:... //此时,就要查看与此关联的文件,是如何 if (AsTmpltList(channelId)) { //生成filename_list.inc文件 NewMethod(channelId); //此处不用考虑其路径问题 } } else { //文件路径是否改变(与重命名有密切关系) if (pageEle.IsChangedPosition) { //先将文件移动到新的位置 } if (pageEle.IsModified) { //页面本身的一些文件重新生成 //关联页面 NewMethod(channelId); //路径关联的一些页面的重新生成 //如果发生CustomID的变化,找到链接到此文件的所有页面,然后重新生成 } else { //如果是模板的内容布局有所在改变,则content还是要重新生成 } } }
public BaseFileElementNode(SimpleExIndexXmlElement element) : base(element, false) { }
public BaseFolderElementNode(SimpleExIndexXmlElement element) : base(element, true) { }
// add by zhangling on 2008年6月23日 2008年6月26日 加上了判断条件以统计相应的个数 private void SearchAndProcess(FolderXmlElement folderEle) { foreach (AnyXmlElement anyXmlEle in folderEle.ChildNodes) { SimpleExIndexXmlElement simpleEle = anyXmlEle as SimpleExIndexXmlElement; if (simpleEle != null) { switch (simpleEle.DataType) { case DataType.Channel: if (!simpleEle.IsDeleted) { _channelAmount = _channelAmount + 1; _includeFileAmount = _includeFileAmount + 1; } SearchAndProcess(simpleEle as FolderXmlElement); break; case DataType.Folder: if (simpleEle.FileName == "System" || !simpleEle.IsDeleted) { _includeFileAmount = _includeFileAmount + 1; } SearchAndProcess(simpleEle as FolderXmlElement); break; case DataType.TmpltFolder: case DataType.Resources: _includeFileAmount = _includeFileAmount + 1; SearchAndProcess(simpleEle as FolderXmlElement); break; case DataType.Tmplt: if (!simpleEle.IsDeleted) { _templetAmount = _templetAmount + 1; _includeFileAmount = _includeFileAmount + 1; } _dealwithFileOrFolder.DealWithFile(simpleEle); break; case DataType.Page: if (!simpleEle.IsDeleted) { _pageAmount = _pageAmount + 1; _includeFileAmount = _includeFileAmount + 1; } _dealwithFileOrFolder.DealWithFile(simpleEle); break; case DataType.File: if (!simpleEle.IsDeleted) { _resourceFileAmount = _resourceFileAmount + 1; _includeFileAmount = _includeFileAmount + 1; } _dealwithFileOrFolder.DealWithFile(simpleEle); break; default: break; } } } }