/// <summary> /// Remove all the stored sync information /// </summary> public void FlushSyncData() { lock (this) { IEnumerator em = Keys.GetEnumerator(); while (em.MoveNext()) { SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource((string)em.Current); connInfo.DbSyncInfo = null; } } }
/// <summary> /// Wrapper for ResourcePool.GetResource(string key). /// </summary> /// <param name="connString"></param> /// <returns></returns> public IDictionary GetResourceSyncInfo(string connString) { lock (this) { SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource(connString); if (connInfo != null) { return(connInfo.DbSyncInfo); } return(null); } }
/// <summary> /// Wrapper for ResourcePool.GetResource(string key). /// </summary> /// <param name="connString"></param> /// <returns></returns> public OleDbConnection GetConnection(string connString) { lock (this) { SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource(connString); if (connInfo != null) { return(connInfo.Connection); } return(null); } }
/// <summary> /// Removes the modified records in ncache_db_sync table /// </summary> /// <param name="syncTable"></param> /// <param name="cacheName"></param> public void RemoveSyncData(string syncTable, string cacheName) { lock (this) { IEnumerator em = Keys.GetEnumerator(); while (em.MoveNext()) { SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource((string)em.Current); RemoveTableData(syncTable, cacheName, connInfo.Connection); connInfo.DbSyncInfo = null; } } }
/// <summary> /// Acquire the modified records in ncache_db_sync table /// </summary> /// <param name="syncTable"></param> /// <param name="cacheName"></param> public void AcquireSyncData(string syncTable, string cacheName) { lock (this) { IEnumerator em = Keys.GetEnumerator(); while (em.MoveNext()) { SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource((string)em.Current); IDictionary dbSyncInfo = LoadTableData(syncTable, cacheName, connInfo.Connection); connInfo.DbSyncInfo = dbSyncInfo; } } }
/// <summary> /// Adds a connection to the _connectionTable if already not present. /// Otherwise, increments the referrence count for it. /// </summary> /// <param name="connectionString"></param> /// <returns></returns> public OleDbConnection PoolConnection(string connString, OleDbConnection connection) { lock (this) { string connKey = connString.ToLower(); SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource(connKey); if (connInfo == null) { connection.Open(); connInfo = new SqlDbResourceInfo(connection); AddResource(connKey, connInfo); } else { AddResource(connKey, null); // To increase the reference count } return(connInfo.Connection); } }
/// <summary> /// Gets the keys which have been modified in the database. /// call this method after acquiring the latest database state. /// </summary> /// <returns> array list of all the modified keys. </returns> internal ArrayList GetExpiredKeys() { ArrayList keys = new ArrayList(); lock (this) { IEnumerator em = Keys.GetEnumerator(); while (em.MoveNext()) { SqlDbResourceInfo connInfo = (SqlDbResourceInfo)GetResource((string)em.Current); if (connInfo != null && connInfo.DbSyncInfo != null) { keys.AddRange(connInfo.DbSyncInfo.Keys); connInfo.DbSyncInfo = null; } } } return(keys); }