コード例 #1
0
        private static void RebuildIndex(SearchIndexInfo index)
        {
            try
            {
                // After installation or deployment the index is new but no web farm task is issued
                // to rebuild the index. This will ensure that index is rebuilt on instance upon first request.
                if (index.IndexStatusLocal == IndexStatusEnum.NEW)
                {
                    var taskCreationParameters = new SearchTaskCreationParameters
                    {
                        TaskType        = SearchTaskTypeEnum.Rebuild,
                        TaskValue       = index.IndexName,
                        RelatedObjectID = index.IndexID
                    };

                    taskCreationParameters.TargetServers.Add(WebFarmHelper.ServerName);

                    SearchTaskInfoProvider.CreateTask(taskCreationParameters, true);
                }
            }
            catch (SearchIndexException ex)
            {
                Service.Resolve <IEventLogService>().LogException("SmartSearch", "INDEX REBUILD", ex);
            }
        }
コード例 #2
0
    /// <summary>
    /// Starts the search index optimization task.
    /// </summary>
    private void Optimize()
    {
        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Optimize, null, null, SearchIndex.IndexName, SearchIndex.IndexID);

        RaiseAsyncIndexTaskStarted();
        ShowInformation(GetString("srch.index.optimizestarted"));
    }
コード例 #3
0
    /// <summary>
    ///  Rebuild click.
    /// </summary>
    protected void Rebuild()
    {
        if (sii != null)
        {
            if (DataHelper.DataSourceIsEmpty(sii.IndexSettings.GetAll()) && (sii.IndexType.ToLowerCSafe() != PredefinedObjectType.USER))
            {
                ShowError(GetString("index.nocontent"));
                return;
            }

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

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

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

        // Reload info panel
        Thread.Sleep(100);
        ReloadInfoPanel();
    }
コード例 #4
0
    private void SaveData()
    {
        if (node != null)
        {
            // Update fields
            node.NodeBodyElementAttributes = txtBodyCss.Text;
            node.NodeDocType  = txtDocType.Text;
            node.NodeHeadTags = txtHeadTags.Value.ToString();

            // Update the node
            node.Update();

            // Update search index
            if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
            }

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

            RegisterRefreshScript();

            // Empty variable for exitwithoutchanges dialog
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "SubmitAction", ScriptHelper.GetScript("NotChanged();"));

            // Clear cache
            PageInfoProvider.RemoveAllPageInfosFromCache();



            ShowChangesSaved();
        }
    }
コード例 #5
0
    /// <summary>
    /// Apply control settings.
    /// </summary>
    public bool ApplySettings()
    {
        if (MasterTemplateId <= 0)
        {
            lblError.Text = GetString("TemplateSelection.SelectTemplate");
            return(false);
        }
        else
        {
            // Update all culture versions
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            DataSet      ds   = tree.SelectNodes(SiteName, "/", TreeProvider.ALL_CULTURES, false, "CMS.Root", null, null, -1, false);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    // Update the document
                    TreeNode node = TreeNode.New(dr, "CMS.Root", tree);

                    node.SetDefaultPageTemplateID(MasterTemplateId);

                    node.Update();

                    // Update search index for node
                    if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
                    {
                        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
                    }
                }
            }
        }

        return(true);
    }
コード例 #6
0
    /// <summary>
    /// Handles click on rebuild link (after sites are saved).
    /// </summary>
    /// <param name="eventArgument"></param>
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            // Check permissions
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.searchindex", CMSAdminControl.PERMISSION_MODIFY))
            {
                RedirectToAccessDenied("cms.searchindex", CMSAdminControl.PERMISSION_MODIFY);
            }

            // Get search index info
            SearchIndexInfo sii = null;
            if (this.indexId > 0)
            {
                sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.indexId);
            }

            // Create rebuild task
            if (sii != null)
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
            }

            lblInfo.Text    = GetString("srch.index.rebuildstarted");
            lblInfo.Visible = true;
        }
    }
コード例 #7
0
    private void SaveData()
    {
        if (node != null)
        {
            // Update fields
            node.NodeBodyElementAttributes = txtBodyCss.Text;
            node.NodeDocType  = txtDocType.Text;
            node.NodeHeadTags = txtHeadTags.Value.ToString();

            // Update the node
            node.Update();

            // Update search index
            if (DocumentHelper.IsSearchTaskCreationAllowed(node))
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID);
            }

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

            RegisterRefreshScript();

            // Empty variable for exitwithoutchanges dialog
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "SubmitAction", "CMSContentManager.changed(false);", true);

            // Clear cache
            PageInfoProvider.RemoveAllPageInfosFromCache();

            ShowChangesSaved();

            // Clear content changed flag
            DocumentManager.ClearContentChanged();
        }
    }
コード例 #8
0
    /// <summary>
    /// Apply control settings.
    /// </summary>
    public bool ApplySettings()
    {
        if (MasterTemplateId <= 0)
        {
            lblError.Text = GetString("TemplateSelection.SelectTemplate");
            return(false);
        }
        else
        {
            // Update all culture versions
            TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
            DataSet      ds   = tree.SelectNodes(SiteName, "/", TreeProvider.ALL_CULTURES, false, SystemDocumentTypes.Root, null, null, -1, false);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    // Update the document
                    TreeNode node = TreeNode.New(SystemDocumentTypes.Root, dr, tree);

                    node.SetDefaultPageTemplateID(MasterTemplateId);

                    node.Update();

                    // Update search index for node
                    if (DocumentHelper.IsSearchTaskCreationAllowed(node))
                    {
                        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID);
                    }
                }
            }
        }

        return(true);
    }
