/// <inheritdoc /> public QueueCreationResult Handle(CreateJobTablesCommand <ITable> command) { foreach (var table in command.Tables) { table.Create(_connectionInformation, _options.Value, _tableNameHelper); } return(new QueueCreationResult(QueueCreationStatus.Success)); }
public QueueCreationResult Handle(CreateJobTablesCommand <ITable> command) { try { return(_decorated.Handle(command)); } //if the queue already exists, return that status; otherwise, bubble the error catch (SqlException error) { if (error.Number == 2714) { return(new QueueCreationResult(QueueCreationStatus.AttemptedToCreateAlreadyExists)); } throw new DotNetWorkQueueException("Failed to create job table(s)", error); } }
public QueueCreationResult Handle(CreateJobTablesCommand <ITable> command) { try { return(_decorated.Handle(command)); } //if the queue already exists, return that status; otherwise, bubble the error catch (PostgresException error) { if (error.SqlState == "42P07" || error.SqlState == "42710") { return(new QueueCreationResult(QueueCreationStatus.AttemptedToCreateAlreadyExists)); } throw new DotNetWorkQueueException($"Failed to create job table(s). SQL script was {error.Statement}", error); } }
/// <inheritdoc /> public QueueCreationResult Handle(CreateJobTablesCommand <ITable> command) { using (var conn = _dbConnectionFactory.Create()) { conn.Open(); using (var trans = _transactionFactory.Create(conn).BeginTransaction()) { using (var commandSql = conn.CreateCommand()) { commandSql.Transaction = trans; _prepareCommandHandler.Handle(command, commandSql, CommandStringTypes.CreateJobTables); commandSql.ExecuteNonQuery(); } trans.Commit(); } } return(new QueueCreationResult(QueueCreationStatus.Success)); }
public QueueCreationResult Handle(CreateJobTablesCommand <ITable> command) { if (!_databaseExists.Exists(_connectionInformation.ConnectionString)) { //no db file, create var fileName = _getFileNameFromConnection.GetFileName(_connectionInformation.ConnectionString); using (File.Create(fileName.FileName)) { } } try { return(_decorated.Handle(command)); } //if the queue already exists, return that status; otherwise, bubble the error catch (SQLiteException error) { if (error.ResultCode == SQLiteErrorCode.Error && error.Message.Contains("table") && error.Message.Contains("already exists")) { return(new QueueCreationResult(QueueCreationStatus.AttemptedToCreateAlreadyExists)); } throw new DotNetWorkQueueException("Failed to create table", error); } }
/// <inheritdoc /> public void Handle(CreateJobTablesCommand <ITable> command, IDbCommand dbCommand, CommandStringTypes commandType) { dbCommand.CommandText = command.Tables.Aggregate(string.Empty, (current, table) => current + table.Script() + Environment.NewLine); }