示例#1
0
        internal static SendPort TransformModel(Microsoft.BizTalk.ExplorerOM.SendPort omSendPort)
        {
            var sendPort = new SendPort
            {
                Name                 = omSendPort.Name,
                Description          = omSendPort.Description,
                FilterGroups         = FilterGroupTransformer.CreateFilterGroups(omSendPort.Filter),
                Priority             = omSendPort.Priority,
                TrackingTypes        = (TrackingTypes)omSendPort.Tracking,
                RouteFailedMessage   = omSendPort.RouteFailedMessage,
                StopSendingOnFailure = omSendPort.StopSendingOnFailure,
                Dynamic              = omSendPort.IsDynamic,
                TwoWay               = omSendPort.IsTwoWay
            };

            if (omSendPort.PrimaryTransport != null)
            {
                sendPort.PrimaryTransport = TransportInfoModelTransformer.TransforModel(omSendPort.PrimaryTransport);
            }

            if (omSendPort.SecondaryTransport != null)
            {
                sendPort.SecondaryTransport = TransportInfoModelTransformer.TransforModel(omSendPort.SecondaryTransport);
            }

            return(sendPort);
        }
示例#2
0
        static void DeleteSendPortFromSendPortGroup(SendPort sendPort)
        {
            BtsCatalogExplorer root = new BtsCatalogExplorer();

            try
            {
                root.ConnectionString = "Integrated Security=SSPI;database=BizTalkMgmtDb;server= YOURSERVER";

                //remove a receive port
                foreach (SendPortGroup sendPortGroup in root.SendPortGroups)
                {
                    if (sendPortGroup.Name == "My Send Port Group")
                    {
                        sendPortGroup.SendPorts.Remove(sendPort);
                        break;
                    }
                }

                //try to commit the changes we made so far.
                //If it fails, roll-back everything we have done so far
                root.SaveChanges();
            }
            catch (Exception e)
            {
                root.DiscardChanges();
                throw e;
            }
        }
示例#3
0
        static void ChangeSendPortStatus()
        {
            // connect to the local BizTalk configuration database
            BtsCatalogExplorer catalog = new BtsCatalogExplorer();

            catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";

            try
            {
                SendPort sendport = catalog.SendPorts["myStaticOnewaySendPort1"];

                // start the sendport to begin processing messages
                sendport.Status = PortStatus.Started;
                Console.WriteLine(sendport.Name + ": " + sendport.Status.ToString());
                catalog.SaveChanges();

                // stop the sendport to stop processing and suspend messages
                sendport.Status = PortStatus.Stopped;
                Console.WriteLine(sendport.Name + ": " + sendport.Status.ToString());
                catalog.SaveChanges();

                // unenlist the sendport to  stop processing and discard messages
                sendport.Status = PortStatus.Bound;
                Console.WriteLine(sendport.Name + ": " + sendport.Status.ToString());
                catalog.SaveChanges();
            }
            catch (Exception e)
            {
                catalog.DiscardChanges();
                throw e;
            }
        }
示例#4
0
        public string DuplicateSendPort(SendPort originalSendPort)
        {
            var app = this._catalog.Applications.Cast <Application>().FirstOrDefault(x => x.Name == originalSendPort.Application.Name);

            // génération du nouveau nom de port
            var baseNewName = Resources.copyPrefix + originalSendPort.Name;
            var newName     = baseNewName;
            var i           = 1;

            while (app.SendPorts.Cast <SendPort>().Count(x => x.Name == newName) > 0)
            {
                newName = baseNewName + i;
                i++;
            }

            //create new send port
            var newSendPort = app.AddNewSendPort(false, originalSendPort.IsTwoWay);

            newSendPort.Name   = newName;
            newSendPort.Filter = originalSendPort.Filter;

            // maps
            foreach (Transform outboundTrans in originalSendPort.OutboundTransforms)
            {
                newSendPort.OutboundTransforms.Add(outboundTrans);
            }

            // config divers
            newSendPort.Priority        = originalSendPort.Priority;
            newSendPort.OrderedDelivery = originalSendPort.OrderedDelivery;
            newSendPort.SendPipeline    = originalSendPort.SendPipeline;
            newSendPort.Description     = string.Format(Resources.TemplateDescription, originalSendPort.Name);

            // transport
            newSendPort.PrimaryTransport.TransportType     = originalSendPort.PrimaryTransport.TransportType;
            newSendPort.PrimaryTransport.Address           = originalSendPort.PrimaryTransport.Address;
            newSendPort.PrimaryTransport.OrderedDelivery   = originalSendPort.PrimaryTransport.OrderedDelivery;
            newSendPort.PrimaryTransport.RetryCount        = originalSendPort.PrimaryTransport.RetryCount;
            newSendPort.PrimaryTransport.RetryInterval     = originalSendPort.PrimaryTransport.RetryInterval;
            newSendPort.PrimaryTransport.SendHandler       = originalSendPort.PrimaryTransport.SendHandler;
            newSendPort.PrimaryTransport.TransportTypeData = originalSendPort.PrimaryTransport.TransportTypeData;

            // partie spécifique aux ports de sollicitation.réponse
            if (originalSendPort.IsTwoWay)
            {
                // maps inbound
                foreach (Transform inboundTrans in originalSendPort.InboundTransforms)
                {
                    newSendPort.InboundTransforms.Add(inboundTrans);
                }

                // receive pipeline
                newSendPort.ReceivePipeline = originalSendPort.ReceivePipeline;
            }

            // enregistrement des modifications
            this._catalog.SaveChanges();

            return(newSendPort.Name);
        }
示例#5
0
        /// <summary>
        /// </summary>
        /// <param name="sendPortName"></param>
        /// <param name="xName"></param>
        /// <param name="value"></param>
        public void SetPortTransportProperty(string sendPortName, NameValueCollection nvc)
        {
            //todo: other methods in this class could probably be refactored to leverage this pattern
            SendPort sendPort = GetSendPort(sendPortName);

            SetPortTransportProperty(sendPort, nvc);
        }
示例#6
0
        private void CreateBasicHttpSendPort(string sendPortName, string httpUri)
        {
            try
            {
                // create a new static one-way SendPort
                SendPort newPort = catalog.AddNewSendPort(false, true);
                newPort.Name = sendPortName;
                newPort.PrimaryTransport.TransportType =
                    catalog.ProtocolTypes.Cast <ProtocolType>().AsEnumerable().Single(x => x.Name == "WCF-BasicHttp");

                newPort.PrimaryTransport.Address = httpUri;
                newPort.SendPipeline             = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];

                // create a new dynamic two-way sendPort
                SendPort myDynamicTwowaySendPort = catalog.AddNewSendPort(true, true);
                myDynamicTwowaySendPort.Name            = "myDynamicTwowaySendPort1";
                myDynamicTwowaySendPort.SendPipeline    = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];
                myDynamicTwowaySendPort.ReceivePipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLReceive"];

                // persist changes to BizTalk Management database
                catalog.SaveChanges();
            }
            catch
            {
                catalog.DiscardChanges();
                throw;
            }
        }
