/// <summary> /// This will create an application /// </summary> /// <param name="catalog"></param> /// <param name="newApplicationName"></param> /// <param name="description"></param> public static void CreateApplication(BtsCatalogExplorer catalog, string newApplicationName, string description) { if (catalog == null) { throw new NullReferenceException("The catalog is null"); } var newApplication = catalog.AddNewApplication(); newApplication.Name = newApplicationName; newApplication.Description = description; catalog.SaveChanges(); catalog.Refresh(); }
private static void createTransmitBindings(string applicationName, string sendPortName, string address, int port, string contentType) { var explorer = new BtsCatalogExplorer(); try { explorer.ConnectionString = ConnectionStringHelper.GetMgmtConnectionString(); var application = explorer.Applications[applicationName]; if (application == null) { application = explorer.AddNewApplication(); application.Name = applicationName; explorer.SaveChanges(); } var sendPort = application.SendPorts[sendPortName]; if (sendPort == null) { var uri = string.Format("microservicebus://{0}:{1}", address, port); var pipeline = explorer.Pipelines["Microsoft.BizTalk.DefaultPipelines.PassThruTransmit"]; sendPort = application.AddNewSendPort(false, false); sendPort.Name = sendPortName; sendPort.SendPipeline = pipeline; var transport = explorer.ProtocolTypes["microServiceBus"]; sendPort.Description = "Automaticly created by the microServiceBus.com host."; sendPort.PrimaryTransport.Address = uri; sendPort.PrimaryTransport.TransportType = transport; sendPort.PrimaryTransport.TransportTypeData = @"<CustomProps><AdapterConfig vt=""8""><CustomProps xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><uri>" + uri + @"</uri><address>" + address + @"</address><port>" + port.ToString() + @"</port><contentType>"+ contentType + @"</contentType></CustomProps></AdapterConfig></CustomProps>"; foreach (SendHandler sendHandler in explorer.SendHandlers) { if (sendHandler.TransportType.Name == "microServiceBus") { sendPort.PrimaryTransport.SendHandler = sendHandler; break; } } sendPort.Status = PortStatus.Started; explorer.SaveChanges(); } } catch (Exception ex) { throw ex; } }
private static void createReceiveBindings(string applicationName, string receivePortName, string receiveLocationName) { var explorer = new BtsCatalogExplorer(); try { explorer.ConnectionString = ConnectionStringHelper.GetMgmtConnectionString(); var application = explorer.Applications[applicationName]; if (application == null) { application = explorer.AddNewApplication(); application.Name = applicationName; explorer.SaveChanges(); } System.Diagnostics.Trace.WriteLine("application done", "microservicebus"); var receivePort = application.ReceivePorts[receivePortName]; if (receivePort == null) { receivePort = application.AddNewReceivePort(false); receivePort.Name = receivePortName; explorer.SaveChanges(); } System.Diagnostics.Trace.WriteLine("receive port done", "microservicebus"); var receiveLocation = receivePort.ReceiveLocations[receiveLocationName]; if (receiveLocation == null) { var submitURI = string.Format("microservicebus://{0}", receiveLocationName); var pipeline = explorer.Pipelines["Microsoft.BizTalk.DefaultPipelines.PassThruReceive"]; var transport = explorer.ProtocolTypes["microServiceBus"]; receiveLocation = receivePort.AddNewReceiveLocation(); receiveLocation.Address = submitURI; receiveLocation.Description = "Automaticly created by the microServiceBus.com host."; receiveLocation.Name = receiveLocationName; receiveLocation.ReceivePipeline = pipeline; receiveLocation.TransportType = transport; receiveLocation.TransportTypeData = @"<CustomProps><AdapterConfig vt=""8""><CustomProps xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><uri>"+submitURI+@"</uri></CustomProps></AdapterConfig></CustomProps>"; foreach (ReceiveHandler receiveHandler in explorer.ReceiveHandlers) { if (receiveHandler.Name == "BizTalkServerIsolatedHost" && receiveHandler.TransportType.Name == "microServiceBus") { receiveLocation.ReceiveHandler = receiveHandler; break; } } receiveLocation.Enable = true; explorer.SaveChanges(); System.Diagnostics.Trace.WriteLine("all done", "microservicebus"); } } catch (Exception ex) { throw ex; } }