Sdílet prostřednictvím


MessageQueueCriteria Třída

Definice

Filtruje fronty zpráv při provádění dotazu pomocí MessageQueue metody třídy GetPublicQueues() .

public ref class MessageQueueCriteria
public class MessageQueueCriteria
type MessageQueueCriteria = class
Public Class MessageQueueCriteria
Dědičnost
MessageQueueCriteria

Příklady

Následující příklad iteruje fronty zpráv a zobrazí cestu ke každé frontě, která byla vytvořena v posledním dni a která existuje v počítači 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

Poznámky

Třída MessageQueue poskytuje řadu metod, které umožňují filtrovat vyhledávání veřejných front v síti. Specifické metody filtrování podle popisku fronty, kategorie nebo umístění serveru jsou GetPublicQueuesByLabel, GetPublicQueuesByCategorya GetPublicQueuesByMachine.

Třída MessageQueueCriteria , při použití s metodou GetPublicQueues , umožňuje upřesnit filtr. Můžete zadat kritéria hledání, která nejsou konkrétně adresována některou z GetPublicQueuesBymetod * nebo více kritérií. Instanci můžete předat MessageQueueCriteria do GetPublicQueues metody, aby bylo možné vyhledávat, například vytvořením fronty nebo úpravami časů, počítače, na kterém se fronta nachází, popisek fronty nebo kategorie nebo libovolnou kombinaci těchto vlastností.

Při filtrování podle více vlastností se kritéria skládají použitím operátoru AND na sadu vlastností. Pokud tedy zadáte hodnotu vlastnosti CreatedAfter společně s MachineName vlastností, žádáte o všechny fronty, které byly vytvořeny po zadaném čase a které se nacházejí v určitém počítači.

Když nastavíte libovolnou vlastnost, metoda, která nastaví vlastnost, nastaví také příznak, který označuje, že by měl být součástí filtru, který vytváříte. Z vyhledávacího filtru nelze odebrat jednotlivé vlastnosti. Místo toho odeberete všechny vlastnosti z filtru voláním ClearAlla pak nastavíte vlastnosti, které chcete sečíst do vyhledávacího filtru. ClearAll obnoví všechny vlastnosti do výchozího stavu nenastavěné.

Před pokusem o přečtení je nutné nastavit vlastnost; v opačném případě je vyvolán výjimka.

Konstruktory

Name Description
MessageQueueCriteria()

Inicializuje novou instanci MessageQueueCriteria třídy.

Vlastnosti

Name Description
Category

Získá nebo nastaví kategorii, podle které chcete filtrovat fronty v síti.

CreatedAfter

Získá nebo nastaví dolní hranici data a času vytvoření fronty, podle kterých se mají filtrovat fronty v síti.

CreatedBefore

Získá nebo nastaví horní hranici data a času vytvoření fronty, podle kterých se mají filtrovat fronty v síti.

Label

Získá nebo nastaví popisek, podle kterého chcete filtrovat fronty v síti.

MachineName

Získá nebo nastaví název počítače, podle kterého chcete filtrovat fronty v síti.

ModifiedAfter

Získá nebo nastaví dolní hranici data a času úpravy fronty, podle kterých se mají filtrovat fronty v síti.

ModifiedBefore

Získá nebo nastaví horní hranici data a času úpravy fronty, podle kterých se mají filtrovat fronty v síti.

Metody

Name Description
ClearAll()

Vymaže všechny vlastnosti, aby byly integrované do filtru, a vloží všechny hodnoty vlastností do stavu "nenastavováno".

Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Type Získá aktuální instanci.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také