/// <summary>
    /// Unigrid on action handler.
    /// </summary>
    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)
            {
                lblInfo.Visible = true;
                lblInfo.Text    = String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
            }
            break;
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(this.ItemGUID);
            if (sisi != null)
            {
                if (!RequestHelper.IsPostBack())
                {
                    selSite.Value = sisi.SiteName;
                    selForum.SetValue("SiteName", sisi.SiteName);
                    selForum.Value = sisi.ForumNames;
                }
                this.ItemType = sisi.Type;
            }
        }

        plcForumsInfo.Visible = true;
        if (this.ItemType == SearchIndexSettingsInfo.TYPE_EXLUDED)
        {
            plcForumsInfo.Visible = false;
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            if (sisi != null)
            {
                if (!RequestHelper.IsPostBack())
                {
                    selSite.Value = sisi.SiteName;
                    selForum.SetValue("SiteName", sisi.SiteName);
                    selForum.Value = sisi.ForumNames;
                }
                ItemType = sisi.Type;
            }
        }

        plcForumsInfo.Visible = true;
        if (ItemType == SearchIndexSettingsInfo.TYPE_EXLUDED)
        {
            plcForumsInfo.Visible = false;
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Disable textbpx editing
        selectInRole.UseFriendlyMode    = true;
        selectNotInRole.UseFriendlyMode = true;

        if (!RequestHelper.IsPostBack())
        {
            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)
                {
                    chkHidden.Checked      = ValidationHelper.GetBoolean(sisi.GetValue("UserHidden"), false);
                    chkOnlyEnabled.Checked = ValidationHelper.GetBoolean(sisi.GetValue("UserEnabled"), true);
                    chkSite.Checked        = ValidationHelper.GetBoolean(sisi.GetValue("UserAllSites"), false);
                    selectInRole.Value     = ValidationHelper.GetString(sisi.GetValue("UserInRoles"), String.Empty);
                    selectNotInRole.Value  = ValidationHelper.GetString(sisi.GetValue("UserNotInRoles"), String.Empty);
                    txtWhere.TextArea.Text = sisi.WhereCondition;
                }
            }
        }
    }
Ejemplo n.º 5
0
    /// <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>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(this.ItemGUID);
            if (sisi != null)
            {
                selectClassnames.Value = sisi.ClassNames;
                selectpath.Value       = sisi.Path;
                this.ItemType          = sisi.Type;

                if (sisi.Type == SearchIndexSettingsInfo.TYPE_ALLOWED)
                {
                    chkInclForums.Checked = sisi.IncludeForums;
                    chkInclBlog.Checked   = sisi.IncludeBlogs;
                    chkInclBoards.Checked = sisi.IncludeMessageCommunication;
                }
            }
        }

        // Hide appropriate contorls for excluded item
        if ((this.ItemType == SearchIndexSettingsInfo.TYPE_EXLUDED) || ((sii != null) && (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX)))
        {
            pnlAllowed.Visible = false;
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            if (sisi != null)
            {
                selectClassnames.Value = sisi.ClassNames;
                selectpath.Value       = sisi.Path;
                ItemType = sisi.Type;

                if (sisi.Type == SearchIndexSettingsInfo.TYPE_ALLOWED)
                {
                    chkInclCats.Checked = sisi.IncludeCategories;
                    chkInclAtt.Checked  = sisi.IncludeAttachments;
                }
            }
        }

        // Hide appropriate controls for excluded item
        if ((ItemType == SearchIndexSettingsInfo.TYPE_EXLUDED) || ((sii != null) && (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX)))
        {
            pnlAllowed.Visible = false;
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            if (sisi != null)
            {
                selectClassnames.Value = sisi.ClassNames;
                selectpath.Value = sisi.Path;
                ItemType = sisi.Type;

                if (sisi.Type == SearchIndexSettingsInfo.TYPE_ALLOWED)
                {
                    chkInclForums.Checked = sisi.IncludeForums;
                    chkInclBlog.Checked = sisi.IncludeBlogs;
                    chkInclBoards.Checked = sisi.IncludeMessageCommunication;
                    chkInclCats.Checked = sisi.IncludeCategories;
                }
            }
        }

        // Hide appropriate controls for excluded item
        if ((ItemType == SearchIndexSettingsInfo.TYPE_EXLUDED) || ((sii != null) && (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX)))
        {
            pnlAllowed.Visible = false;
        }
    }
