Example #1
0
        public static void ImportStyles(Stream stylesXmlStream, Guid siteGuid)
        {
            try
            {
                XmlDocument stylesXmlDoc = new XmlDocument();
                using (stylesXmlStream)
                {
                    stylesXmlDoc.Load(stylesXmlStream);
                }

                if (stylesXmlDoc.DocumentElement.Name != "ContentStyles")
                {
                    return;
                }
                foreach (XmlNode node in stylesXmlDoc.DocumentElement.ChildNodes)
                {
                    if (node.Name == "Style")
                    {
                        ContentStyle style       = ContentStyle.GetNew(siteGuid);
                        SiteUser     currentUser = SiteUtils.GetCurrentSiteUser();
                        if (currentUser != null)
                        {
                            style.LastModBy = currentUser.UserGuid;
                        }
                        style.Name     = node.Attributes["Name"].Value;
                        style.Element  = node.Attributes["Element"].Value;
                        style.CssClass = node.Attributes["CssClass"].Value;
                        style.IsActive = Convert.ToBoolean(node.Attributes["IsActive"].Value);
                        style.Save();
                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                log.Error(ex);
            }
            catch (ArgumentException ex)
            {
                log.Error(ex);
            }
        }