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 、ネットワーク上のパブリック キューの検索をフィルター処理できるメソッドが多数用意されています。 キュー ラベル、カテゴリ、またはサーバーの場所でフィルター処理するための特定の GetPublicQueuesByLabelメソッドは、、 GetPublicQueuesByCategory、および GetPublicQueuesByMachineです。

クラスを MessageQueueCriteria メソッドと共に GetPublicQueues 使用すると、フィルターを絞り込むことができます。 *メソッドの 1 つ、または複数の条件を使用して、特に 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)

適用対象

こちらもご覧ください