示例#1
0
        public void RefreshLock(string token, int timeout, VersionRaising versionRaising)
        {
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Lock"))
            {
                if (this.Locked && this.LockToken == token)
                {
                    _node.LastLockUpdate = DateTime.Now;
                    _node.LockTimeout    = timeout;
                    _node.Save(versionRaising, VersionStatus.Locked);

                    //****Log
                    Logger.WriteVerbose("NodeLock is refreshed."      // message
                                        , new Dictionary <string, object>()
                    {
                        { "Id", Node.Id }, { "Path", Node.Path }
                    }                                                                                   // properties
                                        );
                }
                else
                {
                    if (Locked)
                    {
                        throw new LockedNodeException(this, "Node is locked but passed locktoken is invalid.");
                    }
                    else
                    {
                        throw new LockedNodeException(this, "Node is not locked or lock timed out");
                    }
                }
                traceOperation.IsSuccessful = true;
            }
        }
示例#2
0
 public void Unlock(string token, VersionStatus versionStatus, VersionRaising versionRaising)
 {
     using (var op = SnTrace.ContentOperation.StartOperation("Node.LockHandler.Unlock: NodeId:{0}, VersionId:{1}, Version:{2}, VersionRaising:{3}, Locktoken:{4}.", _node.Id, _node.VersionId, _node.Version, versionRaising, token))
     {
         if (Locked && this.LockToken == token)
         {
             _node.LockedById     = 0;
             _node.LockToken      = string.Empty;
             _node.LockTimeout    = 0;
             _node.LockDate       = new DateTime(1800, 1, 1);
             _node.LastLockUpdate = new DateTime(1800, 1, 1);
             _node.LockType       = 0;
             _node.Save(versionRaising, versionStatus);
         }
         else
         {
             if (Locked)
             {
                 throw new LockedNodeException(this, "Node is not locked or lock timed out");
             }
             else
             {
                 throw new LockedNodeException(this, "Node is not locked or lock timed out");
             }
         }
         op.Successful = true;
     }
 }
示例#3
0
 public void RefreshLock(string token, int timeout, VersionRaising versionRaising)
 {
     using (var op = SnTrace.ContentOperation.StartOperation("Node.LockHandler.RefreshLock: NodeId:{0}, VersionId:{1}, Version:{2}, VersionRaising:{3}, Locktoken:{4}, Timeout:{5}."
                                                             , _node.Id, _node.VersionId, _node.Version, versionRaising, token, timeout))
     {
         if (this.Locked && this.LockToken == token)
         {
             _node.LastLockUpdate = DateTime.UtcNow;
             _node.LockTimeout    = timeout;
             _node.Save(versionRaising, VersionStatus.Locked);
         }
         else
         {
             if (Locked)
             {
                 throw new LockedNodeException(this, "Node is locked but passed locktoken is invalid.");
             }
             else
             {
                 throw new LockedNodeException(this, "Node is not locked or lock timed out");
             }
         }
         op.Successful = true;
     }
 }
示例#4
0
 public void Unlock(VersionStatus versionStatus, VersionRaising versionRaising)
 {
     if (this.LockedBy.Id != AccessProvider.Current.GetCurrentUser().Id)
     {
         this.Node.Security.Assert("Node is locked by another user", PermissionType.ForceCheckin);
     }
     this.Unlock(this.LockToken, versionStatus, versionRaising);
 }
示例#5
0
 public void Unlock(VersionStatus versionStatus, VersionRaising versionRaising)
 {
     using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Unlock"))
     {
         if (this.LockedBy.Id != AccessProvider.Current.GetCurrentUser().Id)
         {
             this.Node.Security.Assert("Node is locked by another user", PermissionType.ForceCheckin);
         }
         this.Unlock(this.LockToken, versionStatus, versionRaising);
         traceOperation.IsSuccessful = true;
     }
 }
