public string Connect(ConnectionOptions connectionOptions)
        {
            var sqlConnectionOptions =
                JsonConvert.DeserializeObject <SqlConnectionOptions>(connectionOptions.ConnectionString);

            var initializer      = PluginContainer.GetInstance <IDbContextOptionsInitializer>(connectionOptions.Provider);
            var dbContextOptions = initializer.Initialize <T>(sqlConnectionOptions.ConnectionString);

            dbContextOptions.ConfigureWarnings(c =>
            {
                if (sqlConnectionOptions.LogWarningEnabled)
                {
                    c.Log();
                }
                else
                {
                    c.Ignore();
                }
            });

            dbContextOptions.EnableSensitiveDataLogging(sqlConnectionOptions.SensitiveDataLoggingEnabled);

            dbContextOptions.UseQueryTrackingBehavior(sqlConnectionOptions.QueryTrackingEnabled
                ? QueryTrackingBehavior.TrackAll
                : QueryTrackingBehavior.NoTracking);

            _dbContext = new DataStoreDbContext <T>(dbContextOptions.Options);

            return("OK");
        }
Esempio n. 2
0
 /// <summary>
 /// base constructor
 /// </summary>
 /// <param name="assembly"></param>
 /// <param name="connectionOptions"></param>
 /// <param name="loggerFactory"></param>
 /// <param name="diagnosticSource"></param>
 public RepositoryStoreFactory(string assembly, ConnectionOptions connectionOptions, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource)
 {
     _instance          = PluginContainer.GetInstance <IRepositoryStore <T> >(assembly);
     _logger            = loggerFactory.CreateLogger <T>();
     _diagnosticSource  = diagnosticSource;
     _connectionOptions = connectionOptions;
 }
Esempio n. 3
0
        public string Connect(ConnectionOptions connectionOptions)
        {
            var noSqlConnectionString =
                JsonConvert.DeserializeObject <NoSqlConnectionString>(connectionOptions.ConnectionString);

            _dbContext = PluginContainer.GetInstance <INoSqlDbConnection <T> >(connectionOptions.Provider, noSqlConnectionString);

            return("OK");
        }
Esempio n. 4
0
        public LoggingItemRepository(string assembly, ConnectionOptions connectionOptions, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource, IOptions <LoggingSettings> options, IConfiguration configuration) :
            base(assembly, connectionOptions, loggerFactory, diagnosticSource)
        {
            AfterInsert = OnInsert;

            _logSettings = options.Value;

            _loggingAppender = PluginContainer.GetInstance <ILoggingAppender>(_logSettings.Appender, _logSettings);
            _loggingAppender.InitializeAppender();

            var loggingRuleRepository = new LoggingRuleRepository(_logSettings.NotificationRules.ProviderAssembly, new ConnectionOptions
            {
                Provider         = _logSettings.NotificationRules.ProviderType,
                ConnectionString = _logSettings.NotificationRules.ConnectionString
            }, loggerFactory, diagnosticSource);

            _loggingRuleManager = new LoggingRuleManager(loggingRuleRepository, configuration, loggerFactory, diagnosticSource);
        }
Esempio n. 5
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(new MonitoringRuleRepository(_monitoringRuleRepositorySettings.ProviderAssembly, new ConnectionOptions
            {
                Provider         = _monitoringRuleRepositorySettings.ProviderType,
                ConnectionString = _monitoringRuleRepositorySettings.ConnectionString,
                IntervalRetry    = 30,
                RetryCount       = 3
            }, _loggerFactory, _diagnosticSource));

            services.AddSingleton(new MonitoringItemRepository(_monitoringItemRepositorySettings.ProviderAssembly, new ConnectionOptions
            {
                Provider         = _monitoringItemRepositorySettings.ProviderType,
                ConnectionString = _monitoringItemRepositorySettings.ConnectionString,
                IntervalRetry    = 30,
                RetryCount       = 3
            }, _loggerFactory, _diagnosticSource));

            services.AddSingleton(provider => PluginContainer.GetInstance <IMonitoringAdapter>(_adapterSettings.AdapterAssembly,
                                                                                               _adapterSettings.AdapterParameters));

            services.AddSingleton <IMonitoringRuleService, IMonitoringRuleService>();
            services.AddSingleton <IMonitoringService, MonitoringService>();
        }