示例#1
0
        public void Save()
        {
            // update node
            XmlDocument configFile = config.MetaBlogConfigFile;
            XmlNode     channelXml = null;

            if (User != null && User.Id > -1)
            {
                channelXml = configFile.SelectSingleNode(string.Format("//channel [user = '******']", this.User.Id));
            }
            if (channelXml != null)
            {
                configFile.DocumentElement.RemoveChild(channelXml);
            }

            // add new node
            XmlElement newChannelxml = configFile.CreateElement("channel");

            newChannelxml.AppendChild(
                xmlHelper.addTextNode(configFile, "name", Name));
            newChannelxml.AppendChild(
                xmlHelper.addTextNode(configFile, "user", User.Id.ToString()));
            newChannelxml.AppendChild(
                xmlHelper.addTextNode(configFile, "startNode", StartNode.ToString()));
            newChannelxml.AppendChild(
                xmlHelper.addTextNode(configFile, "fullTree", FullTree.ToString()));
            newChannelxml.AppendChild(
                xmlHelper.addTextNode(configFile, "documentTypeAlias", DocumentTypeAlias));

            // fields
            XmlElement fieldsxml = configFile.CreateElement("fields");

            fieldsxml.AppendChild(
                xmlHelper.addTextNode(configFile, "categories", FieldCategoriesAlias));
            fieldsxml.AppendChild(
                xmlHelper.addTextNode(configFile, "description", FieldDescriptionAlias));
            fieldsxml.AppendChild(
                xmlHelper.addTextNode(configFile, "excerpt", FieldExcerptAlias));
            newChannelxml.AppendChild(fieldsxml);


            // media
            XmlElement media = configFile.CreateElement("mediaObjectSupport");

            media.Attributes.Append(xmlHelper.addAttribute(configFile, "enabled", ImageSupport.ToString()));
            media.Attributes.Append(xmlHelper.addAttribute(configFile, "folderId", MediaFolder.ToString()));
            media.Attributes.Append(xmlHelper.addAttribute(configFile, "mediaTypeAlias", MediaTypeAlias));
            media.Attributes.Append(xmlHelper.addAttribute(configFile, "mediaTypeFileProperty", MediaTypeFileProperty));
            newChannelxml.AppendChild(media);
            configFile.DocumentElement.AppendChild(newChannelxml);

            configFile.Save(IOHelper.MapPath(SystemFiles.MetablogConfig));
        }