public static void Deconstruct(XmlTransporter transporter, IXPathNavigable doc)
        {
            // builder.ParseItemTypes(doc);
            // builder.ParseRelationshipTypes(doc);
            // builder.ParseApprovalStatusTypes(doc);
            transporter.ImportCategories(doc);
            transporter.ImportArticles(doc);
            transporter.ImportRelationships(doc);
            transporter.ImportItemVersionSettings(doc);
            transporter.ImportModuleSettings(doc);

            // TODO: we need to import module settings
        }
Esempio n. 2
0
        public static void Construct(XmlTransporter transporter, bool exportAll)
        {
            if (transporter == null) throw new ArgumentNullException("transporter");

            transporter.BuildRootNode();
            //transporter.BuildCategories(exportAll);
            transporter.BuildCategories(true);
            transporter.BuildArticles(exportAll);
            transporter.BuildRelationships(exportAll);
            transporter.BuildItemVersionSettings(exportAll);
            transporter.BuildModuleSettings();

            //TODO: we need to export module settings
        }
        /// <summary>
        /// Method is invoked when portal template is created or user selects Export Content from menu.
        /// </summary>
        /// <param name="moduleId"></param>
        /// <returns></returns>
        public string ExportModule(int moduleId)
        {
            bool exportAll = false;

            // check query string for a "All" param to signal all rows, not just for a moduleId
            if (HttpContext.Current != null && HttpContext.Current.Request.QueryString["all"] != null)
            {
                exportAll = true;
            }

            XmlTransporter builder;
            try
            {
                builder = new XmlTransporter(moduleId);
                XmlDirector.Construct(builder, exportAll);
            }
            catch (Exception e)
            {
                Exceptions.LogException(new Exception(e.ToString()));
                throw;
            }

            return builder.Document.OuterXml;
        }
        /// <summary>
        /// Method is invoked when portal template is imported or user selects Import content from menu.
        /// </summary>
        /// <param name="moduleId"></param>
        /// <param name="content"></param>
        /// <param name="version"></param>
        /// <param name="userId"></param>
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            // TODO: implement Import for Text/HTML modules
            var validator = new TransportableXmlValidator();
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));

            if (validator.Validate(stream) == false)
            {
                var invalidXml = new Exception("Unable to import publish content due to incompatible XML file. Error: " + validator.Errors[0]);
                Exceptions.LogException(invalidXml);
                throw invalidXml;
            }

            // The DNN ValidatorBase closes the stream? Must re-create. hk
            stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
            var doc = new XPathDocument(stream);
            var builder = new XmlTransporter(moduleId);

            // TODO: we need to set the ItemID setting to be this recently imported article
            try
            {
                XmlDirector.Deconstruct(builder, doc);
            }
            catch (Exception e)
            {
                Exceptions.LogException(new Exception(e.ToString()));
                throw;
            }
        }
        /// <summary>
        /// Method is invoked when portal template is imported or user selects Import content from menu.
        /// </summary>
        /// <param name="moduleId"></param>
        /// <param name="content"></param>
        /// <param name="version"></param>
        /// <param name="userId"></param>
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            try
            {
                var validator = new TransportableXmlValidator();
                var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));

                if (validator.Validate(stream) == false)
                {
                    var invalidXml = new Exception("Unable to import publish content due to incompatible XML file. Error: " + validator.Errors[0]);
                    Exceptions.LogException(invalidXml);
                    throw invalidXml;
                }

                // The DNN ValidatorBase closes the stream? Must re-create. hk
                stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
                var doc = new XPathDocument(stream);
                var builder = new XmlTransporter(moduleId);
                XmlDirector.Deconstruct(builder, doc);
            }
            catch (Exception e)
            {
                Exceptions.LogException(e);
                throw;
            }
        }