コード例 #9
0
    /// <summary>
    ///  Rebuild click.
    /// </summary>
    protected void btnRebuild_Click(object sender, EventArgs e)
    {
        if (sii != null)
        {
            if ((sii.IndexType.ToLower() == PredefinedObjectType.DOCUMENT) || (sii.IndexType == SearchHelper.DOCUMENTS_CRAWLER_INDEX))
            {
                DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + sii.IndexID, null, 0, "IndexID, IndexCultureID");
                if (SqlHelperClass.DataSourceIsEmpty(ds))
                {
                    lblInfo.Text    = GetString("index.noculture");
                    lblInfo.Visible = true;
                    return;
                }

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

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

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

        // Reload info panel
        System.Threading.Thread.Sleep(100);
        ReloadInfoPanel();
    }
コード例 #10
0
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            // Get search index info
            SearchIndexInfo sii = null;
            if (this.ItemID > 0)
            {
                sii = SearchIndexInfoProvider.GetSearchIndexInfo(this.ItemID);
            }

            // Create rebuild task
            if (sii != null)
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
            }

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

            // Reload info panel
            System.Threading.Thread.Sleep(100);
            ReloadInfoPanel();
        }
    }
コード例 #11
0
    /// <summary>
    /// Rebuilds the search index. Called when the "Rebuild index" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool RebuildIndex()
    {
        // Get the search index
        SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("MyNewIndex");

        if (index != null)
        {
            // Create rebuild task
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, index.IndexType, null, index.IndexName);

            return(true);
        }
        return(false);
    }
コード例 #12
0
    /// <summary>
    ///  Optimize click.
    /// </summary>
    protected void Optimize()
    {
        // Rebuild search index info
        if (sii != null)
        {
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Optimize, sii.IndexType, null, sii.IndexName);
        }

        ShowConfirmation(GetString("srch.index.optimizestarted"));

        // Reload info panel
        Thread.Sleep(100);
        ReloadInfoPanel();
    }
コード例 #13
0
    /// <summary>
    ///  Optimize click.
    /// </summary>
    protected void btnOptimize_Click(object sender, EventArgs e)
    {
        // Rebuild search index info
        if (sii != null)
        {
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Optimize, sii.IndexType, null, sii.IndexName);
        }

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

        // Reload info panel
        System.Threading.Thread.Sleep(100);
        ReloadInfoPanel();
    }
    /// <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);
    }
コード例 #15
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);
        }
    }
コード例 #16
0
        private void Delete_After(object sender, ObjectEventArgs e)
        {
            if (!SearchIndexInfoProvider.SearchEnabled || !SearchIndexInfoProvider.SearchTypeEnabled(CMS.Search.SearchHelper.CUSTOM_SEARCH_INDEX))
            {
                return;
            }

            var fileInfo = e.Object as MediaFileInfo;

            if (fileInfo == null)
            {
                return;
            }

            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Delete, CMS.Search.SearchHelper.CUSTOM_SEARCH_INDEX, SearchFieldsConstants.ID, fileInfo.FileID.ToString(), 0);
        }
コード例 #17
0
    protected void btnSave_Click(object sender, EventArgs ea)
    {
        // Check modify permissions
        CurrentUserInfo ui = CMSContext.CurrentUser;

        if (node != null)
        {
            // Check permissions
            if (ui.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath));
            }

            string conversionValue = ValidationHelper.GetString(ucConversionSelector.Value, String.Empty).Trim();

            if (!ucConversionSelector.IsValid())
            {
                lblError.Text    = ucConversionSelector.ValidationError;
                lblError.Visible = true;
                return;
            }

            if (!usSelectCampaign.IsValid())
            {
                lblError.Visible = true;
                lblError.Text    = usSelectCampaign.ValidationError;
                return;
            }

            node.DocumentCampaign            = ValidationHelper.GetString(usSelectCampaign.Value, String.Empty).Trim();
            node.DocumentConversionValue     = txtConversionValue.Text;
            node.DocumentTrackConversionName = conversionValue;
            node.Update();

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("general.changessaved");

            // Update search index
            if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
            }

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);
        }
    }
コード例 #18
0
    /// <summary>
    /// Adds search index to site. Called when the "Add index to site" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool UpdateIndex()
    {
        // Tree provider
        TreeProvider provider = new TreeProvider(MembershipContext.AuthenticatedUser);
        // Get document of specified site, aliaspath and culture
        TreeNode node = provider.SelectSingleNode(SiteContext.CurrentSiteName, "/", "en-us");

        // If node exists
        if ((node != null) && DocumentHelper.IsSearchTaskCreationAllowed(node))
        {
            // Edit and save document node
            node.NodeDocType += " changed";
            node.Update();

            // Create update task
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID);

            return(true);
        }
        return(false);
    }
コード例 #19
0
    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "saved")
        {
            // Get search index info
            SearchIndexInfo sii = null;
            if (IndexID > 0)
            {
                sii = SearchIndexInfoProvider.GetSearchIndexInfo(IndexID);
            }

            // Create rebuild task
            if (sii != null)
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
            }

            lblInfo.Text    = GetString("srch.index.rebuildstarted");
            lblInfo.Visible = true;
        }
    }
