/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> public void Handle(SetErrorCountCommand <long> command) { if (!_databaseExists.Exists(_connectionInformation.ConnectionString)) { return; } _decorated.Handle(command); }
public void Create_Default() { const int id = 19334; var type = "errorType"; var test = new SetErrorCountCommand(type, id); Assert.Equal(id, test.QueueId); Assert.Equal(type, test.ExceptionType); }
public void Handle(SetErrorCountCommand <T> command) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var commandSql = connection.CreateCommand()) { var commandType = _queryHandler.Handle(new GetErrorRecordExistsQuery <T>(command.ExceptionType, command.QueueId)) ? CommandStringTypes.UpdateErrorCount : CommandStringTypes.InsertErrorCount; _prepareCommand.Handle(command, commandSql, commandType); commandSql.ExecuteNonQuery(); } } }
/// <inheritdoc /> public void Handle(SetErrorCountCommand <T> command, IDbCommand dbCommand, CommandStringTypes commandType) { dbCommand.CommandText = _commandCache.GetCommand(commandType); var param = dbCommand.CreateParameter(); param.ParameterName = "@QueueID"; param.DbType = DbType.Int64; //WARN - type should be T param.Value = command.QueueId; dbCommand.Parameters.Add(param); param = dbCommand.CreateParameter(); param.ParameterName = "@ExceptionType"; param.DbType = DbType.AnsiStringFixedLength; param.Size = 500; param.Value = command.ExceptionType; dbCommand.Parameters.Add(param); }
/// <inheritdoc /> public void Handle(SetErrorCountCommand <int> command) { using (var db = _connectionInformation.GetDatabase()) { db.Database.BeginTrans(); try { var meta = db.Database.GetCollection <Schema.ErrorTrackingTable>(_tableNameHelper.ErrorTrackingName); var results = meta.Query() .Where(x => x.QueueId == command.QueueId) .Where(x => x.ExceptionType == command.ExceptionType) .Limit(1) .ToList(); if (results != null && results.Count == 1) { //update results[0].RetryCount = results[0].RetryCount + 1; meta.Update(results[0]); } else { var record = new Schema.ErrorTrackingTable() { QueueId = command.QueueId, ExceptionType = command.ExceptionType, RetryCount = 1 }; meta.Insert(record); } db.Database.Commit(); } catch { db.Database.Rollback(); throw; } } }