Пример #1
0
        public static DocumentEntity getMergedDocument(long sessionId)
        {
            Dictionary <string, object> listParameter = new Dictionary <string, object>();

            string result = SendGetRequest(AppsSettings.GetInstance().ApiUrl + String.Format("/reviewDocx/getMergedFile/{0}", sessionId), listParameter);

            if (result.Equals(""))
            {
                return(new DocumentEntity());
            }
            else
            {
                try
                {
                    DocumentMessage sessionMsg = JsonConvert.DeserializeObject <DocumentMessage>(result);
                    if (sessionMsg != null)
                    {
                        return(sessionMsg.data);
                    }
                    else
                    {
                        return(new DocumentEntity());
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    return(new DocumentEntity());
                }
            }
        }
Пример #2
0
        public Response SendDocument(DocumentMessage message)
        {
            string url = baseUrl + "senddocument";

            MultipartFormDataContent multiContent = new MultipartFormDataContent
            {
                { new StringContent(message.ChatId.ToString()), "chat_id" },
                { new StringContent(message.Caption), "caption" },
            };

            if (message.ReplyToMessageId != null)
            {
                multiContent.Add(new StringContent("reply_to_message_id"), message.ReplyToMessageId?.ToString());
            }

            ByteArrayContent documentContent = new ByteArrayContent(message.Document);

            documentContent.Headers.ContentType = new MediaTypeHeaderValue("audio/mpeg");

            multiContent.Add(documentContent, "document");


            HttpResponseMessage response = client.PostAsync(url, multiContent).Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                Response result = Utils.Deserialize <Response>(response.Content.ReadAsStringAsync().Result);
                return(result);
            }


            return(new Response());
        }
Пример #3
0
 /// <summary>
 /// Called when [description item message].
 /// </summary>
 /// <param name="obj">The object.</param>
 private void OnDescriptionItemMessage(DocumentMessage <DescriptionItem> obj)
 {
     if (obj.MessageType == DocumentMessageType.Update)
     {
         RefreshDescription(obj.Document);
     }
 }
