public void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort) where TNamingConvention : class
 {
     if (sendPort == null)
     {
         throw new ArgumentNullException(nameof(sendPort));
     }
     ((ISupportValidation)sendPort).Validate();
 }
 internal static string ComputeSendPortName <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
     where TNamingConvention : class
 {
     return(ComputeName(
                sendPort,
                "Send Port",
                convention => convention.ComputeSendPortName(sendPort)));
 }
Beispiel #3
0
        public void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
            where TNamingConvention : class
        {
            var fileAdapter = sendPort.Transport.Adapter as FileAdapter.Outbound;

            if (fileAdapter != null)
            {
                VisitDirectory(fileAdapter.DestinationFolder);
            }
        }
 public void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
     where TNamingConvention : class
 {
     // skip SendPort not belonging to this application
     if (!ReferenceEquals(sendPort.ApplicationBinding, _applicationBinding))
     {
         return;
     }
     _decoratedVisitor.VisitSendPort(sendPort);
 }
Beispiel #5
0
        protected internal override void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
            where TNamingConvention : class
        {
            var visitedSendPort = CreateSendPort(sendPort);

            if (BindingInfo.SendPortCollection.Find(visitedSendPort.Name) != null)
            {
                throw new BindingException($"Duplicate send port name: '{visitedSendPort.Name}'.");
            }
            BindingInfo.SendPortCollection.Add(visitedSendPort);
        }
 void IApplicationBindingVisitor.VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
     where TNamingConvention : class
 {
     if (sendPort == null)
     {
         throw new ArgumentNullException(nameof(sendPort));
     }
     // visit only SendPort belonging to this application
     if (ReferenceEquals(sendPort.ApplicationBinding, _mainApplicationBinding))
     {
         VisitSendPort(sendPort);
     }
 }
        public void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
            where TNamingConvention : class
        {
            var visitedSendPort = CreateSendPort(sendPort);

            if (BindingInfo.SendPortCollection.Find(visitedSendPort.Name) != null)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Duplicate send port name: '{0}'.",
                              visitedSendPort.Name));
            }
            BindingInfo.SendPortCollection.Add(visitedSendPort);
        }
        protected string ComputeSendPortName(ISendPort <TNamingConvention> sendPort)
        {
            if (sendPort.ApplicationBinding == null)
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' SendPort is not bound to application's send port collection.",
                              sendPort.GetType().Name));
            }
            if (Equals(Party, default(TParty)))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' SendPort's Party is required.",
                              sendPort.GetType().Name));
            }
            if (Equals(MessageName, default(TMessageName)))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' SendPort's MessageName is required.",
                              sendPort.GetType().Name));
            }
            if (MessageFormat == null)
            {
                throw new NamingConventionException("A non null MessageFormat is required.");
            }

            var area = ComputeArea(sendPort.GetType());

            return(string.Format(
                       "{0}{1}.SP{2}.{3}.{4}.{5}{6}",
                       ((ISupportNamingConvention)sendPort.ApplicationBinding).Name,
                       area.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", area),
                       sendPort.IsTwoWay ? "2" : "1",
                       Party,
                       MessageName,
                       ComputeAdapterName(sendPort.Transport.Adapter),
                       MessageFormat.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", MessageFormat)));
        }
        protected internal virtual BtsSendPort CreateSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort)
            where TNamingConvention : class
        {
            ((ISupportValidation)sendPort).Validate();

            var port = new BtsSendPort {
                ApplicationName = ApplicationName,
                // TODO BindingOption =
                Description = sendPort.Description,
                // TODO EncryptionCert =
                Filter = sendPort.Filter.IfNotNull(f => f.ToString()),
                // TODO InboundTransforms =
                // TODO IsDynamic =
                IsDynamic        = false,
                Name             = ((ISupportNamingConvention)sendPort).Name,
                OrderedDelivery  = sendPort.OrderedDelivery,
                PrimaryTransport = CreateTransportInfo(sendPort.Transport, true, sendPort.OrderedDelivery),
                Priority         = (int)sendPort.Priority,
                // TODO RouteFailedMessage =
                SecondaryTransport = sendPort.BackupTransport.Adapter is SendPortTransport.UnknownOutboundAdapter
                                        ? null
                                        : CreateTransportInfo(sendPort.BackupTransport, false, false),
                SendPipelineData = ((IPipelineSerializerFactory)sendPort.SendPipeline).GetPipelineBindingSerializer().Serialize(),
                // sendPort.Status is the responsibility of BizTalkServiceConfiguratorVisitor
                StopSendingOnFailure = sendPort.StopSendingOnOrderedDeliveryFailure,
                // TODO Tracking =
                // TODO Transforms =
                TransmitPipeline = CreateSendPipelineRef(sendPort.SendPipeline)
            };

            if (sendPort.IsTwoWay)
            {
                port.IsTwoWay            = true;
                port.ReceivePipeline     = CreateReceivePipelineRef(sendPort.ReceivePipeline);
                port.ReceivePipelineData = ((IPipelineSerializerFactory)sendPort.ReceivePipeline).GetPipelineBindingSerializer().Serialize();
            }
            return(port);
        }
        protected string ComputeSendPortName(ISendPort <TNamingConvention> sendPort)
        {
            if (sendPort == null)
            {
                throw new ArgumentNullException(nameof(sendPort));
            }
            if (sendPort.ApplicationBinding == null)
            {
                throw new NamingConventionException($"'{sendPort.GetType().Name}' SendPort is not bound to application's send port collection.");
            }
            if (Equals(Party, default(TParty)))
            {
                throw new NamingConventionException($"'{sendPort.GetType().Name}' SendPort's Party is required.");
            }
            if (Equals(Subject, default(TSubject)))
            {
                throw new NamingConventionException($"'{sendPort.GetType().Name}' SendPort's Subject is required.");
            }
            if (MessageFormat == null)
            {
                throw new NamingConventionException("A non null MessageFormat is required.");
            }

            var aggregate = ComputeAggregateName(sendPort.GetType());

            return(string.Format(
                       CultureInfo.InvariantCulture,
                       "{0}{1}.SP{2}.{3}.{4}.{5}{6}",
                       sendPort.ApplicationBinding.ResolveName(),
                       aggregate.IsNullOrEmpty() ? string.Empty : $".{aggregate}",
                       sendPort.IsTwoWay ? "2" : "1",
                       Party,
                       Subject,
                       ComputeAdapterName(sendPort.Transport.Adapter),
                       MessageFormat.IsNullOrEmpty() ? string.Empty : $".{MessageFormat}"));
        }
