public void AddLayoutControl_ExistingToolboxSection_VerifyControlIsProperlyAddedToTheToolbox()
        {
            // Arrange: Initialize the GridWidgetRegistrator, ToolboxesConfig and add a PageLayouts section, create a layouts section, create a dummy grid controls
            var initializer      = new DummyGridWidgetRegistrator();
            var fakeTemplatePath = "~/GridSystem/Templates/grid1.html";
            var dummyData        = initializer.PublicCreateGridControlsData(fakeTemplatePath);
            var toolboxesConfig  = new DummyToolboxesConfig();
            var pageControlsMock = new Toolbox(toolboxesConfig.Toolboxes);

            pageControlsMock.Name = "PageLayouts";
            toolboxesConfig.Toolboxes.Add("PageLayouts", pageControlsMock);
            var htmlLayoutsSection = initializer.PublicCreateToolBoxSection(toolboxesConfig, "BootstrapGrids", "BootstrapGridWidgets");
            ConfigElementList <ToolboxItem> parentToolboxItem = htmlLayoutsSection.Tools;

            // Act: add the grid controls to the toolbox
            initializer.PublicAddGridControl(parentToolboxItem, dummyData);

            // Assert: Verify the newly created controls are properly created
            Assert.AreEqual(1, parentToolboxItem.Count, "The grid controls were added to the toolbox.");

            var oneColumnGridToolboxItem = parentToolboxItem.Where <ToolboxItem>(toolboxItem => toolboxItem.Name == dummyData.Name).FirstOrDefault();

            Assert.IsNotNull(oneColumnGridToolboxItem, "The grid control was not added to the toolbox.");
            Assert.AreEqual(dummyData.Title, oneColumnGridToolboxItem.Title, "The grid control toolbox item has wrong title.");
            Assert.AreEqual(dummyData.LayoutTemplatePath, oneColumnGridToolboxItem.LayoutTemplate, "The grid control toolbox item has layout template path.");
        }
示例#2
0
        /// <summary>
        /// Adds or renames the grid control.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="data">The data.</param>
        /// <param name="oldFileName">Old name of the file.</param>
        /// <exception cref="System.ArgumentNullException">data</exception>
        protected virtual void AddOrRenameGridControl(ConfigElementList <ToolboxItem> parent, GridControlData data, string oldFileName = "")
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            string toolboxItemName;

            if (oldFileName.IsNullOrEmpty())
            {
                toolboxItemName = data.Name;
            }
            else
            {
                var oldFileNameWithoutExtension = this.GetFileNameWithoutExtension(oldFileName);
                toolboxItemName = oldFileNameWithoutExtension;
            }

            var control = parent.FirstOrDefault <ToolboxItem>(t => t.Name == toolboxItemName);

            if (control == null)
            {
                control             = new ToolboxItem(parent);
                control.ControlType = typeof(GridControl).AssemblyQualifiedName;
                control.CssClass    = data.CssClass;
                parent.Add(control);
            }

            control.Name           = data.Name;
            control.Title          = data.Title;
            control.LayoutTemplate = data.LayoutTemplatePath;
        }
        private static bool TryInitialize(ConfigElementList <SearchIndexStartupElement> indexes, out WarmupParameters parameters)
        {
            parameters = null;

            if (!(indexes?.Count > 0))
            {
                return(false);
            }

            var publishingManager = PublishingManager.GetManager(PublishingConfig.SearchProviderName);

            if (publishingManager == null)
            {
                return(false);
            }

            var searchService = ServiceBus.ResolveService <ISearchService>();

            if (searchService == null)
            {
                return(false);
            }

            parameters = new WarmupParameters
            {
                PublishingAdminService = new PublishingAdminService(),
                PublishingManager      = publishingManager,
                SearchService          = searchService,
                Indexes        = ((IList <SearchIndexStartupElement>)indexes).OrderBy(i => i.WithBackgroundIndexing),
                WorkerDelegate = new SystemManager.RunWithElevatedPrivilegeDelegate(DoWarmup)
            };

            return(true);
        }
        public static void Warmup(ConfigElementList <SearchIndexStartupElement> indexes)
        {
            if (!TryInitialize(indexes, out var warmupParameters))
            {
                return;
            }

            foreach (var index in warmupParameters.Indexes)
            {
                var publishingPoint = warmupParameters.PublishingManager.GetPublishingPoints().FirstOrDefault(p => p.Name == index.PublishingPointName);

                // can't find the index, so abort for this entry

                if (publishingPoint == null)
                {
                    continue;
                }

                // if the index is already present and not configured for forced rebuild, skip it

                if (!index.WithForceRebuild && warmupParameters.SearchService.IndexExists(index.IndexName))
                {
                    continue;
                }

                if (index.WithBackgroundIndexing)
                {
                    SystemManager.BackgroundTasksService.EnqueueTask(new WarmupBackgroundTask(publishingPoint, warmupParameters));
                }
                else
                {
                    SystemManager.RunWithElevatedPrivilege(warmupParameters.WorkerDelegate, new object[] { publishingPoint, warmupParameters.PublishingAdminService });
                }
            }
        }
示例#5
0
 public static void FillActionMenuItems(ConfigElementList <WidgetElement> menuItems, ConfigElement parent, string resourceClassId)
 {
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Delete", HtmlTextWriterTag.Li, DeleteCommandName, "Delete", resourceClassId, "sfDeleteItm"));
     menuItems.Add(
         CreateActionMenuSeparator(menuItems, "Separator", HtmlTextWriterTag.Li, "sfSeparator", "Edit", resourceClassId));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Content", HtmlTextWriterTag.Li, EditCommandName, "Content", resourceClassId));
 }