コード例 #20
0
    /// <summary>
    /// Adds search index to site. Called when the "Add index to site" button is pressed.
    /// Expects the CreateSearchIndex method to be run first.
    /// </summary>
    private bool UpdateIndex()
    {
        // Tree provider
        TreeProvider provider = new TreeProvider(CMSContext.CurrentUser);
        // Get document of specified site, aliaspath and culture
        TreeNode node = provider.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");

        // If node exists
        if ((node != null) && (node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
        {
            // Edit and save document node
            node.NodeDocType += " changed";
            node.Update();

            // Create update task
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());

            return(true);
        }
        return(false);
    }
コード例 #21
0
    protected void chkMarkDocAsProd_CheckedChanged(object sender, EventArgs e)
    {
        if (!IsAuthorizedToModifyDocument())
        {
            RedirectToAccessDenied("CMS.Content", "Modify");
        }

        this.Node.NodeSKUID = 0;
        this.Node.Update();

        // Update search index for node
        if ((this.Node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
        {
            SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, this.Node.GetSearchID());
        }

        // Log synchronization
        DocumentSynchronizationHelper.LogDocumentChange(this.Node, TaskTypeEnum.UpdateDocument, this.Node.TreeProvider);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "FirstTabSelection", ScriptHelper.GetScript(" parent.window.location = '" + URLHelper.ResolveUrl("~/CMSModules/Ecommerce/Pages/Content/Product/Product_Selection.aspx") + "?nodeid=" + this.NodeID + "&productid=" + productId + "' "));
    }
コード例 #22
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void UniGrid_OnAction(string actionName, object actionArgument)
    {
        switch (actionName)
        {
        case "edit":
            this.SelectedItemID = Convert.ToInt32(actionArgument);
            RaiseOnEdit();
            break;

        case "delete":
            // Delete search index info object from database with it's dependencies
            SearchIndexInfoProvider.DeleteSearchIndexInfo(Convert.ToInt32(actionArgument));
            break;

        case "rebuild":
            if (SearchIndexInfoProvider.SearchEnabled)
            {
                // Rebuild search index info
                SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(Convert.ToInt32(actionArgument));
                if (sii != null)
                {
                    SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName);
                    // Sleep
                    System.Threading.Thread.Sleep(100);
                }

                lblInfo.ResourceString = "srch.index.rebuildstarted";
                lblInfo.Visible        = true;
            }
            else
            {
                lblError.ResourceString = "srch.index.searchdisabled";
                lblError.Visible        = true;
            }
            break;
        }
    }
