コード例 #1
0
    /// <summary>
    /// UniGrid action buttons event handler.
    /// </summary>
    protected void GridAttachmentsOnAction(string actionName, object actionArgument)
    {
        if (Enabled && !HideActions)
        {
            // Check the permissions


            #region "Check permissions"

            if (CheckPermissions)
            {
                if (FormGUID != Guid.Empty)
                {
                    if (!RaiseOnCheckPermissions("Create", this))
                    {
                        if (!CMSContext.CurrentUser.IsAuthorizedToCreateNewDocument(NodeParentNodeID, NodeClassName))
                        {
                            lblError.Text = GetString("attach.actiondenied");
                            return;
                        }
                    }
                }
                else
                {
                    if (!RaiseOnCheckPermissions("Modify", this))
                    {
                        if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
                        {
                            lblError.Text = GetString("attach.actiondenied");
                            return;
                        }
                    }
                }
            }

            #endregion


            Guid attachmentGuid = Guid.Empty;

            // Get action argument (Guid or int)
            if (ValidationHelper.IsGuid(actionArgument))
            {
                attachmentGuid = ValidationHelper.GetGuid(actionArgument, Guid.Empty);
            }

            // Process proper action
            switch (actionName.ToLowerCSafe())
            {
            case "delete":
                if (!createTempAttachment)
                {
                    if (attachmentGuid != Guid.Empty)
                    {
                        // Delete attachment
                        if (FormGUID == Guid.Empty)
                        {
                            // Ensure automatic check-in/ check-out
                            VersionManager vm = null;

                            // Check out the document
                            if (AutoCheck)
                            {
                                vm = VersionManager.GetInstance(TreeProvider);
                                vm.CheckOut(Node, Node.IsPublished, true);
                            }

                            // If the GUID column is set, use it to process additional actions for field attachments
                            if (GUIDColumnName != null)
                            {
                                DocumentHelper.DeleteAttachment(Node, GUIDColumnName, TreeProvider);
                            }
                            else
                            {
                                DocumentHelper.DeleteAttachment(Node, attachmentGuid, TreeProvider);
                            }
                            DocumentHelper.UpdateDocument(Node, TreeProvider);

                            // Ensure full page refresh
                            if (AutoCheck)
                            {
                                ScriptHelper.RegisterStartupScript(Page, typeof(Page), "deleteRefresh", ScriptHelper.GetScript("InitRefresh_" + ClientID + "('', true, true, '" + attachmentGuid + "', 'delete');"));
                            }
                            else
                            {
                                string script = "if (window.RefreshTree) { RefreshTree(" + Node.NodeParentID + ", " + Node.NodeID + "); }";
                                ScriptHelper.RegisterStartupScript(Page, typeof(Page), "refreshTree", ScriptHelper.GetScript(script));
                            }

                            // Check in the document
                            if (AutoCheck)
                            {
                                if (vm != null)
                                {
                                    vm.CheckIn(Node, null, null);
                                }
                            }

                            // Log synchronization task if not under workflow
                            if (!UsesWorkflow)
                            {
                                DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, TreeProvider);
                            }
                        }
                        else
                        {
                            AttachmentInfoProvider.DeleteTemporaryAttachment(attachmentGuid, CMSContext.CurrentSiteName);
                        }
                    }
                }

                LastAction = "delete";
                Value      = Guid.Empty;
                break;
            }

            // Force reload data
            ReloadData(true);
        }
    }
コード例 #2
0
    private void DeleteAttachmentAction(Guid attGuid)
    {
        if (!createTempAttachment)
        {
            if (attGuid != Guid.Empty)
            {
                // Delete attachment
                if (FormGUID == Guid.Empty)
                {
                    // Ensure automatic check-in/ check-out
                    VersionManager vm = null;

                    // Check out the document
                    if (AutoCheck)
                    {
                        vm = VersionManager.GetInstance(TreeProvider);
                        vm.CheckOut(Node, Node.IsPublished, true);
                    }

                    // If the GUID column is set, use it to process additional actions for field attachments
                    if (!String.IsNullOrEmpty(GUIDColumnName))
                    {
                        DocumentHelper.DeleteAttachment(Node, GUIDColumnName);
                    }
                    else
                    {
                        DocumentHelper.DeleteAttachment(Node, attGuid);
                    }
                    DocumentHelper.UpdateDocument(Node, TreeProvider);

                    // Ensure full page refresh
                    if (AutoCheck)
                    {
                        ScriptHelper.RegisterStartupScript(Page, typeof(Page), "deleteRefresh", ScriptHelper.GetScript("InitRefresh_" + ClientID + "('', true, true, '" + attGuid + "', 'delete');"));
                    }
                    else
                    {
                        string script = "if (window.RefreshTree) { RefreshTree(" + Node.NodeParentID + ", " + Node.NodeID + "); }";
                        ScriptHelper.RegisterStartupScript(Page, typeof(Page), "refreshTree", ScriptHelper.GetScript(script));
                    }

                    // Check in the document
                    if (AutoCheck)
                    {
                        vm?.CheckIn(Node, null);
                    }

                    // Log synchronization task if not under workflow
                    if (!UsesWorkflow)
                    {
                        DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, TreeProvider);
                    }
                }
                else
                {
                    AttachmentInfoProvider.DeleteTemporaryAttachment(attGuid, SiteContext.CurrentSiteName);
                }
            }
        }

        LastAction = "delete";
        Value      = null;
    }
