protected void Page_Load(object sender, EventArgs e)
    {
        // Show panel with message how to enable indexing
        ucDisabledModule.SettingsKeys = "CMSSearchIndexingEnabled";
        ucDisabledModule.InfoText     = GetString("srch.searchdisabledinfo");

        indexId = QueryHelper.GetInteger("indexid", 0);

        // Add sites filter
        uniSelector.FilterControl = "~/CMSFormControls/Filters/SiteFilter.ascx";
        uniSelector.SetValue("DefaultFilterValue", SiteContext.CurrentSiteID);
        uniSelector.SetValue("FilterMode", "cultures");

        // Get the active sites
        DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + indexId, null, 0, "IndexID, IndexCultureID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "IndexCultureID"));
        }

        if (!URLHelper.IsPostback())
        {
            uniSelector.Value = currentValues;
        }
    }
Пример #2
0
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            // Check if document index has at least one culture specified
            if (!SearchIndexCultureInfoProvider.SearchIndexHasAnyCulture(indexId))
            {
                ShowError(GetString("index.noculture"));
                return;
            }

            // Check if there is at least one site assigned
            if (!SearchIndexSiteInfoProvider.SearchIndexHasAnySite(indexId))
            {
                ShowError(GetString("index.nosite"));
                return;
            }

            if (!SearchHelper.CreateRebuildTask(indexId))
            {
                ShowError(GetString("index.nocontent"));
                return;
            }

            ShowInformation(GetString("srch.index.rebuildstarted"));
        }
    }
Пример #3
0
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);
            if (sii.IndexType.Equals(Treenode.OBJECT_TYPE, StringComparison.OrdinalIgnoreCase) || (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
            {
                if (!SearchIndexCultureInfoProvider.SearchIndexHasAnyCulture(sii.IndexID))
                {
                    ShowError(GetString("index.noculture"));
                    return;
                }

                if (!SearchIndexSiteInfoProvider.SearchIndexHasAnySite(sii.IndexID))
                {
                    ShowError(GetString("index.nosite"));
                    return;
                }
            }

            if (SearchHelper.CreateRebuildTask(ItemID))
            {
                ShowInformation(GetString("srch.index.rebuildstarted"));
            }
            else
            {
                ShowError(GetString("index.nocontent"));
            }
        }
    }
Пример #4
0
    /// <summary>
    /// Starts the search index rebuild task.
    /// </summary>
    private void Rebuild()
    {
        // Extra check for document index
        if ((SearchIndex.IndexType.Equals(TreeNode.OBJECT_TYPE, StringComparison.OrdinalIgnoreCase) || (SearchIndex.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX)))
        {
            // Check if there is at least one site assigned
            if (!SearchIndexSiteInfoProvider.SearchIndexHasAnySite(SearchIndex.IndexID))
            {
                ShowError(GetString("index.nosite"));
                return;
            }

            // Check if there is any culture assigned
            if (!SearchIndexCultureInfoProvider.SearchIndexHasAnyCulture(SearchIndex.IndexID))
            {
                ShowError(GetString("index.noculture"));
                return;
            }
        }

        if (!SearchHelper.CreateRebuildTask(SearchIndex.IndexID))
        {
            ShowError(GetString("index.nocontent"));
            return;
        }

        RaiseAsyncIndexTaskStarted();
        ShowInformation(GetString("srch.index.rebuildstarted"));
    }
