Example #1
0
        /// <summary>
        /// 实现执行函数
        /// </summary>
        override public void Execute()
        {
            if (NewSnipData == null)
            {
                return;
            }
            TmpltDesignerPanel tDpanel = dPanel as TmpltDesignerPanel;

            tDpanel.SaveRects();
            foreach (Rect rect in PastedSnipRects)
            {
                rect.SnipData = new SnipData(NewSnipData);
                SnipXmlElement newEle = (SnipXmlElement)Doc.ParseElement(rect.SnipData.SnipElementText);
                if (Doc.HasContentSnip && newEle.SnipType == PageSnipType.Content)
                {
                    MessageService.Show("${res:tmpltDesign.tmpltDrawPanel.message.hasContentSnip}");
                    return;
                }
                SnipXmlElement ele = Doc.GetSnipElementById(rect.SnipID);
                ele.SelectSingleNode("parts").RemoveAll();
                ele.SetAttribute("hasSnip", newEle.GetAttribute("hasSnip"));
                ele.SetAttribute("type", newEle.GetAttribute("type"));

                XmlNodeList nodes = newEle.SelectSingleNode("parts").SelectNodes("//part");
                foreach (XmlNode partNode in nodes)
                {
                    (partNode as XmlElement).SetAttribute("partId", XmlUtilService.CreateIncreaseId());
                    ele.SelectSingleNode("parts").AppendChild(partNode);
                }
                rect.HasSnip = true;
            }
            dPanel.Modified = true;
        }
Example #2
0
        private void GetOpenItems(TmpltBaseTreeNode treeNode, List <string> _openItems)
        {
            if (treeNode == null)
            {
                return;
            }

            foreach (TreeNode treenode in treeNode.Nodes)
            {
                TmpltBaseTreeNode node = treenode as TmpltBaseTreeNode;
                if (node != null && node.IsExpanded)
                {
                    if (node is PartElementNode)
                    {
                        SnipPartXmlElement snipPartElement = ((TmpltBaseTreeNode)node).Element as SnipPartXmlElement;
                        _openItems.Add(snipPartElement.SnipPartId);
                    }
                    else if (node is SnipElementNode)
                    {
                        SnipXmlElement snipElement = ((TmpltBaseTreeNode)node).Element as SnipXmlElement;
                        _openItems.Add(snipElement.Id);
                    }
                    else if (node is TmpltElementNode)
                    {
                        TmpltSimpleExXmlElement tmpltElement = ((TmpltBaseTreeNode)node).Element as TmpltSimpleExXmlElement;
                        _openItems.Add(tmpltElement.Id);
                    }
                }
                GetOpenItems(node, _openItems);
            }
        }
Example #3
0
        /// <summary>
        /// 修改NODE显示的TEXT
        /// </summary>
        /// <param name="strNewText"></param>
        public virtual void ChangeNodeText(string strNewText)
        {//对节点重命名暂时仅支持页面片的重命名!
            TmpltBaseTreeNode tmpltBaseTreeNode = this;

            //找到对应的模板1
            while (!(tmpltBaseTreeNode is TmpltElementNode))
            {
                tmpltBaseTreeNode = (TmpltBaseTreeNode)tmpltBaseTreeNode.Parent;
            }

            TmpltSimpleExXmlElement tmpltElement = tmpltBaseTreeNode.Element as TmpltSimpleExXmlElement;

            //得到对应的模板文件DOC
            TmpltXmlDocument tmpltDocument = tmpltElement.GetIndexXmlDocument();

            if (this is SnipElementNode)
            {
                SnipXmlElement snipElement = ((this as SnipElementNode).Element) as SnipXmlElement;
                snipElement.SnipName = strNewText;

                //通知页面设计器,更改FORM的TEXT
                string[] strArray = new string[2];
                strArray[0] = snipElement.Id;
                strArray[1] = strNewText;
                SdsiteXmlDocument.OnSnipDesignerFormTextChange(new EventArgs <string[]>(strArray));
            }
        }
