共用方式為


MSBTS_HostSetting.Name 屬性 (WMI)

 

包含 BizTalk 主機的名稱。

屬性宣告

顯示的語法是語言中性。

string Name;  

備註

建立實例時需要這個屬性。 這個屬性可在實例建立時寫入。 實例建立之後,這個屬性是唯讀的。

此屬性具有 金鑰 限定符。 除了 MgmtDbNameOverrideMgmtDbServerOverride,此索引鍵會形成 類別的複合索引鍵。

此屬性的最大長度為80個字元。

如需使用 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 中宣告。

Namespace: 包含在 \root\MicrosoftBizTalkServer 中。