Пример #5
0
    /// <summary>
    ///  Rebuild click.
    /// </summary>
    protected void btnRebuild_Click(object sender, EventArgs e)
    {
        if (sii != null)
        {
            if ((sii.IndexType.ToLower() == PredefinedObjectType.DOCUMENT) || (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
            {
                DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + sii.IndexID, null, 0, "IndexID, IndexCultureID");
                if (SqlHelperClass.DataSourceIsEmpty(ds))
                {
                    lblInfo.Text    = GetString("index.noculture");
                    lblInfo.Visible = true;
                    return;
                }

                // Test content
                DataSet result = sii.IndexSettings.GetAll();
                if (DataHelper.DataSourceIsEmpty(result))
                {
                    lblInfo.Text    = GetString("index.nocontent");
                    lblInfo.Visible = true;
                    return;
                }
            }

            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
        }

        lblInfo.Text    = GetString("srch.index.rebuildstarted");
        lblInfo.Visible = true;

        // Reload info panel
        System.Threading.Thread.Sleep(100);
        ReloadInfoPanel();
    }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Show panel with message how to enable indexing
        if (!SettingsKeyProvider.GetBoolValue("CMSSearchIndexingEnabled"))
        {
            pnlDisabled.Visible = true;
        }

        indexId = QueryHelper.GetInteger("indexid", 0);

        // Add sites filter
        uniSelector.FilterControl = "~/CMSFormControls/Filters/SiteFilter.ascx";
        uniSelector.SetValue("DefaultFilterValue", CMSContext.CurrentSiteID);
        uniSelector.SetValue("FilterMode", "cultures");

        // Get the active sites
        DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + indexId, null, 0, "IndexID, IndexCultureID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            currentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "IndexCultureID"));
        }

        if (!URLHelper.IsPostback())
        {
            uniSelector.Value = currentValues;
        }

        lblInfo.Text    = String.Format(GetString("general.changessaved") + " " + GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
        lblInfo.Visible = false;
    }
    /// <summary>
    ///  Rebuild click.
    /// </summary>
    protected void Rebuild()
    {
        if (sii != null)
        {
            if (DataHelper.DataSourceIsEmpty(sii.IndexSettings.GetAll()) && (sii.IndexType.ToLowerCSafe() != PredefinedObjectType.USER))
            {
                ShowError(GetString("index.nocontent"));
                return;
            }

            if ((sii.IndexType.ToLowerCSafe() == PredefinedObjectType.DOCUMENT) || (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
            {
                DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + sii.IndexID, null, 0, "IndexID, IndexCultureID");
                if (DataHelper.DataSourceIsEmpty(ds))
                {
                    ShowError(GetString("index.noculture"));
                    return;
                }
            }

            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
        }

        ShowInformation(GetString("srch.index.rebuildstarted"));

        // Reload info panel
        Thread.Sleep(100);
        ReloadInfoPanel();
    }
Пример #8
0
    /// <summary>
    /// Creates content search index.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupContentSearchIndex(GroupInfo group)
    {
        string codeName = "default_group_" + group.GroupGUID;

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);

        if (sii == null)
        {
            // Create search index info
            sii           = new SearchIndexInfo();
            sii.IndexName = codeName;
            const string suffix = " - Default";
            sii.IndexDisplayName      = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix;
            sii.IndexAnalyzerType     = SearchAnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType             = TreeNode.OBJECT_TYPE;
            sii.IndexIsCommunityGroup = false;
            sii.IndexProvider         = SearchIndexInfo.LUCENE_SEARCH_PROVIDER;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID         = Guid.NewGuid();
            sisi.Path       = mGroupTemplateTargetAliasPath + "/" + group.GroupName + "/%";
            sisi.SiteName   = SiteContext.CurrentSiteName;
            sisi.Type       = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.ClassNames = "";

            // Create settings item
            SearchIndexSettings sis = new SearchIndexSettings();

            // Update settings item
            sis.SetSearchIndexSettingsInfo(sisi);

            // Update xml value
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Assign to current website and current culture
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, SiteContext.CurrentSiteID);
            CultureInfo ci = DocumentContext.CurrentDocumentCulture;
            if (ci != null)
            {
                SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);
            }

            // Register rebuild index action
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, null, null, sii.IndexName, sii.IndexID);
        }
    }
    /// <summary>
    /// Creates or rebuild department content search index.
    /// </summary>
    /// <param name="departmentNode">Department node</param>
    private void CreateDepartmentContentSearchIndex(TreeNode departmentNode)
    {
        string codeName       = "default_department_" + departmentNode.NodeGUID;
        string departmentName = departmentNode.GetDocumentName();

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);

        if (sii == null)
        {
            // Create search index info
            sii           = new SearchIndexInfo();
            sii.IndexName = codeName;
            string suffix = " - Default";
            sii.IndexDisplayName      = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix;
            sii.IndexAnalyzerType     = SearchAnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType             = TreeNode.OBJECT_TYPE;
            sii.IndexIsCommunityGroup = false;
            sii.IndexProvider         = SearchIndexInfo.LUCENE_SEARCH_PROVIDER;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID         = Guid.NewGuid();
            sisi.Path       = departmentNode.NodeAliasPath + "/%";
            sisi.Type       = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.ClassNames = "";

            // Create settings item
            SearchIndexSettings sis = new SearchIndexSettings();

            // Update settings item
            sis.SetSearchIndexSettingsInfo(sisi);

            // Update xml value
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Assign to current website
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, SiteContext.CurrentSiteID);
        }

        // Add current culture to search index
        CultureInfo ci = CultureInfoProvider.GetCultureInfo(departmentNode.DocumentCulture);

        SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);

        // Rebuild search index
        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, null, null, sii.IndexName, sii.IndexID);
    }
