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

后端 未结 4 1599
暖寄归人
暖寄归人 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:47

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

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

    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.

提交回复
热议问题