MessageQueueCriteria Kelas

Definisi

Memfilter antrean pesan saat melakukan kueri menggunakan MessageQueue metode kelas GetPublicQueues() .

public ref class MessageQueueCriteria
public class MessageQueueCriteria
type MessageQueueCriteria = class
Public Class MessageQueueCriteria
Warisan
MessageQueueCriteria

Contoh

Contoh berikut berulang melalui antrean pesan dan menampilkan jalur setiap antrean yang dibuat pada hari terakhir dan yang ada di komputer "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

Keterangan

Kelas ini MessageQueue menyediakan sejumlah metode yang memungkinkan Anda memfilter pencarian antrean publik di jaringan. Metode khusus untuk pemfilteran menurut label antrean, kategori, atau lokasi server adalah GetPublicQueuesByLabel, , GetPublicQueuesByCategorydan GetPublicQueuesByMachine.

Kelas MessageQueueCriteria , ketika digunakan dengan GetPublicQueues metode , memungkinkan Anda untuk memperbaiki filter Anda. Anda dapat menentukan kriteria pencarian yang tidak secara khusus ditangani melalui salah GetPublicQueuesBysatu metode * , atau dengan beberapa kriteria. Anda dapat meneruskan MessageQueueCriteria instans ke dalam GetPublicQueues metode untuk mencari, misalnya, dengan waktu pembuatan atau modifikasi antrean, komputer tempat antrean berada, label atau kategori antrean, atau kombinasi properti ini.

Saat memfilter menurut beberapa properti, kriteria terdiri dengan menerapkan AND operator ke kumpulan properti. Dengan demikian, ketika Anda menentukan nilai untuk CreatedAfter properti bersama dengan MachineName properti , Anda meminta semua antrean yang dibuat setelah waktu yang ditentukan dan yang berada di komputer tertentu.

Saat Anda mengatur properti apa pun, metode yang mengatur properti juga mengatur bendera untuk menunjukkan bahwa properti tersebut harus disertakan dalam filter yang Anda bangun. Anda tidak dapat menghapus properti individual dari filter pencarian. Sebagai gantinya, Anda menghapus semua properti dari filter dengan memanggil ClearAll, lalu mengatur properti yang ingin Anda buat ke dalam filter pencarian. ClearAll mengatur ulang semua properti ke dalam status default "tidak diatur".

Anda harus mengatur properti sebelum mencoba membacanya; jika tidak, pengecualian dilemparkan.

Konstruktor

MessageQueueCriteria()

Menginisialisasi instans baru kelas MessageQueueCriteria.

Properti

Category

Mendapatkan atau mengatur kategori untuk memfilter antrean dalam jaringan.

CreatedAfter

Mendapatkan atau mengatur batas bawah tanggal dan waktu pembuatan antrean untuk memfilter antrean di jaringan.

CreatedBefore

Mendapatkan atau mengatur batas atas tanggal dan waktu pembuatan antrean untuk memfilter antrean pada jaringan.

Label

Mendapatkan atau mengatur label untuk memfilter antrean dalam jaringan.

MachineName

Mendapatkan atau mengatur nama komputer untuk memfilter antrean dalam jaringan.

ModifiedAfter

Mendapatkan atau mengatur batas bawah tanggal dan waktu modifikasi antrean untuk memfilter antrean di jaringan.

ModifiedBefore

Mendapatkan atau mengatur batas atas tanggal dan waktu modifikasi antrean untuk memfilter antrean di jaringan.

Metode

ClearAll()

Menghapus semua properti agar tidak dibangun ke dalam filter dan menempatkan semua nilai properti ke dalam status "tidak ditetapkan".

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga