Exemplo n.º 1
0
        public List <QueueInfo> SelectQueues(out string errorMessage)
        {
            errorMessage = string.Empty;
            List <QueueInfo> list = new List <QueueInfo>();
            string           sql  = SqlScripts.SelectQueuesScript();

            {
                SqlDataReader reader     = null;
                SqlConnection connection = new SqlConnection(ConnectionString);
                SqlCommand    command    = connection.CreateCommand();
                command.CommandType = CommandType.Text;
                command.CommandText = sql;
                try
                {
                    connection.Open();
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        QueueInfo queue = new QueueInfo()
                        {
                            Name                  = reader.IsDBNull("name") ? string.Empty : reader.GetString("name"),
                            Status                = reader.IsDBNull("is_enqueue_enabled") ? false : reader.GetBoolean("is_enqueue_enabled"),
                            Retention             = reader.IsDBNull("is_retention_enabled") ? false : reader.GetBoolean("is_retention_enabled"),
                            Activation            = reader.IsDBNull("is_activation_enabled") ? false : reader.GetBoolean("is_activation_enabled"),
                            ProcedureName         = reader.IsDBNull("activation_procedure") ? string.Empty : reader.GetString("activation_procedure"),
                            MaxQueueReaders       = reader.IsDBNull("max_readers") ? (short)0 : reader.GetInt16("max_readers"),
                            PoisonMessageHandling = reader.IsDBNull("is_poison_message_handling_enabled") ? false : reader.GetBoolean("is_poison_message_handling_enabled")
                        };
                        queue.Name = string.IsNullOrWhiteSpace(queue.Name) ? string.Empty : GetQueueName(queue.Name);
                        list.Add(queue);
                    }
                }
                catch (Exception error)
                {
                    errorMessage = ExceptionHelper.GetErrorText(error);
                }
                finally
                {
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            command.Cancel();
                        }
                        reader.Dispose();
                    }
                    if (command != null)
                    {
                        command.Dispose();
                    }
                    if (connection != null)
                    {
                        connection.Dispose();
                    }
                }
            }
            return(list);
        }