コード例 #1
0
 private static INpgsqlResourceManager CreateResourceManager()
 {
     // TODO: create network proxy for resource manager
     if (_resourceManager == null)
     {
         AppDomain rmDomain = AppDomain.CreateDomain("NpgsqlResourceManager", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
         _resourceManager =
             (INpgsqlResourceManager)
             rmDomain.CreateInstanceAndUnwrap(typeof(NpgsqlResourceManager).Assembly.FullName,
                                              typeof(NpgsqlResourceManager).FullName);
     }
     return(_resourceManager);
     //return new NpgsqlResourceManager();
 }
コード例 #2
0
 private static INpgsqlResourceManager CreateResourceManager()
 {
     // TODO: create network proxy for resource manager
     if (_resourceManager == null)
     {
         _sponser = new System.Runtime.Remoting.Lifetime.ClientSponsor();
         AppDomain rmDomain = AppDomain.CreateDomain("NpgsqlResourceManager", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
         _resourceManager =
             (INpgsqlResourceManager)
             rmDomain.CreateInstanceAndUnwrap(typeof(NpgsqlResourceManager).Assembly.FullName,
                                              typeof(NpgsqlResourceManager).FullName);
         _sponser.Register((MarshalByRefObject)_resourceManager);
     }
     return(_resourceManager);
 }
コード例 #3
0
        private static INpgsqlResourceManager CreateResourceManager()
        {
            // TODO: create network proxy for resource manager
            if (_resourceManager == null)
            {
#if NETSTANDARD2_0
                throw new NotSupportedException("Not supported on .NET core");
#else
                _sponser = new System.Runtime.Remoting.Lifetime.ClientSponsor();
                AppDomain rmDomain = AppDomain.CreateDomain("NpgsqlResourceManager", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
                _resourceManager =
                    (INpgsqlResourceManager)
                    rmDomain.CreateInstanceAndUnwrap(typeof(NpgsqlResourceManager).Assembly.FullName,
                                                     typeof(NpgsqlResourceManager).FullName);
                _sponser.Register((MarshalByRefObject)_resourceManager);
#endif
            }
            return(_resourceManager);
        }
コード例 #4
0
 public byte[] Promote()
 {
     _rm = CreateResourceManager();
     // may not be null if Prepare or Enlist is called first
     if (_callbacks == null)
     {
         _callbacks = new NpgsqlTransactionCallbacks(_connection);
     }
     byte[] token = _rm.Promote(_callbacks);
     // mostly likely case for this is the transaction has been prepared.
     if (_npgsqlTx != null)
     {
         // cancel the NpgsqlTransaction since this will
         // be handled by a two phase commit.
         _npgsqlTx.Cancel();
         _npgsqlTx.Dispose();
         _npgsqlTx = null;
     }
     return(token);
 }
コード例 #5
0
 public void Enlist(Transaction tx)
 {
     if (tx != null)
     {
         _isolationLevel = tx.IsolationLevel;
         if (!tx.EnlistPromotableSinglePhase(this))
         {
             // must already have a durable resource
             // start transaction
             _npgsqlTx      = _connection.BeginTransaction(ConvertIsolationLevel(_isolationLevel));
             _inTransaction = true;
             _rm            = CreateResourceManager();
             _callbacks     = new NpgsqlTransactionCallbacks(_connection);
             _rm.Enlist(_callbacks, TransactionInterop.GetTransmitterPropagationToken(tx));
             // enlisted in distributed transaction
             // disconnect and cleanup local transaction
             _npgsqlTx.Cancel();
             _npgsqlTx.Dispose();
             _npgsqlTx = null;
         }
     }
 }
 public byte[] Promote()
 {
     NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Promote");
     _rm = CreateResourceManager();
     // may not be null if Prepare or Enlist is called first
     if (_callbacks == null)
     {
         _callbacks = new NpgsqlTransactionCallbacks(_connection);
     }
     byte[] token = _rm.Promote(_callbacks);
     // mostly likely case for this is the transaction has been prepared.
     if (_npgsqlTx != null)
     {
         // cancel the NpgsqlTransaction since this will
         // be handled by a two phase commit.
         _npgsqlTx.Cancel();
         _npgsqlTx.Dispose();
         _npgsqlTx = null;
         _connection.PromotableLocalTransactionEnded();
     }
     return(token);
 }
コード例 #7
0
		public void Enlist(Transaction tx)
		{
			if (tx != null)
			{
				_isolationLevel = tx.IsolationLevel;
				if (!tx.EnlistPromotableSinglePhase(this))
				{
					// must already have a durable resource
					// start transaction
					_npgsqlTx = _connection.BeginTransaction(ConvertIsolationLevel(_isolationLevel));
					_inTransaction = true;
					_rm = CreateResourceManager();
					_callbacks = new NpgsqlTransactionCallbacks(_connection);
					_rm.Enlist(_callbacks, TransactionInterop.GetTransmitterPropagationToken(tx));
					// enlisted in distributed transaction
					// disconnect and cleanup local transaction
					_npgsqlTx.Cancel();
					_npgsqlTx.Dispose();
					_npgsqlTx = null;
				}
			}
		}
コード例 #8
0
 private static INpgsqlResourceManager CreateResourceManager()
 {
     // TODO: create network proxy for resource manager
     if (_resourceManager == null)
     {
         _sponser = new System.Runtime.Remoting.Lifetime.ClientSponsor();
         AppDomain rmDomain = AppDomain.CreateDomain("NpgsqlResourceManager", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
         _resourceManager =
             (INpgsqlResourceManager)
             rmDomain.CreateInstanceAndUnwrap(typeof (NpgsqlResourceManager).Assembly.FullName,
                                              typeof (NpgsqlResourceManager).FullName);
         _sponser.Register((MarshalByRefObject)_resourceManager);
     }
     return _resourceManager;
     //return new NpgsqlResourceManager();
 }
コード例 #9
0
 public byte[] Promote()
 {
     NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Promote");
     _rm = CreateResourceManager();
     // may not be null if Prepare or Enlist is called first
     if (_callbacks == null)
     {
         _callbacks = new NpgsqlTransactionCallbacks(_connection);
     }
     byte[] token = _rm.Promote(_callbacks);
     // mostly likely case for this is the transaction has been prepared.
     if (_npgsqlTx != null)
     {
         // cancel the NpgsqlTransaction since this will
         // be handled by a two phase commit.
         _npgsqlTx.Cancel();
         _npgsqlTx.Dispose();
         _npgsqlTx = null;
         _connection.PromotableLocalTransactionEnded();
     }
     return token;
 }
コード例 #10
0
		private static INpgsqlResourceManager CreateResourceManager()
		{
			// TODO: create network proxy for resource manager
			if (_resourceManager == null)
			{
				AppDomain rmDomain = AppDomain.CreateDomain("NpgsqlResourceManager", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
				_resourceManager =
					(INpgsqlResourceManager)
					rmDomain.CreateInstanceAndUnwrap(typeof (NpgsqlResourceManager).Assembly.FullName,
					                                 typeof (NpgsqlResourceManager).FullName);
			}
			return _resourceManager;
			//return new NpgsqlResourceManager();
		}
コード例 #11
0
		public byte[] Promote()
		{
			_rm = CreateResourceManager();
			// may not be null if Prepare or Enlist is called first
			if (_callbacks == null)
			{
				_callbacks = new NpgsqlTransactionCallbacks(_connection);
			}
			byte[] token = _rm.Promote(_callbacks);
			// mostly likely case for this is the transaction has been prepared.
			if (_npgsqlTx != null)
			{
				// cancel the NpgsqlTransaction since this will
				// be handled by a two phase commit.
				_npgsqlTx.Cancel();
				_npgsqlTx.Dispose();
				_npgsqlTx = null;
			}
			return token;
		}