Пример #10
0
    /// <summary>
    /// Adds culture to search index. Called when the "Add culture to index" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool AddCultureToSearchIndex()
    {
        // Get the search index and culture
        SearchIndexInfo index   = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");
        CultureInfo     culture = CultureInfoProvider.GetCultureInfo("en-us");

        if ((index != null) && (culture != null))
        {
            // Save the binding
            SearchIndexCultureInfoProvider.AddSearchIndexCulture(index.IndexID, culture.CultureID);

            return(true);
        }

        return(false);
    }
Пример #11
0
    /// <summary>
    /// Creates forum search index.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupForumSearchIndex(GroupInfo group)
    {
        string codeName = "forums_group_" + group.GroupGUID;

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);

        if (sii == null)
        {
            // Create search index info
            sii           = new SearchIndexInfo();
            sii.IndexName = codeName;
            const string suffix = " - Forums";
            sii.IndexDisplayName      = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix;
            sii.IndexAnalyzerType     = SearchAnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType             = PredefinedObjectType.FORUM;
            sii.IndexIsCommunityGroup = false;
            sii.IndexProvider         = SearchIndexInfo.LUCENE_SEARCH_PROVIDER;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID         = Guid.NewGuid();
            sisi.ForumNames = "*_group_" + group.GroupGUID;
            sisi.Type       = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.SiteName   = SiteContext.CurrentSiteName;

            // Create settings item
            SearchIndexSettings sis = new SearchIndexSettings();

            // Update settings item
            sis.SetSearchIndexSettingsInfo(sisi);

            // Update xml value
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Assing to current website and current culture
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, SiteContext.CurrentSiteID);
            CultureInfo ci = DocumentContext.CurrentDocumentCulture;
            if (ci != null)
            {
                SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);
            }
        }
    }