Beispiel #11
0
 string INamingConvention <NamingConvention <TParty, TMessageName> > .ComputeSendPortName(ISendPort <NamingConvention <TParty, TMessageName> > sendPort)
 {
     return(base.ComputeSendPortName(sendPort));
 }
 public string ComputeSendPortNameSpy(ISendPort <NamingConventionDouble> sendPort)
 {
     return(ComputeSendPortName(sendPort));
 }
 string INamingConvention <NamingConvention <TParty, TSubject> > .ComputeSendPortName(ISendPort <NamingConvention <TParty, TSubject> > sendPort)
 {
     return(base.ComputeSendPortName(sendPort));
 }
Beispiel #14
0
        /// <summary>
        /// Creates solicit-response HTTP send port
        /// </summary>
        /// <param name="uri">Send port URI</param>
        /// <param name="portName">Send port name</param>
        /// <param name="receivePort">Name of the receive port to bind this send port to</param>
        /// <returns>True if successful, otherwise false</returns>
        public static bool CreateHttpSolicitResponsePort(string uri, string portName, string receivePort, string affiliateApplication, 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 (ISendPort port in explorer.GetCollection(CollectionType.SendPort))
                {
                    if (port.Name.ToLower() == portName.ToLower())
                    {
                        port.Status = PortStatus.Bound;
                        explorer.RemoveSendPort(port);
                        break;
                    }
                }
                explorer.SaveChanges();

                // Add send port
                ISendPort transmitPort = explorer.AddNewSendPort(false, true);
                transmitPort.Name = portName;

                ITransportInfo TransInfo = transmitPort.PrimaryTransport;

                TransInfo.Address = uri;

                // Set protocol type
                foreach (IProtocolType protocol in explorer.GetCollection(CollectionType.ProtocolType))
                {
                    if (protocol.Name == "HTTP")
                    {
                        TransInfo.TransportType = protocol;
                    }
                }

                // Set the transport data
                string transportTypeData =
                    "<CustomProps>" +
                    "<Address vt=\"8\">" + TransInfo.Address + "</Address>" +
                    "<IsSolicitResponse vt=\"11\">1</IsSolicitResponse>" +
                    "<RequestTimeout vt=\"3\">120</RequestTimeout>" +
                    "<MaxRedirects vt=\"3\">0</MaxRedirects>" +
                    "<ContentType vt=\"8\">text/xml</ContentType>" +
                    "<URI vt=\"8\">" + TransInfo.Address + "</URI>" +
                    "<UseSSO vt=\"11\">1</UseSSO>" +
                    "<AffiliateApplicationName vt=\"8\">" + affiliateApplication + "</AffiliateApplicationName>" +
                    "<AuthenticationScheme vt=\"8\">Basic</AuthenticationScheme>" +
                    "</CustomProps>";

                // Set transport config
                TransInfo.TransportTypeData = transportTypeData;
                ITransportInfo transInfo = transmitPort.PrimaryTransport;

                // Set reference to transmit pipeline
                foreach (IPipeline pipe in explorer.GetCollection(CollectionType.Pipeline))
                {
                    if ((pipe.Type == PipelineType.Send) && (pipe.FullName == "Microsoft.BizTalk.DefaultPipelines.PassThruTransmit"))
                    {
                        transmitPort.SendPipeline = pipe;
                        break;
                    }
                }

                // For synchronous communications we should set up a receive pipeline
                foreach (IPipeline pipe in explorer.GetCollection(CollectionType.Pipeline))
                {
                    if ((pipe.Type == PipelineType.Receive) && (pipe.FullName == "Microsoft.BizTalk.DefaultPipelines.PassThruReceive"))
                    {
                        transmitPort.ReceivePipeline = pipe;
                        break;
                    }
                }

                // Set filter
                transmitPort.Filter =
                    "<Filter>" +
                    "<Group>" +
                    "<Statement Property=\"BTS.ReceivePortName\" Operator=\"0\" Value=\"" + receivePort + "\" />" +
                    "</Group>" +
                    "</Filter>";

                // Enlist and start send port
                transmitPort.Status = PortStatus.Started;

                // Remember this created send port
                explorer.SaveChanges();
            }
            catch (Exception e)
            {
                retMsg = e.Message.ToString();
                if (explorer != null)
                {
                    explorer.DiscardChanges();
                }
                return(false);
            }

            return(true);
        }