示例#7
0
        public ActionResult SendPort(string applicationName, string artifactid, string version)
        {
            Manifest manifest = ManifestReader.GetCurrentManifest(version, Request.PhysicalApplicationPath);

            BizTalkInstallation installation = InstallationReader.GetBizTalkInstallation(manifest);

            BizTalkApplication application = installation.Applications[applicationName];

            SendPort sendPort = application.SendPorts[artifactid];

            var breadCrumbs = new List <BizTalkBaseObject>
            {
                application,
                sendPort
            };

            return(View(new SendPortViewModel(
                            application,
                            ManifestReader.GetAllManifests(Request.PhysicalApplicationPath),
                            manifest,
                            breadCrumbs,
                            installation.Applications.Values,
                            installation.Hosts.Values,
                            sendPort)));
        }
示例#8
0
        public UserControlSendPort(SendPort sendPort)
        {
            InitializeComponent();

            SendPortName.Content = sendPort.Name;

            RtbName.SetText(sendPort.Name);
            RtbDescription.SetText(sendPort.Description);
            RtbSendPipelineData.SetText(sendPort.SendPipelineData);

            MarkText(RtbName);
            MarkText(RtbDescription);
            MarkText(RtbSendPipelineData);

            if (sendPort.IsStatic)
            {
                RtbPrimaryTransmitData.SetText(sendPort.PrimaryTransport.Address);
                RtbPrimaryTransportType.SetText(sendPort.PrimaryTransport.TransportType.Name);
                RtbPrimaryTransmitData.SetXmlText(sendPort.PrimaryTransport.TransportTypeData);

                MarkText(RtbPrimaryTransmitData);
                MarkText(RtbPrimaryTransportType);
                MarkText(RtbPrimaryTransmitData);
            }
            else
            {
                GridTransports.Visibility = Visibility.Collapsed;
            }
        }
示例#9
0
        internal static void SetReferences(SendPort sendPort, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.SendPort omSendPort)
        {
            sendPort.Application  = artifacts.Applications[omSendPort.Application.Id()];
            sendPort.SendPipeline = artifacts.Pipelines[omSendPort.SendPipeline.Id()];

            // Handles dynamic send ports as these don't have a send handler configured
            if (omSendPort.PrimaryTransport != null)
            {
                sendPort.PrimaryTransport.Host = artifacts.Hosts[omSendPort.PrimaryTransport.SendHandler.Host.Id()];
            }

            if (omSendPort.SecondaryTransport != null && omSendPort.SecondaryTransport.SendHandler != null)
            {
                sendPort.SecondaryTransport.Host = artifacts.Hosts[omSendPort.SecondaryTransport.SendHandler.Host.Id()];
            }

            if (omSendPort.InboundTransforms != null)
            {
                var inboundIds = omSendPort.InboundTransforms.Cast <Microsoft.BizTalk.ExplorerOM.Transform>().Select(s => s.Id());
                sendPort.InboundTransforms.AddRange(artifacts.Transforms.Where(t => inboundIds.Contains(t.Key)).Select(s => s.Value));
            }

            if (omSendPort.OutboundTransforms != null)
            {
                var inboundIds = omSendPort.OutboundTransforms.Cast <Microsoft.BizTalk.ExplorerOM.Transform>().Select(s => s.Id());
                sendPort.InboundTransforms.AddRange(artifacts.Transforms.Where(t => inboundIds.Contains(t.Key)).Select(s => s.Value));
            }

            var orchestrations = artifacts.Orchestrations.Where(
                o =>
                o.Value.Ports.Where(p => p.SendPort != null).Select(p => p.SendPort.Id).Contains(omSendPort.Id())).
                                 Select(o => o.Value);

            sendPort.BoundOrchestrations.AddRange(orchestrations);
        }
示例#10
0
        static void CreateSendPort()
        {
            // connect to the local BizTalk configuration database
            BtsCatalogExplorer catalog = new BtsCatalogExplorer();

            catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";

            try
            {
                // create a new static one-way SendPort
                SendPort myStaticOnewaySendPort = catalog.AddNewSendPort(false, false);
                myStaticOnewaySendPort.Name = "myStaticOnewaySendPort1";
                myStaticOnewaySendPort.PrimaryTransport.TransportType = catalog.ProtocolTypes[0];
                myStaticOnewaySendPort.PrimaryTransport.Address       = "http://sample1";
                myStaticOnewaySendPort.SendPipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];

                // create a new dynamic two-way sendPort
                SendPort myDynamicTwowaySendPort = catalog.AddNewSendPort(true, true);
                myDynamicTwowaySendPort.Name            = "myDynamicTwowaySendPort1";
                myDynamicTwowaySendPort.SendPipeline    = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];
                myDynamicTwowaySendPort.ReceivePipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLReceive"];

                // persist changes to BizTalk configuration database
                catalog.SaveChanges();
            }
            catch (Exception e)
            {
                catalog.DiscardChanges();
                throw e;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string customerId = this.ddlCustomer.SelectedValue;
            string handphone  = this.txtHandPhone.Text;
            string weixin     = this.txtWeixin.Text;
            string qq         = this.txtQQ.Text;
            string email      = this.txtEmail.Text;

            if (this.hidePortID.Value == "0")
            {
                using (var context = new ReportContext())
                {
                    var entity = new SendPort
                    {
                        CustomerID = int.Parse(customerId),
                        HandPhone  = handphone,
                        Weixin     = weixin,
                        QQ         = qq,
                        Email      = email,
                        AddDate    = DateTime.Now
                    };
                    context.SendPorts.Add(entity);
                    context.SaveChanges();
                    this.ddlCustomer.SelectedIndex = -1;
                    this.txtHandPhone.Text         = string.Empty;
                    this.txtWeixin.Text            = string.Empty;
                    this.txtQQ.Text    = string.Empty;
                    this.txtEmail.Text = string.Empty;
                    InitRepeater(this.AspNetPager1.CurrentPageIndex, int.Parse(this.ddlCustomer.SelectedValue));
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('发送端口设置成功')", true);
                }
            }
            else
            {
                string id = this.hidePortID.Value;
                using (var context = new ReportContext())
                {
                    var entity = context.SendPorts.Find(int.Parse(id));
                    if (entity != null)
                    {
                        entity.CustomerID = int.Parse(customerId);
                        entity.HandPhone  = handphone;
                        entity.Weixin     = weixin;
                        entity.QQ         = qq;
                        entity.Email      = email;
                        entity.AddDate    = DateTime.Now;
                        context.SaveChanges();
                        this.ddlCustomer.SelectedIndex = -1;
                        this.txtHandPhone.Text         = string.Empty;
                        this.txtWeixin.Text            = string.Empty;
                        this.txtQQ.Text       = string.Empty;
                        this.txtEmail.Text    = string.Empty;
                        this.hidePortID.Value = "0";
                        InitRepeater(this.AspNetPager1.CurrentPageIndex, int.Parse(this.ddlCustomer.SelectedValue));
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('发送端口修改成功')", true);
                    }
                }
            }
        }
        public IEnumerable <SendPort> Get()
        {
            List <SendPort> sendPorts = new List <SendPort>();

            try
            {
                //Create EnumerationOptions and run wql query
                EnumerationOptions enumOptions = new EnumerationOptions();
                enumOptions.ReturnImmediately = false;

                //Search for DB servername and trackingDB name
                ManagementObjectSearcher   searchObject     = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", "Select TrackingDBServerName, TrackingDBName from MSBTS_GroupSetting", enumOptions);
                ManagementObjectCollection searchCollection = searchObject.Get();
                ManagementObject           obj = searchCollection.OfType <ManagementObject>().FirstOrDefault();

                string connectionString = "Server=" + obj["TrackingDBServerName"] + ";Database=" + obj["TrackingDBName"] + ";Integrated Security=True;";
                string query            = @"select A.nvcName [ApplicationName] " +
                                          ",SP.nvcName [SendPortName] " +
                                          ",SP.nPortStatus [PortStatus] " +
                                          ",MAX(MF.[Event/Timestamp]) [LastMessageSentDateTime] " +
                                          "FROM " +
                                          "BizTalkMgmtDb.dbo.bts_sendport SP " +
                                          "LEFT OUTER JOIN BizTalkDTADb.dbo.dtav_MessageFacts MF ON MF.[Event/Port] = SP.nvcName " +
                                          "JOIN BizTalkMgmtDb.dbo.bts_application A ON SP.nApplicationID = A.nID " +
                                          "group by A.nvcName, SP.nvcName, SP.nPortStatus;";
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    SqlCommand command = new SqlCommand(query, connection);
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            SendPort sendPort = new SendPort();
                            sendPort.ApplicationName = (string)reader["ApplicationName"];
                            sendPort.SendPortName    = (string)reader["SendPortName"];
                            sendPort.PortStatus      = Enum.GetName(typeof(SendPort.SendPortStatusEnum), (int)reader["PortStatus"]);
                            if (reader["LastMessageSentDateTime"] != DBNull.Value)
                            {
                                sendPort.LastMessageSentDateTime = (DateTime)reader["LastMessageSentDateTime"];
                            }

                            sendPorts.Add(sendPort);
                        }
                    }
                    finally
                    {
                        // Always call Close when done reading.
                        reader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Exception Occurred in get sendports call. " + ex.Message);
            }
            return(sendPorts);
        }
