MessageQueueCriteria MessageQueueCriteria MessageQueueCriteria MessageQueueCriteria Class

定義

在使用 MessageQueue 類別的 GetPublicQueues() 方法執行查詢時,篩選訊息佇列。Filters message queues when performing a query using the MessageQueue class's GetPublicQueues() method.

public ref class MessageQueueCriteria
public class MessageQueueCriteria
type MessageQueueCriteria = class
Public Class MessageQueueCriteria
繼承
MessageQueueCriteriaMessageQueueCriteriaMessageQueueCriteriaMessageQueueCriteria

範例

下列範例會逐一查看訊息佇列, 並顯示過去一天內所建立且存在於電腦 "MyComputer" 上的每個佇列的路徑。The following example 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".

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

備註

MessageQueue類別提供數種方法, 可讓您篩選搜尋網路上的公用佇列。The MessageQueue class provides a number of methods that enable you to filter your search for public queues on the network. 依佇列標籤、類別目錄或伺服器位置GetPublicQueuesByLabel篩選的特定方法為、 GetPublicQueuesByCategory和。 GetPublicQueuesByMachineSpecific methods for filtering by queue label, category, or server location are the GetPublicQueuesByLabel, GetPublicQueuesByCategory, and GetPublicQueuesByMachine.

MessageQueueCriteria類別GetPublicQueues與方法搭配使用時, 可讓您精簡篩選準則。The MessageQueueCriteria class, when used with the GetPublicQueues method, allows you to refine your filter. 您可以指定不是透過其中一個GetPublicQueuesBy* 方法或多個準則來特別定址的搜尋準則。You can specify search criteria not specifically addressed through one of the GetPublicQueuesBy* methods, or by multiple criteria. 您可以將MessageQueueCriteria實例傳遞GetPublicQueues至方法, 以便搜尋佇列建立或修改時間、佇列所在的電腦、佇列標籤或類別, 或這些屬性的任何組合。You can pass a MessageQueueCriteria instance into the GetPublicQueues method in order to search, for example, by queue creation or modification times, the computer the queue resides on, the queue label or category, or any combination of these properties.

依多個屬性篩選時, 會將AND運算子套用至屬性集來組成條件。When filtering by multiple properties, the criteria are composed by applying the AND operator to the set of properties. 因此, 當您將CreatedAfter屬性的值MachineName與屬性一起指定時, 您會要求在指定的時間之後, 以及位於特定電腦上的所有佇列。Thus, when you specify a value for the CreatedAfter property together with the MachineName property, you are asking for all queues that were created after a specified time and that reside on a specific computer.

當您設定任何屬性時, 設定屬性的方法也會設定旗標, 指出它應該包含在您所建立的篩選中。When you set any property, the method that sets the property also sets a flag to indicate that it should be included in the filter you are building. 您無法從搜尋篩選中移除個別的屬性。You cannot remove individual properties from the search filter. 相反地, 您可以藉由呼叫ClearAll, 從篩選中移除所有屬性, 然後將您想要建立的屬性設定為搜尋篩選準則。Instead, you remove all properties from the filter by calling ClearAll, and then set the properties that you do want to build into the search filter. ClearAll將所有屬性重設為「未設定」預設狀態。ClearAll resets all properties into a "not set" default state.

您必須先設定屬性, 然後再嘗試讀取它。否則, 就會擲回例外狀況。You must set a property before trying to read it; otherwise, an exception is thrown.

建構函式

MessageQueueCriteria() MessageQueueCriteria() MessageQueueCriteria() MessageQueueCriteria()

初始化 MessageQueueCriteria 類別的新執行個體。Initializes a new instance of the MessageQueueCriteria class.

屬性

Category Category Category Category

取得或設定用來在網路上篩選佇列的分類。Gets or sets the category by which to filter queues in the network.

CreatedAfter CreatedAfter CreatedAfter CreatedAfter

取得或設定用來在網路上篩選佇列的佇列建立日期和時間之下限。Gets or sets the lower boundary of the queue creation date and time by which to filter queues on the network.

CreatedBefore CreatedBefore CreatedBefore CreatedBefore

取得或設定用來在網路上篩選佇列之佇列建立日期和時間上限。Gets or sets the upper boundary of the queue creation date and time by which to filter queues on the network.

Label Label Label Label

取得或設定用來在網路上篩選佇列的標記。Gets or sets the label by which to filter queues in the network.

MachineName MachineName MachineName MachineName

取得或設定用來在網路上篩選佇列的電腦名稱。Gets or sets the computer name by which to filter queues in the network.

ModifiedAfter ModifiedAfter ModifiedAfter ModifiedAfter

取得或設定用來在網路上篩選佇列的佇列修改日期和時間之下限。Gets or sets the lower boundary of the queue modification date and time by which to filter queues on the network.

ModifiedBefore ModifiedBefore ModifiedBefore ModifiedBefore

取得或設定用來在網路上篩選佇列的佇列修改日期和時間之上限。Gets or sets the upper boundary of the queue modification date and time by which to filter queues on the network.

方法

ClearAll() ClearAll() ClearAll() ClearAll()

清除所有內建在篩選條件中的屬性,並將所有屬性設為「未設定」狀態。Clears all properties from being built into a filter and puts all property values into a "not set" state.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