Beispiel #1
0
 /// <inheritdoc />
 public int Handle(GetErrorRetryCountQuery <T> query)
 {
     using (var connection = _connectionFactory.Create())
     {
         connection.Open();
         using (var command = connection.CreateCommand())
         {
             _prepareQuery.Handle(query, command, CommandStringTypes.GetErrorRetryCount);
             using (var reader = command.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     return(_readColumn.ReadAsInt32(CommandStringTypes.GetErrorRetryCount, 0, reader));
                 }
             }
         }
     }
     return(0);
 }
        private QueueStatuses RunQuery(DoesJobExistQuery <TConnection, TTransaction> query, IDbConnection connection, IDbTransaction transaction)
        {
            var returnStatus = QueueStatuses.NotQueued;

            using (var command = connection.CreateCommand())
            {
                command.Transaction = transaction;
                _prepareQuery.Handle(query, command, CommandStringTypes.DoesJobExist);
                using (var reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        returnStatus =
                            (QueueStatuses)_readColumn.ReadAsInt32(CommandStringTypes.DoesJobExist, 0, reader);
                    }
                }

                if (returnStatus == QueueStatuses.NotQueued &&
                    _tableExists.Handle(new GetTableExistsQuery(_connectionInformation.ConnectionString,
                                                                _tableNameHelper.JobTableName)))
                {
                    command.CommandText =
                        _commandCache.GetCommand(CommandStringTypes.GetJobLastScheduleTime);
                    command.Transaction = transaction;
                    using (var reader = command.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            return(returnStatus);
                        }
                        var scheduleTime =
                            _readColumn.ReadAsDateTimeOffset(CommandStringTypes.GetJobLastScheduleTime, 0, reader);
                        if (scheduleTime == query.ScheduledTime)
                        {
                            return(QueueStatuses.Processed);
                        }
                    }
                }
            }
            return(returnStatus);
        }
        /// <inheritdoc />
        public Dictionary <string, int> Handle(GetMessageErrorsQuery <T> query)
        {
            var returnData = new Dictionary <string, int>();

            using (var connection = _connectionFactory.Create())
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    _prepareQuery.Handle(query, command, CommandStringTypes.GetMessageErrors);
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var errorType = _readColumn.ReadAsString(CommandStringTypes.GetMessageErrors, 0, reader).Trim();
                            var count     = _readColumn.ReadAsInt32(CommandStringTypes.GetMessageErrors, 1, reader);
                            returnData.Add(errorType, count);
                        }
                    }
                }
            }

            return(returnData);
        }