示例#13
0
        /// <summary>
        ///     only sets - catalog.SaveChanges() must be called later at the caller's disgression
        /// </summary>
        /// <param name="port"></param>
        /// <param name="xName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public void SetXPersistTransportProperty(SendPort port, string xName, string value)
        {
            TransportInfo transportInfo     = port.PrimaryTransport;
            string        transportTypeData = transportInfo.TransportTypeData;
            XDocument     transportSettings = XDocument.Parse(transportTypeData);

            transportSettings.Descendants(xName).Single().Value = value;
            transportInfo.TransportTypeData = transportSettings.ToString();
        }
示例#14
0
        public XElement GetTransportProperty(SendPort port, string xName)
        {
            TransportInfo transportInfo     = port.PrimaryTransport;
            string        transportTypeData = transportInfo.TransportTypeData;
            XDocument     transportSettings = XDocument.Parse(transportTypeData);
            var           ret = transportSettings.Descendants(xName).SingleOrDefault();

            return(ret);
        }
示例#15
0
        private void LoadAllSendPorts(TreeNode treeNode)
        {
            treeNode.Nodes.Clear();
            SendPort.SendPortCollection sendPorts = SendPort.GetInstances();

            foreach (SendPort sendPort in sendPorts)
            {
                TreeNode sendPortNode = treeNode.Nodes.Add(sendPort.Name);
                sendPortNode.Tag = sendPort;
            }
        }
示例#16
0
        static void ConfigureSendPort()
        {
            // connect to the local BizTalk configuration database
            BtsCatalogExplorer catalog = new BtsCatalogExplorer();

            catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";

            try
            {
                SendPort sendport = catalog.SendPorts["myStaticOnewaySendPort1"];

                // specify tracking settings for health and activity tracking
                sendport.Tracking = TrackingTypes.BeforeSendPipeline | TrackingTypes.AfterSendPipeline;

                // specify an encryption certificate for outgoing messages
                foreach (CertificateInfo certificate in catalog.Certificates)
                {
                    if (certificate.UsageType == CertUsageType.Encryption)
                    {
                        sendport.EncryptionCert = certificate;
                    }
                }

                // NOTE: do we need to doc the filter format
                // specify filters for content-based routing
                sendport.Filter = "<Filter><Group>" +
                                  "<Statement Property='SMTP.Subject' Operator='0' Value='Purchase Order'/>" +
                                  "<Statement Property='SMTP.From' Operator='0' Value='Customer'/>" +
                                  "</Group></Filter>";

                // specify transform maps for document normalization
                foreach (Transform transform in catalog.Transforms)
                {
                    if (transform.SourceSchema.FullName == "myPO" &&
                        transform.TargetSchema.FullName == "partnerPO")
                    {
                        sendport.OutboundTransforms.Add(transform);
                    }
                }

                // persist changes to BizTalk configuration database
                catalog.SaveChanges();
            }
            catch (Exception e)
            {
                catalog.DiscardChanges();
                throw e;
            }
        }
        protected override bool ControlIndividualArtifact(string name, Dictionary <string, object> metadata, BtsCatalogExplorer catalog, Application app)
        {
            SendPort inst = app.SendPorts[name];

            PortStatus status = inst.Status;

            ActionType action = (ActionType)metadata[ActionMetadataKey];

            switch (action)
            {
            case ActionType.Enlist:
                if (status == PortStatus.Bound)
                {
                    this.Log.LogMessage(action.ToString() + "ing send port '" + name + "'...");
                    inst.Status = PortStatus.Stopped;
                    return(true);
                }
                break;

            case ActionType.Unenlist:
                if (status != PortStatus.Bound)
                {
                    this.Log.LogMessage("Unenlisting send port '" + name + "'...");
                    inst.Status = PortStatus.Bound;
                    return(true);
                }
                break;

            case ActionType.Start:
                if (status != PortStatus.Started)
                {
                    this.Log.LogMessage("Starting send port '" + name + "'...");
                    inst.Status = PortStatus.Started;
                    return(true);
                }
                break;

            case ActionType.Stop:
                if (status == PortStatus.Started)
                {
                    this.Log.LogMessage(action.ToString() + "ing send port '" + name + "'...");
                    inst.Status = PortStatus.Stopped;
                    return(true);
                }
                break;
            }

            return(false);
        }
示例#18
0
        public void ClearSendPortProxy(string sendPortName)
        {
            SendPort sendPort = GetSendPort(sendPortName);

            if (sendPort == null)
            {
                throw new ArgumentException(string.Format("Send port \"{0}\" was not found in the BizTalk catalog.", sendPortName));
            }

            NameValueCollection nvc = new NameValueCollection();

            nvc.Add(TransportPropertyNames.ProxyAddress, string.Empty);
            nvc.Add(TransportPropertyNames.ProxyToUse, "Default");
            SetPortTransportProperty(sendPort, nvc);
        }
