MessageQueueCriteria Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Фильтрует очереди сообщений при выполнении запроса с помощью MessageQueue метода класса GetPublicQueues() .
public ref class MessageQueueCriteria
public class MessageQueueCriteria
type MessageQueueCriteria = class
Public Class MessageQueueCriteria
- Наследование
-
MessageQueueCriteria
Примеры
В следующем примере выполняется итерацию по очередям сообщений и отображается путь к каждой очереди, созданной в последний день и существующей на компьютере "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
Комментарии
Класс MessageQueue предоставляет ряд методов, позволяющих фильтровать поиск общедоступных очередей в сети. Конкретные методы фильтрации по метки очереди, категории или расположению сервера — это GetPublicQueuesByLabelGetPublicQueuesByCategoryиGetPublicQueuesByMachine.
Класс MessageQueueCriteria , используемый с методом GetPublicQueues , позволяет уточнить фильтр. Вы можете указать критерии поиска, которые не рассматриваются специально с помощью одного из GetPublicQueuesByметодов * или несколькими критериями. Экземпляр можно передать MessageQueueCriteria в GetPublicQueues метод для поиска, например путем создания очереди или изменения времени, компьютера, на котором находится очередь, метка очереди или категория или любое сочетание этих свойств.
При фильтрации по нескольким свойствам критерии создаются путем применения AND оператора к набору свойств. Таким образом, при указании значения свойства CreatedAfter вместе со MachineName свойством запрашиваются все очереди, созданные после указанного времени, и которые находятся на определенном компьютере.
При установке любого свойства метод, который задает свойство, также задает флаг, указывающий, что он должен быть включен в создаваемый фильтр. Вы не можете удалить отдельные свойства из фильтра поиска. Вместо этого вы удаляете все свойства из фильтра путем вызова ClearAll, а затем задаете свойства, которые необходимо выполнить в фильтре поиска. ClearAll сбрасывает все свойства в состояние по умолчанию "не задано".
Прежде чем пытаться прочитать его, необходимо задать свойство; в противном случае создается исключение.
Конструкторы
| Имя | Описание |
|---|---|
| MessageQueueCriteria() |
Инициализирует новый экземпляр класса MessageQueueCriteria. |
Свойства
| Имя | Описание |
|---|---|
| Category |
Возвращает или задает категорию, по которой следует фильтровать очереди в сети. |
| CreatedAfter |
Возвращает или задает нижнюю границу даты и времени создания очереди, по которой следует фильтровать очереди в сети. |
| CreatedBefore |
Возвращает или задает верхнюю границу даты и времени создания очереди, по которой следует фильтровать очереди в сети. |
| Label |
Получает или задает метку, с помощью которой фильтруются очереди в сети. |
| MachineName |
Возвращает или задает имя компьютера, с помощью которого необходимо фильтровать очереди в сети. |
| ModifiedAfter |
Возвращает или задает нижнюю границу даты и времени изменения очереди, по которой следует фильтровать очереди в сети. |
| ModifiedBefore |
Возвращает или задает верхнюю границу даты и времени изменения очереди, по которой следует фильтровать очереди в сети. |
Методы
| Имя | Описание |
|---|---|
| ClearAll() |
Очищает все свойства от встроенного в фильтр и помещает все значения свойств в состояние "не задано". |
| Equals(Object) |
Определяет, равен ли указанный объект текущему объекту. (Унаследовано от Object) |
| GetHashCode() |
Служит хэш-функцией по умолчанию. (Унаследовано от Object) |
| GetType() |
Возвращает Type текущего экземпляра. (Унаследовано от Object) |
| MemberwiseClone() |
Создает неглубокую копию текущей Object. (Унаследовано от Object) |
| ToString() |
Возвращает строку, представляющую текущий объект. (Унаследовано от Object) |