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

发布于 2024-08-07 02:29:58 字数 91 浏览 8 评论 0原文

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

Is there a way to automate the turning on or off of a Receive Location in BizTalk? It seems like there should be some kind of API or some such for this kind of thing. I would prefer to work in C#, but WMI or some kind of script would work too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

维持三分热 2024-08-14 02:29:58

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

我有一个示例 PowerShell 脚本,它展示了如何执行这些操作 如果您有兴趣,请点击这里

Besides ExplorerOM, as you've found out, you can also enable/disable receive locations (and control send ports) using WMI.

I have a sample PowerShell script that shows how to do those things here, if you're interested.

猫腻 2024-08-14 02:29:58

我找到了解决方案。看来 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 位),但这是需要注意的事情。

I found a solution. It appears that the Microsoft.BizTalk.ExplorerOM.dll is what I wanted. Here is an excerpt from the BizTalk documentation that should get anyone else started:

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);
            }
        }
    }
}

One caveat, apparently this dll does not support 64 bit. Since I am only writing a simple utility it's not a big deal for me (just compiling as 32-bit), but it is something to be aware of.

著墨染雨君画夕 2024-08-14 02:29:58

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

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

接收位置就是其中之一。

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

该脚本已发布到 Microsoft 脚本中心:
http://gallery.technet.microsoft.com/scriptcenter/Set-Artifact -状态-270f43a0

Glad to see that you seem to have found a solution.

Wanted to mention a similar alternative which is also using Powershell, ExplorerOM, and the BizTalk API to set BizTalk artifacts to various statuses.

Receive Locations being one of them.

The script accepts XML configuration files, where you list the artifacts and what status you would like to set them to.

The script has been published to Microsoft Script Center:
http://gallery.technet.microsoft.com/scriptcenter/Set-Artifact-Status-270f43a0

窗影残 2024-08-14 02:29:58

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

    /// <summary>
    /// Gets or sets the biz talk catalog.
    /// </summary>
    /// <value>The biz talk catalog.</value>
    private BtsCatalogExplorer BizTalkCatalog { get; set; }

    /// <summary>
    /// Initializes the biz talk artifacts.
    /// </summary>
    private void InitializeBizTalkCatalogExplorer()
    {
        // Connect to the local BizTalk Management database
        BizTalkCatalog = new BtsCatalogExplorer();
        BizTalkCatalog.ConnectionString = "server=BiztalkDbServer;database=BizTalkMgmtDb;integrated security=true";
    }


    /// <summary>
    /// Gets the location from biz talk.
    /// </summary>
    /// <param name="locationName">Name of the location.</param>
    /// <returns></returns>
    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);
    }


    /// <summary>
    /// Turns the off receive location.
    /// </summary>
    /// <param name="vendorName">Name of the vendor.</param>
    public void TurnOffReceiveLocation(string vendorName)
    {
        ReceiveLocation location = Locations[vendorName].ReceiveLocation;
        location.Enable = false;
        BizTalkCatalog.SaveChanges();
    }

您会注意到我遗漏了一些代码,就像我正在创建一个名为“位置”的接收位置字典一样,但您应该能够得到这个想法。该模式几乎适用于您想要与之交互的任何 BizTalk 对象。

In response to Alhambraeidos comment. Here's is some excerpts of code I used in a Windows app to disable a Receive Location remotely:

    /// <summary>
    /// Gets or sets the biz talk catalog.
    /// </summary>
    /// <value>The biz talk catalog.</value>
    private BtsCatalogExplorer BizTalkCatalog { get; set; }

    /// <summary>
    /// Initializes the biz talk artifacts.
    /// </summary>
    private void InitializeBizTalkCatalogExplorer()
    {
        // Connect to the local BizTalk Management database
        BizTalkCatalog = new BtsCatalogExplorer();
        BizTalkCatalog.ConnectionString = "server=BiztalkDbServer;database=BizTalkMgmtDb;integrated security=true";
    }


    /// <summary>
    /// Gets the location from biz talk.
    /// </summary>
    /// <param name="locationName">Name of the location.</param>
    /// <returns></returns>
    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);
    }


    /// <summary>
    /// Turns the off receive location.
    /// </summary>
    /// <param name="vendorName">Name of the vendor.</param>
    public void TurnOffReceiveLocation(string vendorName)
    {
        ReceiveLocation location = Locations[vendorName].ReceiveLocation;
        location.Enable = false;
        BizTalkCatalog.SaveChanges();
    }

You'll notice that there is some I left out, like I was creating a dictionary of receive locations called "Locations", but you should be able to get the idea. The pattern pretty much holds true for any BizTalk object you want to interact with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文