ScrewTurn.Wiki.Collisions.IsPageBeingEdited C# (CSharp) Method

IsPageBeingEdited() public static method

Finds whether a Page is being edited by a different user.
public static IsPageBeingEdited ( System.PageInfo page, string currentUser ) : bool
page System.PageInfo The Page.
currentUser string The User who is requesting the status of the Page.
return bool
        public static bool IsPageBeingEdited(PageInfo page, string currentUser)
        {
            return Cache.Provider.IsPageBeingEdited(page.FullName, currentUser);
        }

Usage Example

示例#1
0
        /// <summary>
        /// Verifies for editing collisions, and if no collision is found, "locks" the page
        /// </summary>
        private void ManageEditingCollisions()
        {
            if (currentPage == null)
            {
                return;
            }

            lblRefreshLink.Text = @"<a href=""" +
                                  UrlTools.BuildUrl(currentWiki, "Edit.aspx?Page=", Tools.UrlEncode(currentPage.FullName), (Request["Section"] != null ? "&amp;Section=" + currentSection.ToString() : "")) +
                                  @""">" + Properties.Messages.Refresh + " &raquo;</a>";

            string username = Request.UserHostAddress;

            if (SessionFacade.LoginKey != null)
            {
                username = SessionFacade.CurrentUsername;
            }

            if (Collisions.IsPageBeingEdited(currentPage, username))
            {
                pnlCollisions.Visible             = true;
                lblConcurrentEditingUsername.Text = "(" + Users.UserLink(currentWiki, Collisions.WhosEditing(currentPage)) + ")";
                if (Settings.GetDisableConcurrentEditing(currentWiki))
                {
                    lblSaveDisabled.Visible    = true;
                    lblSaveDangerous.Visible   = false;
                    btnSave.Enabled            = false;
                    btnSaveAndContinue.Enabled = false;
                }
                else
                {
                    lblSaveDisabled.Visible    = false;
                    lblSaveDangerous.Visible   = true;
                    btnSave.Enabled            = true;
                    btnSaveAndContinue.Enabled = true;
                }
            }
            else
            {
                pnlCollisions.Visible      = false;
                btnSave.Enabled            = true;
                btnSaveAndContinue.Enabled = true;
                Collisions.RenewEditingSession(currentPage, username);
            }
        }