public void Drop() { if (this.ServiceBroker.Services.Contains(this.FullName)) { this.ServiceBroker.Services[this.FullName].Drop(); if (this.ServiceBroker.RemoteServiceBindings.Contains(this.BindingFullName)) { RemoteServiceBinding binding = this.ServiceBroker. RemoteServiceBindings[this.BindingFullName]; binding.Drop(); } } //Drop Certificate if (m_EnableRemoteServiceBinding && !this.AllowAnonymous) { this.DropCertificate(); } }
public void Alter() { BrokerService brokerService; ExtendedProperty prop = null; if (this.ServiceBroker.Services.Contains(this.FullName)) { brokerService = this.ServiceBroker.Services[this.FullName]; brokerService.QueueName = this.QueueName; //Drop Contracts that user removed foreach (ServiceContractMapping map in brokerService.ServiceContractMappings) { if (!this.ContractNames.Contains(map.Name)) { if (map.State != SqlSmoState.ToBeDropped) { map.MarkForDrop(true); } } } //Add Contracts that user added foreach (string name in this.ContractNames) { if (!brokerService.ServiceContractMappings.Contains(name)) { ServiceContractMapping brokerServiceContract = new ServiceContractMapping(brokerService, name); brokerService.ServiceContractMappings.Add(brokerServiceContract); } } brokerService.Alter(); //Drop RemoteServiceBinding and Certificate if (!m_EnableRemoteServiceBinding) { if (this.ServiceBroker.RemoteServiceBindings.Contains(this.BindingFullName)) { RemoteServiceBinding binding = this.ServiceBroker. RemoteServiceBindings[this.BindingFullName]; binding.Drop(); } this.DropCertificate(); //Drop extended property if (brokerService.ExtendedProperties.Contains("CertificateName")) { brokerService.ExtendedProperties["CertificateName"].Drop(); } } //Change RemoteServiceBinding if (m_EnableRemoteServiceBinding && !String.IsNullOrEmpty(this.ServiceOwnerName)) { if (this.ServiceBroker.RemoteServiceBindings.Contains(this.BindingFullName)) { RemoteServiceBinding binding = this.ServiceBroker. RemoteServiceBindings[this.BindingFullName]; binding.IsAnonymous = this.AllowAnonymous; //Can't change service owner binding.Owner = this.ServiceOwnerName; binding.Alter(); } } //Create Certificate if EnableRemoteServiceBinding = true and AllowAnonymous = false if (m_EnableRemoteServiceBinding && !String.IsNullOrEmpty(this.ServiceOwnerName) && !this.AllowAnonymous) { if (!brokerService.ExtendedProperties.Contains("CertificateName")) { prop = new ExtendedProperty(brokerService, "CertificateName", this.Certificate.Name); } this.Certificate.Owner = this.ServiceOwnerName; this.Certificate.Create(); } //Create ReportServiceBinding if (m_EnableRemoteServiceBinding && !String.IsNullOrEmpty(this.ServiceOwnerName)) { this.CreateRemoteServiceBinding(); } if (this.GrantReceive) { CreateGrantReceive(); } //Create property last if (prop != null) { prop.Create(); } } }
internal static void DeleteObject(SsbEnum sType, object smoObj) { switch (sType) { case SsbEnum.Database: Database db = null; if (smoObj.GetType() == typeof(SSBIDatabase)) { db = ((SSBIDatabase)smoObj).DataBase; } else if (smoObj.GetType() == typeof(Database)) { db = (Database)smoObj; } db.Drop(); break; case SsbEnum.MessageType: MessageType mt = (MessageType)smoObj; mt.Drop(); break; case SsbEnum.Contract: ServiceContract sc = (ServiceContract)smoObj; sc.Drop(); break; case SsbEnum.Queu: ServiceQueue sq = (ServiceQueue)smoObj; sq.Drop(); break; case SsbEnum.Service: BrokerService bs = (BrokerService)smoObj; bs.Drop(); break; case SsbEnum.Route: ServiceRoute sr = (ServiceRoute)smoObj; sr.Drop(); break; case SsbEnum.RemoteBinding: RemoteServiceBinding rsb = (RemoteServiceBinding)smoObj; rsb.Drop(); break; case SsbEnum.Conversation: SSBIConversation cnv = (SSBIConversation)smoObj; smo.EndConversation(cnv); break; case SsbEnum.EndPoint: Endpoint ep = (Endpoint)smoObj; ep.Drop(); break; case SsbEnum.Certificate: Certificate cert = (Certificate)smoObj; cert.Drop(); break; } }