MessageQueueCriteria Classe
Definição
Filtra filas de mensagens ao executar uma consulta usando a classe MessageQueue, método GetPublicQueues().Filters message queues when performing a query using the MessageQueue class's GetPublicQueues() method.
public ref class MessageQueueCriteria
public class MessageQueueCriteria
type MessageQueueCriteria = class
Public Class MessageQueueCriteria
- Herança
-
MessageQueueCriteria
Exemplos
O exemplo a seguir itera em filas de mensagens e exibe o caminho de cada fila que foi criada no último dia e que existe no computador "MyComputer".The following example iterates through message queues and displays the path of each queue that was created in the last day and that exists on the computer "MyComputer".
#using <system.dll>
#using <system.messaging.dll>
using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:
// Iterates through message queues and displays the
// path of each queue that was created in the last
// day and that exists on the computer "MyComputer".
void ListPublicQueuesByCriteria()
{
UInt32 numberQueues = 0;
// Specify the criteria to filter by.
MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
myCriteria->MachineName = "MyComputer";
myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
// Get a cursor into the queues on the network.
MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator( myCriteria );
// Move to the next queue and read its path.
while ( myQueueEnumerator->MoveNext() )
{
// Increase the count if priority is Lowest.
Console::WriteLine( myQueueEnumerator->Current->Path );
numberQueues++;
}
// Handle no queues matching the criteria.
if ( numberQueues == 0 )
{
Console::WriteLine( "No public queues match criteria." );
}
return;
}
};
int main()
{
// Create a new instance of the class.
MyNewQueue^ myNewQueue = gcnew MyNewQueue;
// Output the count of Lowest priority messages.
myNewQueue->ListPublicQueuesByCriteria();
return 0;
}
using System;
using System.Messaging;
namespace MyProject
{
/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
//**************************************************
// Provides an entry point into the application.
//
// This example uses a cursor to step through the
// message queues and list the public queues on the
// network that specify certain criteria.
//**************************************************
public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue();
// Output the count of Lowest priority messages.
myNewQueue.ListPublicQueuesByCriteria();
return;
}
//**************************************************
// Iterates through message queues and displays the
// path of each queue that was created in the last
// day and that exists on the computer "MyComputer".
//**************************************************
public void ListPublicQueuesByCriteria()
{
uint numberQueues = 0;
// Specify the criteria to filter by.
MessageQueueCriteria myCriteria = new
MessageQueueCriteria();
myCriteria.MachineName = "MyComputer";
myCriteria.CreatedAfter = DateTime.Now.Subtract(new
TimeSpan(1,0,0,0));
// Get a cursor into the queues on the network.
MessageQueueEnumerator myQueueEnumerator =
MessageQueue.GetMessageQueueEnumerator(myCriteria);
// Move to the next queue and read its path.
while(myQueueEnumerator.MoveNext())
{
// Increase the count if priority is Lowest.
Console.WriteLine(myQueueEnumerator.Current.Path);
numberQueues++;
}
// Handle no queues matching the criteria.
if (numberQueues == 0)
{
Console.WriteLine("No public queues match criteria.");
}
return;
}
}
}
Imports System.Messaging
Public Class MyNewQueue
'
' Provides an entry point into the application.
'
' This example uses a cursor to step through the
' message queues and list the public queues on the
' network that specify certain criteria.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
' Output the count of Lowest priority messages.
myNewQueue.ListPublicQueuesByCriteria()
Return
End Sub
' Iterates through message queues and displays the
' path of each queue that was created in the last
' day and that exists on the computer "MyComputer".
Public Sub ListPublicQueuesByCriteria()
Dim numberQueues As Int32 = 0
' Specify the criteria to filter by.
Dim myCriteria As New MessageQueueCriteria()
myCriteria.MachineName = "MyComputer"
myCriteria.CreatedAfter = DateTime.Now.Subtract(New _
TimeSpan(1, 0, 0, 0))
' Get a cursor into the queues on the network.
Dim myQueueEnumerator As MessageQueueEnumerator = _
MessageQueue.GetMessageQueueEnumerator(myCriteria)
' Move to the next queue and read its path.
While myQueueEnumerator.MoveNext()
' Increase the count if the priority is Lowest.
Console.WriteLine(myQueueEnumerator.Current.Path)
numberQueues += 1
End While
' Handle no queues matching the criteria.
If numberQueues = 0 Then
Console.WriteLine("No queues match the criteria.")
End If
Return
End Sub
End Class
Comentários
A MessageQueue classe fornece vários métodos que permitem filtrar sua pesquisa de filas públicas na rede.The MessageQueue class provides a number of methods that enable you to filter your search for public queues on the network. Métodos específicos para filtragem por rótulo de fila, categoria ou local do servidor são os GetPublicQueuesByLabel , GetPublicQueuesByCategory e GetPublicQueuesByMachine .Specific methods for filtering by queue label, category, or server location are the GetPublicQueuesByLabel, GetPublicQueuesByCategory, and GetPublicQueuesByMachine.
A MessageQueueCriteria classe, quando usada com o GetPublicQueues método, permite refinar seu filtro.The MessageQueueCriteria class, when used with the GetPublicQueues method, allows you to refine your filter. Você pode especificar critérios de pesquisa não especificamente abordados por um dos GetPublicQueuesBy métodos * ou por vários critérios.You can specify search criteria not specifically addressed through one of the GetPublicQueuesBy* methods, or by multiple criteria. Você pode passar uma MessageQueueCriteria instância para o GetPublicQueues método a fim de Pesquisar, por exemplo, pela criação da fila ou tempos de modificação, o computador em que a fila reside, o rótulo ou a categoria da fila ou qualquer combinação dessas propriedades.You can pass a MessageQueueCriteria instance into the GetPublicQueues method in order to search, for example, by queue creation or modification times, the computer the queue resides on, the queue label or category, or any combination of these properties.
Ao filtrar por várias propriedades, os critérios são compostos pela aplicação do AND operador ao conjunto de propriedades.When filtering by multiple properties, the criteria are composed by applying the AND operator to the set of properties. Assim, quando você especifica um valor para a CreatedAfter Propriedade junto com a MachineName propriedade, você está solicitando todas as filas que foram criadas após uma hora especificada e que residem em um computador específico.Thus, when you specify a value for the CreatedAfter property together with the MachineName property, you are asking for all queues that were created after a specified time and that reside on a specific computer.
Quando você define qualquer propriedade, o método que define a propriedade também define um sinalizador para indicar que ele deve ser incluído no filtro que você está criando.When you set any property, the method that sets the property also sets a flag to indicate that it should be included in the filter you are building. Não é possível remover propriedades individuais do filtro de pesquisa.You cannot remove individual properties from the search filter. Em vez disso, você remove todas as propriedades do filtro chamando ClearAll e, em seguida, define as propriedades que você deseja criar no filtro de pesquisa.Instead, you remove all properties from the filter by calling ClearAll, and then set the properties that you do want to build into the search filter. ClearAll Redefine todas as propriedades em um estado padrão "não definido".ClearAll resets all properties into a "not set" default state.
Você deve definir uma propriedade antes de tentar lê-la; caso contrário, uma exceção será lançada.You must set a property before trying to read it; otherwise, an exception is thrown.
Construtores
| MessageQueueCriteria() |
Inicializa uma nova instância da classe MessageQueueCriteria.Initializes a new instance of the MessageQueueCriteria class. |
Propriedades
| Category |
Obtém ou define a categoria pelo qual filtrar filas na rede.Gets or sets the category by which to filter queues in the network. |
| CreatedAfter |
Obtém ou define o limite inferior da data e hora de criação da fila pela qual filtrar as filas na rede.Gets or sets the lower boundary of the queue creation date and time by which to filter queues on the network. |
| CreatedBefore |
Obtém ou define o limite superior da data e hora de criação da fila pelas quais filtrar as filas na rede.Gets or sets the upper boundary of the queue creation date and time by which to filter queues on the network. |
| Label |
Obtém ou define o rótulo pelo qual filtrar as filas na rede.Gets or sets the label by which to filter queues in the network. |
| MachineName |
Obtém ou define o nome do computador pelo qual filtrar as filas na rede.Gets or sets the computer name by which to filter queues in the network. |
| ModifiedAfter |
Obtém ou define o limite inferior da data e hora de modificação da fila pela qual filtrar as filas na rede.Gets or sets the lower boundary of the queue modification date and time by which to filter queues on the network. |
| ModifiedBefore |
Obtém ou define o limite superior da data e hora de modificação da fila pelas quais filtrar as filas na rede.Gets or sets the upper boundary of the queue modification date and time by which to filter queues on the network. |
Métodos
| ClearAll() |
Remove todas as propriedades para que não fiquem internas a um filtro e coloca todos os valores de propriedade em um estado "não configurado".Clears all properties from being built into a filter and puts all property values into a "not set" state. |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |