Esempio n. 1
0
        void IInstallablePlugin.Uninstall()
        {
            #region Remove Widget Files

            FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(this);

            #endregion
        }
Esempio n. 2
0
        //notes on guids
        //evolutionGuid = "aa8056256ecb481bae92f2db9f87e893";
        //fijiGuid = "7e987e474b714b01ba29b4336720c446";
        //socialGuid = "3fc3f82483d14ec485ef92e206116d49";
        //enterpriseGuid = "424eb7d9138d417b994b64bff44bf274";

        //blogThemeTypeID = new Guid("a3b17ab0-af5f-11dd-a350-1fcf55d89593");
        //groupThemeTypeID = new Guid("c6108064-af65-11dd-b074-de1a56d89593");
        //siteThemeTypeID = new Guid("0c647246-6735-42f9-875d-c8b991fe739b");
        void IInstallablePlugin.Install(Version lastInstalledVersion)
        {
            #region Install Widgets

            FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(this);

            //install default widgets and supplementary files
            var definitionFiles = new string[] {
                "SamlLoginAutoSelect-Widget.xml"
                , "SamlLogout-Widget.xml"
            };

            foreach (var definitionFile in definitionFiles)
            {
                using (var stream = EmbeddedResources.GetStream("Telligent.Services.SamlAuthenticationPlugin.Resources.Widgets." + definitionFile))
                    FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(this, definitionFile, stream);
            }

            ContentFragments.Enable(ThemeTypes.Site, ContentFragments.GetScriptedContentFragmentTypeString(new Guid("63b5fbf0d2db41eaa165c27ac43ee0f7"))); //Login Auto Select
            ContentFragments.Enable(ThemeTypes.Site, ContentFragments.GetScriptedContentFragmentTypeString(new Guid("31728beb334e420e84200cc6f81d109c"))); //Logout

            #endregion

            #region Insert Widgets Into existing themes and pages

            foreach (var theme in Themes.List(ThemeTypes.Site))
            {
                //add the saml auto select widget to the login page

                if (theme.Name == "3fc3f82483d14ec485ef92e206116d49")
                {
                    //Add CaseList to User profile page after Activity List
                    InsertWidget(theme
                                 , "common-login"
                                 , false
                                 , "Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.ScriptedContentFragments::b1db6b71c0be43b58925e469eb6315a4"
                                 , ContentFragmentPlacement.Before
                                 , "content"
                                 , "Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.ScriptedContentFragments::63b5fbf0d2db41eaa165c27ac43ee0f7"
                                 , ""
                                 , "no-wrapper responsive-1");
                }
            }


            #endregion

            #region Create Database Table if required
            InitializeScheama();
            #endregion
        }
        public virtual void Install(Version lastInstalledVersion)
        {
            var assembly = GetType().Assembly;

            foreach (var fragment in ScriptedContentFragments)
            {
                FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(this, string.Format("{0}.xml", fragment.GetType().Name), assembly.GetManifestResourceStream(fragment.DefinitionFile));

                foreach (var supplementaryFile in fragment.SupplementaryFiles)
                {
                    FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateSupplementaryFile(this, fragment.FragmentId, supplementaryFile.Filename, assembly.GetManifestResourceStream(supplementaryFile.ResourceName));
                }
            }
        }
Esempio n. 4
0
 public virtual void Uninstall()
 {
     if (!Diagnostics.IsDebug(GetType().Assembly))
     {
         //Only in release do we want to uninstall widgets, when in development we don't want this to happen
         try
         {
             FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(this);
         }
         catch (Exception exception)
         {
             new CSException(CSExceptionType.UnknownError, string.Format("Couldn't delete factory default widgets from provider ID: '{0}'.", ScriptedContentFragmentFactoryDefaultIdentifier), exception).Log();
         }
     }
 }
        public void Initialize()
        {
            Func <string, Guid> getGuidFromResourceString = delegate(string inGuid)
            {
                Guid outGuid;
                if (Guid.TryParse(inGuid.StartsWith("_") ? inGuid.Substring(1) : inGuid, out outGuid))
                {
                    return(outGuid);
                }
                return(Guid.Empty);
            };

            var assembly           = GetType().Assembly;
            var assemblyNameLength = assembly.GetName().Name.Length + 1;

            foreach (string resourceName in assembly.GetManifestResourceNames())
            {
                string[] path = resourceName.Substring(assemblyNameLength).Split('.');
                if (path.Length > 3 &&
                    string.Compare(path[0], "filestorage", true) == 0 &&
                    string.Compare(path[1], "defaultwidgets", true) == 0 &&
                    getGuidFromResourceString(path[2]) == ScriptedContentFragmentFactoryDefaultIdentifier)
                {
                    Guid instanceId = getGuidFromResourceString(path[3]);
                    if (path.Length > 4 &&
                        instanceId != Guid.Empty &&
                        (string.Compare(path[4], "xml", true) != 0 || path.Length > 5))
                    {
                        FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateSupplementaryFile(
                            this,
                            instanceId,
                            string.Join(".", path.ToList().GetRange(4, path.Length - 4)),
                            assembly.GetManifestResourceStream(resourceName)
                            );
                    }
                    else if (string.Compare(path[path.Length - 1], "xml", true) == 0)
                    {
                        FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(
                            this,
                            string.Join(".", path.ToList().GetRange(3, path.Length - 3)),
                            assembly.GetManifestResourceStream(resourceName)
                            );
                    }
                }
            }
        }
Esempio n. 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();
                    }
                });
            }
        }
