Beispiel #1
0
        public void Uninstall()
        {
            InternalApi.PollingDataService.UnInstall();

            #region Remove Content from search
            try
            {
                //Remove Ideas and Challenges from search, mark all for reindexing when plugin is reenabled.
                TEApi.SearchIndexing.Delete(new SearchIndexDeleteOptions {
                    Category = "polls"
                });
                InternalApi.PollingDataService.ReIndexAllPolls();
            }
            catch (Exception ex)
            {
                var csex = new CSException(CSExceptionType.PluginInitializationError, "There was an error removing polling content from search", ex);
                csex.Log();
            }
            #endregion

            #region Delete custom pages used to support polls (from factory defaults, configured defaults, and contextual pages)

            foreach (var theme in UIApi.Themes.List(UIApi.ThemeTypes.Group))
            {
                var themeName = String.Empty;
                if (theme.Name == "7e987e474b714b01ba29b4336720c446")
                {
                    themeName = "Fiji";
                }
                else if (theme.Name == "424eb7d9138d417b994b64bff44bf274")
                {
                    themeName = "Enterprise";
                }

                if (!String.IsNullOrEmpty(themeName))
                {
                    if (theme.IsConfigurationBased)
                    {
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "createeditpoll", true);
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "poll", true);
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "polls", true);
                    }

                    UIApi.ThemePages.DeleteDefault(theme, "createeditpoll", true);
                    UIApi.ThemePages.DeleteDefault(theme, "poll", true);
                    UIApi.ThemePages.DeleteDefault(theme, "polls", true);

                    UIApi.ThemePages.Delete(theme, "createeditpoll", true);
                    UIApi.ThemePages.Delete(theme, "poll", true);
                    UIApi.ThemePages.Delete(theme, "polls", true);
                }
            }

            foreach (var theme in UIApi.Themes.List(UIApi.ThemeTypes.Site))
            {
                var themeName = String.Empty;
                if (theme.Name == "7e987e474b714b01ba29b4336720c446")
                {
                    themeName = "Fiji";
                }
                else if (theme.Name == "424eb7d9138d417b994b64bff44bf274")
                {
                    themeName = "Enterprise";
                }

                if (!String.IsNullOrEmpty(themeName))
                {
                    if (theme.IsConfigurationBased)
                    {
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "user-pollist", true);
                    }

                    UIApi.ThemePages.DeleteDefault(theme, "user-pollist", true);

                    UIApi.ThemePages.Delete(theme, "user-pollist", true);
                }
            }

            #endregion

            #region Remove Widget Files

            UIApi.FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(_widgetProvider);

            #endregion

            #region Uninstall CSS Files

            foreach (var theme in UIApi.Themes.List(UIApi.ThemeTypes.Site))
            {
                if (theme.IsConfigurationBased)
                {
                    UIApi.ThemeFiles.Remove(theme, UIApi.ThemeableApplicationIds.Site, UIApi.ThemeProperties.CssFiles, "polling.css");
                    UIApi.ThemeFiles.RemoveFactoryDefault(theme, UIApi.ThemeProperties.CssFiles, "polling.css");

                    //UIApi.ThemeFiles.Remove(theme, UIApi.ThemeableApplicationIds.Site, UIApi.ThemeProperties.CssFiles, "polling-handheld.css");
                    //UIApi.ThemeFiles.RemoveFactoryDefault(theme, UIApi.ThemeProperties.CssFiles, "polling-handheld.css");
                }
            }

            #endregion
        }
        public void Uninstall()
        {
            InternalApi.PollingDataService.UnInstall();

            #region Remove Content from search
            try
            {
                //Remove Ideas and Challenges from search, mark all for reindexing when plugin is reenabled.
                TEApi.SearchIndexing.Delete(new SearchIndexDeleteOptions { Category = "polls" });
                InternalApi.PollingDataService.ReIndexAllPolls();
            }
            catch (Exception ex)
            {
                var csex = new CSException(CSExceptionType.PluginInitializationError, "There was an error removing polling content from search", ex);
                csex.Log();
            }
            #endregion

            #region Delete custom pages used to support polls (from factory defaults, configured defaults, and contextual pages)

            foreach (var theme in UIApi.Themes.List(UIApi.ThemeTypes.Group))
            {
                var themeName = String.Empty;
                if (theme.Name == "7e987e474b714b01ba29b4336720c446")
                    themeName = "Fiji";
                else if (theme.Name == "424eb7d9138d417b994b64bff44bf274")
                    themeName = "Enterprise";

                if (!String.IsNullOrEmpty(themeName))
                {
                    if (theme.IsConfigurationBased)
                    {
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "createeditpoll", true);
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "poll", true);
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "polls", true);
                    }

                    UIApi.ThemePages.DeleteDefault(theme, "createeditpoll", true);
                    UIApi.ThemePages.DeleteDefault(theme, "poll", true);
                    UIApi.ThemePages.DeleteDefault(theme, "polls", true);

                    UIApi.ThemePages.Delete(theme, "createeditpoll", true);
                    UIApi.ThemePages.Delete(theme, "poll", true);
                    UIApi.ThemePages.Delete(theme, "polls", true);
                }
            }

            foreach (var theme in UIApi.Themes.List(UIApi.ThemeTypes.Site))
            {
                var themeName = String.Empty;
                if (theme.Name == "7e987e474b714b01ba29b4336720c446")
                    themeName = "Fiji";
                else if (theme.Name == "424eb7d9138d417b994b64bff44bf274")
                    themeName = "Enterprise";

                if (!String.IsNullOrEmpty(themeName))
                {
                    if (theme.IsConfigurationBased)
                    {
                        UIApi.ThemePages.DeleteFactoryDefault(theme, "user-pollist", true);
                    }

                    UIApi.ThemePages.DeleteDefault(theme, "user-pollist", true);

                    UIApi.ThemePages.Delete(theme, "user-pollist", true);
                }
            }

            #endregion

            #region Remove Widget Files

            UIApi.FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(_widgetProvider);

            #endregion

            #region Uninstall CSS Files

            foreach (var theme in UIApi.Themes.List(UIApi.ThemeTypes.Site))
            {
                if (theme.IsConfigurationBased)
                {
                    UIApi.ThemeFiles.Remove(theme, UIApi.ThemeableApplicationIds.Site, UIApi.ThemeProperties.CssFiles, "polling.css");
                    UIApi.ThemeFiles.RemoveFactoryDefault(theme, UIApi.ThemeProperties.CssFiles, "polling.css");

                    //UIApi.ThemeFiles.Remove(theme, UIApi.ThemeableApplicationIds.Site, UIApi.ThemeProperties.CssFiles, "polling-handheld.css");
                    //UIApi.ThemeFiles.RemoveFactoryDefault(theme, UIApi.ThemeProperties.CssFiles, "polling-handheld.css");
                }
            }

            #endregion
        }
        public override void AddContentControls(Control control)
        {
            try
            {
                InlineContentControl contentControl = new InlineContentControl(this);

                contentControl.ID = "inlinecontent";
                contentControl.DefaultContent = GetContentText();
                contentControl.DefaultAnonymousContent = GetAnonymousContentText();

                if (DynamicName)
                {
                    contentControl.InlineContentName  = PublicApi.Url.CurrentContext.PageName + "_";
                }

                if (ContextualMode == ContextMode.GroupContext || ContextualMode == ContextMode.Context)
                {
                    //This allows the control to have several instances on a single page
                    if (!string.IsNullOrWhiteSpace(InlineContentName))
                        contentControl.InlineContentName += InlineContentName + "_";

                    ContextualItem(a =>
                    {
                        contentControl.InlineContentName += a.ApplicationId.ToString();

                    }, c =>
                    {
                        if (c != null && c.ContainerId != PublicApi.Groups.Root.ContainerId)
                        {
                            contentControl.InlineContentName += c.ContainerId.ToString();
                        }
                        else
                        {
                            contentControl.InlineContentName += "SiteRoot";
                        }
                    }, ta =>
                    {
                        contentControl.InlineContentName += GetHashString(string.Join("", ta.OrderBy(s => s)));
                    });
                }
                else
                {
                    contentControl.InlineContentName += InlineContentName;    
                }
                
                control.Controls.Add(contentControl);
            }
            catch (CSException csEx)
            {
                csEx.Log();
                control.Controls.Add(new LiteralControl(csEx.Message));
            }
            catch (Exception ex)
            {
                CSException wrappedEx = new CSException(CSExceptionType.UnknownError, "Inline Content Exception", ex);
                wrappedEx.Log();

                control.Controls.Add(new LiteralControl(ex.Message));
            }
        }
        public override void AddContentControls(Control control)
        {
            try
            {
                InlineContentControl contentControl = new InlineContentControl(this);

                contentControl.ID                      = "inlinecontent";
                contentControl.DefaultContent          = GetContentText();
                contentControl.DefaultAnonymousContent = GetAnonymousContentText();

                if (DynamicName)
                {
                    contentControl.InlineContentName = PublicApi.Url.CurrentContext.PageName + "_";
                }

                if (ContextualMode == ContextMode.GroupContext || ContextualMode == ContextMode.Context)
                {
                    //This allows the control to have several instances on a single page
                    if (!string.IsNullOrWhiteSpace(InlineContentName))
                    {
                        contentControl.InlineContentName += InlineContentName + "_";
                    }

                    ContextualItem(a =>
                    {
                        contentControl.InlineContentName += a.ApplicationId.ToString();
                    }, c =>
                    {
                        if (c != null && c.ContainerId != PublicApi.Groups.Root.ContainerId)
                        {
                            contentControl.InlineContentName += c.ContainerId.ToString();
                        }
                        else
                        {
                            contentControl.InlineContentName += "SiteRoot";
                        }
                    }, ta =>
                    {
                        contentControl.InlineContentName += GetHashString(string.Join("", ta.OrderBy(s => s)));
                    });
                }
                else
                {
                    contentControl.InlineContentName += InlineContentName;
                }

                control.Controls.Add(contentControl);
            }
            catch (CSException csEx)
            {
                csEx.Log();
                control.Controls.Add(new LiteralControl(csEx.Message));
            }
            catch (Exception ex)
            {
                CSException wrappedEx = new CSException(CSExceptionType.UnknownError, "Inline Content Exception", ex);
                wrappedEx.Log();

                control.Controls.Add(new LiteralControl(ex.Message));
            }
        }