Existe uma maneira de automatizar transformar um BizTalk receber local ligado ou desligado através de código?

StackOverflow https://stackoverflow.com/questions/1515305

  •  19-09-2019
  •  | 
  •  

Pergunta

Existe uma maneira de automatizar o ligar ou desligar de um local de recebimento no BizTalk? Parece que deve haver algum tipo de API ou algo assim para este tipo de coisa. Eu preferiria trabalhar em C #, mas WMI ou algum tipo de script iria trabalhar muito.

Foi útil?

Solução

Além ExplorerOM, como você descobriu, você também pode ativar / desativar locais de recebimento (e portas de envio de controle) usando WMI.

Eu tenho um script PowerShell de exemplo que mostra como fazer essas coisas aqui , se você estiver interessado.

Outras dicas

Eu encontrei uma solução. Parece que o Microsoft.BizTalk.ExplorerOM.dll é o que eu queria. Aqui está um trecho da documentação BizTalk que deve obter qualquer outra pessoa começou:

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

Uma ressalva, aparentemente, este dll não suporta 64 bits. Desde que eu só estou escrevendo um utilitário simples que não é um grande negócio para mim (apenas compilar como 32-bit), mas é algo a ter em conta.

Fico feliz em ver que você parece ter encontrado uma solução.

queria mencionar uma alternativa semelhante que também está usando Powershell, ExplorerOM, eo BizTalk API para definir artefatos do BizTalk para vários estados.

Receber Locais sendo um deles.

O script aceita arquivos de configuração XML, onde você lista os artefatos e o estado que você gostaria de configurá-los para.

O script foi publicado para Microsoft Script Center: http://gallery.technet.microsoft.com/scriptcenter/Set-Artifact -status-270f43a0

Em resposta ao comentário Alhambraeidos. Aqui está é alguns trechos de código que eu usei em um aplicativo do Windows para desativar um local de recebimento remotamente:

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

Você notará que há algum eu deixei de fora, como eu estava criando um dicionário de locais de recebimento chamado "Locais", mas você deve ser capaz de obter a idéia. O padrão praticamente vale para qualquer objeto BizTalk você quer interagir.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top