Example #4
0
 /// <summary>
 /// 生成正文页面片内容
 /// </summary>
 static public string GetContentPageContent(string contentId)
 {
     try
     {
         PageSimpleExXmlElement pageEle  = ToHtmlSdsiteService.SdsiteXmlDocument.GetPageElementById(contentId);
         TmpltXmlDocument       tmpltDoc = ToHtmlSdsiteService.SdsiteXmlDocument.GetTmpltDocumentById(pageEle.TmpltId);
         SnipXmlElement         snipEle  = tmpltDoc.GetContentSnipEle();
         string contentHtml = null;
         if (snipEle != null)
         {
             // lukan, 2008-6-23 10:38:45, 重构
             //contentHtml = snipEle.ToRealContentHtml(contentId);
             //if (snipEle.IsHaveContent == false && tmpltDoc.TmpltType == TmpltType.General)
             //{
             //    contentHtml += "<span>您在正文页面片中还没有添加正文,正文部分将无法显示</span>";
             //}
             //if (!string.IsNullOrEmpty(snipEle.ToRealCss()))
             //{
             //    ActiveTmpltAndSnip.AddSnipElementIntoDictionary(snipEle);
             //}
         }
         else
         {
             return("您还没有添加正文页面片!");
         }
         return(contentHtml);
     }
     catch (Exception e)
     {
         ExceptionService.CreateException(e);
         return(string.Empty);
     }
 }
