/// <summary>
    /// Gets and bulk updates search indexes. Called when the "Get and bulk update indexes" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateSearchIndexes()
    {
        // Prepare the parameters
        string where = "IndexName LIKE N'MyNewIndex%'";

        // Get the data
        DataSet indexes = SearchIndexInfoProvider.GetSearchIndexes(where, null);

        if (!DataHelper.DataSourceIsEmpty(indexes))
        {
            // Loop through the individual items
            foreach (DataRow indexDr in indexes.Tables[0].Rows)
            {
                // Create object from DataRow
                SearchIndexInfo modifyIndex = new SearchIndexInfo(indexDr);

                // Update the properties
                modifyIndex.IndexDisplayName = modifyIndex.IndexDisplayName.ToUpper();

                // Save the changes
                SearchIndexInfoProvider.SetSearchIndexInfo(modifyIndex);
            }

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Creates index settings. Called when the "Create index settings" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool CreateIndexSettings()
    {
        // Get the search index
        SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");

        if (index != null)
        {
            // Create new index settings
            SearchIndexSettingsInfo indexSettings = new SearchIndexSettingsInfo();
            // Set setting properties
            indexSettings.IncludeBlogs  = true;
            indexSettings.IncludeForums = true;
            indexSettings.IncludeMessageCommunication = true;
            indexSettings.ClassNames = ""; // for all document types
            indexSettings.Path       = "/%";
            indexSettings.Type       = SearchIndexSettingsInfo.TYPE_ALLOWED;
            indexSettings.ID         = Guid.NewGuid();

            // Save index settings
            SearchIndexSettings settings = new SearchIndexSettings();
            settings.SetSearchIndexSettingsInfo(indexSettings);
            index.IndexSettings = settings;

            // Save to database
            SearchIndexInfoProvider.SetSearchIndexInfo(index);

            return(true);
        }
        return(false);
    }
    /// <summary>
    /// Unigrid on action handler.
    /// </summary>
    private void UniGrid_OnAction(string actionName, object actionArgument)
    {
        Guid guid;

        switch (actionName)
        {
        case "edit":
            guid = ValidationHelper.GetGuid(actionArgument, Guid.Empty);
            RaiseOnAction("edit", guid);
            break;

        case "delete":
            // Delete search index info object from database with it's dependences
            guid = ValidationHelper.GetGuid(actionArgument, Guid.Empty);

            sis = sii.IndexSettings;
            sis.DeleteSearchIndexSettingsInfo(guid);
            sii.IndexSettings = sis;
            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Show message about rebuilding index
            if (smartSearchEnabled)
            {
                DataSet result = sii.IndexSettings.GetAll();
                if (!DataHelper.DataSourceIsEmpty(result))
                {
                    ShowInformation(String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>"));
                }
            }
            break;
        }
    }
    /// <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);
    }
Example #5
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);
        }
    }
Example #6
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator().NotEmpty(txtAssembly.Text.Trim(), GetString("srch.index.assemblyempty")).NotEmpty(txtClassName.Text.Trim(), GetString("srch.index.classnameempty")).Result;

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

                // Create new
                if (sisi == null)
                {
                    sisi    = new SearchIndexSettingsInfo();
                    sisi.ID = SearchHelper.CUSTOM_INDEX_DATA;
                }

                sisi.SetValue("AssemblyName", txtAssembly.Text.Trim());
                sisi.SetValue("ClassName", txtClassName.Text.Trim());
                sisi.SetValue("CustomData", txtData.TextArea.Text);

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

                SearchIndexInfoProvider.SetSearchIndexInfo(sii);

                // Redirect to edit mode
                lblInfo.Visible = true;
                lblInfo.Text    = GetString("general.changessaved");

                if (smartSearchEnabled)
                {
                    lblInfo.Text += " " + String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
                }
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
            return;
        }
    }