コード例 #23
0
    /// <summary>
    /// Saves modified image data.
    /// </summary>
    /// <param name="name">Image name</param>
    /// <param name="extension">Image extension</param>
    /// <param name="mimetype">Image mimetype</param>
    /// <param name="title">Image title</param>
    /// <param name="description">Image description</param>
    /// <param name="binary">Image binary data</param>
    /// <param name="width">Image width</param>
    /// <param name="height">Image height</param>
    private void SaveImage(string name, string extension, string mimetype, string title, string description, byte[] binary, int width, int height)
    {
        LoadInfos();

        // Save image data depending to image type
        switch (baseImageEditor.ImageType)
        {
        // Process attachment
        case ImageHelper.ImageTypeEnum.Attachment:
            if (ai != null)
            {
                // Save new data
                try
                {
                    // Get the node
                    TreeNode node = DocumentHelper.GetDocument(ai.AttachmentDocumentID, baseImageEditor.Tree);

                    // Check Create permission when saving temporary attachment, check Modify permission else
                    NodePermissionsEnum permissionToCheck = (ai.AttachmentFormGUID == Guid.Empty) ? NodePermissionsEnum.Modify : NodePermissionsEnum.Create;

                    // Check permission
                    if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(node, permissionToCheck) != AuthorizationResultEnum.Allowed)
                    {
                        baseImageEditor.ShowError(GetString("attach.actiondenied"));
                        SavingFailed = true;

                        return;
                    }

                    if (!IsNameUnique(name, extension))
                    {
                        baseImageEditor.ShowError(GetString("img.namenotunique"));
                        SavingFailed = true;

                        return;
                    }


                    // Ensure automatic check-in/ check-out
                    bool            useWorkflow = false;
                    bool            autoCheck   = false;
                    WorkflowManager workflowMan = WorkflowManager.GetInstance(baseImageEditor.Tree);
                    if (node != null)
                    {
                        // Get workflow info
                        WorkflowInfo wi = workflowMan.GetNodeWorkflow(node);

                        // Check if the document uses workflow
                        if (wi != null)
                        {
                            useWorkflow = true;
                            autoCheck   = !wi.UseCheckInCheckOut(CurrentSiteName);
                        }

                        // Check out the document
                        if (autoCheck)
                        {
                            VersionManager.CheckOut(node, node.IsPublished, true);
                            VersionHistoryID = node.DocumentCheckedOutVersionHistoryID;
                        }

                        // Workflow has been lost, get published attachment
                        if (useWorkflow && (VersionHistoryID == 0))
                        {
                            ai = AttachmentInfoProvider.GetAttachmentInfo(ai.AttachmentGUID, CurrentSiteName);
                        }

                        // If extension changed update CMS.File extension
                        if ((node.NodeClassName.ToLowerCSafe() == "cms.file") && (node.DocumentExtensions != extension))
                        {
                            // Update document extensions if no custom are used
                            if (!node.DocumentUseCustomExtensions)
                            {
                                node.DocumentExtensions = extension;
                            }
                            node.SetValue("DocumentType", extension);

                            DocumentHelper.UpdateDocument(node, baseImageEditor.Tree);
                        }
                    }

                    if (ai != null)
                    {
                        // Test all parameters to empty values and update new value if available
                        if (name != "")
                        {
                            if (!name.EndsWithCSafe(extension))
                            {
                                ai.AttachmentName = name + extension;
                            }
                            else
                            {
                                ai.AttachmentName = name;
                            }
                        }
                        if (extension != "")
                        {
                            ai.AttachmentExtension = extension;
                        }
                        if (mimetype != "")
                        {
                            ai.AttachmentMimeType = mimetype;
                        }

                        ai.AttachmentTitle       = title;
                        ai.AttachmentDescription = description;

                        if (binary != null)
                        {
                            ai.AttachmentBinary = binary;
                            ai.AttachmentSize   = binary.Length;
                        }
                        if (width > 0)
                        {
                            ai.AttachmentImageWidth = width;
                        }
                        if (height > 0)
                        {
                            ai.AttachmentImageHeight = height;
                        }
                        // Ensure object
                        ai.MakeComplete(true);
                        if (VersionHistoryID > 0)
                        {
                            VersionManager.SaveAttachmentVersion(ai, VersionHistoryID);
                        }
                        else
                        {
                            AttachmentInfoProvider.SetAttachmentInfo(ai);

                            // Log the synchronization and search task for the document
                            if (node != null)
                            {
                                // Update search index for given document
                                if (DocumentHelper.IsSearchTaskCreationAllowed(node))
                                {
                                    SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID);
                                }

                                DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, baseImageEditor.Tree);
                            }
                        }

                        // Check in the document
                        if ((autoCheck) && (VersionManager != null) && (VersionHistoryID > 0) && (node != null))
                        {
                            VersionManager.CheckIn(node, null);
                        }
                    }
                }
                catch (Exception ex)
                {
                    baseImageEditor.ShowError(GetString("img.errors.processing"), tooltipText: ex.Message);
                    EventLogProvider.LogException("Image editor", "SAVEIMAGE", ex);
                    SavingFailed = true;
                }
            }
            break;

        case ImageHelper.ImageTypeEnum.PhysicalFile:
            if (!String.IsNullOrEmpty(filePath))
            {
                var currentUser = MembershipContext.AuthenticatedUser;
                if ((currentUser != null) && currentUser.IsGlobalAdministrator)
                {
                    try
                    {
                        string physicalPath = Server.MapPath(filePath);
                        string newPath      = physicalPath;

                        // Write binary data to the disk
                        File.WriteAllBytes(physicalPath, binary);

                        // Handle rename of the file
                        if (!String.IsNullOrEmpty(name))
                        {
                            newPath = DirectoryHelper.CombinePath(Path.GetDirectoryName(physicalPath), name);
                        }
                        if (!String.IsNullOrEmpty(extension))
                        {
                            string oldExt = Path.GetExtension(physicalPath);
                            newPath = newPath.Substring(0, newPath.Length - oldExt.Length) + extension;
                        }

                        // Move the file
                        if (newPath != physicalPath)
                        {
                            File.Move(physicalPath, newPath);
                        }
                    }
                    catch (Exception ex)
                    {
                        baseImageEditor.ShowError(GetString("img.errors.processing"), tooltipText: ex.Message);
                        EventLogProvider.LogException("Image editor", "SAVEIMAGE", ex);
                        SavingFailed = true;
                    }
                }
                else
                {
                    baseImageEditor.ShowError(GetString("img.errors.rights"));
                    SavingFailed = true;
                }
            }
            break;

        // Process metafile
        case ImageHelper.ImageTypeEnum.Metafile:

            if (mf != null)
            {
                if (UserInfoProvider.IsAuthorizedPerObject(mf.MetaFileObjectType, mf.MetaFileObjectID, PermissionsEnum.Modify, CurrentSiteName, MembershipContext.AuthenticatedUser))
                {
                    try
                    {
                        // Test all parameters to empty values and update new value if available
                        if (name.CompareToCSafe("") != 0)
                        {
                            if (!name.EndsWithCSafe(extension))
                            {
                                mf.MetaFileName = name + extension;
                            }
                            else
                            {
                                mf.MetaFileName = name;
                            }
                        }
                        if (extension.CompareToCSafe("") != 0)
                        {
                            mf.MetaFileExtension = extension;
                        }
                        if (mimetype.CompareToCSafe("") != 0)
                        {
                            mf.MetaFileMimeType = mimetype;
                        }

                        mf.MetaFileTitle       = title;
                        mf.MetaFileDescription = description;

                        if (binary != null)
                        {
                            mf.MetaFileBinary = binary;
                            mf.MetaFileSize   = binary.Length;
                        }
                        if (width > 0)
                        {
                            mf.MetaFileImageWidth = width;
                        }
                        if (height > 0)
                        {
                            mf.MetaFileImageHeight = height;
                        }

                        // Save new data
                        MetaFileInfoProvider.SetMetaFileInfo(mf);

                        if (RefreshAfterAction)
                        {
                            if (String.IsNullOrEmpty(externalControlID))
                            {
                                baseImageEditor.LtlScript.Text = ScriptHelper.GetScript("Refresh();");
                            }
                            else
                            {
                                baseImageEditor.LtlScript.Text = ScriptHelper.GetScript(String.Format("InitRefresh({0}, false, false, '{1}', 'refresh')", ScriptHelper.GetString(externalControlID), mf.MetaFileGUID));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        baseImageEditor.ShowError(GetString("img.errors.processing"), tooltipText: ex.Message);
                        EventLogProvider.LogException("Image editor", "SAVEIMAGE", ex);
                        SavingFailed = true;
                    }
                }
                else
                {
                    baseImageEditor.ShowError(GetString("img.errors.rights"));
                    SavingFailed = true;
                }
            }
            break;
        }
    }
