Exemple #1
0
        public void Uninstall()
        {
            if (!Diagnostics.IsDebug(GetType().Assembly))
            {
                #region Delete custom pages from theme (factory defaults, configured defaults, and contextual pages)

                string basePath = BaseResourcePath + "Themes.";

                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.DeleteFactoryDefault(theme, pageName, true);
                                }

                                ThemePages.DeleteDefault(theme, pageName, true);
                                ThemePages.Delete(theme, pageName, true);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        new CSException(CSExceptionType.UnknownError,
                                        string.Format("Couldn't delete page from '{0}' embedded resource.", resourceName), exception)
                        .Log();
                    }
                });

                #endregion
            }
        }
        public void Uninstall()
        {
            if (!Diagnostics.IsDebug(GetType().Assembly))
            {
                string basePath = BaseResourcePath + ".Filestore.";

                EmbeddedResources.EnumerateReosurces(basePath, "", resourceName =>
                {
                    string file;

                    var cfsStore = GetFileStorageProvider(basePath, resourceName, out file);

                    if (cfsStore != null)
                    {
                        cfsStore.Delete("", file);
                    }
                });
            }
        }
        public void Install(Version lastInstalledVersion)
        {
            if (lastInstalledVersion < Version)
            {
                Uninstall();
                string basePath = BaseResourcePath + ".Filestore.";

                EmbeddedResources.EnumerateReosurces(basePath, "", resourceName =>
                {
                    string file;

                    var cfsStore = GetFileStorageProvider(basePath, resourceName, out file);

                    if (cfsStore != null)
                    {
                        cfsStore.AddUpdateFile("", file, EmbeddedResources.GetStream(resourceName));
                    }
                });
            }
        }
Exemple #4
0
 public void Uninstall()
 {
     if (!Diagnostics.IsDebug(GetType().Assembly))
     {
         EmbeddedResources.EnumerateReosurces(BaseResourcePath + "Sql.", ".uninstall.sql", resourceName =>
         {
             using (var connection = GetSqlConnection())
             {
                 connection.Open();
                 foreach (string statement in GetStatementsFromSqlBatch(EmbeddedResources.GetString(resourceName)))
                 {
                     using (var command = new SqlCommand(statement, connection))
                     {
                         command.ExecuteNonQuery();
                     }
                 }
                 connection.Close();
             }
         });
     }
 }
Exemple #5
0
 public void Install(Version lastInstalledVersion)
 {
     if (lastInstalledVersion < Version)
     {
         Uninstall();
         EmbeddedResources.EnumerateReosurces(BaseResourcePath + "Sql.", ".install.sql", resourceName =>
         {
             using (var connection = GetSqlConnection())
             {
                 connection.Open();
                 foreach (string statement in GetStatementsFromSqlBatch(EmbeddedResources.GetString(resourceName)))
                 {
                     using (var command = new SqlCommand(statement, connection))
                     {
                         command.ExecuteNonQuery();
                     }
                 }
                 connection.Close();
             }
         });
     }
 }
Exemple #6
0
        public virtual void Install(Version lastInstalledVersion)
        {
            if (lastInstalledVersion < Version)
            {
                Uninstall();

                string basePath = BaseResourcePath + "Widgets.";

                EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName =>
                {
                    try
                    {
                        string widgetName = resourceName.Substring(basePath.Length);

                        using (var stream = EmbeddedResources.GetStream(resourceName))
                        {
                            FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(this, widgetName, stream);
                        }

                        // Get widget identifier
                        XDocument xdoc = XDocument.Parse(EmbeddedResources.GetString(resourceName));
                        XElement root  = xdoc.Root;

                        if (root == null)
                        {
                            return;
                        }

                        XElement element = root.Element("scriptedContentFragment");

                        if (element == null)
                        {
                            return;
                        }

                        XAttribute attribute = element.Attribute("instanceIdentifier");

                        if (attribute == null)
                        {
                            return;
                        }

                        Guid instanceId = new Guid(attribute.Value);

                        string widgetBasePath = string.Concat(basePath, char.IsNumber(attribute.Value[0]) ? "_" : "", instanceId.ToString("N"), ".");
                        IEnumerable <string> supplementaryResources =
                            GetType().Assembly.GetManifestResourceNames().Where(r => r.StartsWith(widgetBasePath)).ToArray();

                        if (!supplementaryResources.Any())
                        {
                            return;
                        }

                        foreach (string supplementPath in supplementaryResources)
                        {
                            string supplementName = supplementPath.Substring(widgetBasePath.Length);

                            using (var stream = EmbeddedResources.GetStream(supplementPath))
                            {
                                FactoryDefaultScriptedContentFragmentProviderFiles
                                .AddUpdateSupplementaryFile(this, instanceId, supplementName, stream);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        new CSException(CSExceptionType.UnknownError, string.Format("Couldn't load widget from '{0}' embedded resource.", resourceName), exception).Log();
                    }
                });
            }
        }
Exemple #7
0
        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
            }
        }