Ejemplo n.º 1
0
        // Gets the Dictionary of HostNames associated with the application <"HostName", "Whether the host is assocated with dynamic send port (true/false)">
        public static Dictionary <string, bool> GetHostNamesWithAsAResultOfDynamicPort(this Application application)
        {
            //Dictionary<'Host Name', 'Is Dynamic port host'>
            Dictionary <string, bool> hostNames = new Dictionary <string, bool>();

            string hostName = "";

            //OurStopWatch.Enter("List host associated with all receive locations");

            //List host associated with all receive locations
            foreach (ReceivePort item in application.ReceivePorts)
            {
                foreach (Microsoft.BizTalk.ExplorerOM.ReceiveLocation itemLoc in item.ReceiveLocations)
                {
                    if (itemLoc.ReceiveHandler.Host.Type.ToString() == Property.HostInstanceType.InProcess.ToString())
                    {
                        hostName = itemLoc.ReceiveHandler.Host.Name;
                    }

                    if (!hostNames.ContainsKey(hostName))
                    {
                        hostNames.Add(hostName, false);
                    }
                }
            }
            //OurStopWatch.Exit();
            //OurStopWatch.Enter("List host associated with all orchestrations");

            //List host associated with all orchestrations
            foreach (BtsOrchestration item in application.Orchestrations)
            {
                if (item.Host != null)
                {
                    if (item.Host.Type.ToString() == Property.HostInstanceType.InProcess.ToString())
                    {
                        hostName = item.Host.Name;
                    }
                }
                if (!hostNames.ContainsKey(hostName))
                {
                    hostNames.Add(hostName, false);
                }
            }

            //OurStopWatch.Exit();
            //OurStopWatch.Enter("List host associated with all send ports (Non dynamic)");
            //List host associated with all send ports (Non dynamic)
            foreach (Microsoft.BizTalk.ExplorerOM.SendPort item in application.SendPorts)
            {
                if (!item.IsDynamic)
                {
                    if (item.PrimaryTransport.SendHandler.Host.Type.ToString() == Property.HostInstanceType.InProcess.ToString())
                    {
                        hostName = item.PrimaryTransport.SendHandler.Name;
                    }
                }
                if (!hostNames.ContainsKey(hostName))
                {
                    hostNames.Add(hostName, false);
                }
            }

            //OurStopWatch.Exit();

            //OurStopWatch.Enter("List all host if dynamic send port present");
            //List all host if dynamic send port present
            foreach (Microsoft.BizTalk.ExplorerOM.SendPort item in application.SendPorts)
            {
                if (item.IsDynamic)
                {
                    //foreach (string hostNameDynamic in MSBTS_Host.GetAllInProcessHosts())
                    //{
                    //    if (!hostNames.ContainsKey(hostNameDynamic))
                    //    {
                    //        hostNames.Add(hostNameDynamic, item.IsDynamic);
                    //    }
                    //}
                    foreach (string hostNameDynamic in WmiHelper.GetSendHandlerHosts())
                    {
                        if (!hostNames.ContainsKey(hostNameDynamic))
                        {
                            hostNames.Add(hostNameDynamic, true);
                        }
                    }
                    break;
                }
            }
            //OurStopWatch.Exit();
            return(hostNames);
        }