Esempio n. 1
0
        public static bool IsLocked(BusinessBase obj)
        {
            var locksQuery = from l in _lockedItems
                             where l.ObjectType == obj.GetType() &&
                             l.ObjectId == obj.Id
                             select l;

            return(locksQuery.Count() > 0);
        }
        public static bool IsLocked(BusinessBase obj)
        {
            var locksQuery = from l in _lockedItems
                             where l.ObjectType == obj.GetType()
                                   && l.ObjectId == obj.Id
                             select l;

            return (locksQuery.Count() > 0);
        }
Esempio n. 3
0
        public static void ReleaseLock(BusinessBase obj, string sessionId)
        {
            lock (_lockedItems)
            {
                var locksQuery = from l in _lockedItems
                                 where obj.GetType() == obj.GetType() &&
                                 obj.Id == l.ObjectId &&
                                 sessionId == l.SessionId
                                 select l;

                ReleaseLocks(_lockedItems);
            }
        }
        public static void ReleaseLock(BusinessBase obj, string sessionId)
        {
            lock (_lockedItems)
            {
                var locksQuery = from l in _lockedItems
                                 where obj.GetType() == obj.GetType()
                                       && obj.Id == l.ObjectId
                                       && sessionId == l.SessionId
                                 select l;

                ReleaseLocks(_lockedItems);
            }
        }
        public static bool Lock(BusinessBase obj, string sessionId)
        {
            if (IsLocked(obj))
                return false;

            lock (_lockedItems)
            {
                var lockItem = new LockItem
                {
                    ObjectType = obj.GetType(),
                    ObjectId = obj.Id,
                    LockedAt = DateTime.Now,
                    SessionId = sessionId
                };

                _lockedItems.Add(lockItem);
                return true;
            }
        }
Esempio n. 6
0
        public static bool Lock(BusinessBase obj, string sessionId)
        {
            if (IsLocked(obj))
            {
                return(false);
            }

            lock (_lockedItems)
            {
                var lockItem = new LockItem
                {
                    ObjectType = obj.GetType(),
                    ObjectId   = obj.Id,
                    LockedAt   = DateTime.Now,
                    SessionId  = sessionId
                };

                _lockedItems.Add(lockItem);
                return(true);
            }
        }