コード例 #24
0
    private void SubmitForm()
    {
        if (ctrlProduct.ProductID > 0)
        {
            // Check permissions
            if (ctrlProduct.ProductSiteID > 0)
            {
                if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyProducts"))
                {
                    RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts");
                }
            }
            else
            {
                if (!ECommerceContext.IsUserAuthorizedForPermission("EcommerceGlobalModify"))
                {
                    RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
                }
            }

            // Update
            if (chkMarkDocAsProd.Checked)
            {
                ctrlProduct.Save();
            }
            // Delete
            else
            {
                this.Node.NodeSKUID = 0;
                this.Node.Update();

                // Update search index for node
                if ((this.Node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
                {
                    SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, this.Node.GetSearchID());
                }

                // Log synchronization
                DocumentSynchronizationHelper.LogDocumentChange(this.Node, TaskTypeEnum.UpdateDocument, this.Node.TreeProvider);

                URLHelper.Redirect("Product_Selection.aspx?nodeid=" + this.NodeID);
            }
        }
        else
        {
            if (!IsAuthorizedToModifyDocument())
            {
                RedirectToAccessDenied("CMS.Content", "Modify");
            }

            // Use existing product
            if (radSelect.Checked)
            {
                if (skuElem.SKUID > 0)
                {
                    this.Node.NodeSKUID = this.skuElem.SKUID;
                    this.Node.Update();

                    // Update search index for node
                    if ((this.Node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
                    {
                        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, this.Node.GetSearchID());
                    }

                    // Log synchronization
                    DocumentSynchronizationHelper.LogDocumentChange(this.Node, TaskTypeEnum.UpdateDocument, this.Node.TreeProvider);

                    URLHelper.Redirect(String.Format("Product_Edit_Frameset.aspx?productid={0}&nodeid={1}&saved=1", this.Node.NodeSKUID, this.NodeID));
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Products.EmptyList");
                }
            }
            // Create new product
            else
            {
                ctrlProduct.Save();
            }
        }
    }
コード例 #25
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if ((nodeId > 0) && (node != null))
        {
            LayoutTypeEnum layoutType = LayoutInfoProvider.GetLayoutTypeEnum(drpType.SelectedValue);

            // Check the permissions
            if ((layoutType != LayoutTypeEnum.Ascx) || user.IsAuthorizedPerResource("CMS.Design", "EditCode"))
            {
                // Update the layout
                if (node.DocumentPageTemplateID > 0)
                {
                    PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(node.DocumentPageTemplateID);
                    if (pti != null)
                    {
                        // Get shared layout
                        LayoutInfo li = LayoutInfoProvider.GetLayoutInfo(pti.LayoutID);
                        if (li != null)
                        {
                            // Update shared layout
                            li.LayoutCode = txtLayout.Text;
                            li.LayoutType = layoutType;

                            LayoutInfoProvider.SetLayoutInfo(li);
                        }
                        else if (pti.PageTemplateLayoutCheckedOutByUserID <= 0)
                        {
                            // Update custom layout
                            pti.PageTemplateLayout     = txtLayout.Text;
                            pti.PageTemplateLayoutType = layoutType;

                            PageTemplateInfoProvider.SetPageTemplateInfo(pti);
                        }
                    }
                }
            }

            // Update fields
            node.NodeBodyElementAttributes = txtBodyCss.Text;
            node.NodeDocType  = txtDocType.Text;
            node.NodeHeadTags = txtHeadTags.Value.ToString();

            // Update the node
            node.Update();

            // Update search index
            if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
            }

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");

            // Clear cache
            PageInfoProvider.RemoveAllPageInfosFromCache();
        }
    }
