Example #1
0
        /// <summary>
        /// 重置所有的属性,包括Id。一般情况下是从外部导入或复制时调用。
        /// </summary>
        public void ResetAllProperty(bool isRemoveContent, bool isHomeType)
        {
            XmlNodeList snipNodes = DocumentElement.SelectNodes("//snip");

            foreach (XmlNode snipNode in snipNodes)
            {
                XmlElement snipEle = (XmlElement)snipNode;
                snipEle.SetAttribute("id", Utility.Guid.NewGuid());
                if (snipEle.GetAttribute("type").ToLower() == PageSnipType.Content.ToString().ToLower())
                {
                    if (isHomeType)
                    {
                        snipEle.SetAttribute("type", PageSnipType.None.ToString());
                        snipEle.SetAttribute("hasSnip", false.ToString());
                        XmlUtilService.RemoveAllChilds(snipEle);
                        continue;
                    }
                    if (isRemoveContent)
                    {
                        XmlUtilService.RemoveAllChilds((XmlElement)snipEle.SelectSingleNode("parts"));
                        continue;
                    }
                }
                XmlNodeList partNodes = snipEle.SelectNodes("//part");
                foreach (XmlNode partNode in partNodes)
                {
                    XmlElement partEle = (XmlElement)partNode;
                    partEle.SetAttribute("partId", XmlUtilService.CreateIncreaseId());
                }
            }
        }
Example #2
0
        public override void Save()
        {
            SaveDoc();
            List <AnyXmlElement> channelEles = GetAllChannelElement();

            XmlUtilService.RemoveAllChilds(SdsiteElement);
            foreach (AnyXmlElement ele in channelEles)
            {
                AnyXmlElement cEle = (AnyXmlElement)CreateElement("channelofsnip");
                cEle.SetAttribute("id", ele.GetAttribute("id"));
                SdsiteElement.AppendChild(cEle);
            }
            base.Save();
        }