/// <inheritdoc /> public DateTime Handle(GetUtcDateQuery query) { using (var connection = _dbConnectionFactory.Create()) { connection.Open(); using (var command = connection.CreateCommand()) { _prepareQuery.Handle(query, command, CommandStringTypes.GetUtcDate); using (var reader = command.ExecuteReader()) { if (reader.Read()) { return(_readColumn.ReadAsDateTime(CommandStringTypes.GetUtcDate, 0, reader)); } throw new DotNetWorkQueueException("Failed to obtain the UTC date from the server"); } } } }
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 IEnumerable <MessageToReset> Handle(FindMessagesToResetByHeartBeatQuery query) { var results = new List <MessageToReset>(); 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; } results.Add(new MessageToReset(_readColumn.ReadAsInt64(CommandStringTypes.GetHeartBeatExpiredMessageIds, 0, reader), _readColumn.ReadAsDateTime(CommandStringTypes.GetHeartBeatExpiredMessageIds, 1, reader))); } } } } return(results); }