Example #7
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Validate - check for selected object name
        if (string.IsNullOrEmpty(selObjects.Value.ToString()))
        {
            lblError.Visible = true;
            return;
        }

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis  = sii.IndexSettings;
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(SearchHelper.SIMPLE_ITEM_ID);

            // Create new
            if (sisi == null)
            {
                sisi    = new SearchIndexSettingsInfo();
                sisi.ID = SearchHelper.SIMPLE_ITEM_ID;
            }

            sisi.ClassNames     = ValidationHelper.GetString(selObjects.Value, String.Empty);
            sisi.WhereCondition = txtWhere.TextArea.Text.Trim();

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

            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            selObjects.ShowPleaseSelect = false;
            selObjects.Reload(true);

            // Display a message
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("general.changessaved");

            if (smartSearchEnabled)
            {
                lblInfo.Text += " " + String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
            }
        }
    }
    /// <summary>
    /// Gets and updates search index. Called when the "Get and update index" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool GetAndUpdateSearchIndex()
    {
        // Get the search index
        SearchIndexInfo updateIndex = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");

        if (updateIndex != null)
        {
            // Update the properties
            updateIndex.IndexDisplayName = updateIndex.IndexDisplayName.ToLowerCSafe();

            // Save the changes
            SearchIndexInfoProvider.SetSearchIndexInfo(updateIndex);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Creates search index. Called when the "Create index" button is pressed.
    /// </summary>
    private bool CreateSearchIndex()
    {
        // Create new search index object
        SearchIndexInfo newIndex = new SearchIndexInfo();

        // Set the properties
        newIndex.IndexDisplayName      = "My new index";
        newIndex.IndexName             = "MyNewIndex";
        newIndex.IndexIsCommunityGroup = false;
        newIndex.IndexType             = PredefinedObjectType.DOCUMENT;
        newIndex.IndexAnalyzerType     = AnalyzerTypeEnum.StandardAnalyzer;
        newIndex.StopWordsFile         = "";

        // Save the search index
        SearchIndexInfoProvider.SetSearchIndexInfo(newIndex);

        return(true);
    }
Example #10
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);
            }
        }
    }
Example #11
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (assemblyElem.IsValid())
        {
            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);
            if (sii != null)
            {
                SearchIndexSettings     sis  = sii.IndexSettings;
                SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(SearchHelper.CUSTOM_INDEX_DATA);

                // Create new
                if (sisi == null)
                {
                    sisi    = new SearchIndexSettingsInfo();
                    sisi.ID = SearchHelper.CUSTOM_INDEX_DATA;
                }

                sisi.SetValue("AssemblyName", assemblyElem.AssemblyName.Trim());
                sisi.SetValue("ClassName", assemblyElem.ClassName.Trim());
                sisi.SetValue("CustomData", txtData.TextArea.Text);

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

                SearchIndexInfoProvider.SetSearchIndexInfo(sii);

                ShowChangesSaved();

                // Redirect to edit mode
                if (smartSearchEnabled)
                {
                    ShowInformation(String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>"));
                }
            }
        }
        else
        {
            ShowError(assemblyElem.ErrorMessage);
            return;
        }
    }
    /// <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);
        }
    }
Example #13
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Validate - check for selected object name
        if (string.IsNullOrEmpty(drpObjType.Value.ToString()))
        {
            ShowError(GetString("srch.index.objectname.required"));
            return;
        }

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis  = sii.IndexSettings;
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(SearchHelper.SIMPLE_ITEM_ID);

            // Create new
            if (sisi == null)
            {
                sisi    = new SearchIndexSettingsInfo();
                sisi.ID = SearchHelper.SIMPLE_ITEM_ID;
            }

            sisi.ClassNames     = ValidationHelper.GetString(drpObjType.Value, String.Empty);
            sisi.WhereCondition = txtWhere.TextArea.Text.Trim();

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

            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            ShowChangesSaved();

            // Display a message
            if (smartSearchEnabled)
            {
                ShowInformation(String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>"));
            }
        }
    }
