public static MongodbDatabase UsePool(params string[] keys) { int count = pool.Count; if (count != poolkey.Count || count == 0) { pool.Clear(); poolkey.Clear(); count = 0; ConnectionStringSettingsCollection conns = WebConfig.GetConn(); foreach (ConnectionStringSettings info in conns) { string key = info.Name; if (key != "MongoDB" || keys.IndexOf(key) == -1) { continue; } MongodbDatabase db = new MongodbDatabase(key); db.Pool = key; pool[key.ToLower()] = db; poolkey.Add(key.ToLower()); count++; } } return(pool[poolkey[count == 1 ? 0 : Rand.RndInt(0, count)]]); }
public static void AddPool(MongodbDatabase db) { if (db.IsNull()) { return; } AddPool(db.Pool, db); }
public static void AddPool(string key, MongodbDatabase db = null) { if (key.IsNullEmpty()) return; key = key.ToLower(); if (pool.ContainsKey(key)) return; if (db.IsNull()) { MongodbDatabase newdb = new MongodbDatabase(key); newdb.Pool = key; pool[key] = newdb; poolkey.Add(key); } else { pool[key] = db; poolkey.Add(key); } }
public static MongodbDatabase UsePool(params string[] keys) { int count = pool.Count; if (count != poolkey.Count || count == 0) { pool.Clear(); poolkey.Clear(); count = 0; ConnectionStringSettingsCollection conns = WebConfig.GetConn(); foreach (ConnectionStringSettings info in conns) { string key = info.Name; if (key != "MongoDB" || keys.IndexOf(key) == -1) continue; MongodbDatabase db = new MongodbDatabase(key); db.Pool = key; pool[key.ToLower()] = db; poolkey.Add(key.ToLower()); count++; } } return pool[poolkey[count == 1 ? 0 : Rand.RndInt(0, count)]]; }
public static void AddPool(string key, MongodbDatabase db = null) { if (key.IsNullEmpty()) { return; } key = key.ToLower(); if (pool.ContainsKey(key)) { return; } if (db.IsNull()) { MongodbDatabase newdb = new MongodbDatabase(key); newdb.Pool = key; pool[key] = newdb; poolkey.Add(key); } else { pool[key] = db; poolkey.Add(key); } }
public static void AddPool(MongodbDatabase db) { if (db.IsNull()) return; AddPool(db.Pool, db); }