コード例 #26
0
    public void RaisePostBackEvent(string eventArgument)
    {
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Current Node ID
        int nodeId = ValidationHelper.GetInteger(Param1, 0);

        TreeProvider     tree = new TreeProvider(currentUser);
        EventLogProvider log  = new EventLogProvider();

        string documentName = "";
        string action       = Action.ToLower();

        // Process the request
        switch (action)
        {
        case "moveup":
        case "movedown":
            // Move the document up (document order)
            try
            {
                if (nodeId == 0)
                {
                    AddAlert(GetString("ContentRequest.ErrorMissingSource"));
                    return;
                }

                // Get document to move
                TreeNode node = tree.SelectSingleNode(nodeId);

                // Check the permissions for document
                if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)
                {
                    switch (action)
                    {
                    case "moveup":
                        node = tree.MoveNodeUp(nodeId);
                        break;

                    case "movedown":
                        node = tree.MoveNodeDown(nodeId);
                        break;
                    }

                    string siteName = CMSContext.CurrentSiteName;
                    if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges"))
                    {
                        // Load all nodes under parent node
                        if (node != null)
                        {
                            string parentPath = TreePathUtils.GetParentPath(node.NodeAliasPath);

                            DataSet ds = tree.SelectNodes(siteName, parentPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, null, null, 1);

                            // Check if data source is not empty
                            if (!DataHelper.DataSourceIsEmpty(ds))
                            {
                                // Go through all nodes
                                foreach (DataRow dr in ds.Tables[0].Rows)
                                {
                                    // Update child nodes
                                    int    logNodeId = ValidationHelper.GetInteger(dr["NodeID"], 0);
                                    string culture   = ValidationHelper.GetString(dr["DocumentCulture"], "");
                                    string className = ValidationHelper.GetString(dr["ClassName"], "");

                                    TreeNode tn = tree.SelectSingleNode(logNodeId, culture, className);
                                    DocumentSynchronizationHelper.LogDocumentChange(tn, TaskTypeEnum.UpdateDocument, tree);
                                }
                            }
                        }
                    }

                    // Move the node
                    if (node != null)
                    {
                        documentName = node.DocumentName;

                        treeContent.ExpandNodeID = node.NodeParentID;
                        treeContent.NodeID       = node.NodeID;
                    }
                    else
                    {
                        AddAlert(GetString("ContentRequest.MoveFailed"));
                    }
                }
                else
                {
                    AddAlert(GetString("ContentRequest.MoveDenied"));
                }
            }
            catch (Exception ex)
            {
                log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri());
                AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message);
            }
            break;

        case "delete":
            // Delete the document
            try
            {
                if (nodeId == 0)
                {
                    AddAlert(GetString("DefineSiteStructure.ErrorMissingSource"));
                    return;
                }

                // Get the node
                TreeNode node = tree.SelectSingleNode(nodeId);

                // Delete the node
                if (node != null)
                {
                    treeContent.NodeID = node.NodeParentID;

                    node.Delete();

                    // Delete search index for given node
                    if (SearchIndexInfoProvider.SearchEnabled)
                    {
                        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Delete, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
                    }

                    if (node.NodeAliasPath == "/")
                    {
                        // Refresh root document
                        treeContent.NodeID = node.NodeID;
                        AddScript("SelectNode(" + node.NodeID + "); \n");
                    }
                    else
                    {
                        AddScript("SelectNode(" + node.NodeParentID + "); \n");
                    }
                }
            }
            catch (Exception ex)
            {
                AddAlert(GetString("DefineSiteStructure.DeleteFailed") + " : " + ex.Message);
            }
            break;
        }
    }
コード例 #27
0
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        // Get the document
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode);
        if (node != null)
        {
            // Check modify permissions
            if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                return;
            }

            bool correct = true;

            // OWNER group is displayed by UI profile
            if (!this.pnlUIOwner.IsHidden)
            {
                // Set owner
                int ownerId = ValidationHelper.GetInteger(usrOwner.Value, 0);
                if (ownerId > 0)
                {
                    node.SetValue("NodeOwner", usrOwner.Value);
                }
                else
                {
                    node.SetValue("NodeOwner", null);
                }
            }

            // Search
            node.DocumentSearchExcluded = chkExcludeFromSearch.Checked;

            // DESIGN group is displayed by UI profile
            if (!this.pnlUIDesign.IsHidden)
            {
                node.SetValue("DocumentStylesheetID", -1);
                if (!chkCssStyle.Checked)
                {
                    // Set stylesheet
                    int selectedCssId = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0);
                    if (selectedCssId < 1)
                    {
                        node.SetValue("DocumentStylesheetID", null);
                    }
                    else
                    {
                        node.SetValue("DocumentStylesheetID", selectedCssId);
                    }

                    ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = true;
                }
                else
                {
                    ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = false;
                }
            }

            // CACHE group is displayed by UI profile
            bool clearCache = false;
            if (!this.pnlUICache.IsHidden)
            {
                // Cache minutes
                int cacheMinutes = 0;
                if (radNo.Checked)
                {
                    cacheMinutes         = 0;
                    txtCacheMinutes.Text = "";
                }
                else if (radYes.Checked)
                {
                    cacheMinutes = ValidationHelper.GetInteger(txtCacheMinutes.Text, -5);
                    if (cacheMinutes <= 0)
                    {
                        correct = false;
                    }
                }
                else if (radInherit.Checked)
                {
                    cacheMinutes         = -1;
                    txtCacheMinutes.Text = "";
                }

                // Set cache minutes
                if (cacheMinutes != node.NodeCacheMinutes)
                {
                    node.NodeCacheMinutes = cacheMinutes;
                    clearCache            = true;
                }
            }

            if (correct)
            {
                node.DocumentLogVisitActivity = (chkPageVisitInherit.Checked ? (bool?)null : chkLogPageVisit.Checked);
                // Save the data
                node.Update();

                // Update search index for node
                if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
                {
                    SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
                }

                // Log synchronization
                DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

                // Clear cache if cache settings changed
                if (clearCache)
                {
                    node.ClearOutputCache(true, true);
                }

                lblInfo.Text    = GetString("General.ChangesSaved");
                lblInfo.Visible = true;
                ReloadData();
            }
            else
            {
                // Show error message
                lblError.Text    = GetString("GeneralProperties.BadCacheMinutes");
                lblError.Visible = true;
            }
        }
    }
