Esempio n. 1
0
        private ConnectionPoolType CreateConnStr(ConnectionPoolType conn)
        {
            try
            {
                string str_connection = string.Empty;
                ConnectionPoolType aa = new ConnectionPoolType();
                string sDbName = "ConnectionString";
                if (conn.DBName != DBNameType.None)
                {
                    sDbName = string.Format("{0}ConnectionString", conn.DBName);
                }

                if (!String.IsNullOrEmpty(conn.ConfigPath))
                    ConfigManager.ConfigPath = conn.ConfigPath;

                str_connection = ConfigManager.Default[sDbName];

                if (String.IsNullOrEmpty(str_connection))
                    throw new Exception("Connection String Is Null.");

                conn.ConfigPath = str_connection;

                if (conn.DBName != DBNameType.None) Add(conn);

                return conn;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 private void Add(ConnectionPoolType conn)
 {
     objectPool.AddFirst(conn);
     if (objectPool.Count >= MAX_POOL)
     {
         objectPool.RemoveLast();
     }
 }
Esempio n. 3
0
        public ConnectionPoolType GetObjectFromPool(ConnectionPoolType conn)
        {
            lock (this)
            {
                foreach (ConnectionPoolType weak in objectPool)
                {
                    if (conn.DBName == weak.DBName)
                    {
                        return weak;
                    }
                }
            }

            return CreateConnStr(conn);
        }
Esempio n. 4
0
 private void Remove(ConnectionPoolType conn)
 {
     objectPool.Remove(conn);
 }