Пример #4
0
 /// <summary>
 /// Called when [message].
 /// </summary>
 /// <param name="obj">The object.</param>
 private void OnHookItemMessage(DocumentMessage <HookItem> obj)
 {
     switch (obj.MessageType)
     {
     case DocumentMessageType.Update:
     {
         RefreshDescriptions(obj.Document);
         break;
     }
     }
 }
        public void ConvertWithMissingAppConfig(SC002PropertySchemaGenerator generator, IFileRepository fileRepository, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e)
        {
            var messageName = "testMessageName";

            "Given a model"
            .x(() => model = new AzureIntegrationServicesModel());

            "And a message with no appConfig"
            .x(() =>
            {
                var documentMessage = new DocumentMessage
                {
                    Name = messageName
                };

                documentMessage.RoutingProperties.Add("routingPropertyKey1", "routingPropertyValue1");

                var application = new Application();
                application.Messages.Add(documentMessage);

                model.MigrationTarget.MessageBus = new MessageBus();
                model.MigrationTarget.MessageBus.Applications.Add(application);
            });

            "And a file repository"
            .x(() => fileRepository = _mockFileRepository.Object);

            "And a logger"
            .x(() => logger = new Mock <ILogger>().Object);

            "And a context"
            .x(() => context = new MigrationContext());

            "And a generator"
            .x(() => generator = new SC002PropertySchemaGenerator(fileRepository, model, context, logger));

            "When converting"
            .x(async() => e = await Record.ExceptionAsync(async() => await generator.ConvertAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then the code should not throw an exception"
            .x(() => e.Should().BeNull());

            "And there should be a context error"
            .x(() =>
            {
                context.Errors.Should().NotBeEmpty();
                context.Errors.Should().HaveCount(1);
                context.Errors.First().Message.Should().Contain(ModelConstants.ResourceTypeRoutingProperties);
                context.Errors.First().Message.Should().Contain(messageName);
            });
        }
Пример #6
0
        public void BuildMessage_DocumentJSON_TelegramDocumentMessage()
        {
            var expected = new DocumentMessage
            {
                From     = _user,
                Document = _document,
                Caption  = _caption
            };

            AttachGeneralProperties(expected);
            var actual           = MessageBuilder.BuildMessage <DocumentMessage>(_messageToken);
            var compareLogic     = new CompareLogic(_config);
            var comparisonResult = compareLogic.Compare(expected, actual);

            Assert.IsTrue(comparisonResult.AreEqual, comparisonResult.DifferencesString);
        }
Пример #7
0
        public string Encode()
        {
            ISecretMessage message;

            if (File.Exists(mSrcMessage))
            {
                message = new DocumentMessage(mSrcMessage, mCompression, CryptoAlgorithm, mPassword);
            }
            else
            {
                message = new TextMessage(mSrcMessage, mCompression, CryptoAlgorithm, mPassword);
            }

            var result = SteganoAlgorithm.Encode(mSrcObj, message, PasswordHash, mLsbIndicator);

            return(result);
        }
Пример #8
0
        public void SortTargetMessagingObjectByNameXYEqual(MessagingObject x, MessagingObject y, int result)
        {
            "Given a resource x"
            .x(() => x = new DocumentMessage()
            {
                Name = "z"
            });

            "And a resource relationship to compare to"
            .x(() => y = new DocumentMessage()
            {
                Name = "z"
            });

            "When comparing x and y"
            .x(() => result = Comparers.SortTargetMessagingObjectByName(x, y));

            "Expect x to be less than y"
            .x(() => {
                result.Should().Be(0);
            });
        }
Пример #9
0
        public static DocumentEntity RequestMergeAndGetResult(long idAudioParent)
        {
            string url = AppsSettings.GetInstance().ApiUrl + "/reviewDocx/mergeFileEndGetResult";
            Dictionary <string, object> listParameter = new Dictionary <string, object>();

            listParameter.Add("idAudioParent", idAudioParent);

            string result = SendPostJsonApplicationTypeRequest(url, listParameter);

            try
            {
                DocumentMessage message = JsonConvert.DeserializeObject <DocumentMessage>(result);
                if (message != null && message.status == Constants.RESPONSE_STATUS_SUCCESS)
                {
                    return(message.data);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
            return(null);
        }
Пример #10
0
        public async Task HandleFileForceReply(DocumentMessage message)
        {
            if (message.ReplyToMessage == null)
            {
                return;
            }

            try
            {
                FileForceReplyLockers.Add(message.From);

                #region handleAction

                var handleAction = new Func <Task>(async() =>
                {
                    var model = await _dbWorker.FindNmStoreAsync(message.From);
                    if (model == null)
                    {
                        await _botActions.SendLostInfoMessage(message.From);
                        return;
                    }
                    if (message.Document.FileSize > _botSettings.MaxAttachmentSizeBytes)
                    {
                        await _botActions.SendErrorAboutMaxAttachmentSizeToChat(message.From, message.Document.FileName);
                        return;
                    }
                    model.File.Add(new FileModel
                    {
                        FileId       = message.Document.FileId,
                        OriginalName = message.Document.FileName
                    });
                    await _dbWorker.UpdateNmStoreRecordAsync(model);
                    await _botActions.UpdateNewMailMessage(message.From, SendKeyboardState.Continue, model);
                    await _botActions.DeleteMessage(message.ReplyToMessage.Chat, message.ReplyToMessage.MessageId);
                });

                #endregion

                if (FileForceReplyLockers.Any(l => l == message.From))
                {
                    await _fileForceReplySemaphore.WaitAsync();

                    try
                    {
                        await handleAction();
                    }
                    finally
                    {
                        _fileForceReplySemaphore.Release();
                    }
                }
                else
                {
                    await handleAction();
                }
            }
            finally
            {
                FileForceReplyLockers.Remove(message.From);
            }
        }
Пример #11
0
        /// <summary>
        /// Builds a target model.
        /// </summary>
        /// <param name="model">The model.</param>
        private static void BuildTargetModel(AzureIntegrationServicesModel model)
        {
            model.MigrationTarget.TargetEnvironment     = AzureIntegrationServicesTargetEnvironment.Consumption;
            model.MigrationTarget.DeploymentEnvironment = "dev";
            model.MigrationTarget.AzurePrimaryRegion    = "UK South";
            model.MigrationTarget.AzureSecondaryRegion  = "West US";
            model.MigrationTarget.UniqueDeploymentId    = "unit-test";
            model.MigrationTarget.MessageBus            = new MessageBus()
            {
                Name           = "Message Bus",
                Key            = "MessageBus",
                Type           = MessagingObjectType.MessageBus,
                Description    = "Azure Integration Services Message Bus",
                ResourceMapKey = "messageBus",
                Rating         = ConversionRating.NotSupported
            };

            // Message Bus resources
            var resource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "deployResources",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "deploy-resources",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = ""
            };

            resource1.ResourceTemplateFiles.Add("Deploy-All.ps1.liquid");
            resource1.ResourceTemplateFiles.Add("TearDown-All.ps1.liquid");
            model.MigrationTarget.MessageBus.Resources.Add(resource1);

            var resource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "messageBusAzureResourceGroup",
                TemplateType = "microsoft.template.arm",
                ResourceName = "arrg-aimmsgbus-dev-uksouth",
                ResourceType = "microsoft.groups.azureresourcegroup",
                OutputPath   = "messagebus/messagebusgroup",
            };

            resource2.Tags.Add("ApplicationName", "AIM-MessageBus");
            resource2.Tags.Add("Env", "dev");
            resource2.Parameters.Add("azure_primary_region", "UK South");
            resource2.Parameters.Add("azure_secondary_region", "West US");
            resource2.Parameters.Add("azure_subscription_id", "");
            resource2.ResourceTemplateFiles.Add("messagebus/messagebusgroup/messagebusgroup.dev.parameters.json.liquid");
            resource2.ResourceTemplateFiles.Add("messagebus/messagebusgroup/messagebusgroup.json.liquid");
            model.MigrationTarget.MessageBus.Resources.Add(resource2);

            var resource3 = new TargetResourceTemplate()
            {
                TemplateKey  = "deployMessageBusGroup",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "arrg-aimmsgbus-dev-uksouth",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "messagebus/messagebusgroup",
            };

            resource3.Parameters.Add("azure_primary_region", "UK South");
            resource3.Parameters.Add("azure_secondary_region", "West US");
            resource3.Parameters.Add("azure_subscription_id", "");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/Deploy-10-MessageBusGroup.ps1.liquid");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/New-MessageBusGroup.ps1.liquid");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/TearDown-10-MessageBusGroup.ps1.liquid");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/Remove-MessageBusGroup.ps1.liquid");
            model.MigrationTarget.MessageBus.Resources.Add(resource3);

            var resource4 = new TargetResourceTemplate()
            {
                TemplateKey  = "messageBusServiceAzureRole",
                TemplateType = "microsoft.template.json",
                ResourceName = "arapim-aimmsgbussvc-dev",
                ResourceType = "microsoft.security.azurerole",
                OutputPath   = "messagebus/messagebusservice"
            };

            resource4.ResourceTemplateFiles.Add("messagebus/messagebusservice/messagebusservice.logicappsrole.json");
            model.MigrationTarget.MessageBus.Resources.Add(resource4);

            // Applications
            var application1 = new Application()
            {
                Name           = "BTS2010FlatFilePipelineSample",
                Key            = "MessageBus:BTS2010FlatFilePipelineSample",
                Type           = MessagingObjectType.Application,
                Description    = "Azure Integration Application",
                ResourceMapKey = "applicationBTS2010FlatFilePipelineSample",
                Rating         = ConversionRating.NoRating,
            };

            model.MigrationTarget.MessageBus.Applications.Add(application1);

            var appresource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "applicationAzureResourceGroupBTS2010FlatFilePipelineSample",
                TemplateType = "microsoft.template.arm",
                ResourceName = "arrg-aimapp-bts2010flatfilepipelinesample-dev-uksouth",
                ResourceType = "microsoft.groups.azureresourcegroup",
                OutputPath   = "applications/bts2010flatfilepipelinesample/bts2010flatfilepipelinesamplegroup",
            };

            appresource1.Tags.Add("ApplicationName", "BTS2010FlatFilePipelineSample");
            appresource1.Tags.Add("Env", "dev");
            appresource1.Parameters.Add("azure_primary_region", "UK South");
            appresource1.Parameters.Add("azure_secondary_region", "West US");
            appresource1.Parameters.Add("azure_subscription_id", "");
            appresource1.ResourceTemplateFiles.Add("application/applicationgroup/applicationgroup.json.liquid");
            appresource1.ResourceTemplateFiles.Add("application/applicationgroup/applicationgroup.dev.parameters.json.liquid");
            application1.Resources.Add(appresource1);

            var appresource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "deployApplicationGroupBTS2010FlatFilePipelineSample",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "arrg-aimapp-bts2010flatfilepipelinesample-dev-uksouth",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "applications/bts2010flatfilepipelinesample/bts2010flatfilepipelinesamplegroup",
            };

            appresource2.Parameters.Add("azure_primary_region", "UK South");
            appresource2.Parameters.Add("azure_secondary_region", "West US");
            appresource2.Parameters.Add("azure_subscription_id", "");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/Deploy-10-ApplicationGroup.ps1.liquid");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/New-ApplicationGroup.ps1.liquid");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/TearDown-10-ApplicationGroup.ps1.liquid");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/Remove-ApplicationGroup.ps1.liquid");
            application1.Resources.Add(appresource2);

            // Messages in the application
            var documentmessage1 = new DocumentMessage()
            {
                MessageType   = MessageType.Document,
                ContentType   = MessageContentType.Xml,
                MessageSchema = new MessageSchema()
                {
                    Name           = "NewOrder",
                    ResourceKeyRef = "BTS2010FlatFilePipelineSample:ITEM~0:BTS2010FlatFilePipelineSample:NewOrder:schema:Order"
                },
                Name           = "NewOrder",
                Key            = "MessageBus:BTS2010FlatFilePipelineSample:NewOrder",
                Type           = MessagingObjectType.Message,
                Description    = "Azure Integration Application Schema",
                ResourceMapKey = "applicationMessageBTS2010FlatFilePipelineSampleNewOrder",
                Rating         = ConversionRating.NoRating
            };

            application1.Messages.Add(documentmessage1);

            var messageresource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "deploySchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            messageresource1.Parameters.Add("azure_primary_region", "UK South");
            messageresource1.Parameters.Add("azure_secondary_region", "West US");
            messageresource1.Parameters.Add("azure_subscription_id", "");
            messageresource1.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            messageresource1.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            messageresource1.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/Deploy-100-Schema.ps1.liquid");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/New-Schema.ps1.liquid");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/Remove-Schema.ps1.liquid");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/TearDown-100-Schema.ps1.liquid");
            documentmessage1.Resources.Add(messageresource1);

            var messageresource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "messagesAzureIntegrationAccountSchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.json",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.schemas.xml",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            messageresource2.Tags.Add("Application", "BTS2010FlatFilePipelineSample");
            messageresource2.Tags.Add("Env", "dev");
            messageresource2.Parameters.Add("azure_primary_region", "UK South");
            messageresource2.Parameters.Add("azure_secondary_region", "West US");
            messageresource2.Parameters.Add("azure_subscription_id", "");
            messageresource2.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            messageresource2.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            messageresource2.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            messageresource2.ResourceTemplateFiles.Add("messages/schemas/requestbody.dev.json.liquid");
            documentmessage1.Resources.Add(messageresource2);

            // Endpoints
            var ftpadapter1 = new AdapterEndpoint()
            {
                Type                     = MessagingObjectType.Endpoint,
                AdapterProtocol          = "FTP",
                MessageExchangePattern   = MessageExchangePattern.Receive,
                Name                     = "FTP Receive",
                Description              = "FTP Receive Adapter",
                EndpointType             = EndpointType.Adapter,
                MessageDeliveryGuarantee = MessageDeliveryGuarantee.AtLeastOnce,
                Activator                = true,
            };

            ftpadapter1.MessageKeyRefs.Add("MessageBus:BTS2010FlatFilePipelineSample:NewOrder");
            ftpadapter1.OutputChannelKeyRef = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter";
            ftpadapter1.Properties.Add("scenario", "Aim.BizTalk.FTPPassthru.RcvFile.RcvFile.FTP");
            ftpadapter1.Properties.Add("scenarioStep", "ftpReceiveAdapter");
            ftpadapter1.Properties.Add("configuration", new Dictionary <string, object>
            {
                { "btsReceivePortName", "RcvFile" }
            });
            ftpadapter1.ReportMessages.Add(new ReportMessage()
            {
                Severity = MessageSeverity.Error, Message = ModelResources.ExampleErrorMessage
            });
            ftpadapter1.ReportMessages.Add(new ReportMessage()
            {
                Severity = MessageSeverity.Warning, Message = ModelResources.ExampleWarningMessage
            });
            ftpadapter1.ReportMessages.Add(new ReportMessage()
            {
                Severity = MessageSeverity.Information, Message = ModelResources.ExampleInformationMessage
            });
            application1.Endpoints.Add(ftpadapter1);

            var adapterresource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "deploySchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            adapterresource1.Parameters.Add("azure_primary_region", "UK South");
            adapterresource1.Parameters.Add("azure_secondary_region", "West US");
            adapterresource1.Parameters.Add("azure_subscription_id", "");
            adapterresource1.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            adapterresource1.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            adapterresource1.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/Deploy-100-Schema.ps1.liquid");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/New-Schema.ps1.liquid");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/Remove-Schema.ps1.liquid");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/TearDown-100-Schema.ps1.liquid");
            ftpadapter1.Resources.Add(adapterresource1);

            var adapterresource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "messagesAzureIntegrationAccountSchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.json",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.schemas.xml",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            adapterresource2.Tags.Add("Application", "BTS2010FlatFilePipelineSample");
            adapterresource2.Tags.Add("Env", "dev");
            adapterresource2.Parameters.Add("azure_primary_region", "UK South");
            adapterresource2.Parameters.Add("azure_secondary_region", "West US");
            adapterresource2.Parameters.Add("azure_subscription_id", "");
            adapterresource2.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            adapterresource2.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            adapterresource2.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            adapterresource2.ResourceTemplateFiles.Add("messages/schemas/requestbody.dev.json.liquid");
            ftpadapter1.Resources.Add(adapterresource2);

            // Create the channel for the FTP adapter
            var channel1 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.RoutingSlipRouter intermediary.",
            };

            application1.Channels.Add(channel1);

            var routingSlipRouter = new RoutingSlipRouter()
            {
                Type              = MessagingObjectType.Intermediary,
                IntermediaryType  = IntermediaryType.MessageRouter,
                MessageRouterType = MessageRouterType.ContentBasedRouter,
                Name              = "Routing Slip Router",
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:RoutingSlipRouter:RcvFile.FTP-ContentPromoter",
                Description = "The routing slip router calls the next step in the route which is Content Promoter.",
            };

            routingSlipRouter.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter");
            routingSlipRouter.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            application1.Intermediaries.Add(routingSlipRouter);

            var channel2 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.",
                TriggerUrl  = "/routingManager/route/contentPromoter"
            };

            application1.Channels.Add(channel2);

            var contentPromoter = new ContentPromoter()
            {
                Type                 = MessagingObjectType.Intermediary,
                IntermediaryType     = IntermediaryType.MessageProcessor,
                MessageProcessorType = MessageProcessorType.ContentPromoter,
            };

            contentPromoter.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            contentPromoter.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:ContentPromoter-RoutingSlipRouter");
            application1.Intermediaries.Add(contentPromoter);

            var channel3 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:ContentPromoter-RoutingSlipRouter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.RoutingSlipRouter intermediary.",
            };

            application1.Channels.Add(channel3);

            var routingSlipRouter2 = new RoutingSlipRouter()
            {
                Type              = MessagingObjectType.Intermediary,
                IntermediaryType  = IntermediaryType.MessageRouter,
                MessageRouterType = MessageRouterType.ContentBasedRouter,
                Name              = "Routing Slip Router",
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:ContentPromoter",
                Description = "The routing slip router calls the next step in the route which is Content Promoter.",
            };

            routingSlipRouter2.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            routingSlipRouter2.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            application1.Intermediaries.Add(routingSlipRouter2);

            var channel4 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.",
                TriggerUrl  = "/routingManager/route/contentPromoter"
            };

            application1.Channels.Add(channel4);

            var contentPromoter2 = new ContentPromoter()
            {
                Type                 = MessagingObjectType.Intermediary,
                IntermediaryType     = IntermediaryType.MessageProcessor,
                MessageProcessorType = MessageProcessorType.ContentPromoter,
                Name                 = "Content Promoter",
                Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:ContentPromoter",
            };

            contentPromoter2.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            contentPromoter2.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            application1.Intermediaries.Add(contentPromoter2);

            var channel5 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.",
                TriggerUrl  = "/routingManager/route/contentPromoter"
            };

            application1.Channels.Add(channel5);

            // System application
            var systemapp = new Application()
            {
                Name           = "System Application",
                Key            = "MessageBus:SystemApplication",
                Type           = MessagingObjectType.Application,
                Description    = "Azure Integration System Application",
                ResourceMapKey = "applicationSystemApplication",
                Rating         = ConversionRating.NoRating,
            };

            model.MigrationTarget.MessageBus.Applications.Add(systemapp);

            // Channels in the system application
            var topicchannel1 = new TopicChannel()
            {
                ChannelType    = ChannelType.PublishSubscribe,
                Name           = "Message Box",
                Key            = "MessageBus:SystemApplication:MessageBox",
                Type           = MessagingObjectType.Channel,
                Description    = "Azure Integration Message Box",
                ResourceMapKey = "messageBox",
                Rating         = ConversionRating.NotSupported
            };

            systemapp.Channels.Add(topicchannel1);
        }