Пример #12
0
    /// <summary>
    /// Removes culture from search index. Called when the "Remove culture from index" button is pressed.
    /// Expects the AddCultureToSearchIndex method to be run first.
    /// </summary>
    private bool RemoveCultureFromSearchIndex()
    {
        // Get the search index
        SearchIndexInfo removeIndex = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");
        CultureInfo     culture     = CultureInfoProvider.GetCultureInfo("en-us");

        if ((removeIndex != null) && (culture != null))
        {
            // Get the binding
            SearchIndexCultureInfo indexCulture = SearchIndexCultureInfoProvider.GetSearchIndexCultureInfo(removeIndex.IndexID, culture.CultureID);

            // Delete the binding
            SearchIndexCultureInfoProvider.DeleteSearchIndexCultureInfo(indexCulture);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Creates forum search index.
    /// </summary>
    /// <param name="departmentNode">Department node</param>
    private void CreateDepartmentForumSearchIndex(TreeNode departmentNode)
    {
        string codeName       = "forums_department_" + departmentNode.NodeGUID;
        string departmentName = departmentNode.GetDocumentName();

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);

        if (sii == null)
        {
            // Create search index info
            sii           = new SearchIndexInfo();
            sii.IndexName = codeName;
            string suffix = " - Forums";
            sii.IndexDisplayName      = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix;
            sii.IndexAnalyzerType     = SearchAnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType             = PredefinedObjectType.FORUM;
            sii.IndexIsCommunityGroup = false;
            sii.IndexProvider         = SearchIndexInfo.LUCENE_SEARCH_PROVIDER;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID         = Guid.NewGuid();
            sisi.Type       = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.SiteName   = SiteContext.CurrentSiteName;
            sisi.ForumNames = "*_department_" + departmentNode.NodeGUID;

            // Create settings item
            SearchIndexSettings sis = new SearchIndexSettings();

            // Update settings item
            sis.SetSearchIndexSettingsInfo(sisi);

            // Update xml value
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Assign to current website and current culture
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, SiteContext.CurrentSiteID);
            CultureInfo ci = CultureInfoProvider.GetCultureInfo(departmentNode.DocumentCulture);
            SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);
        }
    }
    protected void uniSelector_OnSelectionChanged(object sender, EventArgs e)
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(uniSelector.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Remove all new items
                foreach (string item in newItems)
                {
                    int cultureId = ValidationHelper.GetInteger(item, 0);
                    SearchIndexCultureInfo sici = SearchIndexCultureInfoProvider.GetSearchIndexCultureInfo(indexId, cultureId);
                    SearchIndexCultureInfoProvider.DeleteSearchIndexCultureInfo(sici);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items
                foreach (string item in newItems)
                {
                    int cultureId = ValidationHelper.GetInteger(item, 0);
                    SearchIndexCultureInfoProvider.AddSearchIndexCulture(indexId, cultureId);
                }
            }
        }

        // Show saved message with rebuild link
        ShowChangesSaved();
        ShowInformation(String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>"));
    }
Пример #15
0
    protected void uniSelector_OnSelectionChanged(object sender, EventArgs e)
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(uniSelector.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Remove all new items
                foreach (string item in newItems)
                {
                    int cultureId = ValidationHelper.GetInteger(item, 0);
                    SearchIndexCultureInfo sici = SearchIndexCultureInfoProvider.GetSearchIndexCultureInfo(indexId, cultureId);
                    SearchIndexCultureInfoProvider.DeleteSearchIndexCultureInfo(sici);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items
                foreach (string item in newItems)
                {
                    int cultureId = ValidationHelper.GetInteger(item, 0);
                    SearchIndexCultureInfoProvider.AddSearchIndexCulture(indexId, cultureId);
                }
            }
        }

        // Show saved message with rebuild link
        lblInfo.Visible = true;
    }
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            // Check if document index has at least one culture specified
            DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures(indexId);
            if (DataHelper.DataSourceIsEmpty(ds))
            {
                ShowError(GetString("index.noculture"));
                return;
            }

            if (SearchHelper.CreateRebuildTask(indexId))
            {
                ShowInformation(GetString("srch.index.rebuildstarted"));
            }
            else
            {
                ShowError(GetString("index.nocontent"));
            }
        }
    }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        indexId = QueryHelper.GetInteger("indexid", 0);

        // Add sites filter
        uniSelector.FilterControl = "~/CMSFormControls/Filters/SiteFilter.ascx";
        uniSelector.SetValue("DefaultFilterValue", SiteContext.CurrentSiteID);
        uniSelector.SetValue("FilterMode", "cultures");

        // Get the active sites
        DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + indexId, null, 0, "IndexID, IndexCultureID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "IndexCultureID"));
        }

        if (!RequestHelper.IsPostBack())
        {
            uniSelector.Value = currentValues;
        }
    }