示例#6
0
        public void RefreshLock(int timeout, VersionRaising versionRaising)
        {
            IUser lockUser = this.LockedBy;

            if (lockUser.Id == AccessProvider.Current.GetCurrentUser().Id)
            {
                RefreshLock(this.LockToken, timeout, versionRaising);
            }
            else
            {
                throw new SenseNetSecurityException(this.Node.Id, "Node is locked by another user");
            }
        }
示例#7
0
 public void RefreshLock(int timeout, VersionRaising versionRaising)
 {
     using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Lock"))
     {
         IUser lockUser = this.LockedBy;
         if (lockUser.Id == AccessProvider.Current.GetCurrentUser().Id)
         {
             RefreshLock(this.LockToken, timeout, versionRaising);
         }
         else
         {
             throw new SenseNetSecurityException(this.Node.Id, "Node is locked by another user");
         }
         traceOperation.IsSuccessful = true;
     }
 }
示例#8
0
        public void Lock(int timeout, VersionRaising versionRaising)
        {
            using (var op = SnTrace.ContentOperation.StartOperation("Node.LockHandler.Lock: NodeId:{0}, VersionId:{1}, Version:{2}, VersionRaising:{3}, Timeout:{4}.", _node.Id, _node.VersionId, _node.Version, versionRaising, timeout))
            {
                if (!this.Locked)
                {
                    _node.LockToken      = Guid.NewGuid().ToString();
                    _node.LockedById     = AccessProvider.Current.GetCurrentUser().Id;
                    _node.LockDate       = DateTime.UtcNow;
                    _node.LastLockUpdate = DateTime.UtcNow;
                    _node.LockTimeout    = timeout;

                    _node.Save(versionRaising, VersionStatus.Locked);
                }
                else
                {
                    RefreshLock(versionRaising);
                }
                op.Successful = true;
            }
        }
示例#9
0
        public void Lock(int timeout, VersionRaising versionRaising)
        {
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Lock"))
            {
                if (!this.Locked)
                {
                    _node.LockToken      = Guid.NewGuid().ToString();
                    _node.LockedById     = AccessProvider.Current.GetCurrentUser().Id;
                    _node.LockDate       = DateTime.Now;
                    _node.LastLockUpdate = DateTime.Now;
                    _node.LockTimeout    = timeout;

                    _node.Save(versionRaising, VersionStatus.Locked);
                }
                else
                {
                    RefreshLock(versionRaising);
                }
                //****Log
                Logger.WriteVerbose("Node is locked.", Logger.GetDefaultProperties, this);
                traceOperation.IsSuccessful = true;
            }
        }
示例#10
0
        public void Unlock(string token, VersionStatus versionStatus, VersionRaising versionRaising)
        {
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Unlock"))
            {
                if (Locked && this.LockToken == token)
                {
                    _node.LockedById     = 0;
                    _node.LockToken      = string.Empty;
                    _node.LockTimeout    = 0;
                    _node.LockDate       = new DateTime(1800, 1, 1);
                    _node.LastLockUpdate = new DateTime(1800, 1, 1);
                    _node.LockType       = 0;
                    _node.Save(versionRaising, versionStatus);

                    //****Log
                    Logger.WriteVerbose("Node lock is released."     // message
                                        , new Dictionary <string, object>()
                    {
                        { "Id", Node.Id }, { "Path", Node.Path }
                    }                                                                                   // properties
                                        );
                }
                else
                {
                    if (Locked)
                    {
                        throw new LockedNodeException(this, "Node is not locked or lock timed out");
                    }
                    else
                    {
                        throw new LockedNodeException(this, "Node is not locked or lock timed out");
                    }
                }
                traceOperation.IsSuccessful = true;
            }
        }
示例#11
0
		public void Lock(VersionRaising versionRaising)
		{
			Lock(DefaultLockTimeOut, versionRaising);
		}
示例#12
0
		public void RefreshLock(int timeout, VersionRaising versionRaising)
		{
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Lock"))
            {
                IUser lockUser = this.LockedBy;
                if (lockUser.Id == AccessProvider.Current.GetCurrentUser().Id)
                    RefreshLock(this.LockToken, timeout, versionRaising);
                else
                    throw new SenseNetSecurityException(this.Node.Id, "Node is locked by another user");
                traceOperation.IsSuccessful = true;
            }
		}