Пример #12
0
 public virtual Task <Message> SendDocumentAsync(DocumentMessage message,
                                                 CancellationToken cancellationToken = default)
 {
     return(Client.SendDocumentAsync(message.ChatId, message.InputOnlineFile, message.Caption, message.ParseMode,
                                     message.DisableNotification, message.ReplyToMessageId, message.ReplyMarkup, cancellationToken));
 }
Пример #13
0
        /// <summary>
        /// Gets a populated model to use for the tests.
        /// </summary>
        /// <returns>A model instance.</returns>
        public static AzureIntegrationServicesModel GetModel()
        {
            var model = new AzureIntegrationServicesModel();

            model.MigrationTarget.TargetEnvironment     = AzureIntegrationServicesTargetEnvironment.Consumption;
            model.MigrationTarget.DeploymentEnvironment = "dev";
            model.MigrationTarget.AzureSubscriptionId   = "azure-subs-id";
            model.MigrationTarget.AzurePrimaryRegion    = "UK South";
            model.MigrationTarget.AzureSecondaryRegion  = "UK West";

            // Add a message bus
            model.MigrationTarget.MessageBus = new MessageBus()
            {
                Name           = "ContosoMessageBus",
                Key            = "ContosoMessageBus",
                ResourceMapKey = "messageBus"
            };

            // Add an application
            var systemApp = new Application()
            {
                Name = "System",
                Key  = "ContosoMessageBus:System"
            };

            model.MigrationTarget.MessageBus.Applications.Add(systemApp);

            var app = new Application()
            {
                Name           = "AppA",
                Key            = "ContosoMessageBus:AppA",
                ResourceMapKey = "application"
            };

            model.MigrationTarget.MessageBus.Applications.Add(app);

            // Add an application message
            var appMessage = new DocumentMessage()
            {
                Name           = "PurchaseOrderFlatFile",
                Key            = "ContosoMessageBus:AppA:PurchaseOrderFlatFile",
                ContentType    = MessageContentType.Xml,
                ResourceMapKey = "applicationMessage"
            };

            app.Messages.Add(appMessage);

            // Add a message box
            var messageBox = new TopicChannel()
            {
                Name           = "MessageBox",
                Key            = "ContosoMessageBus:System:MessageBox",
                ResourceMapKey = "messageBox"
            };

            systemApp.Channels.Add(messageBox);

            // Add a message agent
            var messageAgent = new ContentBasedRouter()
            {
                Name           = "MessageAgent",
                Key            = "ContosoMessageBus:System:MessageAgent",
                ResourceMapKey = "messageAgent"
            };

            systemApp.Intermediaries.Add(messageAgent);

            // Add a process manager
            var processManager = new ProcessManager()
            {
                Name           = "FtpTransformWorkflow",
                Key            = "ContosoMessageBus:AppA:FtpTransformWorkflow",
                ResourceMapKey = "processManager"
            };

            processManager.WorkflowModel = GetWorkflowModel();
            app.Intermediaries.Add(processManager);

            // Add workflow model to process manager
            // Add an FTP endpoint
            var ftpReceive = new AdapterEndpoint()
            {
                Name           = "FtpReceive",
                Key            = "ContosoMessageBus:System:FtpReceive",
                ResourceMapKey = "ftpReceive"
            };

            systemApp.Endpoints.Add(ftpReceive);

            return(model);
        }
        /// <summary>
        /// Creates the schema for applications in the migration target.
        /// </summary>
        /// <param name="token">The cancellation token.</param>
        /// <returns>Task used to await the operation.</returns>
        protected override async Task AnalyzeInternalAsync(CancellationToken token)
        {
            // Get parsed BizTalk model from the application model
            var parsedApplicationGroup = Model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (parsedApplicationGroup?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingRuleAsSourceModelMissing, RuleName, nameof(SC001SchemaAnalyzer));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningRule, RuleName, nameof(SC001SchemaAnalyzer));

                foreach (var targetApplication in Model.MigrationTarget.MessageBus.Applications)
                {
                    var sourceApplication = parsedApplicationGroup.Applications.SingleOrDefault(a => a.Application.Name == targetApplication.Name);
                    if (sourceApplication?.Application?.Schemas != null)
                    {
                        var schemaMessages = from schema in sourceApplication.Application.Schemas
                                             from messageDefinition in schema.MessageDefinitions
                                             where schema.SchemaType == Types.Enumerations.BizTalkSchemaType.Document
                                             select new { Schema = schema, MessageDefinition = messageDefinition };

                        foreach (var schemaMessage in schemaMessages)
                        {
                            var appName     = $"{sourceApplication.Application.Name.Replace(".", "-").Replace(" ", string.Empty).Replace(":", "-")}";
                            var messageName = $"{schemaMessage.MessageDefinition.LocalName.Replace(".", "-").Replace(" ", string.Empty).Replace("/", "-").Replace(":", "-")}";

                            var resourceMapKey = $"applicationMessage{appName}{messageName}";

                            // Check if the schema is an envelope or document schema?
                            if (schemaMessage.Schema.IsEnvelope)
                            {
                                // Create an envelope message
                                var envelopeMessage = new EnvelopeMessage
                                {
                                    Name           = schemaMessage.MessageDefinition.LocalName,
                                    Key            = $"{targetApplication.Key}:{schemaMessage.MessageDefinition.LocalName}",
                                    Description    = MigrationTargetResources.SchemaDescription,
                                    ResourceMapKey = resourceMapKey,
                                    ContentType    = MessageContentType.Xml,
                                    MessageSchema  = new MessageSchema
                                    {
                                        ResourceKeyRef = schemaMessage.MessageDefinition.ResourceKey,
                                        Name           = schemaMessage.Schema.Name
                                    }
                                };

                                envelopeMessage.Properties[ModelConstants.MessageType] = schemaMessage.MessageDefinition.MessageType;
                                envelopeMessage.Properties[ModelConstants.TypeName]    = schemaMessage.Schema.FullName;

                                targetApplication.Messages.Add(envelopeMessage);

                                _logger.LogDebug(TraceMessages.CreatedEnvelopeMessage, RuleName, schemaMessage.Schema.Name);
                            }
                            else
                            {
                                // Create a document message
                                var documentMessage = new DocumentMessage
                                {
                                    Name           = schemaMessage.MessageDefinition.LocalName,
                                    Key            = $"{targetApplication.Key}:{schemaMessage.MessageDefinition.LocalName}",
                                    Description    = MigrationTargetResources.SchemaDescription,
                                    ResourceMapKey = resourceMapKey,
                                    ContentType    = MessageContentType.Xml,
                                    MessageSchema  = new MessageSchema
                                    {
                                        ResourceKeyRef = schemaMessage.MessageDefinition.ResourceKey,
                                        Name           = schemaMessage.Schema.Name
                                    }
                                };

                                documentMessage.Properties[ModelConstants.MessageType] = schemaMessage.MessageDefinition.MessageType;
                                documentMessage.Properties[ModelConstants.TypeName]    = schemaMessage.Schema.FullName;

                                targetApplication.Messages.Add(documentMessage);

                                _logger.LogDebug(TraceMessages.CreatedDocumentMessage, RuleName, schemaMessage.Schema.Name);
                            }
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.RuleCompleted, RuleName, nameof(SC001SchemaAnalyzer));
            }

            await Task.CompletedTask.ConfigureAwait(false);
        }
        public void ConvertWithSuccess(SC002PropertySchemaGenerator generator, IFileRepository fileRepository, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e)
        {
            var messageName        = "testMessageName";
            var conversionFolder   = @"c:\conversionFolder";
            var templateOutputPath = "templateOutputPath";
            var messageSchemaName  = "testMessageSchemaName";

            var    generatedFileName = string.Empty;
            JToken generatedJson     = null;

            "Given a model"
            .x(() => model = new AzureIntegrationServicesModel());

            "And a message with no appConfig"
            .x(() =>
            {
                var documentMessage = new DocumentMessage
                {
                    Name          = messageName,
                    MessageSchema = new MessageSchema
                    {
                        Name = messageSchemaName
                    }
                };

                documentMessage.RoutingProperties.Add("routingPropertyKey1", "routingPropertyValue1");

                documentMessage.Resources.Add(new TargetResourceTemplate
                {
                    OutputPath   = templateOutputPath,
                    ResourceType = ModelConstants.ResourceTypeRoutingProperties
                });

                var application = new Application();
                application.Messages.Add(documentMessage);

                model.MigrationTarget.MessageBus = new MessageBus();
                model.MigrationTarget.MessageBus.Applications.Add(application);
            });

            "And a file repository"
            .x(() =>
            {
                _mockFileRepository.Setup(f => f.WriteJsonFile(
                                              It.IsAny <string>(),
                                              It.IsAny <JToken>()
                                              ))
                .Callback <string, JToken>(
                    (p1, p2) =>
                {
                    generatedFileName = p1;
                    generatedJson     = p2;
                });

                fileRepository = _mockFileRepository.Object;
            });

            "And a logger"
            .x(() => logger = new Mock <ILogger>().Object);

            "And a context"
            .x(() =>
            {
                context = new MigrationContext
                {
                    ConversionFolder = conversionFolder
                };
            });

            "And a generator"
            .x(() => generator = new SC002PropertySchemaGenerator(fileRepository, model, context, logger));

            "When converting"
            .x(async() => e = await Record.ExceptionAsync(async() => await generator.ConvertAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then the code should not throw an exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().BeNullOrEmpty());

            "And the file should be generated"
            .x(() =>
            {
                _mockFileRepository.Verify(f => f.WriteJsonFile(
                                               It.IsAny <string>(),
                                               It.IsAny <JObject>()), Times.Once);

                var expectedPath = Path.Combine(conversionFolder, templateOutputPath);

                generatedFileName.Should().StartWith(expectedPath);
                generatedJson.Should().NotBeNull();
            });
        }
Пример #16
0
 /// <summary>
 /// Called when [hook item message].
 /// </summary>
 /// <param name="obj">The object.</param>
 private void OnHookItemMessage(DocumentMessage <HookItem> obj)
 {
     RefreshDocument(obj.Document.Id);
 }
Пример #17
0
        /// <summary>
        /// Creates a default object model for converting.
        /// </summary>
        /// <returns></returns>
        public static AzureIntegrationServicesModel CreateDefaultModelForConverting()
        {
            var model = 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"
            };

            model.MigrationSource.ResourceContainers.Add(resourceContainer);

            var appResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "App 1 Resource Definition",
                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         = "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         = "app-2",
                Description = "App 2 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition2);

            var appResource2 = new ResourceItem
            {
                Name        = "App 2 Resource Definition Application",
                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         = "app-3",
                Description = "App 3 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition3);

            var appResource3 = new ResourceItem
            {
                Name        = "App 3 Resource Definition Application",
                Key         = "app-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             = "document-schema-1",
                ResourceContent = "<some xml>"
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition1);

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

            schemaResourceDefinition1.Resources.Add(schemaResource1);

            var messageResource1 = new ResourceItem()
            {
                Name        = "Message1",
                Description = "This is message 1.",
                Type        = ModelConstants.ResourceMessageType,
                Key         = "document-schema-1:schema1:message1",
                ParentRefId = schemaResource1.RefId
            };

            schemaResource1.Resources.Add(messageResource1);

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

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition2);

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

            schemaResourceDefinition2.Resources.Add(schemaResource2);

            var messageResource2 = new ResourceItem()
            {
                Name        = "Message2",
                Description = "This is message 2.",
                Type        = ModelConstants.ResourceMessageType,
                Key         = "document-schema-2:schema2:message2",
                ParentRefId = schemaResource2.RefId
            };

            schemaResource2.Resources.Add(messageResource2);

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

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition3);

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

            schemaResourceDefinition3.Resources.Add(schemaResource3);

            var messageResource3 = new ResourceItem()
            {
                Name        = "Message3",
                Description = "This is message 3.",
                Type        = ModelConstants.ResourceMessageType,
                Key         = "document-schema-3:schema3:message3",
                ParentRefId = schemaResource3.RefId
            };

            schemaResource3.Resources.Add(messageResource3);

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

            schemaResourceDefinition3.Resources.Add(schemaResource3Property1);

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

            schemaResourceDefinition3.Resources.Add(schemaResource3Property2);

            var transformResourceDefinition1 = new ResourceDefinition()
            {
                Name            = "Transform1",
                Description     = "This is transform 1.",
                Type            = ModelConstants.ResourceDefinitionMap,
                Key             = "transform-1",
                ParentRefId     = resourceContainer.RefId,
                ResourceContent = "<some xml>"
            };

            resourceContainer.ResourceDefinitions.Add(transformResourceDefinition1);

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

            transformResourceDefinition1.Resources.Add(transformResource1);

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

            resourceContainer.ResourceDefinitions.Add(bindingResourceDefinition1);

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

            bindingResourceDefinition1.Resources.Add(sendPortResource1);

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

            sendPortResource1.Resources.Add(sendPortFilterResource1);

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

            bindingResourceDefinition1.Resources.Add(receivePortResource1);

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

            receivePortResource1.Resources.Add(receiveLocation1);

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

            bindingResourceDefinition1.Resources.Add(distributionListResource1);

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

            distributionListResource1.Resources.Add(distributionListFilterResource1);

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

            model.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()
            };

            // 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",
                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",
                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 }
                }
            };

            // Target model
            model.MigrationTarget.TargetEnvironment     = AzureIntegrationServicesTargetEnvironment.Consumption;
            model.MigrationTarget.DeploymentEnvironment = "dev";
            model.MigrationTarget.AzureSubscriptionId   = "azure-subs-id";
            model.MigrationTarget.AzurePrimaryRegion    = "UK South";
            model.MigrationTarget.AzureSecondaryRegion  = "UK West";

            // Add a message bus
            model.MigrationTarget.MessageBus = new MessageBus()
            {
                Name           = "ContosoMessageBus",
                Key            = "ContosoMessageBus",
                ResourceMapKey = "messageBus",
            };
            var messageBusResourceTemplate = new TargetResourceTemplate()
            {
                OutputPath = "output"
            };

            messageBusResourceTemplate.ResourceTemplateFiles.Add("path/to/file.json.liquid");
            messageBusResourceTemplate.ResourceTemplateFiles.Add("path/to/file2.json");
            model.MigrationTarget.MessageBus.Resources.Add(messageBusResourceTemplate);

            // Add an application
            var systemApp = new Application()
            {
                Name = "System",
                Key  = "ContosoMessageBus:System"
            };

            model.MigrationTarget.MessageBus.Applications.Add(systemApp);

            var app = new Application()
            {
                Name           = "AppA",
                Key            = "ContosoMessageBus:AppA",
                ResourceMapKey = "application"
            };

            model.MigrationTarget.MessageBus.Applications.Add(app);

            // Add an application message
            var appMessage = new DocumentMessage()
            {
                Name          = "PurchaseOrderFlatFile",
                MessageSchema = new MessageSchema
                {
                    ResourceKeyRef = messageResource1.Key,
                    Name           = messageResource2.Name
                },
                Key            = "ContosoMessageBus:AppA:PurchaseOrderFlatFile",
                ContentType    = MessageContentType.Xml,
                ResourceMapKey = "applicationMessage"
            };

            app.Messages.Add(appMessage);

            var appMessageResource1 = new TargetResourceTemplate()
            {
                OutputPath   = "OutputPath",
                ResourceType = ModelConstants.ResourceTypeXml
            };

            appMessage.Resources.Add(appMessageResource1);

            var transform = new MessageTransform
            {
                Name           = "MessageTransform",
                ResourceKeyRef = "transform-1-resource",
            };

            appMessage.MessageTransforms.Add(transform);

            var appMessageResource2 = new TargetResourceTemplate()
            {
                OutputPath   = "OutputPath",
                ResourceType = ModelConstants.ResourceTypeXslt
            };

            appMessage.Resources.Add(appMessageResource2);

            // Add a message box
            var messageBox = new TopicChannel()
            {
                Name           = "MessageBox",
                Key            = "ContosoMessageBus:System:MessageBox",
                ResourceMapKey = "messageBox"
            };

            systemApp.Channels.Add(messageBox);

            // Add a message agent
            var messageAgent = new ContentBasedRouter()
            {
                Name           = "MessageAgent",
                Key            = "ContosoMessageBus:System:MessageAgent",
                ResourceMapKey = "messageAgent"
            };

            systemApp.Intermediaries.Add(messageAgent);

            // Add an FTP endpoint
            var ftpReceive = new AdapterEndpoint()
            {
                Name           = "FtpReceive",
                Key            = "ContosoMessageBus:System:FtpReceive",
                ResourceMapKey = "ftpReceive"
            };

            systemApp.Endpoints.Add(ftpReceive);

            return(model);
        }