Example #5
0
        public override bool Save()
        {
            ///得到Document里的相应页面片Element
            SnipXmlElement snipEleNew = _ownerTmpltForm.TmpltDoc.GetSnipElementById(SnipElement.Id);

            ///两个Element不是同一个对象,则更新
            if (!object.ReferenceEquals(SnipElement, snipEleNew))
            {
                SnipElement = snipEleNew;
            }

            //add by fenggy 2008-06-19
            //Snip的NAME有能修改,如果该页面片增加时没有保存且修改了NAME,以后在保存,这样的话,
            //NAME 是保存不上的,所以在这里在将修改过的名字重新赋值给页面片
            if (!string.IsNullOrEmpty(_newSnipName))
            {
                this.SnipElement.SnipName = _newSnipName;
            }

            ///得到页面片保存的Element
            SnipPageDesigner.SaveToElement(this.SnipElement);
            SnipPageDesigner.IsModified = false;

            OnSaved(EventArgs.Empty);

            return(true);
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        public static string GetKeywordListSnip(string tmpltId, string pageId)
        {
            PageSimpleExXmlElement pageEle    = ToHtmlSdsiteService.SdsiteXmlDocument.GetPageElementById(pageId);
            TmpltXmlDocument       tmpltDoc   = ToHtmlSdsiteService.SdsiteXmlDocument.GetTmpltDocumentById(tmpltId);
            SnipXmlElement         snipXmlEle = tmpltDoc.GetKeyListSnip();

            return("");// snipXmlEle.ToKeywordHtml(pageEle);
        }
Example #7
0
 override public void UnExecute()
 {
     foreach (Rect rect in PastedSnipRects)
     {
         rect.SnipData = OldSnipDatas[rect];
         SnipXmlElement ele = Doc.GetSnipElementById(rect.SnipID);
         ele = (SnipXmlElement)Doc.ParseElement(rect.SnipData.SnipElementText);
     }
 }
Example #8
0
        /// <summary>
        /// 删除页面片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void DrawPanel_RectDeleted(object sender, EventArgs <Rect> e)
        {
            e.Item.HasSnip = false;
            SnipXmlElement snipEle = ((TmpltXmlDocument)TmpltDoc).GetSnipElementById(e.Item.SnipID);

            if (snipEle.SnipType == PageSnipType.Content)
            {
                ((TmpltXmlDocument)TmpltDoc).HasContentSnip = false;
            }
            snipEle.HasSnip = false;
            snipEle.GetPartsElement().RemoveAll();
        }
Example #9
0
        /// <summary>
        /// 递归实现 矩形向Xml 节点的转换
        /// </summary>
        /// <param name="parentEle"></param>
        /// <param name="rect"></param>
        void AddRectToXml(XmlElement parentEle, RectTreeNode rect)
        {
            Rect resultRect = DrawPanel.ListRect.SnipRectList.Find(
                new FindRectByLayerRect(rect.RectLayer).PredicateEqualRect);

            if (resultRect != null)
            {
                //由一个矩形(SnipRect)生成一个XmlElement节点
                SnipRect            srect      = (SnipRect)resultRect;
                SnipXmlElement      snipXmlEle = (SnipXmlElement)TmpltDoc.CreateElement("snip");//CreateSnip(srect.SnipID);
                SnipPartsXmlElement partsEle   = (SnipPartsXmlElement)TmpltDoc.CreateElement("parts");
                snipXmlEle.AppendChild(partsEle);
                snipXmlEle.Id       = srect.SnipID;
                snipXmlEle.SnipName = srect.SnipName;
                snipXmlEle.Title    = srect.Title;
                snipXmlEle.Css      = srect.ToCss;
                snipXmlEle.HasSnip  = srect.HasSnip;
                snipXmlEle.SnipType = srect.SnipType;
                if (srect.SnipType == PageSnipType.Content)
                {
                    TmpltDoc.HasContentSnip = true;
                }
                else
                {
                    TmpltDoc.HasContentSnip = false;
                }
                snipXmlEle.X        = srect.X;
                snipXmlEle.Y        = srect.Y;
                snipXmlEle.Width    = srect.Width.ToString() + "px";
                snipXmlEle.Height   = srect.Height.ToString() + "px";
                snipXmlEle.IsLocked = srect.IsLocked;
                rect.Element        = snipXmlEle;
            }
            else
            {
                SnipRectXmlElement rectEle = (SnipRectXmlElement)TmpltDoc.CreateElement("rect");
                rectEle.Css   = rect.RectLayer.Css;
                rectEle.IsRow = !rect.RectLayer.IsRow;
                rect.Element  = rectEle;
                //如果有孩子,则继续遍历
                if (rect.RectLayer.ChildRects != null)
                {
                    foreach (RectLayer childRect in rect.RectLayer.ChildRects)
                    {
                        AddRectToXml(rect.Element, new RectTreeNode(childRect, null));
                    }
                }
            }
            parentEle.AppendChild(rect.Element);
        }
Example #10
0
 /// <summary>
 ///  将已经运行过Tohtml的SnipEle实例加入字典,以便ToCSS的产生
 /// </summary>
 static public void AddSnipElementIntoDictionary(SnipXmlElement snipEle)
 {
     if (_activeSnipDictionary == null)
     {
         _activeSnipDictionary = new Dictionary <string, SnipXmlElement>();
         _activeSnipDictionary.Add(snipEle.Id, snipEle);
     }
     else
     {
         if (!_activeSnipDictionary.ContainsKey(snipEle.Id))
         {
             _activeSnipDictionary.Add(snipEle.Id, snipEle);
         }
     }
 }
Example #11
0
        void pageComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.codeTextBox.Clear();
            this.outXmlTextBox.Clear();
            this.tree.Nodes.Clear();

            string id    = ((PageObject)this.pageComboBox.SelectedItem).Id;
            string title = ((PageObject)this.pageComboBox.SelectedItem).title;

            string         tmpltid = this.InnerDoc.GetPageElementById(id).TmpltId;
            SnipXmlElement snip    = this.InnerDoc.GetTmpltDocumentById(tmpltid).GetContentSnipEle();
            //snip.ToHtmlPage = this.InnerDoc.GetPageDocumentById(id);

            bool b = this.InnerDoc.GetPageDocumentById(id).SaveXhtml(this._htmlHelper);

            MessageBox.Show("Save Page:\r\n(" + id + ") \r\n" + title + "\r\n" + b.ToString());
        }
