Example #1
0
        public override bool Execute()
        {
            this.Log.LogMessage("Checking for existence of BizTalk application '{0}'...", _applicationName);

            using (BtsCatalogExplorer catalog = BizTalkCatalogExplorerFactory.GetCatalogExplorer())
            {
                Application application = catalog.Applications[_applicationName];
                if (application != null)
                {
                    if (application.Assemblies.Count > 0 ||
                        application.ReceivePorts.Count > 0 ||
                        application.SendPorts.Count > 0 ||
                        application.SendPortGroups.Count > 0)
                    {
                        _hasResources = true;
                    }
                    else
                    {
                        _hasResources = false;
                    }
                }
                else
                {
                    _hasResources = false;
                }
            }

            if (_hasResources)
            {
                this.Log.LogMessage("Found Resources in BizTalk application '{0}'.", _applicationName);
            }
            else
            {
                this.Log.LogMessage("Did not find Resources in BizTalk application '{0}'.", _applicationName);
            }

            return(true);
        }
Example #2
0
        public override bool Execute()
        {
            this.Log.LogMessage("Removing ports from Bindingfile '{0}'...", _portBindingsMasterFile);
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(_portBindingsMasterFile);
            using (BtsCatalogExplorer catalog = BizTalkCatalogExplorerFactory.GetCatalogExplorer())
            {
                Application application = catalog.Applications[_applicationName];
                try
                {
                    //Removing Receive Ports
                    XmlNodeList Recieveport = xmldoc.SelectNodes("BindingInfo/ReceivePortCollection/ReceivePort");
                    foreach (XmlNode xndNode in Recieveport)
                    {
                        string name = xndNode.Attributes["Name"].Value;
                        foreach (ReceivePort receivePort in application.ReceivePorts)
                        {
                            if (receivePort.Name == name)
                            {
                                catalog.RemoveReceivePort(receivePort);
                                break;
                            }
                        }
                    }

                    //Removing Send Port Groups
                    XmlNodeList SendportGroup = xmldoc.SelectNodes("BindingInfo/DistributionListCollection/DistributionList");
                    foreach (XmlNode xndNode in SendportGroup)
                    {
                        string name = xndNode.Attributes["Name"].Value;
                        foreach (SendPortGroup sendPortGroup in application.SendPortGroups)
                        {
                            if (sendPortGroup.Name == name)
                            {
                                sendPortGroup.Status = PortStatus.Bound;
                                catalog.RemoveSendPortGroup(sendPortGroup);
                                break;
                            }
                        }
                    }

                    //Removing Send Ports
                    XmlNodeList Sendport = xmldoc.SelectNodes("BindingInfo/SendPortCollection/SendPort");
                    foreach (XmlNode xndNode in Sendport)
                    {
                        string name = xndNode.Attributes["Name"].Value;
                        foreach (SendPort sendPort in application.SendPorts)
                        {
                            if (sendPort.Name == name)
                            {
                                sendPort.Status = PortStatus.Bound;
                                catalog.RemoveSendPort(sendPort);
                                break;
                            }
                        }
                    }
                    catalog.SaveChanges();
                }
                catch (Exception ex)
                {
                    this.Log.LogMessage("Error In removing ports. " + ex.ToString());
                }
            }
            return(true);
        }