public override bool Execute()
 {
     BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
     Log.LogMessage("Terminating all Orchestrations for BizTalk application '{0}'.", this.ApplicationName);
     bizTalkApplication.TerminateAllOrchestrations();
     return true;
 }
 public override bool Execute()
 {
     BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
     Log.LogMessage("Starting BizTalk application '{0}'.", this.ApplicationName);
     bizTalkApplication.StartAll();
     return true;
 }
 public override bool Execute()
 {
     BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
     Log.LogMessage("Enabling all Receive Locations for BizTalk application '{0}'.", this.ApplicationName);
     bizTalkApplication.EnableAllReceiveLocations();
     return true;
 }
 public override bool Execute()
 {
     BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
     Log.LogMessage("Stopping all Send Ports for BizTalk application '{0}'.", this.ApplicationName);
     bizTalkApplication.StopAllSendPorts();
     return true;
 }
        public override bool Execute()
        {
            BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
            foreach (ITaskItem sendPortName in this.SendPortNames)
            {
                Log.LogMessage("Stopping Send Port '{0}' for BizTalk application '{1}'.", sendPortName.ItemSpec, this.ApplicationName);
                bizTalkApplication.StopSendPort(sendPortName.ItemSpec);
            }

            return true;
        }
        public override bool Execute()
        {
            BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
            foreach (ITaskItem orchestrationName in this.OrchestrationNames)
            {
                Log.LogMessage("Starting Orchestration '{0}' for BizTalk application '{1}'.", orchestrationName.ItemSpec, this.ApplicationName);
                bizTalkApplication.StartOrchestration(orchestrationName.ItemSpec);
            }

            return true;
        }
        public override bool Execute()
        {
            BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
            foreach (ITaskItem recieveLocationName in this.ReceiveLocationNames)
            {
                Log.LogMessage("Enabling Receive Location '{0}' for BizTalk application '{1}'.", recieveLocationName.ItemSpec, this.ApplicationName);
                bizTalkApplication.EnableReceiveLocation(recieveLocationName.ItemSpec);
            }

            return true;
        }
        public override bool Execute()
        {
            BizTalkCatalogExplorer bizTalkCatalogExplorer = new BizTalkCatalogExplorer(ManagementDatabaseConnectionString);
            if (bizTalkCatalogExplorer.ApplicationExists(this.ApplicationName))
            {
                BizTalkApplication bizTalkApplication = new BizTalkApplication(ManagementDatabaseConnectionString, ApplicationName);
                if (this.TerminateOrchestrations)
                {
                    Log.LogMessage("Disabling all Receive Locations for BizTalk application '{0}'.", this.ApplicationName);
                    bizTalkApplication.DisableAllReceiveLocations();
                    Log.LogMessage("Terminating all Orchestrations for BizTalk application '{0}'.", this.ApplicationName);
                    bizTalkApplication.TerminateAllOrchestrations();
                }

                Log.LogMessage("Bringing BizTalk application '{0}' to a complete stop.", this.ApplicationName);
                bizTalkApplication.StopAll();
            }
            else
            {
                Log.LogMessage("Skipping stopping of BizTalk application '{0}' as none exist matching that name.", this.ApplicationName);
            }

            return true;
        }
        /// <summary>
        /// Remove the <c>BizTalk</c> application.
        /// </summary>
        /// <param name="applicationName">The application name.</param>
        public void RemoveApplication(string applicationName)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentException("The applicationName should not be null or empty.", "applicationName");
            }

            if (!this.ApplicationExists(applicationName))
            {
                string exceptionMessage = string.Format(CultureInfo.CurrentCulture, "The BizTalk application with the name '{0}' does not exist and could not be removed.", applicationName);
                throw new BizTalkExtensionsException(exceptionMessage);
            }

            using (Group group = new Group())
            {
                // Bring application to a stop (we can't removed an app with running Orchestrations)
                BizTalkApplication bizTalkApplication1 = new BizTalkApplication(this.managementDatabaseConnectionString, applicationName);
                bizTalkApplication1.StopAll();
                BizTalkApplication bizTalkApplication2 = new BizTalkApplication(this.managementDatabaseConnectionString, applicationName);
                bizTalkApplication2.TerminateAllOrchestrations();

                // Now remove the app
                group.DBName = this.managementDatabaseName;
                group.DBServer = this.managementDatabaseServerName;
                Microsoft.BizTalk.ApplicationDeployment.ApplicationCollection applications = group.Applications;
                applications.UiLevel = 2;
                Microsoft.BizTalk.ApplicationDeployment.Application applicationToRemove = applications[applicationName];
                applications.Remove(applicationToRemove);
            }
        }