示例#1
0
        public void LockSettingsUnLockTest()
        {
            string lockId = "LockID2";
            IUser  user   = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;

            MCS.Library.SOA.DataObjects.Lock _lock = GetInstanceOfLock(lockId, user);

            LockAdapter.SetLock(_lock);
            CheckLockResult result = LockAdapter.CheckLock(lockId, user.ID);

            Assert.IsNotNull(result.CurrentLock);

            LockAdapter.Unlock(lockId, user.ID);

            CheckLockResult checkResult = LockAdapter.CheckLock(lockId, user.ID);

            Assert.IsNull(checkResult.CurrentLock);

            IUser user2 = (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object;

            result.CurrentLock.PersonID = user2.ID;
            LockAdapter.SetLock(result.CurrentLock);

            CheckLockResult reResult = LockAdapter.CheckLock(lockId, user2.ID);

            Assert.IsNotNull(reResult.CurrentLock);

            LockAdapter.Unlock(lockId, user2.ID);
        }
示例#2
0
        /// <summary>
        /// 检查锁是否有效,只需一个无效,则抛异常
        /// </summary>
        public void CheckLocksAvailable()
        {
            foreach (Lock lockInfo in this._Locks)
            {
                CheckLockResult result = LockAdapter.CheckLock(lockInfo);

                ExceptionHelper.FalseThrow(
                    result.CurrentLockStatus == LockStatus.LockedByRight || result.CurrentLockStatus == LockStatus.LockedByRightAndExpire,
                    result.GetCheckLockStatusText());
            }
        }
示例#3
0
        /// <summary>
        /// 检查锁
        /// </summary>
        private static void CheckLock(string lockID, string personID)
        {
            if (!string.IsNullOrEmpty(lockID) && !string.IsNullOrEmpty(personID))
            {
                CheckLockResult result = LockAdapter.CheckLock(lockID, personID);

                //如果不是本人加锁 则不允许上传
                ExceptionHelper.FalseThrow(
                    (result.CurrentLockStatus == LockStatus.LockedByRight ||
                     result.CurrentLockStatus == LockStatus.LockedByRightAndExpire),
                    CheckLockOperation.GetCheckLockStatusText(result));
            }
        }
示例#4
0
        public void LockSettingsSaveTest()
        {
            string lockId = "LockID1";
            IUser  user   = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            MCS.Library.SOA.DataObjects.Lock _lock = GetInstanceOfLock(lockId, user);

            LockAdapter.SetLock(_lock);

            CheckLockResult result = LockAdapter.CheckLock(lockId, user.ID);

            Assert.AreEqual(user.ID, result.PersonID);
            Assert.AreEqual(lockId, result.CurrentLock.LockID);

            LockAdapter.Unlock(lockId, user.ID);
        }
示例#5
0
        public void LockSettingsFoceLockTest()
        {
            string lockId = "LockID3";
            IUser  user   = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;

            MCS.Library.SOA.DataObjects.Lock _lock = GetInstanceOfLock(lockId, user);
            _lock.LockType = LockType.AdminLock;
            LockAdapter.SetLock(_lock);

            CheckLockResult result = LockAdapter.CheckLock(_lock.LockID, user.ID);

            IUser user2 = (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object;

            result.CurrentLock.LockType = LockType.ActivityLock;
            result.CurrentLock.PersonID = user2.ID;
            LockAdapter.SetLock(result.CurrentLock, true);

            LockAdapter.Unlock(result.CurrentLock.LockID, user.ID);
        }