Пример #1
0
        public async Task <IEnumerable <ProductEntity> > GetAsync(CancellationToken cancellationToken = default)
        {
            const string query = @"
select Id, Name
from Product
";

            await using var connection = new SqlConnection(_connectionStringProvider.Get());
            var products = await connection.QueryAsyncWithRetry <ProductEntity>(query);

            return(products);
        }
Пример #2
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     if (!optionsBuilder.IsConfigured)
     {
         optionsBuilder.UseSqlServer(_connectionStringProvider.Get());
     }
 }
Пример #3
0
 public IAsyncBlockBlobRepository CreateAsyncBlockBlobRepository(string containerName)
 {
     if (_azureSettings.CreateIfNotExists)
     {
         throw new InvalidOperationException("Creation of resources can only be done through an asynchronous factory");
     }
     return(new AsyncBlockBlobRepository(_connectionStringProvider.Get <IAsyncBlockBlobRepository>(containerName), containerName, _loggerFactory));
 }
        public IStorageAccount Create(string connectionName = null)
        {
            if (connectionName == null)
            {
                connectionName = "DefaultStorageConnection";
            }

            return(new AzureStorageAccount(_connectionStringProvider.Get(connectionName)));
        }
Пример #5
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            Task.Run(async() =>
            {
                var connectionString = await _provider.Get();
                optionsBuilder.UseMySQL(connectionString);
            }).Wait();

            base.OnConfiguring(optionsBuilder);
        }
        public DapperAggregateRootEventStorage(ILoggerFactory loggerFactory
                                             , ISerialiser serialiser
                                             , IConnectionStringProvider connectionStringProvider
                                             , IEventToAggregateEventMapper eventToAggregateEventMapper)
        {
            _serialiser = serialiser;
            _eventToAggregateEventMapper = eventToAggregateEventMapper;

            logger = loggerFactory.Create();
            _connectionString = connectionStringProvider.Get("events");
        }
Пример #7
0
        public IFtpClient Create(string connectionName = null)
        {
            if (connectionName == null)
            {
                connectionName = "DefaultFtpConnection";
            }

            string connectionString = _connectionStringProvider.Get(connectionName);

            var ftpClientSettings = new FtpClientSettings(connectionString);

            return(ftpClientSettings.IsSftp
                ? (IFtpClient) new RensiSftpClient(connectionString)
                : (IFtpClient) new SystemFtpClient(connectionString));
        }
Пример #8
0
        public IAsyncTableStorageRepository <T> Create <T>(string tableName) where T : ITableEntity, new()
        {
            if (_azureSettings.CreateIfNotExists)
            {
                throw new InvalidOperationException("Creation of resources can only be done through an asynchronous factory");
            }

            if (String.IsNullOrWhiteSpace(tableName))
            {
                throw new ArgumentNullException(nameof(tableName));
            }
            string connectionString = _connectionStringProvider.Get <IAsyncTableStorageRepository <T> >(tableName);
            IAsyncTableStorageRepository <T> result = new AsyncTableStorageRepository <T>(connectionString, tableName, _tableStorageQueryBuilder, _tableContinuationTokenSerializer, _loggerFactory.CreateLogger <AsyncTableStorageRepository <T> >());

            return(result);
        }
Пример #9
0
        private async Task <MySqlConnection> GetConnectionAsync()
        {
            if (!_cache.TryGetValue(Constants.ConnectionStringCacheKey, out string connectionString))
            {
                _logger.LogDebug("Getting connection string...");
                connectionString = await _connectionStringProvider.Get();

                var options = new MemoryCacheEntryOptions()
                              .SetSlidingExpiration(TimeSpan.FromMinutes(5));
                _cache.Set(Constants.ConnectionStringCacheKey, connectionString, options);
                _logger.LogDebug("Cached connection string.");
                _logger.LogDebug("Connection string: {0}", connectionString);
            }
            else
            {
                _logger.LogDebug("Using cached connection string: {0}", connectionString);
            }

            return(new MySqlConnection(connectionString));
        }
        public AccessToSqlServerProcessor(
            IDatabaseCommanderFactory databaseCommanderFactory,
            IConnectionStringProvider connectionStringProvider)
        {
            _databaseCommander = databaseCommanderFactory.Create(_settings.ConnectionStringName);
            _settings          = new SqlServerFileProcessorSettings
            {
                ConnectionStringName = Constants.Configuration.ConnectionString.DefaultConnection,
                FilePath             = connectionStringProvider.Get("AccessConnection"),
                SchemaName           = "issue",
                TableName            = "ESGBeforeOpSolve",
                PrimaryKeyColumnName = "ESGBeforeOpSolveID",
                CreatedBy            = "sferguson",
                IsAppendAuditFields  = true
            };

            _databaseColumns = new Dictionary <string, string>();

            Init();
        }
        public bool IsActive()
        {
            var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(_connectionStringProvider.Get(ConnectionStringName))
            {
                ConnectTimeout = 3
            };

            using (var connection = new SqlConnection(sqlConnectionStringBuilder.ConnectionString))
            {
                connection.Open();

                var command = connection.CreateCommand();
                command.CommandTimeout = 3;
                command.CommandType    = CommandType.Text;
                command.CommandText    = "SELECT db_name()";
                var dbName = (string)command.ExecuteScalar();

                connection.Close();

                return(dbName == sqlConnectionStringBuilder.InitialCatalog);
            }
        }
Пример #12
0
 public DapperReportingRepository(ILoggerFactory loggerFactory
                                  , IConnectionStringProvider connectionStringProvider)
 {
     _connectionString = connectionStringProvider.Get("events");
     _logger           = loggerFactory.Create();
 }
Пример #13
0
        public ISmtpClient Create(string connectionName = null)
        {
            connectionName ??= "DefaultSmtpConnection";

            return(new SystemSmtpClient(_connectionStringProvider.Get(connectionName)));
        }
Пример #14
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySQL(_connectionStringProvider.Get());

            base.OnConfiguring(optionsBuilder);
        }
Пример #15
0
 public SqlAggregateRootEventStorage(ILoggerFactory loggerFactory, IConnectionStringProvider connectionStringProvider)
 {
     logger            = loggerFactory.Create();
     _connectionString = connectionStringProvider.Get("events");
 }
Пример #16
0
 public FluentNHibernateSessionFactoryBuilder(IConnectionStringProvider connectionStringProvider)
 {
     this.connectionString = connectionStringProvider.Get("events");
 }