コード例 #1
0
ファイル: Pooling.cs プロジェクト: ewin66/Management-System
        public static int CloseDB(string applicationID)
        {
            if (TransactionPool.GetTransaction(applicationID) == null ||
                TransactionPool.GetTransaction(applicationID).Connection == null) //没开起事务
            {
                if (timers.ContainsKey(applicationID))
                {
                    timers[applicationID] = true;
                }
                else
                {
                    timers.Add(applicationID, true);
                }

                if (ticks.ContainsKey(applicationID))
                {
                    ticks[applicationID] = System.DateTime.Now.Ticks;
                }
                else
                {
                    ticks.Add(applicationID, System.DateTime.Now.Ticks);
                }
            }
            return(0);
        }
コード例 #2
0
 public void Rollback()
 {
     try
     {
         TransactionPool.GetTransaction(this.applicationID).Rollback();
     }
     catch (Exception ex)
     {
         Management.PublicTrans.log.WriteLog("Rollback出错!" + ex.Message);
     }
     try
     {
         TransactionPool.GetTransaction(this.applicationID).Dispose();
         TransactionPool.RemoveTransaction(this.applicationID);
     }
     catch { }
     //数据库关闭连接处理
     CloseDB();
 }
コード例 #3
0
        public void BeginTransaction()
        {
            //数据库重新开启连接
            OpenDB();
            //事务判断
            if (TransactionPool.GetTransaction(this.applicationID) == null)
            {
                TransactionPool.SetTransaction(this.applicationID, ConnectionPool.GetConnection(this.applicationID).BeginTransaction(System.Data.IsolationLevel.ReadCommitted));
                //必须在事务开始之后加上
                //{0A5C1FD6-C6DF-46b1-9EA6-AAD4CA6D12F4}Neusoft.FrameWork.Server.ServerManager  里 把下面方法更新一下,解决DB2事务不能开启的问题
                //ConnectionPool.GetConnection(this.applicationID).GetType().GetProperty("TransactionState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(ConnectionPool.GetConnection(this.applicationID), 1, null);

                if (Neusoft.FrameWork.Management.Connection.DBType == Neusoft.FrameWork.Management.Connection.EnumDBType.ORACLE)
                {
                    ConnectionPool.GetConnection(this.applicationID).GetType().GetProperty("TransactionState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(ConnectionPool.GetConnection(this.applicationID), 1, null);
                }
                else if (Neusoft.FrameWork.Management.Connection.DBType == Neusoft.FrameWork.Management.Connection.EnumDBType.DB2)
                {
                    ConnectionPool.GetConnection(this.applicationID).GetType().GetProperty("TransactionState");
                }
            }
        }
コード例 #4
0
 public System.Data.IDbTransaction GetTrans()
 {
     return(TransactionPool.GetTransaction(this.applicationID));
 }
コード例 #5
0
 private void setDB(IDBServer db)
 {
     this.db = db;
     this.db.SetConnection(ConnectionPool.GetConnection(this.applicationID), TransactionPool.GetTransaction(this.applicationID));
 }