示例#19
0
 /// <summary>
 /// </summary>
 /// <param name="sendPortName"></param>
 /// <param name="xName"></param>
 /// <param name="value"></param>
 public void SetPortTransportProperty(SendPort sendPort, NameValueCollection nvc)
 {
     //todo: other methods in this class could probably be refactored to leverage this pattern
     try
     {
         foreach (var xName in nvc.AllKeys)
         {
             SetXPersistTransportProperty(sendPort, xName, nvc[xName]);
         }
         catalog.SaveChanges();
     }
     catch
     {
         catalog.DiscardChanges();
         throw;
     }
 }
示例#20
0
        /// <summary>
        ///     ModifySendPrimaryTransport method to modify the SendPort's URI.
        /// </summary>
        /// <param name="sendPortName">Name of the send port</param>
        /// <param name="proxyUri">Proxy uri (e.g. http://localhost:8080)</param>
        /// <returns></returns>
        public void SetSendPortProxy(string sendPortName, string proxyUri)
        {
            SendPort sendPort = GetSendPort(sendPortName);

            if (sendPort == null)
            {
                throw new ArgumentException(string.Format("Send port \"{0}\" was not found in the BizTalk catalog.", sendPortName));
            }

            NameValueCollection nvc = new NameValueCollection
            {
                { TransportPropertyNames.ProxyAddress, proxyUri },
                { TransportPropertyNames.ProxyToUse, "UserSpecified" }
            };

            SetPortTransportProperty(sendPortName, nvc);
        }
示例#21
0
 public SendPortViewModel(BizTalkApplication currentApplication, IEnumerable <Manifest> manifests, Manifest currentManifest, IEnumerable <BizTalkBaseObject> breadCrumbs, IEnumerable <BizTalkApplication> applications, IEnumerable <Host> hosts, SendPort sendPort)
     : base(currentApplication, manifests, currentManifest, breadCrumbs, applications, hosts)
 {
     SendPort = sendPort;
 }
示例#22
0
        private MessagingObject CreateSendEndpoint(string endpointKeyPrefix, SendPort sendPort)
        {
            AdapterEndpoint endpointAdapter;

            // Is this a static or dynamic send port (that is, has a transport been set)?
            if (sendPort.IsStatic)
            {
                _logger.LogDebug(TraceMessages.CreatingSendEndpointAdapter, RuleName, sendPort.PrimaryTransport.TransportType.Name, sendPort.Name);

                // TODO: Use primary transport only, but need to think about how to handle backup transport

                // Create an endpoint adapter (assume request-reply or send, but some adapters may be fire and forget which will be changed later by a specific rule)
                endpointAdapter = new AdapterEndpoint(sendPort.Name, sendPort.PrimaryTransport.TransportType.Name);

                // Set step name as a property on the endpoint
                endpointAdapter.Properties.Add(ModelConstants.ScenarioStepName, $"{sendPort.PrimaryTransport.TransportType.Name.ToLowerInvariant()}SendAdapter");
            }
            else
            {
                _logger.LogDebug(TraceMessages.CreatingDynamicSendEndpointAdapter, RuleName, sendPort.Name);

                // Create an endpoint adapter (assume request-reply or send, but some adapters may be fire and forget which will be changed later by a specific rule)
                endpointAdapter = new AdapterEndpoint(sendPort.Name, MigrationTargetResources.DynamicSendPortDefaultProtocol);

                // Set step name as a property on the endpoint
                endpointAdapter.Properties.Add(ModelConstants.ScenarioStepName, $"{MigrationTargetResources.DynamicSendPortDefaultProtocol.ToLowerInvariant()}SendAdapter");

                // TODO: Handle dynamic send port - need to figure out how to find the actual procotol from an orchestration
            }

            // Set common property values
            endpointAdapter.Activator   = false;
            endpointAdapter.Description = sendPort.Description;
            endpointAdapter.Key         = $"{endpointKeyPrefix}:{ModelConstants.AdapterEndpointLeafKey}";
            endpointAdapter.MessageDeliveryGuarantee = MessageDeliveryGuarantee.AtLeastOnce;
            endpointAdapter.MessageExchangePattern   = sendPort.IsTwoWay ? MessageExchangePattern.RequestReply : MessageExchangePattern.Send;

            // Set BizTalk specific configuration properties
            var configurationEntries = new Dictionary <string, object>()
            {
                { ModelConstants.IsTwoWay, sendPort.IsTwoWay }
            };

            // Add configuration properties
            endpointAdapter.Properties.Add(ModelConstants.ConfigurationEntry, configurationEntries);

            // Set BizTalk specific routing properties
            var routingProperties = new Dictionary <string, object>()
            {
                { ModelConstants.BizTalkSpName, ModelConstants.BizTalkSpName },
                { ModelConstants.BizTalkSpId, ModelConstants.BizTalkSpId }
            };

            // Add routing properties if two-way
            if (sendPort.IsTwoWay)
            {
                // Set BizTalk specific routing properties
                routingProperties.Add(ModelConstants.BizTalkAckReceivePortName, ModelConstants.BizTalkAckReceivePortName);
                routingProperties.Add(ModelConstants.BizTalkAckReceivePortId, ModelConstants.BizTalkAckReceivePortId);
                routingProperties.Add(ModelConstants.BizTalkAckSendPortName, ModelConstants.BizTalkAckSendPortName);
                routingProperties.Add(ModelConstants.BizTalkAckSendPortId, ModelConstants.BizTalkAckSendPortId);
                routingProperties.Add(ModelConstants.BizTalkAckInboundTransportLocation, ModelConstants.BizTalkAckInboundTransportLocation);
                routingProperties.Add(ModelConstants.BizTalkAckOutboundTransportLocation, ModelConstants.BizTalkAckOutboundTransportLocation);
                routingProperties.Add(ModelConstants.BizTalkAckFailureCategory, ModelConstants.BizTalkAckFailureCategory);
                routingProperties.Add(ModelConstants.BizTalkAckFailureCode, ModelConstants.BizTalkAckFailureCode);
                routingProperties.Add(ModelConstants.BizTalkAckId, ModelConstants.BizTalkAckId);
                routingProperties.Add(ModelConstants.BizTalkAckType, ModelConstants.BizTalkAckType);
            }

            // Add routing properties
            endpointAdapter.Properties.Add(ModelConstants.RoutingProperties, routingProperties);

            // TODO: Add schema references from source application

            // By default, this isn't convertible unless overridden by a specific rule
            endpointAdapter.Rating = ConversionRating.NoAutomaticConversion;

            return(endpointAdapter);
        }
示例#23
0
 /// <summary>
 ///     ModifySendPrimaryTransport method to modify the SendPort's URI.
 /// </summary>
 /// <param name="sendPort">send port</param>
 /// <param name="proxyUri">Proxy uri (e.g. http://localhost:8080)</param>
 /// <returns></returns>
 public void SetSendPortProxy(SendPort sendPort, string proxyUri)
 {
     SetSendPortProxy(sendPort.Name, proxyUri);
 }
