Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// 解锁
        /// </summary>
        public void UnlockAll()
        {
            Lock[] lockArray = new Lock[this._Locks.Count];

            //this._Locks.CopyTo(lockArray, 0);
            LockAdapter.Unlock(lockArray);

            this._Locks.Clear();
        }
Esempio n. 3
0
        protected override void OnInit(EventArgs e)
        {
            if (WebUtility.GetRequestQueryString("_op", string.Empty) == "lockCallBack")
            {
                if (string.Compare(Page.Request.HttpMethod, "POST", true) == 0)
                {
                    string cmd = WebUtility.GetRequestQueryString("cmd", string.Empty);

                    string requestData = string.Empty;
                    string result      = string.Empty;

                    try
                    {
                        using (StreamReader sr = new StreamReader(Page.Request.InputStream))
                        {
                            requestData = sr.ReadToEnd();

                            Lock[]      locks    = (Lock[])JSONSerializerExecute.DeserializeObject(requestData, typeof(Lock[]));
                            List <Lock> addLocks = new List <Lock>();

                            switch (cmd)
                            {
                            case "checkLock":
                                Array.ForEach(locks, l => addLocks.Add(LockAdapter.SetLock(l).NewLock));
                                break;

                            case "unlock":
                                LockAdapter.Unlock(locks);
                                break;

                            default:
                                throw new ApplicationException(string.Format("Invalid command {0}", cmd));
                            }

                            result = JSONSerializerExecute.Serialize(addLocks.ToArray());
                        }
                    }
                    catch (System.Exception ex)
                    {
                        var err = new { type = "$ErrorType", message = ex.Message };

                        result = JSONSerializerExecute.Serialize(err);
                    }
                    finally
                    {
                        Page.Response.Write(result);
                        Page.Response.End();
                    }
                }
            }
            else
            {
                base.OnInit(e);
            }
        }
Esempio n. 4
0
        protected override void OnSaveApplicationData(WfExecutorDataContext dataContext)
        {
            base.OnSaveApplicationData(dataContext);

            if (this.Locks != null)
            {
                foreach (Lock wfLock in this.Locks)
                {
                    LockAdapter.Unlock(wfLock);
                }
            }
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }