Beispiel #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);
        }
Beispiel #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;
            }
        }
Beispiel #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);
            }
        }