public RelationalDatabaseWriterBase(PredefinedSqlConnection predefinedSqlConnection) { if (SqlServerFactoryNames.Contains(predefinedSqlConnection.FactoryName)) { IsSqlServerFactoryType = true; } }
public RelationalDatabaseWriterSimulator(PredefinedSqlConnection predefinedSqlConnection, SqlReplication sqlReplication) : base(predefinedSqlConnection) { _sqlReplication = sqlReplication; providerFactory = DbProviderFactories.GetFactory(predefinedSqlConnection.FactoryName); commandBuilder = providerFactory.CreateCommandBuilder(); }
public bool PrepareSqlReplicationConfig(BlittableJsonReaderObject connections, bool writeToLog = true) { if (string.IsNullOrWhiteSpace(Configuration.ConnectionStringName) == false) { object connection; if (connections.TryGetMember(Configuration.ConnectionStringName, out connection)) { _predefinedSqlConnection = JsonDeserializationServer.PredefinedSqlConnection(connection as BlittableJsonReaderObject); if (_predefinedSqlConnection != null) { return(true); } } if (writeToLog) { if (_logger.IsInfoEnabled) { _logger.Info("Could not find connection string named '" + Configuration.ConnectionStringName + "' for sql replication config: " + Configuration.Name + ", ignoring sql replication setting."); } } Statistics.LastAlert = new Alert { CreatedAt = SystemTime.UtcNow, Type = AlertType.SqlReplicationConnectionStringMissing, Severity = AlertSeverity.Error, Message = "Could not start replication", Content = new ExceptionAlertContent { Message = $"Could not find connection string named '{Configuration.ConnectionStringName}' for sql replication config: {Configuration.Name}, ignoring sql replication setting.", } }; return(false); } if (writeToLog) { if (_logger.IsInfoEnabled) { _logger.Info("Connection string name cannot be empty for sql replication config: " + Configuration.ConnectionStringName + ", ignoring sql replication setting."); } } Statistics.LastAlert = new Alert { Type = AlertType.SqlReplicationConnectionStringMissing, CreatedAt = SystemTime.UtcNow, Severity = AlertSeverity.Error, Message = "Could not start replication", Content = new ExceptionAlertContent { Message = $"Connection string name cannot be empty for sql replication config: {Configuration.Name}, ignoring sql replication setting." } }; return(false); }
public RelationalDatabaseWriter(DocumentDatabase database, DocumentsOperationContext context, PredefinedSqlConnection predefinedSqlConnection, SqlReplication sqlReplication) : base(predefinedSqlConnection) { _database = database; _context = context; _predefinedSqlConnection = predefinedSqlConnection; _sqlReplication = sqlReplication; _logger = LoggingSource.Instance.GetLogger <RelationalDatabaseWriter>(_database.Name); _providerFactory = GetDbProviderFactory(_sqlReplication.Configuration); _commandBuilder = _providerFactory.CreateCommandBuilder(); _connection = _providerFactory.CreateConnection(); _connection.ConnectionString = predefinedSqlConnection.ConnectionString; try { _connection.Open(); } catch (Exception e) { database.Alerts.AddAlert(new Alert { Type = AlertType.SqlReplicationConnectionError, Message = "Sql Replication could not open connection", Content = new ExceptionAlertContent { Message = "Sql Replication could not open connection to " + _connection.ConnectionString, Exception = e.ToString() }, CreatedAt = SystemTime.UtcNow, Key = _connection.ConnectionString, Severity = AlertSeverity.Error }); throw; } _tx = _connection.BeginTransaction(); stringParserList = GenerateStringParsers(); }