public IEnumerable <MessageToReset <T> > Handle(FindMessagesToResetByHeartBeatQuery <T> query) { var results = new List <MessageToReset <T> >(); if (query.Cancellation.IsCancellationRequested) { return(results); } 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(results); } using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetHeartBeatExpiredMessageIds); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (query.Cancellation.IsCancellationRequested) { break; } var headers = _readColumn.ReadAsByteArray(CommandStringTypes.GetHeartBeatExpiredMessageIds, 2, reader); if (headers != null) { var allheaders = _serialization.InternalSerializer.ConvertBytesTo <IDictionary <string, object> >(headers); results.Add(new MessageToReset <T>(_readColumn.ReadAsType <T>(CommandStringTypes.GetHeartBeatExpiredMessageIds, 0, reader), _readColumn.ReadAsDateTime(CommandStringTypes.GetHeartBeatExpiredMessageIds, 1, reader), new ReadOnlyDictionary <string, object>(allheaders))); } else { results.Add(new MessageToReset <T>(_readColumn.ReadAsType <T>(CommandStringTypes.GetHeartBeatExpiredMessageIds, 0, reader), _readColumn.ReadAsDateTime(CommandStringTypes.GetHeartBeatExpiredMessageIds, 1, reader), null)); } } } } } return(results); }
/// <inheritdoc /> public T Handle(GetJobIdQuery <T> query) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetJobId); using (var reader = command.ExecuteReader()) { if (reader.Read()) { return(_readColumn.ReadAsType <T>(CommandStringTypes.GetJobId, 0, reader)); } } } } return(default);
public IEnumerable <T> Handle(FindExpiredMessagesToDeleteQuery <T> query) { if (query.Cancellation.IsCancellationRequested) { return(Enumerable.Empty <T>()); } var results = new List <T>(); var commandType = _options.Value.EnableStatus ? CommandStringTypes.FindExpiredRecordsWithStatusToDelete : CommandStringTypes.FindExpiredRecordsToDelete; 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, commandType); using (var reader = command.ExecuteReader()) { while (reader.Read()) { if (query.Cancellation.IsCancellationRequested) { break; } results.Add(_readColumn.ReadAsType <T>(commandType, 0, reader)); } } } } return(results); }