Ejemplo n.º 9
0
 public DocumentService(
     IDocumentFactory factory,
     IDocumentRepository repository,
     SearchIndexSettings searchIndexSettings)
 {
     _factory             = factory;
     _repository          = repository;
     _searchIndexSettings = searchIndexSettings;
 }
    /// <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);
    }
Ejemplo n.º 11
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);
        }
    }
Ejemplo n.º 12
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;
        }
    }
Ejemplo n.º 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            if (SearchIndexInfo != null)
            {
                SearchIndexSettings     sis  = SearchIndexInfo.IndexSettings;
                SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(SearchHelper.SIMPLE_ITEM_ID);

                if (sisi != null)
                {
                    drpObjType.Value       = sisi.ClassNames;
                    txtWhere.TextArea.Text = sisi.WhereCondition;
                }
            }
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            if (sisi != null)
            {
                customTableSelector.Value = sisi.ClassNames;
                txtWhere.TextArea.Text = sisi.WhereCondition;
            }
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(this.ItemGUID);
            if (sisi != null)
            {
                customTableSelector.Value = sisi.ClassNames;
                txtWhere.TextArea.Text    = sisi.WhereCondition;
            }
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        string siteWhere = String.Empty;

        // Load only those site to which the index is assigned
        var siteIDs = SearchIndexSiteInfoProvider.GetIndexSiteBindings(ItemID).Column("IndexSiteID").Select(X => X.IndexSiteID.ToString()).ToList();

        if (siteIDs.Count > 0)
        {
            siteWhere = SqlHelper.GetWhereCondition <string>("SiteID", siteIDs, false);

            // Preselect current site if it is assigned to index
            if (!RequestHelper.IsPostBack() && siteIDs.Contains(SiteContext.CurrentSiteID.ToString()))
            {
                selSite.Value = SiteContext.CurrentSiteName;
            }

            selSite.UniSelector.WhereCondition = siteWhere;
            selSite.Reload(false);
        }
        else
        {
            pnlForm.Visible = false;

            ShowError(GetString("srch.index.nositeselected"));
        }

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            if (sisi != null)
            {
                selectForm.Value       = ValidationHelper.GetString(sisi.GetValue("FormName"), "");
                txtWhere.TextArea.Text = sisi.WhereCondition;
                selSite.Value          = sisi.SiteName;
            }
        }

        // Init controls
        SetControlsStatus(false);
    }
Ejemplo n.º 17
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>");
            }
        }
    }
Ejemplo n.º 18
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);
            }
        }
    }
Ejemplo n.º 19
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;
        }
    }
Ejemplo n.º 20
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>"));
            }
        }
    }
    /// <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 Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            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)
                {
                    txtAssembly.Text      = ValidationHelper.GetString(sisi.GetValue("AssemblyName"), String.Empty);
                    txtClassName.Text     = ValidationHelper.GetString(sisi.GetValue("ClassName"), String.Empty);
                    txtData.TextArea.Text = ValidationHelper.GetString(sisi.GetValue("CustomData"), String.Empty);
                }
            }
        }
    }
Ejemplo n.º 23
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>");
            }
        }
    }
