protected void btn_DesignMode_Click(object sender, CommandEventArgs e) { if (e.CommandArgument != null) { string _pageindexid = e.CommandArgument.ToString(); PageEditorMgr myPageEditorMgr = new PageEditorMgr(); if (myPageEditorMgr.Chk_Page_Lock(_pageindexid)) { // Page is Locked Pages.Page_Lock myPage_Lock = myPageEditorMgr.Get_Page_Lock(_pageindexid); if (myPage_Lock.UserID == Security.Users.UserStatus.Current_UserID(this.Page)) { // For same user will recover his previous work e2Data[] UpdateData = { new e2Data("Page_LockID", myPage_Lock.Page_LockID), new e2Data("LockDate", DateTime.Now.ToString()) }; myPageEditorMgr.Edit_Page_Lock(UpdateData); Response.Redirect(string.Format("PageDesign.aspx?PageIndexID={0}&PageLink=Disable", _pageindexid)); return; } // Page is released over 10min with no actions if (DateTime.Now.Subtract(myPage_Lock.LockDate).TotalMinutes > 10) { //Tools.AlertMessage.Show_Alert(this.Page, string.Format("<h4>The desgin mode is locked at {0} by other user.<br/> now is realease to you.</h4>", myPage_Lock.LockDate.ToString()), "Page is locked!"); // Delete Locks myPageEditorMgr.Release_PageLock(_pageindexid); Load_DesignMode(); return; } Tools.AlertMessage.Show_Alert(this.Page, "<h4>The desgin mode is locked <br/> please try again later.</h4>", "Page is locked!"); } else { Load_DesignMode(); } } }
private void DesignerMode(string _pageindexid) { PageEditorMgr myPageEditorMgr = new PageEditorMgr(); if (myPageEditorMgr.Chk_Page_Lock(_pageindexid)) { // Page is Locked Pages.Page_Lock myPage_Lock = myPageEditorMgr.Get_Page_Lock(_pageindexid); if (myPage_Lock.UserID == Security.Users.UserStatus.Current_UserID(this.Page)) { // It's same user, check if he open same page PageMgr MyPageMgr = new PageMgr(); NexusCore_Page myPage = MyPageMgr.Get_Page_ActiveID(_pageindexid); if (myPage_Lock.PageID == myPage.PageID) { // For same user will recover his previous work e2Data[] UpdateData = { new e2Data("Page_LockID", myPage_Lock.Page_LockID), new e2Data("LockDate", DateTime.Now.ToString()) }; myPageEditorMgr.Edit_Page_Lock(UpdateData); Response.Redirect(string.Format("/App_AdminCP/SiteAdmin/PageDesign.aspx?PageIndexID={0}&PageLink=Disable", _pageindexid)); return; } else { // For same user but create new session page // Delete Locks myPageEditorMgr.Release_PageLock(_pageindexid); Load_DesignMode(_pageindexid); return; } } // Page is released over 10min with no actions if (DateTime.Now.Subtract(myPage_Lock.LockDate).TotalMinutes > 10) { //Tools.AlertMessage.Show_Alert(this.Page, string.Format("<h4>The desgin mode is locked at {0} by other user.<br/> now is realease to you.</h4>", myPage_Lock.LockDate.ToString()), "Page is locked!"); // Delete Locks myPageEditorMgr.Release_PageLock(_pageindexid); Load_DesignMode(_pageindexid); return; } //Tools.AlertMessage.Show_Alert(this.Page, "<h4>The desgin mode is locked <br/> please try again later.</h4>", "Page is locked!"); LockPage_Failed("Page is locked by other user, please try again later."); } else { Load_DesignMode(_pageindexid); } }