Example #14
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis  = sii.IndexSettings;
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(SearchHelper.SIMPLE_ITEM_ID);

            // Create new
            if (sisi == null)
            {
                sisi    = new SearchIndexSettingsInfo();
                sisi.ID = SearchHelper.SIMPLE_ITEM_ID;
            }

            sisi.SetValue("UserHidden", chkHidden.Checked);
            sisi.SetValue("UserEnabled", chkOnlyEnabled.Checked);
            sisi.SetValue("UserAllSites", chkSite.Checked);
            sisi.SetValue("UserInRoles", selectInRole.Value);
            sisi.SetValue("UserNotInRoles", selectNotInRole.Value);
            sisi.WhereCondition = txtWhere.TextArea.Text.Trim();

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

            SearchIndexInfoProvider.SetSearchIndexInfo(sii);

            // Redirect to edit mode
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("general.changessaved");

            if (smartSearchEnabled)
            {
                lblInfo.Text += " " + String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
            }
        }
    }
    /// <summary>
    /// Stores data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis = sii.IndexSettings;
            SearchIndexSettingsInfo sisi;

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

            // Save values
            if (sisi != null)
            {
                sisi.ClassNames     = Convert.ToString(customTableSelector.Value);
                sisi.WhereCondition = txtWhere.TextArea.Text.Trim();

                DataClassInfo dci = DataClassInfoProvider.GetDataClass(sisi.ClassNames);
                if (dci != null)
                {
                    sisi.SetValue("DisplayName", dci.ClassDisplayName);
                }

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

                // Redirect to edit mode
                lblInfo.Visible = true;
                lblInfo.Text    = GetString("general.changessaved");
                if (smartSearchEnabled)
                {
                    lblInfo.Text += " " + String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
                }
            }
            // Error loading SearchIndexSettingsInfo
            else
            {
                lblError.Text    = GetString("srch.err.loadingsisi");
                lblError.Visible = true;
            }
        }
        // Error loading SearchIndexInfo
        else
        {
            lblError.Text    = GetString("srch.err.loadingsii");
            lblError.Visible = true;
        }
    }
    /// <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;

                var isInsert = false;

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

                    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;
                    sisi.IncludeAttachments          = chkInclAtt.Checked;

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

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

                    if (isInsert)
                    {
                        // Redirect to edit mode
                        var editUrl = "SearchIndex_Content_Edit.aspx";
                        editUrl = URLHelper.AddParameterToUrl(editUrl, "indexId", sii.IndexID.ToString());
                        editUrl = URLHelper.AddParameterToUrl(editUrl, "guid", sisi.ID.ToString());
                        editUrl = URLHelper.AddParameterToUrl(editUrl, "saved", "1");
                        if (smartSearchEnabled)
                        {
                            editUrl = URLHelper.AddParameterToUrl(editUrl, "rebuild", "1");
                        }
                        URLHelper.Redirect(UrlResolver.ResolveUrl(editUrl));
                    }

                    ShowChangesSaved();

                    if (smartSearchEnabled)
                    {
                        // Show rebuild message
                        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);
        }
    }
