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