Esempio n. 1
0
        private IMongoCollection <BsonDocument> GetCollection(DbConnectionSettings connectionSettings)
        {
            var settings = new MongoClientSettings
            {
                Server = new MongoServerAddress(connectionSettings.Host, connectionSettings.Port)
            };

            if (connectionSettings.UseSsl)
            {
                settings.UseSsl      = true;
                settings.SslSettings = new SslSettings {
                    EnabledSslProtocols = SslProtocols.Tls12
                };
            }
            settings.ConnectionMode = ConnectionMode.Direct;

            settings.Credentials = new[]
            {
                MongoCredential.CreateCredential(connectionSettings.AuthDbName, connectionSettings.UserName, connectionSettings.Password)
            };

            var client             = new MongoClient(settings);
            var database           = client.GetDatabase(connectionSettings.DbName);
            var todoTaskCollection = database.GetCollection <BsonDocument>(connectionSettings.CollectionName);

            return(todoTaskCollection);
        }
Esempio n. 2
0
        public Transferer(IOptions <AppSettings> settings, ILogger <Transferer> logger)
        {
            _logger                 = logger;
            _destination            = settings.Value.DestinationDb;
            _batchSize              = settings.Value.BatchSize;
            _maxDegreeOfParallelism = settings.Value.MaxDegreeOfParallelism;

            _destinationCollection = GetCollection(_destination);
        }