private void GetLocks() { foreach (var entity in CurrentTransaction.ToAdd) { entity.Value.TransactionId = CurrentTransaction.Id; FechadurasAdquiridas.Add(entity.Key, entity.Value); EstaLiberado = true; } foreach (var entity in CurrentTransaction.ToSave) { entity.Value.TransactionId = CurrentTransaction.Id; if (!this.IMDB.Lock(entity.Value, CurrentTransaction.Id)) { throw new ApplicationException(String.Format("Commit ({0}) - GetLocks", this.CurrentTransaction.Id)); } FechadurasAdquiridas.Add(entity.Key, entity.Value); EstaLiberado = true; } foreach (var entity in CurrentTransaction.ToRemove) { entity.Value.TransactionId = CurrentTransaction.Id; if (!this.IMDB.Lock(entity.Value, CurrentTransaction.Id)) { throw new ApplicationException(String.Format("Commit ({0}) - GetLocks", this.CurrentTransaction.Id)); } FechadurasAdquiridas.Add(entity.Key, entity.Value); EstaLiberado = true; } }
private void ReleaseLocks() { foreach (var entity in CurrentTransaction.ToAdd) { entity.Value.TransactionId = Guid.Empty; if (FechadurasAdquiridas.ContainsKey(entity.Key) && !EstaLiberado) { if (!this.IMDB.UnLock(entity.Value, CurrentTransaction.Id)) { throw new ApplicationException(String.Format("Commit ({0}) - Liberar bloqueios", this.CurrentTransaction.Id)); } } } foreach (var entity in CurrentTransaction.ToSave) { entity.Value.TransactionId = Guid.Empty; if (FechadurasAdquiridas.ContainsKey(entity.Key)) { if (!this.IMDB.UnLock(entity.Value, CurrentTransaction.Id)) { throw new ApplicationException(String.Format("Commit ({0}) - Liberar bloqueios", this.CurrentTransaction.Id)); } } } foreach (var entity in CurrentTransaction.ToRemove) { entity.Value.TransactionId = Guid.Empty; if (FechadurasAdquiridas.ContainsKey(entity.Key)) { if (!this.IMDB.UnLock(entity.Value, CurrentTransaction.Id)) { throw new ApplicationException(String.Format("Commit ({0}) - Liberar bloqueios", this.CurrentTransaction.Id)); } } } }