/// <summary> /// Creates the artifacts 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(AP001ApplicationAnalyzer)); } else { _logger.LogDebug(TraceMessages.RunningRule, RuleName, nameof(AP001ApplicationAnalyzer)); foreach (var application in parsedApplicationGroup.Applications) { var resourceMapKey = $"application{application.Application.Name.Replace(".", "-").Replace(" ", string.Empty).Replace(":", "-")}"; var targetApplication = new ApplicationModel.Target.Application { Name = application.Application.Name, Key = $"{Model.MigrationTarget.MessageBus.Key}:{application.Application.Name.FormatKey()}", ResourceMapKey = resourceMapKey, Description = MigrationTargetResources.ApplicationDescription }; targetApplication.Properties.Add(ModelConstants.SourceApplicationResourceKey, application.Application.ApplicationDefinition.Resource.Key); Model.MigrationTarget.MessageBus.Applications.Add(targetApplication); } _logger.LogDebug(TraceMessages.RuleCompleted, RuleName, nameof(AP001ApplicationAnalyzer)); } await Task.CompletedTask.ConfigureAwait(false); }
/// <summary> /// Copies the source model to the target model. /// </summary> /// <param name="model">The model containing the source and target.</param> public static void CopySourceToTarget(AzureIntegrationServicesModel model, bool includeFtpReceive = false, bool includeFtpSend = false) { model = model ?? throw new ArgumentNullException(nameof(model)); model.MigrationTarget.MessageBus = new ApplicationModel.Target.MessageBus { Name = "nameMessageBus", Key = ModelConstants.MessageBusLeafKey, ResourceMapKey = "resourceMapKeyMessageBus", }; foreach (var application in model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications) { var targetApplication = new ApplicationModel.Target.Application { Name = application.Application.Name, Key = $"{model.MigrationTarget.MessageBus.Key}:{application.Application.Name.FormatKey()}", ResourceMapKey = "application", }; var schemaMessages = from schema in application.Application.Schemas from messageDefintion in schema.MessageDefinitions where schema.SchemaType == BizTalkSchemaType.Document select new { Schema = schema, MessageDefinition = messageDefintion }; foreach (var schemaMessage in schemaMessages) { var resourceMapKey = $"applicationMessage{application.Application.Name}{schemaMessage.MessageDefinition.LocalName}"; targetApplication.Messages.Add(new DocumentMessage { Name = schemaMessage.MessageDefinition.LocalName, MessageSchema = new MessageSchema { ResourceKeyRef = schemaMessage.MessageDefinition.ResourceKey, Name = schemaMessage.Schema.Name }, Key = $"{targetApplication.Key}:{schemaMessage.MessageDefinition.LocalName}", ContentType = MessageContentType.Xml, ResourceMapKey = resourceMapKey, Description = "Schema description" }); } if (includeFtpReceive) { var ftpReceiveAdapter = new AdapterEndpoint() { Name = "FTP Receive Adapter", Description = "Test FTP receive adapter", Key = $"{targetApplication.Key}:ReceivePort1:ReceiveLocation1:{ModelConstants.AdapterEndpointLeafKey}", Activator = true, AdapterProtocol = "FTP", MessageExchangePattern = MessageExchangePattern.Accept }; ftpReceiveAdapter.Properties.Add(ModelConstants.ScenarioName, $"{targetApplication.Name}:ReceivePort1:ReceiveLocation1"); targetApplication.Endpoints.Add(ftpReceiveAdapter); } if (includeFtpSend) { var ftpSendAdapter = new AdapterEndpoint() { Name = "FTP Send Adapter", Description = "Test Send receive adapter", Key = $"{targetApplication.Key}:Test.SendPorts.SendPort1:{ModelConstants.AdapterEndpointLeafKey}", Activator = true, AdapterProtocol = "FTP", MessageExchangePattern = MessageExchangePattern.Send }; ftpSendAdapter.Properties.Add(ModelConstants.ScenarioName, $"{targetApplication.Name}:Test.SendPorts.SendPort1"); targetApplication.Endpoints.Add(ftpSendAdapter); } model.MigrationTarget.MessageBus.Applications.Add(targetApplication); } }