有没有办法通过代码自动打开或关闭BizTalk接收位置?

有没有办法自动打开或关闭BizTalk中的接收位置? 似乎应该有某种API或某些类似的东西。 我更喜欢在C#中工作,但WMI或某种脚本也可以工作。

除了ExplorerOM之外,您还可以使用WMI启用/禁用接收位置(以及控制发送端口)。

我有一个示例PowerShell脚本,如果您感兴趣,可以在此处显示如何执行这些操作。

我找到了解决方案。 似乎Microsoft.BizTalk.ExplorerOM.dll是我想要的。 以下是BizTalk文档的摘录,应该让其他人开始:

using System; using Microsoft.BizTalk.ExplorerOM; public static void EnumerateOrchestrationArtifacts() { // Connect to the local BizTalk Management database BtsCatalogExplorer catalog = new BtsCatalogExplorer(); catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;"; // Enumerate all orchestrations and their ports/roles Console.WriteLine("ORCHESTRATIONS: "); foreach(BtsAssembly assembly in catalog.Assemblies) { foreach(BtsOrchestration orch in assembly.Orchestrations) { Console.WriteLine(" Name:{0}\r\n Host:{1}\r\n Status:{2}", orch.FullName, orch.Host.Name, orch.Status); // Enumerate ports and operations foreach(OrchestrationPort port in orch.Ports) { Console.WriteLine("\t{0} ({1})", port.Name, port.PortType.FullName); foreach(PortTypeOperation operation in port.PortType.Operations) { Console.WriteLine("\t\t" + operation.Name); } } // Enumerate used roles foreach(Role role in orch.UsedRoles) { Console.WriteLine("\t{0} ({1})", role.Name, role.ServiceLinkType); foreach(EnlistedParty enlistedparty in role.EnlistedParties) { Console.WriteLine("\t\t" + enlistedparty.Party.Name); } } // Enumerate implemented roles foreach(Role role in orch.ImplementedRoles) { Console.WriteLine("\t{0} ({1})", role.Name, role.ServiceLinkType); } } } } 

一个警告,显然这个DLL不支持64位。 由于我只编写一个简单的实用程序,对我来说并不是什么大问题(只是编译为32位),但需要注意的是。

很高兴看到你似乎找到了解决方案。

想要提一个类似的替代品,它也使用Powershell,ExplorerOM和BizTalk API将BizTalk工件设置为各种状态。

接收地点就是其中之一。

该脚本接受XML配置文件,您可以在其中列出工件以及要将其设置为的状态。

该脚本已发布到Microsoft Script Center: http : //gallery.technet.microsoft.com/scriptcenter/Set-Artifact-Status-270f43a0

回应Alhambraeidos的评论。 以下是我在Windows应用程序中用于远程禁用接收位置的一些代码摘录:

  ///  /// Gets or sets the biz talk catalog. ///  /// The biz talk catalog. private BtsCatalogExplorer BizTalkCatalog { get; set; } ///  /// Initializes the biz talk artifacts. ///  private void InitializeBizTalkCatalogExplorer() { // Connect to the local BizTalk Management database BizTalkCatalog = new BtsCatalogExplorer(); BizTalkCatalog.ConnectionString = "server=BiztalkDbServer;database=BizTalkMgmtDb;integrated security=true"; } ///  /// Gets the location from biz talk. ///  /// Name of the location. ///  private ReceiveLocation GetLocationFromBizTalk(string locationName) { ReceivePortCollection receivePorts = BizTalkCatalog.ReceivePorts; foreach (ReceivePort port in receivePorts) { foreach (ReceiveLocation location in port.ReceiveLocations) { if (location.Name == locationName) { return location; } } } throw new ApplicationException("The following receive location could not be found in the BizTalk Database: " + locationName); } ///  /// Turns the off receive location. ///  /// Name of the vendor. public void TurnOffReceiveLocation(string vendorName) { ReceiveLocation location = Locations[vendorName].ReceiveLocation; location.Enable = false; BizTalkCatalog.SaveChanges(); } 

你会注意到我遗漏了一些东西,比如我正在创建一个名为“Locations”的接收位置字典,但你应该能够理解。 对于要与之交互的任何BizTalk对象,该模式非常适用。