Пример #18
0
    /// <summary>
    /// Starts the search index rebuild task.
    /// </summary>
    private void Rebuild()
    {
        // Check culture for document index
        if ((SearchIndex.IndexType.ToLowerCSafe() == TreeNode.OBJECT_TYPE) || (SearchIndex.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
        {
            var ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + SearchIndex.IndexID, null, 0, "IndexID, IndexCultureID");
            if (DataHelper.DataSourceIsEmpty(ds))
            {
                ShowError(GetString("index.noculture"));
                return;
            }
        }

        var taskCreated = SearchHelper.CreateRebuildTask(SearchIndex.IndexID);

        if (!taskCreated)
        {
            ShowError(GetString("index.nocontent"));
            return;
        }

        RaiseAsyncIndexTaskStarted();
        ShowInformation(GetString("srch.index.rebuildstarted"));
    }
    /// <summary>
    /// Handles click on rebuild link (after sites are saved).
    /// </summary>
    /// <param name="eventArgument">Event argument</param>
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            // Check permissions
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.searchindex", CMSAdminControl.PERMISSION_MODIFY))
            {
                RedirectToAccessDenied("cms.searchindex", CMSAdminControl.PERMISSION_MODIFY);
            }

            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(indexId);
            if (sii.IndexType.Equals(CMS.DocumentEngine.TreeNode.OBJECT_TYPE, StringComparison.OrdinalIgnoreCase) || (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
            {
                if (!SearchIndexCultureInfoProvider.SearchIndexHasAnyCulture(sii.IndexID))
                {
                    ShowError(GetString("index.noculture"));
                    return;
                }

                if (!SearchIndexSiteInfoProvider.SearchIndexHasAnySite(sii.IndexID))
                {
                    ShowError(GetString("index.nosite"));
                    return;
                }
            }

            if (SearchHelper.CreateRebuildTask(indexId))
            {
                ShowInformation(GetString("srch.index.rebuildstarted"));
            }
            else
            {
                ShowError(GetString("index.nocontent"));
            }
        }
    }
    /// <summary>
    /// Stores data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // If classnames is not filled set default value
        string classNames = selectClassnames.Value.ToString();

        // Perform validation
        string errorMessage = new Validator().NotEmpty(selectpath.Value, GetString("srch.err.emptypath")).Result;

        if (String.IsNullOrEmpty(errorMessage))
        {
            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);
            if (sii != null)
            {
                SearchIndexSettings     sis = sii.IndexSettings;
                SearchIndexSettingsInfo sisi;

                // If we are updating existing Search Index Settings Info
                if (ItemGUID != Guid.Empty)
                {
                    sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
                }
                // If we are creating new Search Index Settings Info
                else
                {
                    sisi      = new SearchIndexSettingsInfo();
                    sisi.ID   = Guid.NewGuid();
                    sisi.Type = ItemType;
                }

                // Save values
                if (sisi != null)
                {
                    sisi.ClassNames    = classNames;
                    sisi.Path          = selectpath.Value.ToString();
                    sisi.IncludeForums = chkInclForums.Checked;
                    sisi.IncludeBlogs  = chkInclBlog.Checked;
                    sisi.IncludeMessageCommunication = chkInclBoards.Checked;
                    sisi.IncludeCategories           = chkInclCats.Checked;

                    // Update settings item
                    sis.SetSearchIndexSettingsInfo(sisi);
                    // Update xml value
                    sii.IndexSettings = sis;
                    SearchIndexInfoProvider.SetSearchIndexInfo(sii);
                    ItemGUID = sisi.ID;

                    // Redirect to edit mode
                    if ((sii.IndexType.ToLowerCSafe() == PredefinedObjectType.DOCUMENT) || (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
                    {
                        DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + sii.IndexID, null, 0, "IndexID, IndexCultureID");
                        if (DataHelper.DataSourceIsEmpty(ds))
                        {
                            ShowConfirmation(GetString("general.changessaved") + " " + GetString("index.noculture"));
                            return;
                        }
                    }

                    ShowChangesSaved();

                    if (smartSearchEnabled)
                    {
                        ShowInformation(String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>"));
                    }
                }
                // Error loading SearchIndexSettingsInfo
                else
                {
                    ShowError(GetString("srch.err.loadingsisi"));
                }
            }
            // Error loading SearchIndexInfo
            else
            {
                ShowError(GetString("srch.err.loadingsii"));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }