Is there a way to automate turning a BizTalk Receive Location on or off through code?

后端 未结 4 1590
暖寄归人
暖寄归人 2020-12-17 01:52

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 woul

4条回答
  •  旧巷少年郎
    2020-12-17 02:31

    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.

提交回复
热议问题