示例#24
0
        /// <summary>
        /// Binds the route with the routing slip router between the intermediaries and endpoint.
        /// </summary>
        /// <param name="intermediaryKeyPrefix">The prefix for the intermediary key.</param>
        /// <param name="targetApplication">The application in the target.</param>
        /// <param name="sendPort">The send port.</param>
        /// <param name="route">The chain of messaging objects that need to be bound by routing slip router.</param>
        /// <returns>Returns the new route bound with routing slip router intermediaries.</returns>
        private IList <MessagingObject> BindRoute(string intermediaryKeyPrefix, Application targetApplication, SendPort sendPort, IList <MessagingObject> route)
        {
            _logger.LogDebug(TraceMessages.BindingRouteForSendPort, RuleName, sendPort.Name);

            var boundRoute = new List <MessagingObject>();

            // Add routing slip routers
            for (var i = 1; i < route.Count; i++)
            {
                // Determine from and to steps
                var fromStep = route[i - 1];
                var toStep   = route[i];

                // Add step and then follow with a routing slip router intermediary
                boundRoute.Add(fromStep);
                boundRoute.Add(CreateRoutingSlipRouterIntermediary(intermediaryKeyPrefix, fromStep.Name, toStep.Name));

                // If at the end, add last step
                if (i == (route.Count - 1))
                {
                    boundRoute.Add(toStep);
                }
            }

            // Add to target application
            foreach (var step in boundRoute)
            {
                if (step is Endpoint)
                {
                    targetApplication.Endpoints.Add((Endpoint)step);
                }
                else
                {
                    targetApplication.Intermediaries.Add((Intermediary)step);
                }
            }

            return(boundRoute);
        }
示例#25
0
        public SendPort GetSendPort(string sendPortName)
        {
            SendPort sendPort = catalog.SendPorts[sendPortName];

            return(sendPort);
        }
示例#26
0
        /// <summary>
        /// Binds the route with the routing slip router between the intermediaries and endpoint (if present).
        /// </summary>
        /// <param name="intermediaryKeyPrefix">The prefix for the intermediary key.</param>
        /// <param name="targetApplication">The application in the target.</param>
        /// <param name="sendPort">The send port.</param>
        /// <param name="route">The chain of messaging objects that need to be bound by routing slip router.</param>
        /// <returns>Returns the new route bound with routing slip router intermediaries.</returns>
        private IList <MessagingObject> BindResponseRoute(string intermediaryKeyPrefix, Application targetApplication, SendPort sendPort, IList <MessagingObject> route)
        {
            _logger.LogDebug(TraceMessages.BindingRouteForSendPortResponse, RuleName, sendPort.Name);

            var boundRoute = new List <MessagingObject>();

            for (var i = 0; i < route.Count; i++)
            {
                // Get messaging object
                var step = route[i];

                // Determine from and to step names (if last step, end the route)
                var fromStep = route[i].Name;
                var toStep   = i == (route.Count - 1) ? MigrationTargetResources.EndRoute : route[i + 1].Name;

                // Add step and then follow with a routing slip router intermediary
                boundRoute.Add(step);
                boundRoute.Add(CreateRoutingSlipRouterIntermediary(intermediaryKeyPrefix, fromStep, toStep));
            }

            // Add to target application
            foreach (var step in boundRoute)
            {
                if (!(step is Endpoint))
                {
                    targetApplication.Intermediaries.Add((Intermediary)step);
                }
            }

            return(boundRoute);
        }
示例#27
0
        /// <summary>
        ///     only sets - catalog.SaveChanges() must be called later at the caller's disgression
        /// </summary>
        /// <param name="port"></param>
        /// <param name="xName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public XElement GetTransportProperty(string sendPortName, string xName)
        {
            SendPort port = GetSendPort(sendPortName);

            return(GetTransportProperty(port, xName));
        }
示例#28
0
        /// <summary>
        /// Binds the endpoint and intermediaries together.
        /// </summary>
        /// <param name="channelKeyPrefix">The prefix for the channel key.</param>
        /// <param name="activatorChannelKey">The key of the channel that hooks up to the activator intermediary.</param>
        /// <param name="targetApplication">The application in the target.</param>
        /// <param name="sendPort">The send port.</param>
        /// <param name="route">The chain of messaging objects that need to be bound by channels.</param>
        private void BindChannels(string channelKeyPrefix, string activatorChannelKey, Application targetApplication, SendPort sendPort, IList <MessagingObject> route)
        {
            _logger.LogDebug(TraceMessages.BindingChannelsForSendPort, RuleName, sendPort.Name);

            // Find topic channel to hook up the route
            var activatorChannel = Model.FindMessagingObject(activatorChannelKey);

            if (activatorChannel.application != null && activatorChannel.messagingObject != null)
            {
                // First object in route should be an activating intermediary, hook it up to the activator channel (if it's not an activator, it's a bug!)
                var activatorIntermediary = (Intermediary)route.First();
                if (activatorIntermediary.Activator)
                {
                    activatorIntermediary.InputChannelKeyRefs.Add(activatorChannel.messagingObject.Key);

                    // Assume route is in order, that is, first entry is the start of the route.  As the route is built
                    // in this class, not expecting anything other than intermediaries and an endpoint.
                    for (var i = 0; i < route.Count - 1; i++)
                    {
                        // Determine from and to steps
                        var fromStep = route[i];
                        var toStep   = route[i + 1];

                        // Create channel
                        var channel = new TriggerChannel(MigrationTargetResources.TriggerChannelName)
                        {
                            Description = string.Format(CultureInfo.CurrentCulture, MigrationTargetResources.TriggerChannelDescription, toStep.Name),
                            Key         = $"{channelKeyPrefix}:{ModelConstants.TriggerChannelLeafKey}:{fromStep.Name.FormatKey()}-{toStep.Name.FormatKey()}",
                            Rating      = ConversionRating.FullConversion
                        };

                        // Are we going from a routing slip router?
                        if (fromStep is RoutingSlipRouter)
                        {
                            // Set URL
                            var scenarioStep = toStep.Properties[ModelConstants.ScenarioStepName];
                            channel.TriggerUrl = $"/routingManager/route/{scenarioStep}";

                            // Label the channel appropriately
                            channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteToChannelLabel);
                        }
                        else
                        {
                            // Label the channel appropriately
                            channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteFromChannelLabel);
                        }

                        // Add channel to application
                        targetApplication.Channels.Add(channel);

                        // Bind channel with endpoint and intermediaries
                        ((Intermediary)fromStep).OutputChannelKeyRefs.Add(channel.Key);

                        if (toStep is Endpoint toEndpoint)
                        {
                            toEndpoint.InputChannelKeyRef = channel.Key;
                        }

                        if (toStep is Intermediary toIntermediary)
                        {
                            toIntermediary.InputChannelKeyRefs.Add(channel.Key);
                        }
                    }
                }
                else
                {
                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.SendRouteStartNotAnActivator, activatorChannel.messagingObject.Name);
                    _logger.LogError(error);
                    Context.Errors.Add(new ErrorMessage(error));
                }
            }
            else
            {
                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindMessagingObjectWithKeyInTargetModel, MessagingObjectType.Channel, activatorChannelKey);
                _logger.LogError(error);
                Context.Errors.Add(new ErrorMessage(error));
            }
        }
