示例#1
0
        /// <summary>
        /// Enlists if necessary.
        /// </summary>
        /// <param name="weAreSessionOwner">if set to <c>true</c> [we are session owner].</param>
        /// <param name="transaction">The transaction.</param>
        /// <param name="session">The session.</param>
        /// <returns></returns>
        protected bool EnlistIfNecessary(bool weAreSessionOwner,
                                         ITransaction transaction,
                                         SessionDelegate session)
        {
            if (transaction == null)
            {
                Logger.Info("Tx not found. Nothing to do here.");

                return(false);
            }

            Logger.InfoFormat("Enlistment status. Session: {0}. Tx IsActive: {1}. Are we Session Owner: {2}",
                              session.GetSessionImplementation().SessionId, session.Transaction.IsActive, weAreSessionOwner);

            if (weAreSessionOwner && session.Transaction.IsActive)
            {
                Logger.Info("Enlisted Session " + session.GetSessionImplementation().SessionId);

                var ue = new UnregisterEnlistment(Logger, session.UnregisterFromStore, transaction);

                transaction.Inner.EnlistVolatile(ue, EnlistmentOptions.EnlistDuringPrepareRequired);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Enlists if necessary.
        /// </summary>
        /// <param name="weAreSessionOwner">if set to <c>true</c> [we are session owner].</param>
        /// <param name="transaction">The transaction.</param>
        /// <param name="session">The session.</param>
        /// <returns></returns>
        protected bool EnlistIfNecessary(bool weAreSessionOwner,
                                         ITransaction transaction,
                                         StatelessSessionDelegate session)
        {
            if (transaction == null)
            {
                return(false);
            }

            if (weAreSessionOwner && session.Transaction.IsActive)
            {
                var ue = new UnregisterEnlistment(Logger, session.UnregisterFromStore, transaction);

                transaction.Inner.EnlistVolatile(ue, EnlistmentOptions.EnlistDuringPrepareRequired);
            }


            return(true);
        }
		/// <summary>
		/// Enlists if necessary.
		/// </summary>
		/// <param name="weAreSessionOwner">if set to <c>true</c> [we are session owner].</param>
		/// <param name="transaction">The transaction.</param>
		/// <param name="session">The session.</param>
		/// <returns></returns>
		protected bool EnlistIfNecessary(bool weAreSessionOwner,
										 ITransaction transaction,
										 StatelessSessionDelegate session)
		{
			if (transaction == null) return false;

			if (weAreSessionOwner && session.Transaction.IsActive)
			{
				var ue = new UnregisterEnlistment(Logger, session.UnregisterFromStore, transaction);

				transaction.Inner.EnlistVolatile(ue, EnlistmentOptions.EnlistDuringPrepareRequired);
			}
				

			return true;
		}
		/// <summary>
		/// Enlists if necessary.
		/// </summary>
		/// <param name="weAreSessionOwner">if set to <c>true</c> [we are session owner].</param>
		/// <param name="transaction">The transaction.</param>
		/// <param name="session">The session.</param>
		/// <returns></returns>
		protected bool EnlistIfNecessary(bool weAreSessionOwner,
										 ITransaction transaction,
										 SessionDelegate session)
		{
			if (transaction == null)
			{
				Logger.Info("Tx not found. Nothing to do here.");

				return false;
			}

			Logger.InfoFormat("Enlistment status. Session: {0}. Tx IsActive: {1}. Are we Session Owner: {2}", 
				session.GetSessionImplementation().SessionId, session.Transaction.IsActive, weAreSessionOwner);

			if (weAreSessionOwner && session.Transaction.IsActive)
			{
				Logger.Info("Enlisted Session " + session.GetSessionImplementation().SessionId);

				var ue = new UnregisterEnlistment(Logger, session.UnregisterFromStore, transaction);

				transaction.Inner.EnlistVolatile(ue, EnlistmentOptions.EnlistDuringPrepareRequired);
			}

			return true;
		}