MSBTS_HostSetting.IsDefault 屬性 (WMI)

 

指示此 WMI 執行個體的 BizTalk 主控件,是否為 BizTalk 群組中的預設 BizTalk 主控件。

屬性宣告

所顯示的語法為非語言相關。

boolean IsDefault = FALSE;  

備註

這是一個讀寫屬性。

此屬性的預設值為 false

如需使用 MSBTS_HostSetting 類別的 範例程式碼,請參閱 使用 WMI 建立、更新和刪除主機實例

範例

下列範例取自 SDK\Samples\Admin\WMI\Enlist Orchestration\CSharp\EnlistOrc.cs 檔案。

  
static void Main(string[] args)  
{  
   try  
   {  
      //Make sure the expected number of arguments were provided on the command line.  
      //If not, print usage text and exit.  
      if (args.Length != 2)   
      {   
         PrintUsage();                 
         return;  
      }  
  
      else  
      {  
         //set up a WMI query to acquire a list of orchestrations with the given Name and   
         //AssemblyName key values.  This should be a list of zero or one Orchestrations.  
         //Create the WMI search object.  
         ManagementObjectSearcher Searcher = new ManagementObjectSearcher();  
  
         Console.WriteLine("Got the args");  
  
         // create the scope node so we can set the WMI root node correctly.  
         ManagementScope Scope = new ManagementScope("root\\MicrosoftBizTalkServer");  
         Searcher.Scope = Scope;  
  
         string HostName = "";  
  
         // Build a Query to enumerate the MSBTS_Orchestration instances with the  
         // specified name and assembly name.  
         SelectQuery Query = new SelectQuery();      
         Query.QueryString = "SELECT * FROM MSBTS_HostSetting WHERE IsDefault ='TRUE'";  
  
         // Set the query for the searcher.  
         Searcher.Query = Query;  
         ManagementObjectCollection QueryCol = Searcher.Get();   
  
         foreach (ManagementObject Inst in QueryCol)  
         {  
            //Get the default host name.  
            HostName = Inst.Properties["Name"].Value.ToString();  
  
            Console.WriteLine("The Orchestration will be enlisted with the default host: " + HostName + ".");  
         }  
  
         // Build a Query to enumerate the MSBTS_Orchestration instances with the  
         // specified name and assembly name.  
         Query.QueryString = "SELECT * FROM MSBTS_Orchestration WHERE Name = '" + args[0]+ "' AND AssemblyName = '" + args[1] + "'";  
  
         // Set the query for the searcher.  
         Searcher.Query = Query;  
         QueryCol = Searcher.Get();   
  
         // Use a bool to tell if we enter the for loop  
         // below because Count property is not supported  
         bool OrchestrationFound = false;  
  
         foreach (ManagementObject Inst in QueryCol)  
         {  
            // There is at least one Orchestration  
            OrchestrationFound = true;  
  
            ManagementBaseObject inParams = Inst.GetMethodParameters("Enlist");  
            //Fill in input parameter values  
            inParams["HostName"] = HostName;  
  
            //Execute the method  
            ManagementBaseObject outParams = Inst.InvokeMethod("Enlist",inParams,null);  
            Console.WriteLine("The Orchestration was successfully enlisted.");  
         }  
  
         if(!OrchestrationFound)  
         {  
            Console.WriteLine("No Orchestration found matching that Name and AssemblyName.");  
         }  
      }  
   }  
  
   catch(Exception excep)  
   {  
      Console.WriteLine("An exception occurred " + excep.Message);  
      Console.WriteLine(excep.StackTrace);  
   }  
  
   Console.WriteLine("\r\n\r\nPress Enter to continue...");  
   Console.Read();  
}  
  

下列範例取自 SDK\Samples\Admin\WMI\Enlist Orchestration\VBScript\EnlistOrch.vbs 檔案。

  
Sub EnlistOrch()  
   'Get the command line arguments entered for the script  
   Dim Args: Set Args = WScript.Arguments  
  
   'error handling is done by explicity checking the err object rather than using  
   'the VB ON ERROR construct, so set to resume next on error.  
   on error resume next  
  
   'Make sure the expected number of arguments were provided on the command line.  
   'if not, print usage text and exit.  
   If (Args.Count < 2) Or (Args.Count > 3) Then  
      PrintUsage()  
      wscript.quit 0  
   End If  
  
   Dim InstSet, Inst, Query, OrchestrationName, AssemblyName, HostName, Start  
  
   OrchestrationName = Args(0)  
   AssemblyName = Args(1)  
  
   'Check if orchestration is to be started  
   If (Args.Count = 3) Then  
      If ("Start" = Args(2)) Then  
         Start = True  
      Else  
         wscript.echo "Wrong optional flag."  
         PrintUsage()  
         wscript.quit 0  
      End If  
   End If  
  
   'set up a WMI query to acquire a list of defaul inprocess hosts  
   'This should be a list of zero or one host.  
   Query = "SELECT * FROM MSBTS_HostSetting WHERE IsDefault =""TRUE"""  
   Set InstSet = GetObject("Winmgmts:!root\MicrosoftBizTalkServer").ExecQuery(Query)  
  
   'Check for error condition before continuing.  
   If Err <> 0 Then  
      PrintWMIErrorthenExit Err.Description, Err.Number  
   End If  
  
   'if Default Host found, get Host Name and NT Group Name.  There is only one default host.  
   If InstSet.Count > 0 Then  
      For Each Inst In InstSet  
         HostName = Inst.Name  
         If Err <> 0   Then  
            PrintWMIErrorthenExit Err.Description, Err.Number  
         End If  
         wscript.echo "Using default inprocess host " & HostName & "."  
      Next  
   End If  
  
   'set up a WMI query to acquire a list of orchestrations with the given Name and   
   'AssemblyName key values.  This should be a list of zero or one Orchestrations.  
   Query = "SELECT * FROM MSBTS_Orchestration WHERE Name =""" & OrchestrationName & """ AND AssemblyName = """ & AssemblyName & """"  
   Set InstSet = GetObject("Winmgmts:!root\MicrosoftBizTalkServer").ExecQuery(Query)  
  
   'Check for error condition before continuing.  
   If Err <> 0   Then  
      PrintWMIErrorThenExit Err.Description, Err.Number  
   End If  
  
   'If orchestration found, enlist the orchestration, otherwise print error and end.  
   If InstSet.Count > 0 then  
      For Each Inst in InstSet  
         Inst.Enlist(HostName)  
         If Err <> 0   Then  
            PrintWMIErrorThenExit Err.Description, Err.Number  
         End If  
         wscript.echo "The Orchestration was successfully enlisted."  
  
         If Start Then  
            Inst.Start 2, 2  
            If Err <> 0   Then  
               PrintWMIErrorThenExit Err.Description, Err.Number  
            End If  
            wscript.echo "The Orchestration was successfully started."  
         End If  
      Next  
   Else  
      wscript.echo "No orchestration was found matching that Name and AssemblyName."  
   End If  
  
End Sub  
  

規格需求

頭: 在 BTSWMISchemaXP.mof 中宣告。

命名空間: 包含在 \root\MicrosoftBizTalkServer 中。