コード例 #3
0
    /// <summary>
    /// UniGrid action buttons event handler.
    /// </summary>
    protected void gridAttachments_OnAction(string actionName, object actionArgument)
    {
        if (Enabled && !HideActions)
        {
            #region "Check permissions"

            if (CheckPermissions)
            {
                if (FormGUID != Guid.Empty)
                {
                    if (!RaiseOnCheckPermissions("Create", this))
                    {
                        if (!MembershipContext.AuthenticatedUser.IsAuthorizedToCreateNewDocument(NodeParentNodeID, NodeClassName))
                        {
                            ShowError(GetString("attach.actiondenied"));
                            return;
                        }
                    }
                }
                else
                {
                    if (!RaiseOnCheckPermissions("Modify", this))
                    {
                        if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
                        {
                            ShowError(GetString("attach.actiondenied"));
                            return;
                        }
                    }
                }
            }

            #endregion


            Guid attachmentGuid = Guid.Empty;

            // Get action argument (Guid or int)
            if (ValidationHelper.IsGuid(actionArgument))
            {
                attachmentGuid = ValidationHelper.GetGuid(actionArgument, Guid.Empty);
            }

            // Process proper action
            switch (actionName.ToLowerCSafe())
            {
            case "moveup":
                if (attachmentGuid != Guid.Empty)
                {
                    // Move attachment up
                    if (FormGUID == Guid.Empty)
                    {
                        PerformAttachmentAction("moveup", () => DocumentHelper.MoveAttachmentUp(attachmentGuid, Node));
                    }
                    else
                    {
                        AttachmentInfoProvider.MoveAttachmentUp(attachmentGuid, 0);
                    }
                }
                break;

            case "movedown":
                if (attachmentGuid != Guid.Empty)
                {
                    // Move attachment down
                    if (FormGUID == Guid.Empty)
                    {
                        PerformAttachmentAction("movedown", () => DocumentHelper.MoveAttachmentDown(attachmentGuid, Node));
                    }
                    else
                    {
                        AttachmentInfoProvider.MoveAttachmentDown(attachmentGuid, 0);
                    }
                }
                break;

            case "delete":
                if (attachmentGuid != Guid.Empty)
                {
                    // Delete attachment
                    if (FormGUID == Guid.Empty)
                    {
                        PerformAttachmentAction("delete", () => DocumentHelper.DeleteAttachment(Node, attachmentGuid, TreeProvider));
                    }
                    else
                    {
                        AttachmentInfoProvider.DeleteTemporaryAttachment(attachmentGuid, SiteContext.CurrentSiteName);
                    }

                    ShowConfirmation(GetString("attach.deleted"));
                }
                break;
            }
        }
    }
