public void SetInactive(int conID) { if (ActiveConnections.Contains(conID) && connections.Count > conID) { activeConnections.Remove(conID); ConnectionVoxelContainer.RemoveConnection(connections[conID]); } }
public void SetActive(int conID) { if (!ActiveConnections.Contains(conID) && connections.Count > conID && conID >= 0) { activeConnections.Add(conID); ConnectionVoxelContainer.StoreConnection(connections[conID]); } }
/// <summary> /// create a new managed connection. /// </summary> /// <param name="connection">connection</param> /// <param name="attemptToPool">true if we are going to try and reuse the /// connection if possible</param> public ManagedConnection(SqlOlapConnectionInfoBase sourceConnection, bool attemptToPool) { // parameter check if (sourceConnection == null) { throw new ArgumentNullException("sourceConnection"); } // see if the connection can restrict access (single user mode) IRestrictedAccess access = sourceConnection as IRestrictedAccess; // see if it is cloneable ICloneable cloneable = sourceConnection as ICloneable; lock (ActiveConnections) { // if it's not single user mode then we can see if the object can be cloned if (access == null || access.SingleConnection == false) { // if we are going to attempt to pool, see if the connection is in use if (attemptToPool && !ActiveConnections.Contains(SharedConnectionUtil.GetConnectionKeyName(sourceConnection))) { // add it to the hashtable to indicate use. ActiveConnections.Add(SharedConnectionUtil.GetConnectionKeyName(sourceConnection), sourceConnection); this.connection = sourceConnection; this.closeOnDispose = false; this.connectionAddedToActiveConnections = true; } else if (cloneable != null) { this.connection = (SqlOlapConnectionInfoBase)cloneable.Clone(); this.closeOnDispose = true; } else if (sourceConnection is SqlConnectionInfoWithConnection) { this.connection = ((SqlConnectionInfoWithConnection)sourceConnection).Copy(); this.closeOnDispose = true; } } } // if everything else has failed just use to passed in connection. if (this.connection == null) { this.connection = sourceConnection; } // always set the lock timeout to prevent the shell from not responding if (this.connection is SqlConnectionInfoWithConnection) { // set lock_timeout to 10 seconds ((SqlConnectionInfoWithConnection)this.connection).ServerConnection.LockTimeout = 10; } }
public void SetInactive(Connection c) { int i = 0; foreach (Connection con in Connections) { if (c == con) { if (ActiveConnections.Contains(i)) { activeConnections.Remove(i); } } ++i; } }
public void SetActive(Connection c) { int i = 0; foreach (Connection con in Connections) { if (c == con) { if (!ActiveConnections.Contains(i)) { activeConnections.Add(i); } } ++i; } }
public void SetActive(Connection c) { int i = 0; foreach (Connection con in Connections) { if (c == con) { if (!ActiveConnections.Contains(i)) { activeConnections.Add(i); ConnectionVoxelContainer.StoreConnection(con); return; } } ++i; } }
public void SetInactive(Connection c) { int i = 0; foreach (Connection con in Connections) { if (c == con) { if (ActiveConnections.Contains(i)) { activeConnections.Remove(i); ConnectionVoxelContainer.RemoveConnection(con); return; } } ++i; } }