示例#29
0
        /// <summary>
        /// Binds the intermediaries and endpoint together.
        /// </summary>
        /// <param name="channelKeyPrefix">The prefix for the channel key.</param>
        /// <param name="targetApplication">The application in the target.</param>
        /// <param name="sendPort">The send port.</param>
        /// <param name="route">The chain of messaging objects that need to be bound by channels.</param>
        private void BindResponseChannels(string channelKeyPrefix, Application targetApplication, SendPort sendPort, IList <MessagingObject> route)
        {
            _logger.LogDebug(TraceMessages.BindingChannelsForReceivePort, RuleName, sendPort.Name);

            // Assume route is in order, that is, first entry is the start of the route.  As the route is built
            // in this class, not expecting anything other than intermediaries and optionally an endpoint.
            for (var i = 0; i < route.Count - 1; i++)
            {
                // Determine from and to steps
                var fromStep = route[i];
                var toStep   = route[i + 1];

                // Create channel
                var channel = new TriggerChannel(MigrationTargetResources.TriggerChannelName)
                {
                    Description = string.Format(CultureInfo.CurrentCulture, MigrationTargetResources.TriggerChannelDescription, toStep),
                    Key         = $"{channelKeyPrefix}:{ModelConstants.TriggerChannelLeafKey}Response:{fromStep.Name.FormatKey()}-{toStep.Name.FormatKey()}",
                    Rating      = ConversionRating.FullConversion
                };

                // Are we going from a routing slip router?
                if (fromStep is RoutingSlipRouter)
                {
                    // Set URL
                    var scenarioStep = toStep.Properties[ModelConstants.ScenarioStepName];
                    channel.TriggerUrl = $"/routingManager/route/{scenarioStep}";

                    // Label the channel appropriately
                    channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteToChannelLabel);
                }
                else
                {
                    // Label the channel appropriately
                    channel.Properties.Add(ModelConstants.RouteLabel, MigrationTargetResources.RouteFromChannelLabel);
                }

                // Add channel to application
                targetApplication.Channels.Add(channel);

                // Bind channel with endpoint and intermediaries
                if (fromStep is Endpoint endpoint)
                {
                    endpoint.OutputChannelKeyRef = channel.Key;
                }

                if (fromStep is Intermediary intermediary)
                {
                    intermediary.OutputChannelKeyRefs.Add(channel.Key);
                }

                ((Intermediary)toStep).InputChannelKeyRefs.Add(channel.Key);
            }
        }