コード例 #4
0
    /// <summary>
    /// UniGrid action buttons event handler.
    /// </summary>
    protected void gridAttachments_OnAction(string actionName, object actionArgument)
    {
        if (Enabled && !HideActions)
        {
            #region "Check permissions"

            if (CheckPermissions)
            {
                if (FormGUID != Guid.Empty)
                {
                    if (!RaiseOnCheckPermissions("Create", this))
                    {
                        if (!CMSContext.CurrentUser.IsAuthorizedToCreateNewDocument(NodeParentNodeID, NodeClassName))
                        {
                            ShowError(GetString("attach.actiondenied"));
                            return;
                        }
                    }
                }
                else
                {
                    if (!RaiseOnCheckPermissions("Modify", this))
                    {
                        if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
                        {
                            ShowError(GetString("attach.actiondenied"));
                            return;
                        }
                    }
                }
            }

            #endregion


            Guid attachmentGuid = Guid.Empty;

            // Get action argument (Guid or int)
            if (ValidationHelper.IsGuid(actionArgument))
            {
                attachmentGuid = ValidationHelper.GetGuid(actionArgument, Guid.Empty);
            }

            // Process proper action
            switch (actionName.ToLowerCSafe())
            {
            case "moveup":
                if (attachmentGuid != Guid.Empty)
                {
                    // Move attachment up
                    if (FormGUID == Guid.Empty)
                    {
                        // Ensure automatic check-in/ check-out
                        VersionManager vm = null;

                        // Check out the document
                        if (AutoCheck)
                        {
                            vm = VersionManager.GetInstance(TreeProvider);
                            vm.CheckOut(Node, Node.IsPublished, true);
                        }

                        DocumentHelper.MoveAttachmentUp(attachmentGuid, Node);

                        // Check in the document
                        if (AutoCheck)
                        {
                            if (vm != null)
                            {
                                vm.CheckIn(Node, null, null);
                            }

                            // Ensure full page refresh
                            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "moveUpRefresh", ScriptHelper.GetScript(String.Format("InitRefresh_{0}('', true, false, 'moveup');", ClientID)));
                        }

                        // Log synchronization task if not under workflow
                        if (!UsesWorkflow)
                        {
                            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, TreeProvider);
                        }
                    }
                    else
                    {
                        AttachmentInfoProvider.MoveAttachmentUp(attachmentGuid, 0);
                    }
                }
                break;

            case "movedown":
                if (attachmentGuid != Guid.Empty)
                {
                    // Move attachment down
                    if (FormGUID == Guid.Empty)
                    {
                        // Ensure automatic check-in/ check-out
                        VersionManager vm = null;

                        // Check out the document
                        if (AutoCheck)
                        {
                            vm = VersionManager.GetInstance(TreeProvider);
                            vm.CheckOut(Node, Node.IsPublished, true);
                        }

                        DocumentHelper.MoveAttachmentDown(attachmentGuid, Node);

                        // Check in the document
                        if (AutoCheck)
                        {
                            if (vm != null)
                            {
                                vm.CheckIn(Node, null, null);
                            }

                            // Ensure full page refresh
                            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "moveDownRefresh", ScriptHelper.GetScript(String.Format("InitRefresh_{0}('', true, false, 'movedown');", ClientID)));
                        }

                        // Log synchronization task if not under workflow
                        if (!UsesWorkflow)
                        {
                            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, TreeProvider);
                        }
                    }
                    else
                    {
                        AttachmentInfoProvider.MoveAttachmentDown(attachmentGuid, 0);
                    }
                }
                break;

            case "delete":
                if (attachmentGuid != Guid.Empty)
                {
                    // Delete attachment
                    if (FormGUID == Guid.Empty)
                    {
                        // Ensure automatic check-in/ check-out
                        VersionManager vm = null;

                        // Check out the document
                        if (AutoCheck)
                        {
                            vm = VersionManager.GetInstance(TreeProvider);
                            vm.CheckOut(Node, Node.IsPublished, true);
                        }

                        DocumentHelper.DeleteAttachment(Node, attachmentGuid, TreeProvider);

                        // Check in the document
                        if (AutoCheck)
                        {
                            if (vm != null)
                            {
                                vm.CheckIn(Node, null, null);
                            }

                            // Ensure full page refresh
                            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "deleteRefresh", ScriptHelper.GetScript(String.Format("InitRefresh_{0}('', true, false, 'delete');", ClientID)));
                        }

                        // Log synchronization task if not under workflow
                        if (!UsesWorkflow)
                        {
                            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, TreeProvider);
                        }
                    }
                    else
                    {
                        AttachmentInfoProvider.DeleteTemporaryAttachment(attachmentGuid, CMSContext.CurrentSiteName);
                    }

                    ShowConfirmation(GetString("attach.deleted"));
                }
                break;
            }
        }
    }
    private void ProcessGridAttachmentAction(string actionName, Guid attachmentGuid)
    {
        // Process proper action
        switch (actionName.ToLowerInvariant())
        {
        case "moveup":
            if (attachmentGuid != Guid.Empty)
            {
                // Move attachment up
                if (FormGUID == Guid.Empty)
                {
                    PerformAttachmentAction("moveup", () => DocumentHelper.MoveAttachmentUp(attachmentGuid, Node));
                }
                else
                {
                    var ai = AttachmentInfoProvider.GetTemporaryAttachmentInfo(attachmentGuid);
                    if (ai != null)
                    {
                        ai.Generalized.MoveObjectUp();
                    }
                }
            }
            break;

        case "movedown":
            if (attachmentGuid != Guid.Empty)
            {
                // Move attachment down
                if (FormGUID == Guid.Empty)
                {
                    PerformAttachmentAction("movedown", () => DocumentHelper.MoveAttachmentDown(attachmentGuid, Node));
                }
                else
                {
                    var ai = AttachmentInfoProvider.GetTemporaryAttachmentInfo(attachmentGuid);
                    if (ai != null)
                    {
                        ai.Generalized.MoveObjectDown();
                    }
                }
            }
            break;

        case "delete":
            if (attachmentGuid != Guid.Empty)
            {
                // Delete attachment
                if (FormGUID == Guid.Empty)
                {
                    PerformAttachmentAction("delete", () => DocumentHelper.DeleteAttachment(Node, attachmentGuid));
                }
                else
                {
                    AttachmentInfoProvider.DeleteTemporaryAttachment(attachmentGuid, SiteContext.CurrentSiteName);
                }

                ShowConfirmation(GetString("attach.deleted"));
            }
            break;
        }
    }