private void InstallPages(string assemblyName, IEnumerable <string> resourceNames) { var xml = new XmlDocument(); var contentPages = Pages(assemblyName, resourceNames); foreach (var theme in Themes.List(ThemeTypes.Group)) { var supportedTheme = SupportedThemes.Get(theme.Id); if (supportedTheme == null) { continue; } var themeName = supportedTheme.Name; foreach (var contentPage in contentPages.Where(p => p.Theme == themeName).ToList()) { xml.LoadXml(EmbeddedResources.GetString(contentPage.Path)); foreach (XmlNode xmlPage in xml.SelectNodes("//contentFragmentPage")) { var pageName = xmlPage.Attributes["pageName"].Value; #if DEBUG Telligent.Evolution.Extensibility.Api.Version1.PublicApi.Eventlogs.Write(string.Format("Adding Page \"{0}\"", pageName), new Telligent.Evolution.Extensibility.Api.Version1.EventLogEntryWriteOptions { Category = "SharePoint", EventId = 1000, EventType = "Information" }); #endif if (theme.IsConfigurationBased) { ThemePages.AddUpdateFactoryDefault(theme, xmlPage); } if (!ThemePages.DefaultExists(theme, pageName, false)) { ThemePages.AddUpdateDefault(theme, xmlPage); } ThemePages.AddUpdate(theme, ThemeTypes.Site, xmlPage); } } } }
public void Install(Version lastInstalledVersion) { if (lastInstalledVersion < Version) { Uninstall(); #region Install custom theme string basePath = BaseResourcePath + "Themes."; EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName => { // Get widget identifier XmlDocument xmlDocument = new XmlDocument(); try { xmlDocument.LoadXml(EmbeddedResources.GetString(resourceName)); XmlNode node = xmlDocument.SelectSingleNode("/theme/themeImplementation"); if (node != null) { ThemeConfigurations.DeserializeTheme(node, true, false); } } catch (Exception exception) { new CSException(CSExceptionType.UnknownError, string.Format("Couldn't load theme from '{0}' embedded resource.", resourceName), exception).Log(); } }); #endregion #region Install custom pages into theme (and revert any configured defaults or contextual versions of these pages) basePath = BaseResourcePath + "Pages."; EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName => { XmlDocument xml = new XmlDocument(); try { xml.LoadXml(EmbeddedResources.GetString(resourceName)); XmlNode node = xml.SelectSingleNode("/theme/contentFragmentPages/contentFragmentPage"); if (node == null || node.Attributes == null) { return; } string pageName = node.Attributes["pageName"].Value; string themeType = node.Attributes["themeType"].Value; if (string.IsNullOrEmpty(pageName) || string.IsNullOrEmpty(themeType)) { return; } foreach (Theme theme in Themes.List(Guid.Parse(themeType))) { if (theme != null) { if (theme.IsConfigurationBased) { ThemePages.AddUpdateFactoryDefault(theme, node); ThemePages.DeleteDefault(theme, pageName, true); } else { ThemePages.AddUpdateDefault(theme, node); } ThemePages.Delete(theme, pageName, true); } } } catch (Exception exception) { new CSException(CSExceptionType.UnknownError, string.Format("Couldn't load page from '{0}' embedded resource.", resourceName), exception).Log(); } }); #endregion } }