Example #17
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Trim blank space and too long string
        string codeName = txtCodeName.Text.Trim();

        if (codeName.Length > 200)
        {
            codeName = codeName.Substring(0, 200);
        }

        // Get code name
        codeName         = ValidationHelper.GetCodeName(codeName, null, null);
        txtCodeName.Text = codeName;

        // Perform validation
        string errorMessage = new Validator().NotEmpty(codeName, rfvCodeName.ErrorMessage)
                              .NotEmpty(txtDisplayName.Text, rfvDisplayName.ErrorMessage).Result;

        // Check CodeName for identificator format
        if (!ValidationHelper.IsCodeName(codeName))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat");
        }

        // Check length of code name
        if (codeName.Length > codeNameLength)
        {
            errorMessage = GetString("srch.codenameexceeded");
        }

        if (errorMessage == "")
        {
            // Check code name
            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);

            // Get current item
            SearchIndexInfo current = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);


            // Check if code name is unique
            if ((sii == null) || (sii == current))
            {
                // Get original index path
                string originalPath = current.CurrentIndexPath;

                // Set the fields
                current.IndexName = codeName;

                // Trim blank space and too long string
                txtDisplayName.Text = txtDisplayName.Text.Trim();
                if (txtDisplayName.Text.Length > 200)
                {
                    txtDisplayName.Text = txtDisplayName.Text.Substring(0, 200);
                }

                if (current.IndexDisplayName != txtDisplayName.Text)
                {
                    // Refresh a breadcrumb if used in the tabs layout
                    ScriptHelper.RefreshTabHeader(Page, string.Empty);
                }

                current.IndexDisplayName = txtDisplayName.Text;

                // Check if analyzer type is changed
                bool analyzerTypeChanged = false;
                if ((current != null) &&
                    ((current.IndexAnalyzerType != SearchIndexInfoProvider.AnalyzerCodenameToEnum(drpAnalyzer.SelectedValue)) ||
                     (String.Compare(current.StopWordsFile, stopCustomControl.StopWordsFile, true) != 0) ||
                     (String.Compare(current.CustomAnalyzerAssemblyName, stopCustomControl.CustomAnalyzerAssemblyName) != 0) ||
                     (String.Compare(current.CustomAnalyzerClassName, stopCustomControl.CustomAnalyzerClassName) != 0)))
                {
                    analyzerTypeChanged = true;
                }
                current.IndexAnalyzerType = SearchIndexInfoProvider.AnalyzerCodenameToEnum(drpAnalyzer.SelectedValue);

                // Community indexing is not yet supported
                //current.IndexIsCommunityGroup = chkCommunity.Checked;
                current.IndexIsCommunityGroup      = false;
                current.CustomAnalyzerAssemblyName = stopCustomControl.CustomAnalyzerAssemblyName;
                current.CustomAnalyzerClassName    = stopCustomControl.CustomAnalyzerClassName;
                current.StopWordsFile  = stopCustomControl.StopWordsFile;
                current.IndexBatchSize = ValidationHelper.GetInteger(txtBatchSize.Text, 10);

                // Save the object
                SearchIndexInfoProvider.SetSearchIndexInfo(current);

                // Codename changed
                bool codenameChanged = false;
                if (sii == null)
                {
                    try
                    {
                        DirectoryHelper.MoveDirectory(originalPath, current.CurrentIndexPath);
                    }
                    catch (Exception ex)
                    {
                        EventLogProvider ep = new EventLogProvider();
                        ep.LogEvent("SmartSearch", "Rename", ex);
                    }

                    codenameChanged = true;
                }

                if (codenameChanged || analyzerTypeChanged)
                {
                    lblInfo.Text = String.Format(GetString("general.changessaved") + " " + GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
                }
                else
                {
                    lblInfo.Text = GetString("General.ChangesSaved");
                }

                // Redirect to edit mode
                RaiseOnSaved();
                lblInfo.Visible = true;
            }
            else
            {
                // Error message - code name already exists
                lblError.Visible = true;
                lblError.Text    = GetString("srch.index.codenameexists");
            }
        }
        else
        {
            // Error message - validation
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
    /// <summary>
    /// Stores data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Perform validation
        string errorMessage = new Validator().NotEmpty(selSite.Value, GetString("srch.err.emptysite")).Result;

        if (String.IsNullOrEmpty(errorMessage) && (ItemType == SearchIndexSettingsInfo.TYPE_EXLUDED) && String.IsNullOrEmpty(Convert.ToString(selForum.Value)))
        {
            errorMessage = GetString("srch.err.emptyforum");
        }

        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)
                {
                    string siteName = selSite.Value.ToString();
                    if (siteName == "-1")
                    {
                        siteName = String.Empty;
                    }

                    sisi.SiteName   = siteName;
                    sisi.ForumNames = selForum.Value.ToString();

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

                    ShowChangesSaved();

                    // Redirect to edit mode
                    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);
        }
    }
    /// <summary>
    /// Stores data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!selSite.UniSelector.HasData || !selectForm.HasData)
        {
            ShowError(GetString("srch.err.selectform"));
            return;
        }

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis = sii.IndexSettings;
            SearchIndexSettingsInfo sisi;

            var isInsert = false;

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

                sisi    = new SearchIndexSettingsInfo();
                sisi.ID = Guid.NewGuid();
            }

            // Save values
            if (sisi != null)
            {
                string formName = ValidationHelper.GetString(selectForm.Value, "");

                sisi.SetValue("FormName", formName);
                sisi.WhereCondition = txtWhere.TextArea.Text.Trim();
                sisi.SiteName       = selSite.Value.ToString();

                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formName, sisi.SiteName);
                if (bfi != null)
                {
                    sisi.SetValue("DisplayName", bfi.FormDisplayName);
                    sisi.ClassNames = BizFormItemProvider.BIZFORM_ITEM_PREFIX + DataClassInfoProvider.GetClassName(bfi.FormClassID);
                }

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

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

                if (isInsert)
                {
                    // Redirect to edit mode
                    var editUrl = "SearchIndex_Content_Edit.aspx";
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "indexId", sii.IndexID.ToString());
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "guid", sisi.ID.ToString());
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "saved", "1");
                    if (smartSearchEnabled)
                    {
                        editUrl = URLHelper.AddParameterToUrl(editUrl, "rebuild", "1");
                    }
                    URLHelper.Redirect(editUrl);
                }

                ShowChangesSaved();

                if (smartSearchEnabled)
                {
                    // Show rebuild message
                    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"));
        }
    }
    /// <summary>
    /// Stores data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis = sii.IndexSettings;
            SearchIndexSettingsInfo sisi;

            var isInsert = false;

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

                sisi      = new SearchIndexSettingsInfo();
                sisi.ID   = Guid.NewGuid();
                sisi.Type = ItemType;
            }

            // Save values
            if (sisi != null)
            {
                sisi.ClassNames     = Convert.ToString(customTableSelector.Value);
                sisi.WhereCondition = txtWhere.TextArea.Text.Trim();

                DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(sisi.ClassNames);
                if (dci != null)
                {
                    sisi.SetValue("DisplayName", dci.ClassDisplayName);
                }

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

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

                if (isInsert)
                {
                    // Redirect to edit mode
                    var editUrl = "SearchIndex_Content_Edit.aspx";
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "indexId", sii.IndexID.ToString());
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "guid", sisi.ID.ToString());
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "saved", "1");
                    if (smartSearchEnabled)
                    {
                        editUrl = URLHelper.AddParameterToUrl(editUrl, "rebuild", "1");
                    }
                    URLHelper.Redirect(UrlResolver.ResolveUrl(editUrl));
                }

                ShowChangesSaved();

                if (smartSearchEnabled)
                {
                    // Show rebuild message
                    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"));
        }
    }
    /// <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);
        }
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Get code name
        string codeName = txtCodeName.Text.Trim();

        // Perform validation
        string errorMessage = new Validator().NotEmpty(codeName, rfvCodeName.ErrorMessage)
                              .NotEmpty(txtDisplayName.Text, rfvDisplayName.ErrorMessage).Result;

        // Check CodeName for identifier format
        if (!ValidationHelper.IsCodeName(codeName))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentifierFormat");
        }

        // Check length of code name
        if (codeName.Length > codeNameLength)
        {
            errorMessage = GetString("srch.codenameexceeded");
        }

        if (errorMessage == "")
        {
            // Create new
            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName);

            if (sii == null)
            {
                sii = new SearchIndexInfo();

                // Set the fields
                sii.IndexName         = codeName;
                sii.IndexDisplayName  = txtDisplayName.Text.Trim();
                sii.IndexAnalyzerType = SearchIndexInfoProvider.AnalyzerCodenameToEnum(drpAnalyzer.SelectedValue);
                // Community indexing is not yet supported
                //sii.IndexIsCommunityGroup = chkCommunity.Checked;
                sii.IndexIsCommunityGroup      = false;
                sii.IndexType                  = drpType.SelectedValue;
                sii.CustomAnalyzerAssemblyName = stopCustomControl.CustomAnalyzerAssemblyName;
                sii.CustomAnalyzerClassName    = stopCustomControl.CustomAnalyzerClassName;
                sii.StopWordsFile              = stopCustomControl.StopWordsFile;

                // Save the object
                SearchIndexInfoProvider.SetSearchIndexInfo(sii);
                ItemID = sii.IndexID;

                // Assign to current website
                if (chkAddIndexToCurrentSite.Checked)
                {
                    SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, CMSContext.CurrentSiteID);
                }

                // Redirect to edit mode
                RaiseOnSaved();
            }
            else
            {
                // Error message - code name already exists
                ShowError(GetString("srch.index.codenameexists"));
            }
        }
        else
        {
            // Error message - validation
            ShowError(errorMessage);
        }
    }