Esempio n. 7
0
 public void Uninstall()
 {
     FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(this);
 }
 private static void RemoveWidgets(IScriptedContentFragmentFactoryDefaultProvider provider)
 {
     FactoryDefaultScriptedContentFragmentProviderFiles.DeleteAllFiles(provider);
 }
        private void InstallWidgets(string assemblyName, IEnumerable <string> resourceNames)
        {
            foreach (string resourceName in resourceNames)
            {
                string[] path = resourceName.Split('.');

                // path: Resources.Widgets.[name]
                const int resourcesIndex  = 0;
                const int widgetsIndex    = 1;
                const int widgetNameIndex = 2;

                // path: Resources.Widgets.[name].[file].xml
                const int xmlFileIndex      = 3;
                int       xmlExtensionIndex = path.Length - 1;

                // path: Resources.Widgets.[name].[guid].[theme].[file]
                const int widgetFolderIdIndex = 3;
                const int themeIndex          = 4;
                const int fileIndex           = 5;

                bool isAWidgetDefinitionFile = path.Length > 4 &&
                                               string.Equals(path[resourcesIndex], "Resources", StringComparison.OrdinalIgnoreCase) &&
                                               string.Equals(path[widgetsIndex], "Widgets", StringComparison.OrdinalIgnoreCase);
                if (!isAWidgetDefinitionFile)
                {
                    continue;
                }

                var  resourceFullName = string.Concat(assemblyName, ".", resourceName);
                bool isAWidgetXmlFile = path.Length == 5 &&
                                        string.Equals(path[xmlExtensionIndex], "xml", StringComparison.OrdinalIgnoreCase);
                if (isAWidgetXmlFile)
                {
                    var fileName = string.Join(".", path.ToList().GetRange(xmlFileIndex, path.Length - xmlFileIndex));
                    FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(
                        this,
                        fileName,
                        EmbeddedResources.GetStream(resourceFullName));
                    continue;
                }

                var  widgetFolderId        = GetGuidFromResourceString(path[widgetFolderIdIndex]);
                bool isAWidgetResourceFile = path.Length > 5 &&
                                             widgetFolderId != Guid.Empty;
                if (isAWidgetResourceFile)
                {
                    var fileName = string.Join(".", path.ToList().GetRange(fileIndex, path.Length - fileIndex));
                    var theme    = SupportedThemes.Get(path[themeIndex]);
                    if (theme != null)
                    {
                        FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateSupplementaryFile(
                            this,
                            widgetFolderId,
                            theme.Id.ToString("N"),
                            fileName,
                            EmbeddedResources.GetStream(resourceFullName));
                    }
                    else
                    {
                        FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateSupplementaryFile(
                            this,
                            widgetFolderId,
                            fileName,
                            EmbeddedResources.GetStream(resourceFullName));
                    }
                }
            }
        }
        private void InstallWidgets()
        {
            var assembly           = GetType().Assembly;
            var assemblyNameLength = assembly.GetName().Name.Length + 1;

            foreach (string resourceName in assembly.GetManifestResourceNames())
            {
                string[] path = resourceName.Substring(assemblyNameLength).Split('.');

                // path: Resources.Widgets.[widget files]
                const int resourcesIndex = 0;
                const int widgetsIndex   = 1;

                bool isAWidgetDefinitionFile = path.Length > 2 &&
                                               string.Equals(path[resourcesIndex], "Resources", StringComparison.OrdinalIgnoreCase) &&
                                               string.Equals(path[widgetsIndex], "Widgets", StringComparison.OrdinalIgnoreCase);
                if (isAWidgetDefinitionFile)
                {
                    // path: Resources.Widgets.WidgetFolderId.[widget files]
                    const int widgetFolderIdIndex = 2;
                    Guid      widgetFolderId      = GetGuidFromResourceString(path[widgetFolderIdIndex]);
                    bool      isAWidgetXmlFile    = (string.Equals(path[path.Length - 1], "xml", StringComparison.OrdinalIgnoreCase));
                    bool      isAWidgetFolder     = path.Length > 3 &&
                                                    widgetFolderId != Guid.Empty &&
                                                    !isAWidgetXmlFile;
                    if (isAWidgetFolder)
                    {
                        // path: Resources.Widgets.WidgetFolderId.ThemeId.[widget files]
                        const int themeIdIndex  = 3;
                        Guid      themeId       = GetGuidFromResourceString(path[themeIdIndex]);
                        bool      hasSubfolders = (themeId != Guid.Empty);
                        if (hasSubfolders)
                        {
                            string fileName = string.Join(".", path.ToList().GetRange(themeIdIndex + 1, path.Length - themeIdIndex - 1));
                            FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateSupplementaryFile(
                                this,
                                widgetFolderId,
                                themeId.ToString("N"),
                                fileName,
                                assembly.GetManifestResourceStream(resourceName)
                                );
                        }
                        else
                        {
                            // path: Resources.Widgets.WidgetFolderId.FileName
                            const int fileNameIndex = 3;
                            string    fileName      = string.Join(".", path.ToList().GetRange(fileNameIndex, path.Length - fileNameIndex));
                            FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateSupplementaryFile(
                                this,
                                widgetFolderId,
                                fileName,
                                assembly.GetManifestResourceStream(resourceName));
                        }
                    }
                    else if (isAWidgetXmlFile)
                    {
                        // path: Resources.Widgets.WidgetName.xml
                        const int widgetNameIndex = 2;
                        FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(
                            this,
                            string.Join(".", path.ToList().GetRange(widgetNameIndex, path.Length - widgetNameIndex)),
                            assembly.GetManifestResourceStream(resourceName));
                    }
                }
            }
        }