Example #12
0
 /// <summary>
 /// 通过模板及snipID获得页面片的HTml,并将该SnipEle实例加入到字典中,为Tocss做准备
 /// </summary>
 static public string GetSnipContent(string tmpltId, string snipId)
 {
     try
     {
         TmpltXmlDocument tmpltDoc = ToHtmlSdsiteService.SdsiteXmlDocument.GetTmpltDocumentById(tmpltId);
         SnipXmlElement   snipEle  = tmpltDoc.GetSnipElementById(snipId);
         string           snipHtml = "";// lukan, 2008-6-23 10:38:45, 重构             snipEle.ToRealHtml();
         //if (!string.IsNullOrEmpty(snipEle.ToRealCss()))
         //{
         //    ActiveTmpltAndSnip.AddSnipElementIntoDictionary(snipEle);
         //}
         return(snipHtml);
     }
     catch (Exception e)
     {
         ExceptionService.CreateException(e);
         return(string.Empty);
     }
 }
Example #13
0
        private void NewMethod(string channelId)
        {
            //查找拥有此页面直属的频道节点的所有的模板节点,返回模板ID集合
            string[] tmpltIdArray = SdsiteDocument.GetTmpltIdArray(channelId);

            foreach (var tmpltId in tmpltIdArray)
            {
                TmpltXmlDocument tmpltDoc = SdsiteDocument.GetTmpltDocumentById(tmpltId);

                //得到当前模板下拥有此页面所属频道的类型为list的所有part的父父级snip的集合
                string[] snipIdArray = SdsiteDocument.GetSnipIdArray(tmpltId, channelId);

                //循环snip集合,获得每个snip节点下的分别有拥有此页面所属的频道的类型为list的part节点的集合
                foreach (var snipId in snipIdArray)
                {
                    //重新生成 snip 页面
                    SnipXmlElement snipEle = tmpltDoc.GetSnipElementById(snipId);
                    if (!snipEle.IsModified)
                    {
                        snipEle.SaveXhtml(ToHtmlHelperObj);
                    }

                    //对其part 的处理
                    snipEle.GetPartsElement();
                }

                //不论按哪种排序,则先将其所属的snip节点重新生成一遍


                //如果其排序方式为自动提取关键字,则取出此part下的所有频道id,及页面类型集合


                //循环这些频道,找出页面类型为以上类型集合的所有页面


                //此处应有一些分支操作:=====isModified = false的一定要重新生成(并记录下isModified=false,并记录重新生成过的页面),而ismodified为真或是isAlreadyPublish =false,或是isdeleted=true自然会有一些相应的操作


                //最后,将重新生成这些页面
            }
        }
Example #14
0
        /// <summary>
        /// 打开或添加页面片属性
        /// </summary>
        /// <param name="selectedRect"></param>
        private void ChangeSnipPerperty(SnipRect selectedRect)
        {
            if (selectedRect.HasSnip)
            {
                ///打开页面片
                Form snipForm = Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, selectedRect.SnipID, (TDPanel as TmpltDesignerPanel).TmpltID);
            }
            else
            {
                TmpltXmlDocument   doc     = TmpltDoc;
                TmpltDesignerPanel tDpanel = TDPanel as TmpltDesignerPanel;
                //tDpanel.SaveTmplt(doc);
                tDpanel.SaveRects();
                NewSnipSetupForm form = new NewSnipSetupForm(doc, selectedRect, GetHasContentSnip());
                if (form.ShowDialog() == DialogResult.OK)
                {
                    SnipXmlElement snipElement = doc.GetSnipElementById(selectedRect.SnipID);
                    snipElement.SnipName = form.SnipName;
                    snipElement.SnipType = form.SnipType;
                    snipElement.Width    = selectedRect.Width.ToString() + "px";
                    snipElement.Height   = selectedRect.Height.ToString() + "px";
                    snipElement.Title    = form.SnipName;
                    snipElement.HasSnip  = true;

                    tDpanel.SaveRects();
                    selectedRect.HasSnip  = true;
                    TDPanel.Modified      = true;
                    selectedRect.SnipType = form.IsContent ? PageSnipType.Content : PageSnipType.General;
                    if (form.IsContent)
                    {
                        if (!doc.HasContentSnip)
                        {
                            doc.HasContentSnip = true;
                        }
                    }
                    TDPanel.HasContentSnip = form.IsContent;
                    ///打开页面片
                    Form snipForm = Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, selectedRect.SnipID, (TDPanel as TmpltDesignerPanel).TmpltID);
                }
            }
        }
        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);
            }
        }
