Freigeben über


MessageQueueCriteria-Klasse

Filtert Meldungswarteschlangen beim Durchführen einer Abfrage mit der GetPublicQueues-Methode der MessageQueue-Klasse.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

Syntax

'Declaration
Public Class MessageQueueCriteria
'Usage
Dim instance As MessageQueueCriteria
public class MessageQueueCriteria
public ref class MessageQueueCriteria
public class MessageQueueCriteria
public class MessageQueueCriteria

Hinweise

Die MessageQueue-Klasse stellt mehrere Methoden bereit, mit denen Filter zum Suchen von öffentlichen Warteschlangen im Netzwerk angegeben werden können. Spezifische Methoden zum Filtern nach Bezeichnung, Kategorie oder Serverstandort der Warteschlange sind GetPublicQueuesByLabel, GetPublicQueuesByCategory und GetPublicQueuesByMachine.

Die MessageQueueCriteria-Klasse ermöglicht beim Verwenden mit der GetPublicQueues-Methode das Anpassen der Filter. Sie können andere nicht über die GetPublicQueuesBy-Methoden verfügbare Suchkriterien oder mehrere Kriterien angeben. Sie können eine MessageQueueCriteria-Instanz an die GetPublicQueues-Methode übergeben und so z. B. nach der Erstellungs- oder Änderungszeit der Warteschlange, nach dem Computer, auf dem sich die Warteschlange befindet, nach der Bezeichnung oder Kategorie der Warteschlange oder nach einer Kombination dieser Eigenschaften suchen.

Beim Filtern anhand mehrerer Eigenschaften werden die Kriterien zusammengestellt, indem der AND-Operator auf die Gruppe von Eigenschaften angewendet wird. Wenn Sie einen Wert für die CreatedAfter-Eigenschaft und die MachineName-Eigenschaft angeben, wird daher nach allen Warteschlangen gesucht, die nach einem angegebenen Datum erstellt wurden und sich auf einem bestimmten Computer befinden.

Wenn Sie eine Eigenschaft festlegen, legt die die Eigenschaft festlegende Methode zusätzlich ein Flag fest und zeigt damit an, dass die Eigenschaft in den zurzeit erstellten Filter aufgenommen werden soll. Sie können keine einzelnen Eigenschaften aus dem Suchfilter entfernen. Stattdessen müssen Sie durch einen Aufruf von ClearAll alle Eigenschaften aus dem Filter entfernen und dann die Eigenschaften festlegen, die im Suchfilter enthalten sein sollen. ClearAll setzt alle Eigenschaften auf den Standardwert (nicht festgelegt) zurück.

Sie müssen vor einem Leseversuchen eine Eigenschaft festlegen, andernfalls wird eine Ausnahme ausgelöst.

Beispiel

Im folgenden Beispiel werden Meldungswarteschlangen durchlaufen und die Pfade aller Warteschlangen angezeigt, die am vergangenen Tag erstellt wurden und auf dem Computer "MyComputer" vorhanden sind.

Imports System
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 'Main


        
        ' 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 'ListPublicQueuesByCriteria

End Class 'MyNewQueue
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;
        }
    }
}
#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;
}
package MyProject;

import System.*;
import System.Messaging.*;

/// <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(String[] args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Output the count of Lowest priority messages.
        myNewQueue.ListPublicQueuesByCriteria();
        return;
    } //main

    //**************************************************
    // 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()
    {
        long numberQueues = 0;        
        // Specify the criteria to filter by.
        MessageQueueCriteria myCriteria = new MessageQueueCriteria();
        myCriteria.set_MachineName("MyComputer");
        myCriteria.set_CreatedAfter(DateTime.get_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.get_Current().get_Path());
            numberQueues++;
        }
        // Handle no queues matching the criteria.
        if (numberQueues == 0) {
            Console.WriteLine("No public queues match criteria.");
        }
        return;
    } //ListPublicQueuesByCriteria
} //MyNewQueue

Vererbungshierarchie

System.Object
  System.Messaging.MessageQueueCriteria

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MessageQueueCriteria-Member
System.Messaging-Namespace
GetPublicQueues
GetPublicQueuesByMachine
GetPublicQueuesByLabel
GetPublicQueuesByCategory