/// <inheritdoc /> public IEnumerable <int> Handle(FindErrorMessagesToDeleteQuery <int> query) { if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <int>()); } using (var db = _connectionInformation.GetDatabase()) { //before executing a query, double check that we aren't stopping //otherwise, there is a chance that the tables no longer exist in memory mode if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <int>()); } var col = db.Database.GetCollection <Schema.MetaDataErrorsTable>(_tableNameHelper.MetaDataErrorsName); var date = DateTime.UtcNow.Subtract(_configuration.MessageAge); var results = col.Query() .Where(x => x.LastExceptionDate < date) .ToList(); var data = new List <int>(results.Count); foreach (var record in results) { data.Add(record.QueueId); } return(data); } }
/// <inheritdoc /> public void Handle(FindErrorMessagesToDeleteQuery <long> query, IDbCommand dbCommand, CommandStringTypes commandType) { dbCommand.CommandText = _commandCache.GetCommand(commandType); var command = (NpgsqlCommand)dbCommand; command.Parameters.Add("@CurrentDate", NpgsqlDbType.Timestamp); command.Parameters["@CurrentDate"].Value = _getTime.GetCurrentUtcDate().Subtract(_configuration.MessageAge); }
/// <inheritdoc /> public void Handle(FindErrorMessagesToDeleteQuery query, IDbCommand dbCommand, CommandStringTypes commandType) { dbCommand.CommandText = _commandCache.GetCommand(commandType); var param = dbCommand.CreateParameter(); param.ParameterName = "@CurrentDate"; param.DbType = DbType.DateTime; param.Value = _getTime.GetCurrentUtcDate().Subtract(_configuration.MessageAge); dbCommand.Parameters.Add(param); }
/// <inheritdoc /> public void Handle(FindErrorMessagesToDeleteQuery <long> query, IDbCommand dbCommand, CommandStringTypes commandType) { dbCommand.CommandText = _commandCache.GetCommand(commandType); var command = dbCommand; var param = command.CreateParameter(); param.ParameterName = "@CurrentDateTime"; param.DbType = DbType.Int64; param.Value = _getTime.GetCurrentUtcDate().Ticks - _configuration.MessageAge.Ticks; command.Parameters.Add(param); }
/// <inheritdoc /> public IEnumerable <T> Handle(FindErrorMessagesToDeleteQuery <T> query) { if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <T>()); } var results = new List <T>(); using (var connection = _dbConnectionFactory.Create()) { connection.Open(); //before executing a query, double check that we aren't stopping //otherwise, there is a chance that the tables no longer exist in memory mode if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <T>()); } using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.FindErrorRecordsToDelete); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (query.Cancellation.IsCancellationRequested) { break; } results.Add(_readColumn.ReadAsType <T>(CommandStringTypes.FindErrorRecordsToDelete, 0, reader)); } } } } return(results); }