示例#30
0
        /// <summary>
        /// Creates a default object model for parsing and building a report.
        /// </summary>
        /// <returns></returns>
        public static AzureIntegrationServicesModel CreateDefaultModelForParsing()
        {
            var aisModel = new AzureIntegrationServicesModel();

            // Create a report node with a resource container and resource definitions
            var resourceContainer = new ResourceContainer()
            {
                Name        = "TestApp1.msi",
                Description = "This is the description of the MSI.",
                Type        = ModelConstants.ResourceContainerMsi,
                Key         = "test-app-1-container-key"
            };

            aisModel.MigrationSource.ResourceContainers.Add(resourceContainer);

            var appResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "App 1 Resource Definition",
                Key         = $"{resourceContainer.Key}:app-1",
                Description = "App 1 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition1);

            var appResource1 = new ResourceItem
            {
                Name        = "App 1 Resource Definition Application",
                Key         = $"{appResourceDefinition1.Key}:app-resource-1",
                Description = "App 1 Resource Description",
                Type        = ModelConstants.ResourceApplication
            };

            appResourceDefinition1.Resources.Add(appResource1);

            var appResourceDefinition2 = new ResourceDefinition()
            {
                Name        = "App 2 Resource Definition",
                Key         = $"{resourceContainer.Key}:app-2",
                Description = "App 2 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition2);

            var appResource2 = new ResourceItem
            {
                Name        = "App 2 Resource Definition Application",
                Key         = $"{appResourceDefinition2.Key}:app-resource-2",
                Description = "App 1 Resource Description",
                Type        = ModelConstants.ResourceApplication
            };

            appResourceDefinition2.Resources.Add(appResource2);

            var appResourceDefinition3 = new ResourceDefinition()
            {
                Name        = "App 3 Resource Definition",
                Key         = $"{resourceContainer.Key}:app-3",
                Description = "App 3 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition3);

            var appResource3 = new ResourceItem
            {
                Name        = "App 3 Resource Definition Application",
                Key         = $"{appResourceDefinition3.Key}:pp-resource-3",
                Description = "App 3 Resource Description",
                Type        = ModelConstants.ResourceApplication
            };

            appResourceDefinition3.Resources.Add(appResource3);

            var schemaResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "DocumentSchema1",
                Description = "This is document schema 1.",
                Type        = ModelConstants.ResourceDefinitionSchema,
                Key         = $"{resourceContainer.Key}:document-schema-1"
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition1);

            var schemaResource1 = new ResourceItem()
            {
                Name        = "DocumentSchema1",
                Description = "This is document schema 1.",
                Type        = ModelConstants.ResourceDocumentSchema,
                Key         = $"{schemaResourceDefinition1.Key}:document-schema-1:schema"
            };

            schemaResourceDefinition1.Resources.Add(schemaResource1);

            var schemaResourceDefinition2 = new ResourceDefinition()
            {
                Name        = "DocumentSchema2",
                Description = "This is document schema 2.",
                Type        = ModelConstants.ResourceDefinitionSchema,
                Key         = $"{resourceContainer.Key}:document-schema-2"
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition2);

            var schemaResource2 = new ResourceItem()
            {
                Name        = "DocumentSchema2",
                Description = "This is document schema 2.",
                Type        = ModelConstants.ResourceDocumentSchema,
                Key         = $"{schemaResourceDefinition2.Key}:document-schema-2:schema"
            };

            schemaResourceDefinition2.Resources.Add(schemaResource2);

            var schemaResourceDefinition3 = new ResourceDefinition()
            {
                Name        = "PropertySchema1",
                Description = "This is property schema 1.",
                Type        = ModelConstants.ResourceDefinitionSchema,
                Key         = $"{resourceContainer.Key}:property-schema-1"
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition3);

            var schemaResource3 = new ResourceItem()
            {
                Name        = "PropertySchema1",
                Description = "This is property schema 2.",
                Type        = ModelConstants.ResourceDocumentSchema,
                Key         = $"{schemaResourceDefinition3.Key}:property-schema-1:schema"
            };

            schemaResourceDefinition3.Resources.Add(schemaResource3);

            var schemaResource3Property1 = new ResourceItem()
            {
                Name        = "Property1",
                Description = "This is property 2",
                Type        = ModelConstants.ResourcePropertySchema,
                Key         = $"{schemaResourceDefinition3.Key}:property-schema-1:schema:Property1"
            };

            schemaResourceDefinition3.Resources.Add(schemaResource3Property1);

            var schemaResource3Property2 = new ResourceItem()
            {
                Name        = "Property2",
                Description = "This is property 2",
                Type        = ModelConstants.ResourcePropertySchema,
                Key         = $"{schemaResourceDefinition3.Key}:property-schema-1:schema:Property2"
            };

            schemaResourceDefinition3.Resources.Add(schemaResource3Property2);

            var transformResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "Transform1",
                Description = "This is transform 1.",
                Type        = ModelConstants.ResourceDefinitionMap,
                Key         = $"{resourceContainer.Key}:transform-1"
            };

            resourceContainer.ResourceDefinitions.Add(transformResourceDefinition1);

            var transformResource1 = new ResourceItem()
            {
                Name        = "Transform1",
                Description = "This is the transform 1, resource",
                Type        = ModelConstants.ResourceMap,
                Key         = $"{transformResourceDefinition1.Key}:transform-1-resource"
            };

            transformResourceDefinition1.Resources.Add(transformResource1);

            var bindingResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "Binding1",
                Description = "This is binding 1.",
                Type        = ModelConstants.ResourceDefinitionBindings,
                Key         = $"{resourceContainer.Key}:binding-1"
            };

            resourceContainer.ResourceDefinitions.Add(bindingResourceDefinition1);

            var sendPortResource1 = new ResourceItem()
            {
                Name        = "SendPort1",
                Description = "This is sendport 1.",
                Type        = ModelConstants.ResourceSendPort,
                Key         = $"{bindingResourceDefinition1.Key}:sendport-1"
            };

            bindingResourceDefinition1.Resources.Add(sendPortResource1);

            var sendPortFilterResource1 = new ResourceItem()
            {
                Name        = "SendPort1-Filter",
                Description = "This is sendport 1, filter expression",
                Type        = ModelConstants.ResourceFilterExpression,
                Key         = $"{sendPortResource1.Key}:sendport-1-filter"
            };

            sendPortResource1.Resources.Add(sendPortFilterResource1);

            var receivePortResource1 = new ResourceItem()
            {
                Name        = "ReceivePort1",
                Description = "This is receive port 1.",
                Type        = ModelConstants.ResourceReceivePort,
                Key         = $"{bindingResourceDefinition1.Key}:receiveport-1"
            };

            bindingResourceDefinition1.Resources.Add(receivePortResource1);

            var receiveLocation1 = new ResourceItem()
            {
                Name        = "ReceiveLocation1",
                Description = "This is receive location 1.",
                Type        = ModelConstants.ResourceReceiveLocation,
                Key         = $"{receivePortResource1.Key}:receivelocation-1"
            };

            receivePortResource1.Resources.Add(receiveLocation1);

            var distributionListResource1 = new ResourceItem
            {
                Name        = "DistributionList1",
                Description = "This is distributionlist 1.",
                Type        = ModelConstants.ResourceDistributionList,
                Key         = $"{bindingResourceDefinition1.Key}:distributionlist-1"
            };

            bindingResourceDefinition1.Resources.Add(distributionListResource1);

            var distributionListFilterResource1 = new ResourceItem
            {
                Name        = "DistributionListFilter1",
                Description = "This is distribution list filer 1.",
                Type        = ModelConstants.ResourceFilterExpression,
                Key         = $"{distributionListResource1.Key}:distributionlistfilter-1"
            };

            distributionListResource1.Resources.Add(distributionListFilterResource1);

            // Create a parsed BizTalk Application Group
            var applicationGroup = new ParsedBizTalkApplicationGroup();

            aisModel.MigrationSource.MigrationSourceModel = applicationGroup;

            // Create applications
            var application1 = new ParsedBizTalkApplication();

            application1.Application.Name = "Test App 1";
            applicationGroup.Applications.Add(application1);

            var application2 = new ParsedBizTalkApplication();

            application2.Application.Name     = "Test App 2";
            application2.Application.Bindings = new BindingFile {
                BindingInfo = new BindingInfo()
            };

            applicationGroup.Applications.Add(application2);

            var application3 = new ParsedBizTalkApplication();

            application3.Application.Name = "Test App 3";
            applicationGroup.Applications.Add(application3);
            application3.Application.Bindings = new BindingFile {
                BindingInfo = new BindingInfo()
            };

            var container = new ResourceContainer();

            container.ResourceDefinitions.Add(new ResourceDefinition());
            container.ResourceDefinitions[0].Resources.Add(new ResourceItem {
                Key = appResource1.Key
            });
            aisModel.MigrationSource.ResourceContainers.Add(container);

            // Create application definitions
            application1.Application.ApplicationDefinition = new ApplicationDefinitionFile()
            {
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = appResourceDefinition1.Key,
                ResourceKey           = appResource1.Key,
                ApplicationDefinition = new ApplicationDefinition()
                {
                    Properties = new List <ApplicationDefinitionProperty>()
                    {
                        new ApplicationDefinitionProperty()
                        {
                            Name = "DisplayName", Value = application1.Application.Name
                        },
                        new ApplicationDefinitionProperty()
                        {
                            Name = "ApplicationDescription", Value = application1.Application.Name + " Description"
                        }
                    }.ToArray()
                }
            };

            application2.Application.ApplicationDefinition = new ApplicationDefinitionFile()
            {
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = appResourceDefinition2.Key,
                ResourceKey           = appResource2.Key,
                ApplicationDefinition = new ApplicationDefinition()
                {
                    References = new List <ApplicationDefinitionReference>()
                    {
                        new ApplicationDefinitionReference()
                        {
                            Name = application3.Application.Name
                        }
                    }.ToArray(),
                    Properties = new List <ApplicationDefinitionProperty>()
                    {
                        new ApplicationDefinitionProperty()
                        {
                            Name = "DisplayName", Value = application2.Application.Name
                        },
                        new ApplicationDefinitionProperty()
                        {
                            Name = "ApplicationDescription", Value = application2.Application.Name + " Description"
                        }
                    }.ToArray()
                }
            };

            application3.Application.ApplicationDefinition = new ApplicationDefinitionFile()
            {
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = appResourceDefinition3.Key,
                ResourceKey           = appResource3.Key,
                ApplicationDefinition = new ApplicationDefinition()
                {
                    Properties = new List <ApplicationDefinitionProperty>()
                    {
                        new ApplicationDefinitionProperty()
                        {
                            Name = "DisplayName", Value = application3.Application.Name
                        },
                        new ApplicationDefinitionProperty()
                        {
                            Name = "ApplicationDescription", Value = application3.Application.Name + " Description"
                        }
                    }.ToArray()
                }
            };

            // Create schemas
            var documentSchema1 = new Types.Entities.Schema()
            {
                Name                  = "DocumentSchema1",
                Namespace             = "Test.Schemas",
                FullName              = "Test.Schemas.DocumentSchema1",
                XmlNamespace          = "http://schemas.test.com/DocumentSchema1",
                RootNodeName          = "Root",
                ResourceContainerKey  = "app-1-assembly-resource-key",
                ResourceDefinitionKey = schemaResourceDefinition1.Key,
                ResourceKey           = schemaResource1.Key,
                SchemaType            = BizTalkSchemaType.Document
            };

            documentSchema1.MessageDefinitions.Add(new MessageDefinition(documentSchema1.RootNodeName, documentSchema1.XmlNamespace, "Test.Schemas.DocumentSchema1", "DocumentSchema1", "document-schema-1:schema:Root"));
            documentSchema1.PromotedProperties.Add(new PromotedProperty()
            {
                PropertyType = "Test.Schemas.PropertySchema1.Property1", XPath = "some xpath"
            });
            application1.Application.Schemas.Add(documentSchema1);

            var documentSchema2 = new Types.Entities.Schema()
            {
                Name                  = "DocumentSchema2",
                Namespace             = "Test.Schemas",
                FullName              = "Test.Schemas.DocumentSchema2",
                XmlNamespace          = "http://schemas.test.com/DocumentSchema2",
                RootNodeName          = "Root",
                ResourceContainerKey  = "app-1-assembly-resource-key",
                ResourceDefinitionKey = schemaResourceDefinition2.Key,
                ResourceKey           = schemaResource2.Key,
                SchemaType            = BizTalkSchemaType.Document
            };

            documentSchema2.MessageDefinitions.Add(new MessageDefinition(documentSchema2.RootNodeName, documentSchema2.XmlNamespace, "Test.Schemas.DocumentSchema2", "DocumentSchema2", "document-schema-2:schema:Root"));
            application1.Application.Schemas.Add(documentSchema2);

            var propertySchema = new Types.Entities.Schema()
            {
                Name                  = "PropertySchema1",
                Namespace             = "Test.Schemas",
                FullName              = "Test.Schemas.PropertySchema1",
                XmlNamespace          = "http://schemas.test.com/PropertySchema1",
                RootNodeName          = "Root",
                ResourceDefinitionKey = schemaResourceDefinition3.Key,
                ResourceKey           = schemaResource3.Key,
                SchemaType            = BizTalkSchemaType.Property
            };

            propertySchema.ContextProperties.Add(new ContextProperty()
            {
                DataType = "xs:string", FullyQualifiedName = "Test.Schemas.PropertySchema1.Property1", PropertyName = schemaResource3Property1.Name, Namespace = "Test.Schemas.PropertySchema1", ResourceKey = schemaResource3Property1.Key
            });
            propertySchema.ContextProperties.Add(new ContextProperty()
            {
                DataType = "xs:int", FullyQualifiedName = "Test.Schemas.PropertySchema1.Property2", PropertyName = schemaResource3Property2.Name, Namespace = "Test.Schemas.PropertySchema1", ResourceKey = schemaResource3Property2.Key
            });
            application1.Application.Schemas.Add(propertySchema);

            // Create transforms
            var map = new Types.Entities.Transform()
            {
                Name                  = "Transform1",
                FullName              = "Test.Maps.Transform1",
                ModuleName            = "Test.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
                Namespace             = "Test.Maps",
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = transformResourceDefinition1.Key
            };

            map.SourceSchemaTypeNames.Add("Test.Schemas.DocumentSchema1");
            map.TargetSchemaTypeNames.Add("Test.Schemas.DocumentSchema2");
            application1.Application.Transforms.Add(map);

            // Create send ports.
            var sendPort = new SendPort
            {
                ResourceKey      = sendPortResource1.Key,
                Description      = "This is a send port description.",
                Name             = "Test.SendPorts.SendPort1",
                FilterExpression = new Types.Entities.Filters.Filter
                {
                    Group = new Types.Entities.Filters.Group[]
                    {
                        new Types.Entities.Filters.Group
                        {
                            Statement = new Types.Entities.Filters.Statement[]
                            {
                                new Types.Entities.Filters.Statement()
                            }
                        }
                    }
                }
            };

            /// Create receive ports.
            var receivePort = new ReceivePort
            {
                ResourceKey      = receivePortResource1.Key,
                Description      = receivePortResource1.Description,
                Name             = receivePortResource1.Name,
                ReceiveLocations = new ReceiveLocation[]
                {
                    new ReceiveLocation
                    {
                        ResourceKey = receiveLocation1.Key,
                        Name        = receiveLocation1.Name,
                        Description = receiveLocation1.Name
                    }
                }
            };

            // Create distribution lists.
            var distributionList = new DistributionList
            {
                ResourceKey      = distributionListResource1.Key,
                Description      = distributionListResource1.Description,
                Name             = distributionListResource1.Name,
                FilterExpression = new Types.Entities.Filters.Filter
                {
                    ResourceKey = distributionListFilterResource1.Key,
                    Group       = new Types.Entities.Filters.Group[]
                    {
                        new Types.Entities.Filters.Group()
                    }
                }
            };

            application1.Application.Bindings = new BindingFile
            {
                BindingInfo = new BindingInfo
                {
                    SendPortCollection         = new SendPort[] { sendPort },
                    ReceivePortCollection      = new ReceivePort[] { receivePort },
                    DistributionListCollection = new DistributionList[] { distributionList }
                }
            };

            var app1Msi = new ResourceContainer()
            {
                Name        = "App 1 MSI",
                Description = "App 1 MSI Description",
                Key         = "app-1-msi-resource-key",
                Type        = ModelConstants.ResourceContainerMsi
            };

            aisModel.MigrationSource.ResourceContainers.Add(app1Msi);
            var app1Cab = new ResourceContainer()
            {
                Name        = "App 1 CAB",
                Description = "App 1 CAB Description",
                Key         = $"{app1Msi.Key}:app-1-cab-resource-key",
                Type        = ModelConstants.ResourceContainerCab
            };

            app1Msi.ResourceContainers.Add(app1Cab);
            var app1Assembly = new ResourceContainer()
            {
                Name        = "App 1 Assembly",
                Description = "App 1 Assembly Description",
                Key         = $"{app1Cab.Key}:app-1-assembly-resource-key",
                Type        = ModelConstants.ResourceContainerAssembly
            };

            app1Cab.ResourceContainers.Add(app1Assembly);
            var app1Schema = new ResourceDefinition()
            {
                Name        = "Document Schema 1",
                Description = "Document Schema 1 Description",
                Key         = $"{app1Assembly.Key}:document-schema-1",
                Type        = ModelConstants.ResourceDefinitionSchema
            };

            app1Assembly.ResourceDefinitions.Add(app1Schema);
            var app1DocumentSchema = new ResourceItem()
            {
                Name        = "DocumentSchema1",
                Description = "DocumentSchema1Description",
                Key         = $"{app1Schema.Key}:app-1-schema-resource-key"
            };

            app1Schema.Resources.Add(app1DocumentSchema);
            var app1Schema2 = new ResourceDefinition()
            {
                Name        = "Document Schema 2",
                Description = "Document Schema 2 Description",
                Key         = $"{app1Assembly.Key}:document-schema-2",
                Type        = ModelConstants.ResourceDefinitionSchema
            };

            app1Assembly.ResourceDefinitions.Add(app1Schema2);
            var app1DocumentSchema2 = new ResourceItem()
            {
                Name        = "DocumentSchema2",
                Description = "DocumentSchema2Description",
                Key         = $"{app1Schema.Key}:app-1-schema-2-resource-key"
            };

            app1Schema.Resources.Add(app1DocumentSchema2);

            return(aisModel);
        }