public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { if (receiveLocation == null) { throw new ArgumentNullException(nameof(receiveLocation)); } ((ISupportValidation)receiveLocation).Validate(); }
public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { if (receiveLocation == null) { throw new ArgumentNullException(nameof(receiveLocation)); } ((ISupportEnvironmentOverride)receiveLocation).ApplyEnvironmentOverrides(Environment); }
internal static string ComputeReceiveLocationName <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { return(ComputeName( receiveLocation, "Receive Location", convention => convention.ComputeReceiveLocationName(receiveLocation))); }
protected string ComputeReceiveLocationName(IReceiveLocation <TNamingConvention> receiveLocation) { if (receiveLocation == null) { throw new ArgumentNullException(nameof(receiveLocation)); } if (receiveLocation.ReceivePort == null) { throw new NamingConventionException($"'{receiveLocation.GetType().Name}' ReceiveLocation is not bound to any receive port."); } if (Equals(Party, default(TParty))) { Party = receiveLocation.ReceivePort.Name.Party; } if (Equals(Party, default(TParty))) { throw new NamingConventionException($"'{receiveLocation.GetType().Name}' ReceiveLocation's Party is required."); } if (!Equals(Party, receiveLocation.ReceivePort.Name.Party)) { throw new NamingConventionException( $"'{receiveLocation.GetType().Name}' ReceiveLocation's Party, '{Party}', does not match its ReceivePort's one, '{receiveLocation.ReceivePort.Name.Party}'."); } if (Equals(Subject, default(TSubject))) { throw new NamingConventionException($"'{receiveLocation.GetType().Name}' ReceiveLocation's Subject is required."); } if (MessageFormat == null) { throw new NamingConventionException("A non null MessageFormat is required."); } var aggregate = ComputeAggregateName(receiveLocation.GetType()); var receivePortAggregate = ComputeAggregateName(receiveLocation.ReceivePort.GetType()); if (aggregate.IsNullOrEmpty() && !receivePortAggregate.IsNullOrEmpty()) { aggregate = receivePortAggregate; } if (!receivePortAggregate.IsNullOrEmpty() && receivePortAggregate != aggregate) { throw new NamingConventionException( $"'{receiveLocation.GetType().Name}' ReceiveLocation's Aggregate, '{aggregate}', does not match its ReceivePort's one, '{receivePortAggregate}'."); } return(string.Format( CultureInfo.InvariantCulture, "{0}{1}.RL{2}.{3}.{4}.{5}{6}", receiveLocation.ReceivePort.ApplicationBinding.ResolveName(), aggregate.IsNullOrEmpty() ? string.Empty : $".{aggregate}", receiveLocation.ReceivePort.IsTwoWay ? "2" : "1", Party, Subject, ComputeAdapterName(receiveLocation.Transport.Adapter), MessageFormat.IsNullOrEmpty() ? string.Empty : $".{MessageFormat}")); }
public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { var fileAdapter = receiveLocation.Transport.Adapter as FileAdapter.Inbound; if (fileAdapter != null) { VisitDirectory(fileAdapter.ReceiveFolder); } }
public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { // skip ReceiveLocation not belonging to this application if (!ReferenceEquals(receiveLocation.ReceivePort.ApplicationBinding, _applicationBinding)) { return; } _decoratedVisitor.VisitReceiveLocation(receiveLocation); }
protected internal override void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { var visitedReceiveLocation = CreateReceiveLocation(receiveLocation); if (_lastVisitedReceivePort.ReceiveLocations.Cast <BtsReceiveLocation>().Any(rl => rl.Name == visitedReceiveLocation.Name)) { throw new BindingException($"Duplicate receive location name: '{visitedReceiveLocation.Name}'."); } _lastVisitedReceivePort.ReceiveLocations.Add(visitedReceiveLocation); }
void IApplicationBindingVisitor.VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { if (receiveLocation == null) { throw new ArgumentNullException(nameof(receiveLocation)); } // visit only ReceiveLocation belonging to this application if (ReferenceEquals(receiveLocation.ReceivePort.ApplicationBinding, _mainApplicationBinding)) { VisitReceiveLocation(receiveLocation); } }
public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { var visitedReceiveLocation = CreateReceiveLocation(receiveLocation); if (_lastVisitedReceivePort.ReceiveLocations.Cast <BtsReceiveLocation>().Any(rl => rl.Name == visitedReceiveLocation.Name)) { throw new InvalidOperationException( string.Format( "Duplicate receive location name: '{0}'.", visitedReceiveLocation.Name)); } _lastVisitedReceivePort.ReceiveLocations.Add(visitedReceiveLocation); }
public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { var name = ((ISupportNamingConvention)receiveLocation).Name; var rl = _receivePort.ReceiveLocations[name]; if (_logger.IsDebugEnabled) { _logger.DebugFormat( receiveLocation.Enabled ? "Enabling receive location '{0}'" : "Disabling receive location '{0}'", name); } rl.Enabled = receiveLocation.Enabled; }
string INamingConvention <NamingConvention <TParty, TSubject> > .ComputeReceiveLocationName(IReceiveLocation <NamingConvention <TParty, TSubject> > receiveLocation) { return(base.ComputeReceiveLocationName(receiveLocation)); }
/// <summary> /// Creates receive port with one request-response HTTP receive location /// </summary> /// <param name="virtualDirectory">Virtual directory name</param> /// <param name="portName">Receive port name</param> /// <param name="locationName">Receive location name</param> /// <returns>True if successful, otherwise false</returns> public static bool CreateHttpRequestResponsePort(string virtualDirectory, string portName, string locationName, ref string retMsg) { IBtsCatalogExplorer explorer = null; try { string mgmtDBName = "BizTalkMgmtDb"; string mgmtDBServer = "localhost"; ManagementClass groupSettings = new ManagementClass("root\\MicrosoftBizTalkServer:MSBTS_GroupSetting"); foreach (ManagementObject obj in groupSettings.GetInstances()) { mgmtDBName = (string)obj.Properties["MgmtDbName"].Value; mgmtDBServer = (string)obj.Properties["MgmtDbServerName"].Value; } // Get BizTalk Explorer object explorer = new BtsCatalogExplorer(); explorer.ConnectionString = "SERVER=" + mgmtDBServer + ";DATABASE=" + mgmtDBName + ";Integrated Security=SSPI"; // Delete this port if it already exists foreach (IReceivePort port in explorer.GetCollection(CollectionType.ReceivePort)) { if (port.Name.ToLower() == portName.ToLower()) { explorer.RemoveReceivePort(port); break; } } explorer.SaveChanges(); // Add new port IReceivePort receivePort = explorer.AddNewReceivePort(true); receivePort.Name = portName; // Add new location IReceiveLocation rxLocation = receivePort.AddNewReceiveLocation(); rxLocation.Name = locationName; // Set the receive location rxLocation.Address = "/" + virtualDirectory + "/BTSHttpReceive.dll"; // Set the transport type foreach (IProtocolType protocol in explorer.GetCollection(CollectionType.ProtocolType)) { if (protocol.Name == "HTTP") { rxLocation.TransportType = protocol; } } // Set the transport data rxLocation.TransportTypeData = "<CustomProps>" + "<Address vt=\"8\">" + rxLocation.Address + "</Address>" + "<LoopBack vt=\"11\">0</LoopBack>" + "<IsSynchronous vt=\"11\">1</IsSynchronous>" + "<ReturnCorrelationHandle vt=\"11\">0</ReturnCorrelationHandle>" + "<ResponseContentType vt=\"8\">text/html</ResponseContentType>" + "<URI vt=\"8\">" + rxLocation.Address + "</URI>" + "<UseSSO vt=\"11\">1</UseSSO>" + "</CustomProps>"; // Set the receive pipeline foreach (IPipeline pipe in explorer.GetCollection(CollectionType.Pipeline)) { if ((pipe.Type == PipelineType.Receive) && (pipe.FullName == "Microsoft.BizTalk.DefaultPipelines.PassThruReceive")) { rxLocation.ReceivePipeline = pipe; break; } } // Set the receive handler foreach (IReceiveHandler handler in explorer.GetCollection(CollectionType.ReceiveHandler)) { if (handler.TransportType == rxLocation.TransportType) { rxLocation.ReceiveHandler = handler; break; } } foreach (IPipeline pipe in explorer.GetCollection(CollectionType.Pipeline)) { if ((pipe.Type == PipelineType.Send) && (pipe.FullName == "Microsoft.BizTalk.DefaultPipelines.PassThruTransmit")) { receivePort.SendPipeline = pipe; break; } } // Enable this receive location rxLocation.Enable = true; // Save changes explorer.SaveChanges(); } catch (Exception e) { retMsg = e.Message.ToString(); if (explorer != null) { explorer.DiscardChanges(); } return(false); } return(true); }
string INamingConvention <NamingConventionSpy> .ComputeReceiveLocationName(IReceiveLocation <NamingConventionSpy> receiveLocation) { throw new NotSupportedException(); }
protected string ComputeReceiveLocationName(IReceiveLocation <TNamingConvention> receiveLocation) { if (receiveLocation.ReceivePort == null) { throw new NamingConventionException( string.Format( "'{0}' ReceiveLocation is not bound to any receive port.", receiveLocation.GetType().Name)); } if (Equals(Party, default(TParty))) { Party = receiveLocation.ReceivePort.Name.Party; } if (Equals(Party, default(TParty))) { throw new NamingConventionException( string.Format( "'{0}' ReceiveLocation's Party is required.", receiveLocation.GetType().Name)); } if (!Equals(Party, receiveLocation.ReceivePort.Name.Party)) { throw new NamingConventionException( string.Format( "'{0}' ReceiveLocation's Party, '{1}', does not match its ReceivePort's one, '{2}'.", receiveLocation.GetType().Name, Party, receiveLocation.ReceivePort.Name.Party)); } if (Equals(MessageName, default(TMessageName))) { throw new NamingConventionException( string.Format( "'{0}' ReceiveLocation's MessageName is required.", receiveLocation.GetType().Name)); } if (MessageFormat == null) { throw new NamingConventionException("A non null MessageFormat is required."); } var area = ComputeArea(receiveLocation.GetType()); var receivePortArea = ComputeArea(receiveLocation.ReceivePort.GetType()); if (area.IsNullOrEmpty() && !receivePortArea.IsNullOrEmpty()) { area = receivePortArea; } if (!receivePortArea.IsNullOrEmpty() && receivePortArea != area) { throw new NamingConventionException( string.Format( "'{0}' ReceiveLocation's Area, '{1}', does not match its ReceivePort's one, '{2}'.", receiveLocation.GetType().Name, area, receivePortArea)); } return(string.Format( "{0}{1}.RL{2}.{3}.{4}.{5}{6}", ((ISupportNamingConvention)receiveLocation.ReceivePort.ApplicationBinding).Name, area.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", area), receiveLocation.ReceivePort.IsTwoWay ? "2" : "1", Party, MessageName, ComputeAdapterName(receiveLocation.Transport.Adapter), MessageFormat.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", MessageFormat))); }
IReceiveLocationCollection <TNamingConvention> IReceiveLocationCollection <TNamingConvention> .Add(IReceiveLocation <TNamingConvention> receiveLocation) { return(((IReceiveLocationCollection <TNamingConvention>) this).Add(new[] { receiveLocation })); }
protected internal abstract void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class;
public ReceiveLocationTransport(IReceiveLocation <TNamingConvention> receiveLocation) : this() { ReceiveLocation = receiveLocation ?? throw new ArgumentNullException(nameof(receiveLocation)); }
public void VisitReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { ((ISupportEnvironmentOverride)receiveLocation).ApplyEnvironmentOverrides(Environment); ((ISupportValidation)receiveLocation).Validate(); }
string INamingConvention <NamingConventionDouble> .ComputeReceiveLocationName(IReceiveLocation <NamingConventionDouble> receiveLocation) { throw new NotImplementedException(); }
public string ComputeReceiveLocationNameSpy(IReceiveLocation <NamingConventionDouble> receiveLocation) { return(ComputeReceiveLocationName(receiveLocation)); }
protected internal virtual BtsReceiveLocation CreateReceiveLocation <TNamingConvention>(IReceiveLocation <TNamingConvention> receiveLocation) where TNamingConvention : class { ((ISupportValidation)receiveLocation).Validate(); var location = new BtsReceiveLocation { Name = ((ISupportNamingConvention)receiveLocation).Name, Address = receiveLocation.Transport.Adapter.Address, Description = receiveLocation.Description, Enable = false, // receiveLocation.Enabled is the responsibility of BizTalkServiceConfiguratorVisitor EndDate = receiveLocation.Transport.Schedule.StopDate, EndDateEnabled = receiveLocation.Transport.Schedule.StopDateEnabled, // TODO EncryptionCert = FromTime = receiveLocation.Transport.Schedule.ServiceWindow.StartTime, // TODO Primary = PublicAddress = receiveLocation.Transport.Adapter.PublicAddress, ReceiveHandler = new ReceiveHandlerRef { // TODO HostTrusted = , Name = receiveLocation.Transport.Host, TransportType = receiveLocation.Transport.Adapter.ProtocolType }, ReceivePipeline = CreateReceivePipelineRef(receiveLocation.ReceivePipeline), ReceivePipelineData = ((IPipelineSerializerFactory)receiveLocation.ReceivePipeline).GetPipelineBindingSerializer().Serialize(), ServiceWindowEnabled = receiveLocation.Transport.Schedule.ServiceWindow.Enabled, StartDate = receiveLocation.Transport.Schedule.StartDate, StartDateEnabled = receiveLocation.Transport.Schedule.StartDateEnabled, ToTime = receiveLocation.Transport.Schedule.ServiceWindow.StopTime, TransportType = receiveLocation.Transport.Adapter.ProtocolType, TransportTypeData = ((IAdapterBindingSerializerFactory)receiveLocation.Transport.Adapter).GetAdapterBindingSerializer().Serialize() }; if (receiveLocation.SendPipeline != null) { location.SendPipeline = CreateSendPipelineRef(receiveLocation.SendPipeline); location.SendPipelineData = ((IPipelineSerializerFactory)receiveLocation.SendPipeline).GetPipelineBindingSerializer().Serialize(); } return(location); }
string INamingConvention <NamingConvention> .ComputeReceiveLocationName(IReceiveLocation <NamingConvention> receiveLocation) { return(base.ComputeReceiveLocationName(receiveLocation)); }