示例#13
0
		public void RefreshLock(VersionRaising versionRaising)
		{
			RefreshLock(DefaultLockTimeOut, versionRaising);
		}
示例#14
0
 public void RefreshLock(VersionRaising versionRaising)
 {
     RefreshLock(DefaultLockTimeOut, versionRaising);
 }
示例#15
0
		public void RefreshLock(string token, int timeout, VersionRaising versionRaising)
		{
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Lock"))
            {
                if (this.Locked && this.LockToken == token)
                {
                    _node.LastLockUpdate = DateTime.Now;
                    _node.LockTimeout = timeout;
                    _node.Save(versionRaising, VersionStatus.Locked);

                    //****Log
                    Logger.WriteVerbose("NodeLock is refreshed."      // message
                        , new Dictionary<string, object>() { { "Id", Node.Id }, { "Path", Node.Path } } // properties
                        );
                }
                else
                {
                    if (Locked)
                        throw new LockedNodeException(this, "Node is locked but passed locktoken is invalid.");
                    else
                        throw new LockedNodeException(this, "Node is not locked or lock timed out");
                }
                traceOperation.IsSuccessful = true;
            }
		}
示例#16
0
		public void Unlock(VersionStatus versionStatus, VersionRaising versionRaising)
		{
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Unlock"))
            {
                if(this.LockedBy.Id != AccessProvider.Current.GetCurrentUser().Id)
                    this.Node.Security.Assert("Node is locked by another user", PermissionType.ForceCheckin);
                this.Unlock(this.LockToken, versionStatus, versionRaising);
                traceOperation.IsSuccessful = true;
            }
        }
示例#17
0
 public void Lock(VersionRaising versionRaising)
 {
     Lock(DefaultLockTimeOut, versionRaising);
 }
示例#18
0
		public void Unlock(string token, VersionStatus versionStatus, VersionRaising versionRaising)
		{
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Unlock"))
            {
                if (Locked && this.LockToken == token)
                {
                    _node.LockedById = 0;
                    _node.LockToken = string.Empty;
                    _node.LockTimeout = 0;
                    _node.LockDate = new DateTime(1800, 1, 1);
                    _node.LastLockUpdate = new DateTime(1800, 1, 1);
                    _node.LockType = 0;
                    _node.Save(versionRaising, versionStatus);

                    //****Log
                    Logger.WriteVerbose("Node lock is released."     // message
                        , new Dictionary<string, object>() { { "Id", Node.Id }, { "Path", Node.Path } } // properties
                        );

                }
                else
                {
                    if (Locked)
                        throw new LockedNodeException(this, "Node is not locked or lock timed out");
                    else
                        throw new LockedNodeException(this, "Node is not locked or lock timed out");
                }
                traceOperation.IsSuccessful = true;
            }
        }
示例#19
0
 public void RefreshLock(VersionRaising versionRaising)
 {
     RefreshLock(RepositoryEnvironment.DefaultLockTimeout, versionRaising);
 }
示例#20
0
		public void Lock(int timeout, VersionRaising versionRaising)
		{
            using (var traceOperation = Logger.TraceOperation("Node.LockHandler.Lock"))
            {
                if (!this.Locked)
                {
                    _node.LockToken = Guid.NewGuid().ToString();
                    _node.LockedById = AccessProvider.Current.GetCurrentUser().Id;
                    _node.LockDate = DateTime.Now;
                    _node.LastLockUpdate = DateTime.Now;
                    _node.LockTimeout = timeout;

                    _node.Save(versionRaising, VersionStatus.Locked);

                }
                else
                {
                    RefreshLock(versionRaising);
                }
                //****Log
                Logger.WriteVerbose("Node is locked.", Logger.GetDefaultProperties, this);
                traceOperation.IsSuccessful = true;
            }
		}