void OnTransactionCompleted(object sender, TransactionEventArgs e) { lock (this.SyncRoot) { this.enlistments.Remove(e.Transaction.TransactionInformation.LocalIdentifier); } }
private void OnTransactionCompleted(object sender, System.Transactions.TransactionEventArgs args) { if (this.users.Count == 0 && this.autoClose) { this.CloseConnection(); } }
private void TransactionCompleted(object sender, System.Transactions.TransactionEventArgs e) { TransactionInformation ti = e.Transaction.TransactionInformation; if (ti.Status == TransactionStatus.Aborted || ti.Status == TransactionStatus.Committed) { string key = ti.LocalIdentifier; lock (_ActiveManagerLock) { //Don't interfere too much - just let go. This will help maintain flexibility for developers if (_ActiveManagers.ContainsKey(key)) { TransactionBoundConnectionManager tim = _ActiveManagers[key]; if (tim._CurrentConnection != null) { tim._CurrentConnection.Close(); } _ActiveManagers.Remove(key); } //if there are other managers around, start their auto kill foreach (TransactionBoundConnectionManager tim in _ActiveManagers.Values) { tim.StartAutoKill(); } } } }
/// <summary> /// This event handler is called whenever a transaction is about to be disposed, which allows /// us to remove the transaction from our list and dispose the connection instance we created. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void OnTransactionCompleted(object sender, TransactionEventArgs e) { Dictionary<string, DbConnection> connectionList; lock (transactionConnections) { if (!transactionConnections.TryGetValue(e.Transaction, out connectionList)) { // we don't know about this transaction. odd. return; } // we know about this transaction - remove it from the mappings transactionConnections.Remove(e.Transaction); } lock (connectionList) { // acquiring this lock should not be necessary unless there's a possibility for this event to be fired // while the transaction involved in the event is still set as the current transaction for a // different thread. foreach (DbConnection connection in connectionList.Values) { connection.Dispose(); } } }
private void CommitTransaction(object sender, TransactionEventArgs e) { var transactionInfo = e.Transaction.TransactionInformation; if (transactionInfo.Status != TransactionStatus.Committed) { OutstandingOperations.Clear(); return; } var transactionId = transactionInfo.LocalIdentifier; if (!OutstandingOperations.ContainsKey(transactionId)) return; var messages = OutstandingOperations[transactionId]; if (!messages.Any()) return; var result = connectionManager.GetConnection() .AppendToStream(EndpointAddress.GetIntermediateOutgoingQueue(), ExpectedVersion.Any, messages); OutstandingOperations.Clear(); }
void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e) { SysTx.Transaction transaction = e.Transaction; SqlClientEventSource.Log.PoolerTraceEvent("<prov.DbConnectionInternal.TransactionCompletedEvent|RES|CPOOL> {0}, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount); CleanupTransactionOnCompletion(transaction); CleanupConnectionOnTransactionCompletion(transaction); }
void OnCompleted(object sender, TransactionEventArgs e) { if (e.Transaction.TransactionInformation.Status != TransactionStatus.Committed) { return; } RecordSuccess(); }
private void TransactionCompleted(object sender, TransactionEventArgs e) { var session = _sessionContextStrategy.Retrieve(); if (session != null && session.IsOpen) { session.Close(); } _sessionContextStrategy.Clear(); }
void HandleTransactionCompleted(object sender, TransactionEventArgs e) { if (e.Transaction.TransactionInformation.Status != TransactionStatus.Committed) return; foreach (var counters in outboundCounters) counters.Value.CommittTo(providerToCommitTo.GetOutboundCounters(counters.Key)); foreach (var counters in inboundCounters) counters.Value.CommittTo(providerToCommitTo.GetInboundCounters(counters.Key)); }
private void HandleTransactionCompleted(object sender, TransactionEventArgs e) { if (e.Transaction.TransactionInformation.Status == TransactionStatus.Committed) { foreach (KeyValuePair<string, TransactionalOutboundPerformanceCounters> pair in _outboundCounters) pair.Value.CommittTo(_providerToCommitTo.GetOutboundCounters(pair.Key)); foreach (KeyValuePair<string, TransactionalInboundPerformanceCounters> pair2 in _inboundCounters) pair2.Value.CommittTo(_providerToCommitTo.GetInboundCounters(pair2.Key)); } }
void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e) { SysTx.Transaction transaction = e.Transaction; Bid.Trace("<prov.DbConnectionInternal.TransactionCompletedEvent|RES|CPOOL> %d#, Transaction Completed. (pooledCount=%d)\n", ObjectID, _pooledCount); CleanupTransactionOnCompletion(transaction); CleanupConnectionOnTransactionCompletion(transaction); }
private void TransactedUnlockCompleted(object sender, TransactionEventArgs e) { lock (this.synchLock) { if ((e.Transaction.TransactionInformation.Status != TransactionStatus.Committed) && this.IsSafeToUnlock) { this.store.GenerateUnlockCommand(this); } } }
internal override void AddOutcomeRegistrant(InternalTransaction tx, TransactionCompletedEventHandler transactionCompletedDelegate) { if (transactionCompletedDelegate != null) { TransactionEventArgs e = new TransactionEventArgs { transaction = tx.outcomeSource.InternalClone() }; transactionCompletedDelegate(e.transaction, e); } }
// Logs the transaction if rollbacked, given different details depending on logger level private static void LogTransactionIfAborted(TransactionEventArgs args) { if (args.Transaction.TransactionInformation.Status.Equals(TransactionStatus.Aborted)) { //Log any rollbacked transaction Logger.Error(TransactionRollbackedMessage); if (Logger.IsInfoEnabled) { Logger.Info( TransactionRollbackedDetailedMessage, args.Transaction.TransactionInformation.LocalIdentifier, args.Transaction.IsolationLevel, args.Transaction.TransactionInformation.CreationTime); } } }
internal static void FireDistributedTransactionStarted(Transaction transaction) { TransactionStartedEventHandler?localStartedEventHandler = null; lock (ClassSyncObject) { localStartedEventHandler = s_distributedTransactionStartedDelegate; } if (null != localStartedEventHandler) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = transaction.InternalClone(); localStartedEventHandler(args._transaction, args); } }
internal static void FireDistributedTransactionStarted(Transaction transaction) { TransactionStartedEventHandler distributedTransactionStartedDelegate = null; lock (ClassSyncObject) { distributedTransactionStartedDelegate = TransactionManager.distributedTransactionStartedDelegate; } if (distributedTransactionStartedDelegate != null) { TransactionEventArgs e = new TransactionEventArgs { transaction = transaction.InternalClone() }; distributedTransactionStartedDelegate(e.transaction, e); } }
private static void OnTransactionCompleted(object sender, TransactionEventArgs e) { Dictionary<string, DbConnection> dictionary; transactionConnections.TryGetValue(e.Transaction, out dictionary); if (dictionary != null) { lock (transactionConnections) { transactionConnections.Remove(e.Transaction); } foreach (DbConnection connection in dictionary.Values) { connection.Dispose(); } } }
/// <summary> /// This event handler is called whenever a transaction is about to be disposed, which allows /// us to remove the transaction from our list and dispose the connection instance we created. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnTransactionCompleted(object sender, TransactionEventArgs e) { Dictionary<string, DbConnection> connectionList; // = connections[e.Transaction]; transactionConnections.TryGetValue(e.Transaction, out connectionList); if (connectionList == null) return; lock (transactionConnections) transactionConnections.Remove(e.Transaction); foreach (DbConnection conneciton in connectionList.Values) { conneciton.Dispose(); } }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock ( PromotedTransactionTable ) { foreach (DictionaryEntry entry in PromotedTransactionTable) { WeakReference weakRef = (WeakReference)entry.Value; Transaction tx = (Transaction)weakRef.Target; if (tx != null) { TransactionEventArgs args = new TransactionEventArgs(); args.transaction = tx.InternalClone(); eventHandler(args.transaction, args); } } } }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock (PromotedTransactionTable) { foreach (DictionaryEntry entry in PromotedTransactionTable) { WeakReference reference = (WeakReference)entry.Value; Transaction target = (Transaction)reference.Target; if (target != null) { TransactionEventArgs e = new TransactionEventArgs { transaction = target.InternalClone() }; eventHandler(e.transaction, e); } } } }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock (PromotedTransactionTable) { // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations. IDictionaryEnumerator e = PromotedTransactionTable.GetEnumerator(); while (e.MoveNext()) { WeakReference weakRef = (WeakReference)e.Value !; if (weakRef.Target is Transaction tx) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = tx.InternalClone(); eventHandler(args._transaction, args); } } } }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock (PromotedTransactionTable) { // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations. IDictionaryEnumerator e = PromotedTransactionTable.GetEnumerator(); while (e.MoveNext()) { WeakReference weakRef = (WeakReference)e.Value; Transaction tx = (Transaction)weakRef.Target; if (tx != null) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = tx.InternalClone(); eventHandler(args._transaction, args); } } } }
void TransactionCompleted(object sender, TransactionEventArgs e) { lock (this.synchLock) { if (e.Transaction.TransactionInformation.Status == TransactionStatus.Committed) { if (this.IsHandleFreed) { this.store.GenerateUnlockCommand(this); } else { this.IsSafeToUnlock = true; } } else { this.BoundToLock = false; } } }
static void OnTransactionCompleted(object sender, TransactionEventArgs e) { Dictionary<string, DatabaseConnectionWrapper> connectionList; lock (transactionConnections) { if (!transactionConnections.TryGetValue(e.Transaction, out connectionList)) { return; } transactionConnections.Remove(e.Transaction); } lock (connectionList) { foreach (var connectionWrapper in connectionList.Values) { connectionWrapper.Dispose(); } } }
private void Current_TransactionCompleted(object sender, TransactionEventArgs e) { e.Transaction.TransactionCompleted -= this.transactionCompletedHandler; if (e.Transaction.TransactionInformation.Status == System.Transactions.TransactionStatus.Aborted) { List<long> list = null; lock (this.internalStateLock) { if (this.dtcTransMap.TryGetValue(e.Transaction.TransactionInformation.DistributedIdentifier, out list)) { this.dtcTransMap.Remove(e.Transaction.TransactionInformation.DistributedIdentifier); } } if (list != null) { foreach (long num in list) { this.TryRelockMessage(num); } } } else if (e.Transaction.TransactionInformation.Status == System.Transactions.TransactionStatus.Committed) { List<long> list2 = null; lock (this.internalStateLock) { if (this.dtcTransMap.TryGetValue(e.Transaction.TransactionInformation.DistributedIdentifier, out list2)) { this.dtcTransMap.Remove(e.Transaction.TransactionInformation.DistributedIdentifier); } if (list2 != null) { foreach (long num2 in list2) { this.lockMap.Remove(num2); } } } } }
void ExecuteActionsAgainstRabbitMq(object sender, TransactionEventArgs transactionEventArgs) { transactionEventArgs.Transaction.TransactionCompleted -= ExecuteActionsAgainstRabbitMq; var transactionInfo = transactionEventArgs.Transaction.TransactionInformation; var transactionId = transactionInfo.LocalIdentifier; if (transactionInfo.Status != TransactionStatus.Committed) { return; } IList<Action<IModel>> actions; OutstandingOperations.TryRemove(transactionId, out actions); if (!actions.Any()) { return; } ExecuteRabbitMqActions(actions); }
private static void OnTransactionCompleted(Object sender, TransactionEventArgs e) { Dictionary<SystemTransaction, Dictionary<String, DatabaseConnectionWrapper>> obj; Monitor.Enter(obj = TransactionConnections); Dictionary<String, DatabaseConnectionWrapper> connectionList; try { if (!TransactionConnections.TryGetValue(e.Transaction, out connectionList)) { return; } TransactionConnections.Remove(e.Transaction); } finally { Monitor.Exit(obj); } Dictionary<String, DatabaseConnectionWrapper> obj2; Monitor.Enter(obj2 = connectionList); try { foreach (DatabaseConnectionWrapper connectionWrapper in connectionList.Values) { connectionWrapper.Dispose(); } } finally { Monitor.Exit(obj2); } }
void ExecuteActionsAgainstRabbitMq(object sender, TransactionEventArgs transactionEventArgs) { var transactionInfo = transactionEventArgs.Transaction.TransactionInformation; if (transactionInfo.Status != TransactionStatus.Committed) { OutstandingOperations.Clear(); return; } var transactionId = transactionInfo.LocalIdentifier; if (!OutstandingOperations.ContainsKey(transactionId)) return; var actions = OutstandingOperations[transactionId]; if (!actions.Any()) return; ExecuteRabbitMqActions(actions); OutstandingOperations.Clear(); }
// <summary> // Event handler invoked when the transaction has completed (either by committing or rolling back). // </summary> // <param name="sender"> The source of the event. </param> // <param name="e"> // The <see cref="TransactionEventArgs" /> that contains the event data. // </param> // <remarks> // Note that to avoid threading issues we never reset the <see cref=" _enlistedTransaction" /> field here. // </remarks> private void EnlistedTransactionCompleted(object sender, TransactionEventArgs e) { e.Transaction.TransactionCompleted -= EnlistedTransactionCompleted; }
private void CurrentOnTransactionCompleted(object sender, TransactionEventArgs transactionEventArgs) { transactionEventArgs.Transaction.TransactionCompleted -= CurrentOnTransactionCompleted; _transactionIdentifiers.Remove(transactionEventArgs.Transaction.TransactionInformation.LocalIdentifier); }
private void OnDtcTransactionCompleted(object sender, TransactionEventArgs args) { TransactionStatus aborted; try { aborted = args.Transaction.TransactionInformation.Status; } catch (ObjectDisposedException) { aborted = TransactionStatus.Aborted; } Stats.DtcTransactionCompleted(ConnectionId, aborted); }
void OnEnlistedTransactionTransactionCompleted( object sender, TransactionEventArgs e ) { try { this.OnTransactionCompleted(); } finally { if( this.enlistedTransaction != null ) { lock( syncRoot ) { if( this.enlistedTransaction != null ) { //WARN: potenziale race condition da gestire con un lock this.enlistedTransaction.TransactionCompleted -= new TransactionCompletedEventHandler( OnEnlistedTransactionTransactionCompleted ); this.enlistedTransaction = null; } } } } }
void OnTransactionComplete(object sender, TransactionEventArgs e) { if (e.Transaction.TransactionInformation.Status == TransactionStatus.Aborted) { try { IAsyncResult result = this.receiveContext.BeginAbandon( TimeSpan.MaxValue, abandonCallback, new CallbackState { ChannelHandler = this.channelHandler, ReceiveContext = this.receiveContext }); if (result.CompletedSynchronously) { this.receiveContext.EndAbandon(result); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.channelHandler.HandleError(exception); } } }
internal override void AddOutcomeRegistrant(InternalTransaction tx, TransactionCompletedEventHandler transactionCompletedDelegate) { if (transactionCompletedDelegate != null) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = tx._outcomeSource.InternalClone(); transactionCompletedDelegate(args._transaction, args); } }
private static void Current_TransactionCompleted(TransactionEventArgs e) { try { List<CacheNotifyData> dataList = new List<CacheNotifyData>(); foreach (KeyValuePair<string, string> kp in TaskChangedUserIDs) { CacheNotifyData notifyData = new CacheNotifyData(typeof(UserTaskChangingCache), kp.Key, CacheNotifyType.Update); notifyData.CacheData = Guid.NewGuid().ToString(); dataList.Add(notifyData); } CacheNotifyData[] notifyArray = dataList.ToArray(); UdpCacheNotifier.Instance.SendNotifyAsync(notifyArray); MmfCacheNotifier.Instance.SendNotify(notifyArray); } finally { TaskChangedUserIDs.Clear(); TransactionEventAttached = false; } }
void OnTransactionCompleted(object sender, TransactionEventArgs e) { e.Transaction.TransactionCompleted -= this.transactionCompletedHandler; lock (this.internalStateLock) { if (e.Transaction.TransactionInformation.Status == TransactionStatus.Committed) { List<MsmqReceiveContext> toRemove; if (this.transMessages.TryGetValue(e.Transaction.TransactionInformation.DistributedIdentifier, out toRemove)) { foreach (MsmqReceiveContext entry in toRemove) { this.messageExpiryMap.Remove(entry.LookupId); } } } // on abort the messages stay locked, we just remove the transaction info from our collection this.transMessages.Remove(e.Transaction.TransactionInformation.DistributedIdentifier); } }
private void OnTransactionCompleted(object sender, TransactionEventArgs e) { e.Transaction.TransactionCompleted -= this.transactionCompletedHandler; lock (this.internalStateLock) { List<MsmqReceiveContext> list; if ((e.Transaction.TransactionInformation.Status == TransactionStatus.Committed) && this.transMessages.TryGetValue(e.Transaction.TransactionInformation.DistributedIdentifier, out list)) { foreach (MsmqReceiveContext context in list) { this.messageExpiryMap.Remove(context.LookupId); } } this.transMessages.Remove(e.Transaction.TransactionInformation.DistributedIdentifier); } }
public virtual void OnTransactionCompleted(object sender, TransactionEventArgs e) { Trace.WriteIf(Tracing.Is.TraceVerbose, "sender=\"{0}\" e.Transaction.TransactionInformation.DistributedIdentifier={1}".FormatWith(sender, null == e ? Guid.Empty : e.Transaction.TransactionInformation.DistributedIdentifier)); }
private void TransactionCompletedEvent(object sender, TransactionEventArgs e) { Transaction transaction = e.Transaction; Bid.Trace("<prov.DbConnectionInternal.TransactionCompletedEvent|RES|CPOOL> %d#, Transaction Completed. (pooledCount=%d)\n", this.ObjectID, this._pooledCount); this.CleanupTransactionOnCompletion(transaction); this.CleanupConnectionOnTransactionCompletion(transaction); }