コード例 #28
0
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        if (node != null)
        {
            // Check modify permissions
            if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                DisableFormEditing();

                lblInfo.Visible = true;
                lblInfo.Text    = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath);
                return;
            }

            if (hasDesign)
            {
                // Update the data
                int selectedPageTemplateId = ValidationHelper.GetInteger(Request.Params["SelectedTemplateId"], 0);

                // Save just created ad-hoc template
                if (cloneId > 0)
                {
                    selectedPageTemplateId = cloneId;
                }

                if (selectedPageTemplateId != 0)
                {
                    ltlScript.Text += ScriptHelper.GetScript("document.getElementById('SelectedTemplateId').value = " + selectedPageTemplateId);
                    if ((txtTemplate.Text.Length > 5) && (txtTemplate.Text.ToLower().Substring(0, 6) == "ad-hoc"))
                    {
                        // Ad-hoc page is used, set ad-hoc page as DocumentPageTemplateID
                        node.SetValue("DocumentPageTemplateID", selectedPageTemplateId);

                        PageTemplateInfo pt = PageTemplateInfoProvider.GetPageTemplateInfo(selectedPageTemplateId);
                        if (pt != null)
                        {
                            ltlScript.Text += ScriptHelper.GetScript("pressedClone(" + selectedPageTemplateId + ",null); ShowButtons(" + pt.IsPortal.ToString().ToLower() + ", " + pt.IsReusable.ToString().ToLower() + ", true)");
                        }
                    }
                    else
                    {
                        // Template was selected, set SelectedTemplateId as DocumentPageTemplateID
                        PageTemplateInfo pt = PageTemplateInfoProvider.GetPageTemplateInfo(selectedPageTemplateId);
                        if (pt != null)
                        {
                            node.SetValue("DocumentPageTemplateID", ValidationHelper.GetInteger(Request.Params["SelectedTemplateId"], 0));
                            ltlScript.Text += ScriptHelper.GetScript("SelectTemplate(" + selectedPageTemplateId + ", null, " + pt.IsPortal.ToString().ToLower() + ", " + pt.IsReusable.ToString().ToLower() + ")");
                        }
                    }
                }
                else
                {
                    // Template is inherited, set null as DocumentPageTemplateID
                    node.SetValue("DocumentPageTemplateID", null);
                    int inheritedTemplateID = ValidationHelper.GetInteger(Request.Params["InheritedTemplateId"], 0);
                    if (inheritedTemplateID > 0)
                    {
                        PageTemplateInfo pt = PageTemplateInfoProvider.GetPageTemplateInfo(inheritedTemplateID);
                        if (pt != null)
                        {
                            ltlScript.Text += ScriptHelper.GetScript("pressedInherit(" + inheritedTemplateID + "); ShowButtons(" + pt.IsPortal.ToString().ToLower() + ", " + pt.IsReusable.ToString().ToLower() + ", false)");
                        }
                    }
                    else
                    {
                        node.SetValue("DocumentPageTemplateID", null);
                        ltlScript.Text += ScriptHelper.GetScript("pressedInherit(0); ShowButtons(false, false, false); ");
                    }
                }
            }

            node.SetValue("NodeInheritPageLevels", inheritElem.Value);
            node.Update();

            // Ensure default combination if page template changed
            if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSMVTEnabled") &&
                LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.MVTesting) &&
                (ModuleCommands.OnlineMarketingContainsMVTest(node.NodeAliasPath, node.NodeSiteID, node.DocumentCulture, false)))
            {
                ModuleCommands.OnlineMarketingEnsureDefaultCombination(node.DocumentPageTemplateID);
            }

            // Update search index for node
            if (node.PublishedVersionExists && SearchIndexInfoProvider.SearchEnabled)
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
            }

            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");
        }

        // Log the synchronization
        DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);
    }
