/// <inheritdoc /> public IDictionary <string, object> Handle(GetHeaderQuery query) { using (var connection = _connectionFactory.Create()) { connection.Open(); using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetHeader); using (var reader = command.ExecuteReader()) { if (!reader.Read()) { return(null); } var headerRaw = _readColumn.ReadAsByteArray(CommandStringTypes.GetHeader, 0, reader); if (headerRaw != null) { return(_serialization.InternalSerializer .ConvertBytesTo <IDictionary <string, object> >( headerRaw)); } } } } return(null); }
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); }
public TTransportOptions Handle(GetQueueOptionsQuery <TTransportOptions> query) { if (!_tableExists.Handle(new GetTableExistsQuery(_connectionInformation.ConnectionString, _tableNameHelper.ConfigurationName))) { return(null); } using (var conn = _dbConnectionFactory.Create()) { conn.Open(); using (var command = conn.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetConfiguration); using (var reader = command.ExecuteReader()) { return(!reader.Read() ? null : _serializer.ConvertBytesTo <TTransportOptions>(_readColumn.ReadAsByteArray(CommandStringTypes.GetConfiguration, 0, reader))); } } } }