Ejemplo n.º 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);
            if (sii != null)
            {
                SearchIndexSettings     sis  = sii.IndexSettings;
                SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(SearchHelper.SIMPLE_ITEM_ID);

                if (sisi != null)
                {
                    selObjects.Value       = sisi.ClassNames;
                    txtWhere.TextArea.Text = sisi.WhereCondition;
                }
            }
        }


        // Setup the UniSelector - exclude classes which have their special type of a search index
        selObjects.ExcludeSmartSearchClassNames = true;
        selObjects.ShowPleaseSelect             = String.IsNullOrEmpty(ValidationHelper.GetString(selObjects.Value, String.Empty));
    }
    /// <summary>
    /// Unigrid on action handler.
    /// </summary>
    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)
                {
                    lblInfo.Visible = true;
                    lblInfo.Text = String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
                }
                break;
        }
    }
    /// <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;

            // 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);
            }
        }
    }
    /// <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;

            // 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>
    /// 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 (!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)
    {
        // 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>
    /// 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.DocumentName;

        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 = AnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType = PredefinedObjectType.DOCUMENT;
            sii.IndexIsCommunityGroup = false;

            // 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);

            // Assing to current website
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, CMSContext.CurrentSiteID);

        }

        // Add curent culture to search index
        CultureInfo ci = CultureInfoProvider.GetCultureInfo(departmentNode.DocumentCulture);
        SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);

        // Rebuild search index
        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
    }
Ejemplo n.º 32
0
 public SearchIndex(IOptions <SearchIndexSettings> settings)
 {
     _settings = settings.Value;
 }
    /// <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"));
        }
    }
Ejemplo n.º 34
0
    /// <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>
    /// 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);
        }
    }
Ejemplo n.º 36
0
 public ToolsController(ToolsService toolsService, IOptions <SearchIndexSettings> settings)
 {
     _toolsService = toolsService;
     _settings     = settings.Value;
 }
    /// <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);
        }
    }
    /// <summary>
    /// Resets all boxes.
    /// </summary>
    public void LoadControls()
    {
        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        string siteWhere = String.Empty;

        // Load only those site to which the index is assigned
        var siteIDs = SearchIndexSiteInfoProvider.GetIndexSiteBindings(ItemID).Column("IndexSiteID").Select(X => X.IndexSiteID.ToString()).ToList();
        if (siteIDs.Count > 0)
        {
            siteWhere = SqlHelper.GetWhereCondition<string>("SiteID", siteIDs, false);

            // Preselect current site if it is assigned to index
            if (!RequestHelper.IsPostBack() && siteIDs.Contains(SiteContext.CurrentSiteID.ToString()))
            {
                selSite.Value = SiteContext.CurrentSiteName;
            }

            selSite.UniSelector.WhereCondition = siteWhere;
            selSite.Reload(false);
        }
        else
        {
            pnlForm.Visible = false;

            ShowError(GetString("srch.index.nositeselected"));
        }

        // If we are editing existing search index
        if (sii != null)
        {
            SearchIndexSettings sis = new SearchIndexSettings();
            sis.LoadData(sii.IndexSettings.GetData());
            SearchIndexSettingsInfo sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            if (sisi != null)
            {
                selectForm.Value = ValidationHelper.GetString(sisi.GetValue("FormName"), "");
                txtWhere.TextArea.Text = sisi.WhereCondition;
                selSite.Value = sisi.SiteName;
            }
        }

        // Init controls
        SetControlsStatus(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.DocumentName;

        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 = AnalyzerTypeEnum.StandardAnalyzer;
            sii.IndexType = PredefinedObjectType.FORUM;
            sii.IndexIsCommunityGroup = false;

            // Create search index settings info
            SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo();
            sisi.ID = Guid.NewGuid();
            sisi.Type = SearchIndexSettingsInfo.TYPE_ALLOWED;
            sisi.SiteName = CMSContext.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);

            // Assing to current website and current culture
            SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, CMSContext.CurrentSiteID);
            CultureInfo ci = CultureInfoProvider.GetCultureInfo(departmentNode.DocumentCulture);
            SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID);
        }
    }