コード例 #29
0
    /// <summary>
    /// Saves metadata and file name of attachment.
    /// </summary>
    /// <param name="newFileName">New attachment file name</param>
    /// <returns>Returns True if attachment was succesfully saved.</returns>
    private bool SaveAttachment(string newFileName)
    {
        bool saved = false;

        // Save new data
        try
        {
            AttachmentInfo attachmentInfo = InfoObject as AttachmentInfo;

            if (attachmentInfo != null)
            {
                // Set new file name
                if (!string.IsNullOrEmpty(newFileName))
                {
                    string name = newFileName + attachmentInfo.AttachmentExtension;
                    if (IsAttachmentNameUnique(attachmentInfo, name))
                    {
                        attachmentInfo.AttachmentName = name;
                    }
                    else
                    {
                        // Attachment already exists.
                        LabelError = GetString("img.errors.fileexists");
                        return(false);
                    }
                }

                // Ensure automatic check-in/ check-out
                bool            useWorkflow = false;
                bool            autoCheck   = false;
                WorkflowManager workflowMan = new WorkflowManager(TreeProvider);

                if (Node != null)
                {
                    // Get workflow info
                    WorkflowInfo wi = workflowMan.GetNodeWorkflow(Node);

                    // Check if the document uses workflow
                    if (wi != null)
                    {
                        useWorkflow = true;
                        autoCheck   = !wi.UseCheckInCheckOut(SiteName);
                    }

                    // Check out the document
                    if (autoCheck)
                    {
                        VersionManager.CheckOut(Node, Node.IsPublished, true);
                        VersionHistoryID = Node.DocumentCheckedOutVersionHistoryID;
                    }

                    // Workflow has been lost, get published attachment
                    if (useWorkflow && (VersionHistoryID == 0))
                    {
                        attachmentInfo = AttachmentManager.GetAttachmentInfo(attachmentInfo.AttachmentGUID, SiteName);
                    }
                }

                if (attachmentInfo != null)
                {
                    // Set filename title and description
                    attachmentInfo.AttachmentTitle       = ObjectTitle;
                    attachmentInfo.AttachmentDescription = ObjectDescription;

                    // Document uses workflow and document is already saved (attachment is not temporary)
                    if ((VersionHistoryID > 0) && !nodeIsParent)
                    {
                        attachmentInfo.AllowPartialUpdate = true;
                        VersionManager.SaveAttachmentVersion(attachmentInfo, VersionHistoryID);
                    }
                    else
                    {
                        // Update without binary
                        attachmentInfo.AllowPartialUpdate = true;
                        AttachmentManager.SetAttachmentInfo(attachmentInfo);

                        // Log the sycnhronization and search task for the document
                        if (Node != null)
                        {
                            // Update search index for given document
                            if ((Node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
                            {
                                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, Node.GetSearchID());
                            }

                            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, TreeProvider);
                        }
                    }

                    // Check in the document
                    if (autoCheck)
                    {
                        if (VersionManager != null)
                        {
                            if (VersionHistoryID > 0 && (Node != null))
                            {
                                VersionManager.CheckIn(Node, null, null);
                            }
                        }
                    }

                    saved = true;

                    string fullRefresh = "false";

                    if (autoCheck || (Node == null))
                    {
                        fullRefresh = "true";
                    }

                    // Refresh parent update panel
                    LtlScript.Text = ScriptHelper.GetScript("RefreshMetaData(" + ScriptHelper.GetString(ExternalControlID) + ", '" + fullRefresh + "', '" + attachmentInfo.AttachmentGUID + "', 'refresh')");
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text = GetString("metadata.errors.processing");
            EventLogProvider.LogException("Metadata editor", "SAVEATTACHMENT", ex);
        }

        return(saved);
    }
コード例 #30
0
    /// <summary>
    /// On click OK save secured settings.
    /// </summary>
    protected void btnRadOk_Click(object sender, EventArgs e)
    {
        // Check permission
        CanModifyPermission(true);

        if (Node != null)
        {
            string message    = null;
            bool   clearCache = false;
            // Authentication
            if (!pnlUIAuth.IsHidden)
            {
                int isSecuredNode = Node.IsSecuredNode;

                if (radYes.Checked)
                {
                    isSecuredNode = 1;
                }
                else if (radNo.Checked)
                {
                    isSecuredNode = 0;
                }
                else if (radParent.Checked)
                {
                    isSecuredNode = -1;
                }

                // Set secured areas settings
                if (isSecuredNode != Node.IsSecuredNode)
                {
                    Node.IsSecuredNode = isSecuredNode;
                    clearCache         = true;
                    message           += ResHelper.GetAPIString("security.documentaccessauthchanged", "Document authentication settings have been modified.");
                }
            }

            // SSL
            if (!pnlUISsl.IsHidden)
            {
                int requiresSSL = Node.RequiresSSL;

                if (radYesSSL.Checked)
                {
                    requiresSSL = 1;
                }
                else if (radNoSSL.Checked)
                {
                    requiresSSL = 0;
                }
                else if (radParentSSL.Checked)
                {
                    requiresSSL = -1;
                }
                else if (radNeverSSL.Checked)
                {
                    requiresSSL = 2;
                }

                // Set SSL settings
                if (requiresSSL != Node.RequiresSSL)
                {
                    Node.RequiresSSL = requiresSSL;
                    clearCache       = true;
                    if (message != null)
                    {
                        message += "<br />";
                    }
                    message += ResHelper.GetAPIString("security.documentaccesssslchanged", "Document SSL settings have been modified.");
                }
            }

            Node.Update();

            // Insert information about this event to eventlog.
            if (Tree.LogEvents && (message != null))
            {
                EventLog.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, "Content", "DOCACCESSMODIFIED", Tree.UserInfo.UserID, Tree.UserInfo.UserName, Node.NodeID, DocumentName, ipAddress, message, Node.NodeSiteID, eventUrl);
            }

            // Update search index for node
            if ((Node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
            {
                SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, Node.GetSearchID());
            }

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Tree);

            // Clear cache if security settings changed
            if (clearCache)
            {
                CacheHelper.ClearPageInfoCache(Node.NodeSiteName);
                CacheHelper.ClearFileNodeCache(Node.NodeSiteName);
            }

            lblAccessInfo.Visible = !pnlUIAuth.IsHidden;
            lblAccesInfo2.Visible = !pnlUISsl.IsHidden;
            lblAccessInfo.Text    = GetString("general.changessaved");
            lblAccesInfo2.Text    = !lblAccessInfo.Visible ? lblAccessInfo.Text : "<br/>";
        }
    }