Beispiel #15
0
 string INamingConvention <NamingConventionSpy> .ComputeSendPortName(ISendPort <NamingConventionSpy> sendPort)
 {
     throw new NotSupportedException();
 }
 public void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort) where TNamingConvention : class
 {
     ((ISupportEnvironmentOverride)sendPort).ApplyEnvironmentOverrides(Environment);
     ((ISupportValidation)sendPort).Validate();
 }
 ISendPortCollection <TNamingConvention> ISendPortCollection <TNamingConvention> .Add(ISendPort <TNamingConvention> sendPort)
 {
     return(((ISendPortCollection <TNamingConvention>) this).Add(new[] { sendPort }));
 }
 string INamingConvention <NamingConventionDouble> .ComputeSendPortName(ISendPort <NamingConventionDouble> sendPort)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 string INamingConvention <NamingConvention> .ComputeSendPortName(ISendPort <NamingConvention> sendPort)
 {
     return(base.ComputeSendPortName(sendPort));
 }
 protected internal abstract void VisitSendPort <TNamingConvention>(ISendPort <TNamingConvention> sendPort) where TNamingConvention : class;
 public SendPortTransport(ISendPort <TNamingConvention> sendPort) : this()
 {
     SendPort = sendPort ?? throw new ArgumentNullException(nameof(sendPort));
 }