Example #16
0
        /// <summary>
        /// 响应当前矩形Css属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CurRectProperty_Click(object sender, EventArgs e)
        {
            ((TmpltDesignerPanel)TDPanel).SaveTmplt(TmpltDoc);
            Rect selectedRect = ListRect.GetSelectedRect(FirstRealPoint, SelectPrecision);

            if (selectedRect is SnipRect)
            {
                SnipRect       snipRect = (SnipRect)selectedRect;
                SnipXmlElement ele      = TmpltDoc.GetSnipElementById(snipRect.SnipID);

                //writed by zhenghao 2008.05.20
                CssSettingForm form = new CssSettingForm(snipRect.ToCss);
                form.Owner = this.FindForm();
                if (form.ShowDialog() == DialogResult.OK)
                {
                    snipRect.ToCss = form.CssText;
                    ele.Css        = snipRect.ToCss;
                    this.DrawFrame.TDPanel.Modified = true;
                }
            }
        }
Example #17
0
        /// <summary>
        /// 保存矩形
        /// </summary>
        public void SaveRects()
        {
            float x = DrawPanel.CurZoom;

            DrawPanel.CurZoom = 1;
            Dictionary <string, XmlElement> _tempSnips = TmpltDoc.GetAllSnipElementClone();
            XmlElement docEle = (XmlElement)TmpltDoc.DocumentElement.SelectSingleNode("rects");

            docEle.RemoveAll();

            RectLayer boundaryRect = new RectLayer(0, 0, DrawPanel.Width, DrawPanel.Height, TmpltDoc.TmpltCss);

            LineToRect(boundaryRect);


            AddRectToXml(docEle, new RectTreeNode(boundaryRect, null));

            XmlNodeList snipNodes = docEle.SelectNodes(@"//snip");

            foreach (XmlNode snipNode in snipNodes)
            {
                if (snipNode.NodeType == XmlNodeType.Element)
                {
                    SnipXmlElement snipEle = (SnipXmlElement)snipNode;
                    string         id      = snipEle.Id;
                    if (_tempSnips.ContainsKey(id))
                    {
                        CssSection tempCss = CssSection.Parse(snipEle.GetAttribute("css"));
                        XmlUtilService.CopyXmlElement(_tempSnips[id], snipEle);
                        snipEle.Width  = tempCss.Properties["width"];
                        snipEle.Height = tempCss.Properties["height"];
                        snipEle.Css    = tempCss.ToString();
                    }
                }
            }
            DrawPanel.CurZoom = x;

            TmpltDoc.Reseted = true;
        }
Example #18
0
        private void SetTmpltTree(AnyXmlElement anyXmlElement, TreeNode treenode)
        {
            ToHtmlXmlElement ele = (ToHtmlXmlElement)anyXmlElement;

            i++;
            TreeNode newNode = new TreeNode(ele.LocalName);

            treenode.Nodes.Add(newNode);
            if (ele.SaveXhtml(this._htmlHelper))
            {
                SnipXmlElement snip    = (SnipXmlElement)anyXmlElement;
                StreamReader   sr      = new StreamReader(snip.HtmlFile);
                string         content = sr.ReadToEnd().Replace(">", ">\r\n");
                sr.Close();
                sr.Dispose();


                newNode.ToolTipText = content;
            }
            else
            {
                newNode.ToolTipText = "Don't must be creat file!";
            }
            foreach (XmlNode node in ele.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (!(node is ToHtmlXmlElement))
                {
                    continue;
                }
                SetTmpltTree((AnyXmlElement)node, newNode);
            }
        }
