private static IMongoCollection <LockData> GetCollection()
        {
            var database   = MongoFactory.GetDatabaseFromConnectionName("Messaging");
            var collection = database.GetCollection <LockData>("throttle-lock");

            return(collection);
        }
Пример #2
0
        private static QueueRepository GetRepository()
        {
            var database   = MongoFactory.GetDatabaseFromConnectionName("Messaging");
            var collection = database.GetCollection <Message>("test-queue");
            var repo       = new QueueRepository(collection);

            return(repo);
        }
        private IMongoCollection <LogEvent> CreateCollection()
        {
            string collectionName = ConfigurationManager.AppSettings["LoggingCollectionName"];

            if (string.IsNullOrEmpty(collectionName))
            {
                collectionName = "Logging";
            }

            var database = MongoFactory.GetDatabaseFromConnectionName("LoggingConnection");

            var mongoCollection = database.GetCollection <LogEvent>(collectionName);

            mongoCollection.Indexes.CreateOneAsync(Builders <LogEvent> .IndexKeys.Descending(s => s.Date));
            mongoCollection.Indexes.CreateOneAsync(Builders <LogEvent> .IndexKeys.Ascending(s => s.Level));
            mongoCollection.Indexes.CreateOneAsync(Builders <LogEvent> .IndexKeys.Ascending(s => s.Source));
            mongoCollection.Indexes.CreateOneAsync(Builders <LogEvent> .IndexKeys.Ascending(s => s.Correlation));

            return(mongoCollection);
        }
Пример #4
0
        private void CreateDatabase()
        {
            if (_database != null)
            {
                return;
            }

            // thread safe database creation
            lock (_databaseLock)
            {
                if (_database != null)
                {
                    return;
                }

                _database = string.IsNullOrEmpty(ConnectionName)
                    ? MongoFactory.GetDatabaseFromConnectionString("mongodb://localhost/Messaging")
                    : MongoFactory.GetDatabaseFromConnectionName(ConnectionName);
            }
        }
Пример #5
0
 public UserRepository(string connectionName)
     : base(MongoFactory.GetDatabaseFromConnectionName(connectionName))
 {
 }