示例#6
0
 public UserRoleToolboxItemFilter
 (
     ConfigElementList <WidgetSecurityElement> settings,
     [Dependency("UserId")] Guid userId,
     [Dependency("AppRoles")] RoleManager appRoleManager
 )
 {
     _settings       = settings;
     _userId         = userId;
     _appRoleManager = appRoleManager;
 }
示例#7
0
 /// <summary>
 /// Adds the layout control.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="data">The data.</param>
 protected virtual void AddLayoutControl(ConfigElementList<ToolboxItem> parent, GridControlData data)
 {
     var control = parent.FirstOrDefault<ToolboxItem>(t => t.Name == data.Name);
     if (control == null)
     {
         control = new ToolboxItem(parent);
         control.ControlType = typeof(GridControl).AssemblyQualifiedName;
         control.Name = data.Name;
         control.Title = data.Title;
         control.LayoutTemplate = data.LayoutTemplatePath;
         control.CssClass = data.CssClass;
         parent.Add(control);
     }
 }
示例#8
0
        /// <summary>
        /// Adds the layout control.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="data">The data.</param>
        protected virtual void AddLayoutControl(ConfigElementList <ToolboxItem> parent, GridControlData data)
        {
            var control = parent.FirstOrDefault <ToolboxItem>(t => t.Name == data.Name);

            if (control == null)
            {
                control                = new ToolboxItem(parent);
                control.ControlType    = typeof(GridControl).AssemblyQualifiedName;
                control.Name           = data.Name;
                control.Title          = data.Title;
                control.LayoutTemplate = data.LayoutTemplatePath;
                control.CssClass       = data.CssClass;
                parent.Add(control);
            }
        }
 /// <summary>
 /// Fills the action menu items.
 /// </summary>
 /// <param name="menuItems">The menu items.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="resourceClassId">The resource class pageId.</param>
 public static void FillActionMenuItems(ConfigElementList<WidgetElement> menuItems, ConfigElement parent, string resourceClassId)
 {
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "View", HtmlTextWriterTag.Li, PreviewCommandName, "View", resourceClassId));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Delete", HtmlTextWriterTag.Li, DeleteCommandName, "Delete", resourceClassId, "sfDeleteItm"));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Publish", HtmlTextWriterTag.Li, PublishCommandName, "Publish", resourceClassId, "sfPublishItm"));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Unpublish", HtmlTextWriterTag.Li, UnpublishCommandName, "Unpublish", resourceClassId, "sfUnpublishItm"));
     menuItems.Add(
         CreateActionMenuSeparator(menuItems, "Separator", HtmlTextWriterTag.Li, "sfSeparator", "Edit", resourceClassId));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Content", HtmlTextWriterTag.Li, EditCommandName, "Content", resourceClassId));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "Permissions", HtmlTextWriterTag.Li, PermissionsCommandName, "Permissions", resourceClassId));
     menuItems.Add(
         CreateActionMenuCommand(menuItems, "History", HtmlTextWriterTag.Li, HistoryGridCommandName, "HistoryMenuItemTitle", "VersionResources"));
 }
 /// <inheritdoc />
 public void PublicAddLayoutControl(ConfigElementList<ToolboxItem> parent, GridControlData data)
 {
     this.AddLayoutControl(parent, data);
 }
        /// <inheritdoc />
        public void PublicAddGridControl(ConfigElementList <ToolboxItem> parent, GridControlData data, string oldFileName = "")
        {
            bool needsSaveSection = false;

            this.AddOrRenameGridControl(parent, data, ref needsSaveSection, oldFileName);
        }
        /// <summary>
        /// Adds or renames the grid control.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="data">The data.</param>
        /// <param name="oldFileName">Old name of the file.</param>
        /// <exception cref="System.ArgumentNullException">data</exception>
        protected virtual void AddOrRenameGridControl(ConfigElementList<ToolboxItem> parent, GridControlData data, string oldFileName = "")
        {
            if (data == null)
                throw new ArgumentNullException("data");

            string toolboxItemName;
            if (oldFileName.IsNullOrEmpty())
            {
                toolboxItemName = data.Name;
            }
            else
            {
                var oldFileNameWithoutExtension = this.GetFileNameWithoutExtension(oldFileName);
                toolboxItemName = oldFileNameWithoutExtension;
            }

            var control = parent.FirstOrDefault<ToolboxItem>(t => t.Name == toolboxItemName);

            if (control == null)
            {
                control = new ToolboxItem(parent);
                control.ControlType = typeof(GridControl).AssemblyQualifiedName;
                control.CssClass = data.CssClass;
                parent.Add(control);
            }

            control.Name = data.Name;
            control.Title = data.Title;
            control.LayoutTemplate = data.LayoutTemplatePath;
        }
示例#13
0
 /// <inheritdoc />
 public void PublicAddLayoutControl(ConfigElementList <ToolboxItem> parent, GridControlData data)
 {
     this.AddLayoutControl(parent, data);
 }
 /// <inheritdoc />
 public void PublicAddGridControl(ConfigElementList <ToolboxItem> parent, GridControlData data, string oldFileName = "")
 {
     this.AddOrRenameGridControl(parent, data, oldFileName);
 }
示例#15
0
 public PageTemplateToolboxItemFilter(ConfigElementList <WidgetSecurityElement> settings)
 {
     _settings = settings;
 }
 /// <inheritdoc />
 public void PublicAddGridControl(ConfigElementList<ToolboxItem> parent, GridControlData data, string oldFileName = "")
 {
     this.AddOrRenameGridControl(parent, data, oldFileName);
 }