Example #19
0
        /// <summary>
        /// 定位到模板/页面片/PART
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TmpltTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TmpltBaseTreeNode tmpltBaseNode = e.Node as TmpltBaseTreeNode;

            if (tmpltBaseNode == null)
            {
                return;
            }

            switch (tmpltBaseNode.NodeType)
            {
            case TreeNodeType.Tmplt:
                //打开(或激活)模板
                Service.Workbench.OpenWorkDocument(WorkDocumentType.TmpltDesigner, ((TmpltSimpleExXmlElement)tmpltBaseNode.Element).Id);
                break;

            case TreeNodeType.Snip:
            {        //打开页面片
                //得到对应的页面片
                SnipElementNode snipElementNode = tmpltBaseNode as SnipElementNode;
                SnipXmlElement  snipElement     = snipElementNode.Element as SnipXmlElement;

                //得到页面片所属的模板文件
                TmpltElementNode        tmpltElementNode = snipElementNode.Parent as TmpltElementNode;
                TmpltSimpleExXmlElement tmpltElement     = tmpltElementNode.Element as TmpltSimpleExXmlElement;

                //先打开(或激活)对应的模板 如果该模板已经打开,不用打开也不用激活她,因为目的是为了打开页面片
                //如果打开的话回出现令人烦的闪烁现象
                if (!Service.Workbench.GetResultKeyID(WorkDocumentType.TmpltDesigner, tmpltElement.Id))
                {
                    Service.Workbench.OpenWorkDocument(WorkDocumentType.TmpltDesigner, tmpltElement.Id);
                }
                //打开(激活)页面片
                Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, snipElement.Id, tmpltElement.Id);


                //因为如果添加一个页面片且没有保存,再重命名,新的名不能保存,模板里没有对应的内容
                //所以的通知页面片设计器,将FORM的TEXT进行修改
                snipElementNode.ChangeNodeText(e.Node.Text);
            }

            break;

            case TreeNodeType.SnipPart:
            {         //找到PART对应的页面片
                PartElementNode    partElemetNode  = tmpltBaseNode as PartElementNode;
                SnipPartXmlElement snipPartElement = partElemetNode.Element as SnipPartXmlElement;

                TmpltBaseTreeNode tmpltNode = (TmpltBaseTreeNode)partElemetNode;
                while (!(tmpltNode is SnipElementNode))
                {
                    tmpltNode = (TmpltBaseTreeNode)(tmpltNode.Parent);
                }

                //得到对应的页面片
                SnipElementNode snipElementNode = tmpltNode as SnipElementNode;
                SnipXmlElement  snipElement     = snipElementNode.Element as SnipXmlElement;


                ////得到页面片所属的模板文件
                TmpltElementNode        tmpltElementNode = snipElementNode.Parent as TmpltElementNode;
                TmpltSimpleExXmlElement tmpltElement     = tmpltElementNode.Element as TmpltSimpleExXmlElement;

                //先打开(或激活)对应的模板
                if (!Service.Workbench.GetResultKeyID(WorkDocumentType.TmpltDesigner, tmpltElement.Id))
                {
                    Service.Workbench.OpenWorkDocument(WorkDocumentType.TmpltDesigner, tmpltElement.Id);
                }

                //打开页面片!
                Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, snipElement.Id, tmpltElement.Id);
                string [] strArray = new string[2];
                strArray[0] = snipElement.Id;
                strArray[1] = snipPartElement.SnipPartId;

                SdsiteXmlDocument.OnOrientationPart(new EventArgs <string[]>(strArray));
            }
            break;
            }
        }
Example #20
0
        /// <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);
                        }
                    }
                }
            }
        }
Example #21
0
 public SnipElementNode(SnipXmlElement element)
     : base(element)
 {
 }