Inheritance: IMongoCollection
Esempio n. 1
0
 public PersistToMongo(string connectionString)
 {
     _mongoServer = new MongoClient(connectionString).GetServer();
     var databaseName = MongoUrl.Create(connectionString).DatabaseName;
     _mongoDatabase = _mongoServer.GetDatabase(databaseName);
     _mongoCollection = _mongoDatabase.GetCollection(COLLECTION_NAME);
 }
Esempio n. 2
0
 public PostController()
 {
     var connectionString = ConfigurationManager.ConnectionStrings["MongoServerSettings"].ConnectionString;
     var client = new MongoClient(connectionString);
     var server = client.GetServer();
     MongoDatabase database;
     database = server.GetDatabase(ConfigurationManager.AppSettings["MongoDatabaseName"]);
     this.expiredPostCollection = database.GetCollection<Post>("ExpiredPost");
     this.deletedPostCollection = database.GetCollection<Post>("DeletedPost");
 }
Esempio n. 3
0
 public SearchHashForm(string collectionName = "HashForm", string dbName = "emdsdb", string hostIP = "localhost")
 {
     connectionString = String.Format("mongodb://{0}/?safe=true", hostIP);
     try
     {
         server = MongoServer.Create(connectionString);
         database = server.GetDatabase(dbName);
         collection = database.GetCollection<FormHash>(collectionName);
         server.Ping();
     }
     catch
     {
         throw new Exception("Проблема подключением к монге");
     }
     log = FileLogger.GetLogger();
 }
Esempio n. 4
0
 public TrainLogRepository(string collectionName = "NeuralTrainLog", string dbName = "emdsdb", string connectionString = "mongodb://localhost/?safe=true")
 {
     CollectionName = collectionName;
     DbName = dbName;
     ConnectionString = String.Format("{0}/{1}", connectionString, dbName);
     try
     {
         var client = new MongoClient(ConnectionString);
         server = client.GetServer();
         database = server.GetDatabase(dbName);
         collection = database.GetCollection(collectionName);
         server.Ping();
     }
     catch
     {
         throw new Exception("Не удалось подключиться к MongoDB");
     }
 }
Esempio n. 5
0
 private TrainLogger(string collectionName = "NeuralTrainLog", string dbName = "emdsdb", string connectionStringMongo = "mongodb://localhost/?safe=true")
 {
     IdSession = Guid.NewGuid();
     isCreate = true;
     CollectionName = collectionName;
     DbName = dbName;
     AgeNumber = -1;
     connectionString = connectionStringMongo;
     try
     {
         server = MongoServer.Create(connectionString);
         database = server.GetDatabase(dbName);
         collection = database.GetCollection(collectionName);
         server.Ping();
     }
     catch
     {
         throw new Exception("Не удалось подключиться к MongoDB");
     }
 }
        public CreditCardRepository(string connection)
        {
            if (string.IsNullOrWhiteSpace(connection))
            {
                connection = "mongodb://localhost:27017";
            }

            _client = new MongoClient(connection);
            _server = _client.GetServer();
            _database = _server.GetDatabase("Customers");
            _creditCards = _database.GetCollection("CreditCard");

            // Reset database and add some default entries
            //_creditCards.RemoveAll();
            /*
            for (int index = 1; index < 5; index++)
            {
                CreditCardItem card = new CreditCardItem
                {
                    Number = string.Format("{0}{0}{0}", index)
                };
                AddCard(card);
            }*/
        }
 public EntityHandler()
 {
     producerList = DBConnection.db.GetCollection<Producer>("producerList");
 }
        public void TestFixtureSetUp()
        {
            log4net.Config.XmlConfigurator.Configure();
            var appenders = log.Logger.Repository.GetAppenders();
            Assert.IsTrue(appenders.Length > 0, "Seems that MongoDB Appender is not configured");

            appender = appenders[0] as MongoDBAppender;
            Assert.IsNotNull(appender, "MongoDBAppender is expected to be the only one configured for tests");

            // Use mongo collection configured at appender level for tests
            collection = appender.LogCollection;
        }
Esempio n. 9
0
 protected override void OnClose()
 {
     collection = null;
     connection.Disconnect();
     base.OnClose();
 }
Esempio n. 10
0
        public override void ActivateOptions()
        {
            try
            {
                var mongoConnectionString = new StringBuilder(string.Format("Server={0}:{1}", Host, Port));
                if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
                {
                    // use MongoDB authentication
                    mongoConnectionString.AppendFormat(";Username={0};Password={1}", UserName, Password);
                }

                mongoConnectionString.AppendFormat(";connectTimeoutMS={0};socketTimeoutMS={1}", ConnectTimeout, SocketTimeout);

                connection = MongoServer.Create(mongoConnectionString.ToString());
                connection.Connect();
                var db = connection.GetDatabase(DatabaseName);
                collection = db.GetCollection(CollectionName);
            }
            catch (Exception e)
            {
                ErrorHandler.Error("Exception while initializing MongoDB Appender", e, ErrorCode.GenericFailure);
            }
        }
 public DocumentFromFifo()
 {
     FIFO = DBConnection.db.GetCollection<PackedDocument>("FIFO");
 }
Esempio n. 12
0
 /// <summary>
 ///   Drops the collection.
 /// </summary>
 /// <param name = "collection">The col.</param>
 /// <returns></returns>
 public bool DropCollection(MongoCollection collection)
 {
     return DropCollection(collection.Name);
 }
Esempio n. 13
0
 public ItemQuery(MongoConfig mongoConfig)
 {
     _document = mongoConfig.MongoDatabase.GetCollection(typeof(Item).Name);
     _reports = mongoConfig.MongoDatabase.GetCollection(typeof(ItemReports).Name);
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "MongoCollection&lt;T&gt;" /> class.
 /// </summary>
 /// <param name = "configuration">The configuration.</param>
 /// <param name = "connection">The connection.</param>
 /// <param name = "databaseName">Name of the database.</param>
 /// <param name = "name">The name.</param>
 internal MongoCollection(MongoConfiguration configuration, Connection connection, string databaseName, string name)
 {
     //Todo: add public constrcutor for users to call
     _collection = new MongoCollection<Document>(configuration, connection, databaseName, name);
 }
 public AnalyserMap()
 {
     dictionary = DBConnection.db.GetCollection<PackedMap>("AnalyserMap");
 }