More in this section

Forums / Developing with Sitefinity / Custom config not installed when module is installed

Custom config not installed when module is installed

3 posts, 0 answered
  1. Chad
    Chad avatar
    9 posts
    Registered:
    23 Aug 2012
    25 Sep 2012
    Link to this post
    My custom module is installing but when sitefinity runs it changes startuptype to Disabled and it looks like the Configuration section is not getting installed. My code is below. Would really like some help.

    using System;
    using System.Linq;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Abstractions;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Fluent.Modules;
    using Telerik.Sitefinity.Services;
    using Telerik.Sitefinity.Modules.Pages.Configuration;
    using Telerik.Sitefinity.Modules.Pages;
    using Telerik.Sitefinity.Web;
    using Telerik.Sitefinity.Utilities.TypeConverters;
     
    namespace SitefinityWebApp.Modules.Avianis
    {
        public class AvianisModule : ModuleBase
        {
            #region Properties
            /// <summary>
            /// Gets the landing page id for each module inherit from <see cref="T:Telerik.Sitefinity.Services.SecuredModuleBase" /> class.
            /// </summary>
            /// <value>The landing page id.</value>
            public override Guid LandingPageId
            {
                get { return SiteInitializer.DashboardPageNodeId; }
            }
     
            public override Guid ModuleId
            {
                get
                {
                    return new Guid("15B26842-6E80-498F-BDD0-CD56B2310435");
                }
            }
     
            /// <summary>
            /// Gets the CLR types of all data managers provided by this module.
            /// </summary>
            /// <value>An array of <see cref="T:System.Type" /> objects.</value>
            public override Type[] Managers
            {
                get { return null; }
            }
            #endregion
     
            #region Methods
     
            public static void InstallModule()
            {
                var configManger = ConfigManager.GetManager();
                var appConfig = configManger.GetSection<SystemConfig>();
     
                Config.RegisterSection<AvianisModuleConfig>();
     
                var appModuleConfig = appConfig.ApplicationModules;
                if (!appModuleConfig.ContainsKey(AvianisModule.ModuleName))
                    appModuleConfig.Add(new AppModuleSettings(appModuleConfig)
                    {
                        Name = AvianisModule.ModuleName,
                        Title = "Avianis Module",
                        ModuleId = new Guid("15B26842-6E80-498F-BDD0-CD56B2310435"),
                        Type = typeof(AvianisModule).FullName,
                        Version = new Version("1.0.0"),
                        StartupType = StartupType.OnApplicationStart
                    });
                configManger.SaveSection(appConfig);           
            }
     
            public static void UninstallModule()
            {
                var pageManager = PageManager.GetManager();
     
                var landingPage = pageManager.GetPageNodes().SingleOrDefault(p => p.Name == AvianisModule.ModuleName);
                if (landingPage != null)
                {
                    pageManager.Delete(landingPage);
                    pageManager.SaveChanges();
                    SiteMapBase.FlushNodeFiltersCacheForAllUsers();
                }
     
                var configMgr = ConfigManager.GetManager();
                var config = configMgr.GetSection<ToolboxesConfig>();
                var pageControls = config.Toolboxes["PageControls"];
     
                /*
     
                var section = pageControls
                    .Sections
                    .Where<ToolboxSection>(e => e.Name == ToolboxesConfig.ContentToolboxSectionName)
                    .FirstOrDefault();
                if (section != null)
                {
                    var emptyLeg = section.Tools.FirstOrDefault<ToolboxItem>(e => e.Name == "EmptyLegList");
                    if (emptyLeg != null) section.Tools.Remove(emptyLeg);
     
                    var quoter = section.Tools.FirstOrDefault<ToolboxItem>(e => e.Name == "Quoter");
                    if (quoter != null) section.Tools.Remove(quoter);
     
                    var leadCapture = section.Tools.FirstOrDefault<ToolboxItem>(e => e.Name == "LeadCapture");
                    if (leadCapture != null) section.Tools.Remove(leadCapture);
                }
                configMgr.SaveSection(config);
                            */
     
                var appConfig = configMgr.GetSection<SystemConfig>();
     
                var appModuleConfig = appConfig.ApplicationModules;
                if (appModuleConfig.ContainsKey(AvianisModule.ModuleName))
                    appModuleConfig.Remove(AvianisModule.ModuleName);
     
                configMgr.SaveSection(appConfig);           
            }
     
            /// <summary>
            /// Installs this module in Sitefinity system for the first time.
            /// </summary>
            /// <param name="initializer">The Site Initializer. A helper class for installing Sitefinity modules.</param>
            public override void Install(SiteInitializer initializer)
            {
                App.WorkWith().
                    Module(AvianisModule.ModuleName, initializer.PageManager).
                    Install().
                        CreateModulePage(Guid.NewGuid(), "Avianis Module").
                            SetOrdinal(1).
                            ShowInNavigation().
                            SetTitle("Avianis Module").
                            SetHtmlTitle("Avianis Module").
                            SetDescription("Avianis Module").
                            SetUrlName("AvianisModule").
                            PlaceUnder(CommonNode.System).
                            AddControl(new Literal() { Text = "<h1 class=\"sfBreadCrumb\">Avianis Module Installed</h1>", Mode = LiteralMode.PassThrough }).
                            Done();
     
                /*
                // get section from toolbox
                var config = initializer.Context.GetConfig<ToolboxesConfig>();
                var pageControls = config.Toolboxes["PageControls"];
                var section = pageControls.Sections
                    .Where<ToolboxSection>(e => e.Name == ToolboxesConfig.ContentToolboxSectionName)
                    .FirstOrDefault();
     
                if (section == null)
                {
                    section = new ToolboxSection(pageControls.Sections)
                    {
                        Name = ToolboxesConfig.ContentToolboxSectionName,
                        Title = ToolboxesConfig.ContentToolboxSectionName,
                        Description = "Content Toolbox Section"
                    };
                }
     
                // add widget to section if it doesn't exist
                if (!section.Tools.Any<ToolboxItem>(e => e.Name == "Quoter"))
                {
                    var tool = new ToolboxItem(section.Tools)
                    {
                        Name = "Quoter",
                        Title = "Quoter",
                        Description = "Quoter",
                        ControlType = "~/Modules/Avianis/Controls/QuoteCapture/Quoter.ascx",
                        ModuleName = "AvianisModule"
                    };
                    section.Tools.Add(tool);
                }
     
                // add widget to section if it doesn't exist
                if (!section.Tools.Any<ToolboxItem>(e => e.Name == "LeadCapture"))
                {
                    var tool = new ToolboxItem(section.Tools)
                    {
                        Name = "LeadCapture",
                        Title = "Lead Capture",
                        Description = "Captures the lead and request",
                        ControlType = "~/Modules/Avianis/Controls/QuoteCapture/LeadCapture.ascx",
                        ModuleName = "AvianisModule"
                    };
                    section.Tools.Add(tool);
                }
                 
                // add widget to section if it doesn't exist
                if (!section.Tools.Any<ToolboxItem>(e => e.Name == "EmptyLegList"))
                {
                    var tool = new ToolboxItem(section.Tools)
                    {
                        Name = "EmptyLegList",
                        Title = "Empty Legs",
                        Description = "Gets and displays all empty legs from Avianis",
                        ControlType = "~/Modules/Avianis/Controls/EmptyLeg/EmptyLegList.ascx",
                        ModuleName = "AvianisModule"
                    };
                    section.Tools.Add(tool);
                }
     
                */
            }
     
            /// <summary>
            /// Initializes the service with specified settings.
            /// </summary>
            /// <param name="settings">The settings.</param>
            public override void Initialize(ModuleSettings settings)
            {
                base.Initialize(settings);
     
                App.WorkWith().               
                    Module(AvianisModule.ModuleName).Initialize().
                    Configuration<AvianisModuleConfig>();
            }
     
            /// <summary>
            /// Upgrades this module from the specified version.
            /// </summary>
            /// <param name="initializer">The Site Initializer. A helper class for installing
            /// Sitefinity modules.</param>
            /// <param name="upgradeFrom">The version this module us upgrading from.</param>
            public override void Upgrade(SiteInitializer initializer, Version upgradeFrom)
            {
            }
     
            /// <summary>
            /// Gets the module configuration.
            /// </summary>
            /// <returns></returns>
            protected override ConfigSection GetModuleConfig()
            {
                return Config.Get<AvianisModuleConfig>();
            }
     
            #endregion
     
            #region Private members & constants
            /// <summary>
            /// Name of the module.
            /// </summary>
            public const string ModuleName = "AvianisModule";       
            #endregion
        }
    }
  2. Chad
    Chad avatar
    9 posts
    Registered:
    23 Aug 2012
    25 Sep 2012
    Link to this post
    So I was able to get my custom module installed but not I am getting the following error.

    "The license you are currently using does not support this module.To be able to edit it, you need to purchase a higher license."

    Has anyone received this error before? Why do I need a higher license to install my own custom module?
  3. Atanas Valchev
    Atanas Valchev avatar
    414 posts
    Registered:
    04 Jan 2016
    27 Sep 2012
    Link to this post
    Hello Chad,

    I replied in your support ticket but I will post here for other people who are faced with the same error. This is a result of your module using API of a feature that is not included in your license. In your case it was Workflows. In most cases could be either that or permissions that cause the issue. I hope this will help someone in  the future if they encounter the same issue. 

    Kind regards,
    Atanas Valchev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered