static void Main(string[] args)
        {
            if (doMongoInsert)
            {
                Console.WriteLine($"Listening for events from rabbit :)");

                _connectionFactory = new ConnectionFactory {
                    HostName = "localhost"
                };
                _connection = _connectionFactory.CreateConnection();

                _mongoSetting    = new MongoSetting();
                _mongoRepository = new MongoRepository(_mongoSetting);

                var sub = new Subscriber(_connection, _mongoRepository);
            }

            Console.WriteLine($"Mode to process set to : {doMongoInsert}");
            Console.Read();
        }
Esempio n. 2
0
 public MongoRepository(IMongoSetting mongoSettings)
 {
     _mongoSettings = mongoSettings;
     _mongoClient   = new MongoClient(_mongoSettings.ConnectionString);
     _mongoDatabase = _mongoClient.GetDatabase(_mongoSettings.Database);
 }
Esempio n. 3
0
 public static bool DropCollection(string databaseName, IMongoSetting setting, string collectionName)
 {
     MongoDatabase db = GetDatabase(databaseName, setting);
     CommandResult result = db.DropCollection(collectionName);
     return (result.Ok ? true : false);
 }
Esempio n. 4
0
 public static bool CollectionExists(string databaseName, IMongoSetting setting, string collectionName)
 {
     MongoDatabase db = GetDatabase(databaseName, setting);
     return db.CollectionExists(collectionName);
 }
Esempio n. 5
0
 public static IEnumerable<string> GetCollectionNames(string databaseName, IMongoSetting setting)
 {
     MongoDatabase db = GetDatabase(databaseName, setting);
     return db.GetCollectionNames();
 }
Esempio n. 6
0
 public static void DeleteDatabase(string databaseName, IMongoSetting setting)
 {
     MongoDatabase db = GetDatabase(databaseName, setting);
     db.Drop();
 }
Esempio n. 7
0
 public static IEnumerable<string> GetDatabaseNames(IMongoSetting setting)
 {
     MongoServer server = GetMongoServer(setting);
     return server.GetDatabaseNames();
 }
Esempio n. 8
0
 public static MongoDatabase GetDatabase(string databaseName, IMongoSetting setting)
 {
     MongoDatabase db = GetMongoServer(setting).GetDatabase(databaseName);
     return db;
 }
Esempio n. 9
0
 private static MongoServer GetMongoServer(IMongoSetting setting)
 {
     var client = new MongoClient(setting.ConnectionString);
     MongoServer server = client.GetServer();
     return server;
 }