예제 #1
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BizTalkPipelineParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(BizTalkPipelineParser));

                foreach (var application in group.Applications)
                {
                    _logger.LogDebug(TraceMessages.ParsingBizTalkPipelinesInApplication, application.Application.Name);

                    var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    // Loop through all of the pipelines.
                    foreach (var pipeline in application.Application.Pipelines)
                    {
                        try
                        {
                            var pipelineResourceDefinition = model.FindResourceDefinitionByKey(pipeline.ResourceDefinitionKey, pipeline.Direction == PipelineDirection.Receive ? ModelConstants.ResourceDefinitionReceivePipeline : ModelConstants.ResourceDefinitionSendPipeline);

                            pipeline.Document = Document.FromXml((string)pipelineResourceDefinition.ResourceContent);

                            pipeline.ResourceKey = string.Concat(pipelineResourceDefinition.Key, ":", "pipelineresource");

                            // Create the resource.
                            var pipelineResource = new ResourceItem
                            {
                                Name        = pipeline.Name,
                                Key         = pipeline.ResourceKey,
                                Type        = pipeline.Direction == PipelineDirection.Send ? ModelConstants.ResourceSendPipeline : ModelConstants.ResourceReceivePipeline,
                                Description = pipeline.Description,
                                ParentRefId = pipelineResourceDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            pipeline.Resource             = pipelineResource; // Maintain reference to the resource.
                            pipelineResource.SourceObject = pipeline;         // Maintain backward pointer.

                            pipelineResourceDefinition.Resources.Add(pipelineResource);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(pipelineResource.RefId, ResourceRelationshipType.Child));
                                pipelineResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }

                            _logger.LogDebug(TraceMessages.ParsedBizTalkPipeline, pipeline.FullName);
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingPipelineDocument, pipeline.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(BizTalkPipelineParser));
            }
        }
        /// <summary>
        /// Implements the internal logic of the parser.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The migration context.</param>
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            // Get the applications from the source model.
            var parsedApplications = model.GetSourceModel <ParsedBizTalkApplicationGroup>()?.Applications;

            if (parsedApplications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(DocumentSchemaParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(DocumentSchemaParser));

                // Iterate through the applications and then through the parsed schemas.
                foreach (var application in parsedApplications)
                {
                    var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    foreach (var schema in application.Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document))
                    {
                        _logger.LogDebug(TraceMessages.ParsingBizTalkDocumentSchema, schema.Name);

                        // Find resource definition
                        var resourceDefinition = model.FindResourceDefinitionByKey(schema.ResourceDefinitionKey, ModelConstants.ResourceDefinitionSchema);
                        if (resourceDefinition != null)
                        {
                            var schemaResource = new ResourceItem()
                            {
                                Name        = schema.Name,
                                Description = schema.XmlNamespace,
                                Type        = ModelConstants.ResourceDocumentSchema,
                                Key         = schema.ResourceKey,
                                ParentRefId = resourceDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            schema.Resource             = schemaResource; // Maintain pointer to the resource.
                            schemaResource.SourceObject = schema;         // Maintain backward pointer.
                            schemaResource.Properties.Add(ResourceItemProperties.XmlNamespaceProperty, schema.XmlNamespace);
                            schemaResource.Properties.Add(ResourceItemProperties.DotnetTypeNameProperty, schema.FullName);
                            schemaResource.Properties.Add(ResourceItemProperties.NumberOfRootNodesProperty, schema.MessageDefinitions.Count.ToString(CultureInfo.CurrentCulture));
                            schemaResource.Properties.Add(ResourceItemProperties.IsEnvelopeProperty, schema.IsEnvelope.ToString());

                            if (schema.IsEnvelope)
                            {
                                schemaResource.Properties.Add(ResourceItemProperties.BodyXPathProperty, schema.BodyXPath);
                            }

                            // Add the message definitions.
                            foreach (var messageDefinition in schema.MessageDefinitions)
                            {
                                _logger.LogDebug(TraceMessages.ParsingMessageTypeDefinition, messageDefinition.MessageType);

                                var messageDefResource = new ResourceItem()
                                {
                                    Name        = messageDefinition.RootElementName,
                                    Description = messageDefinition.MessageType,
                                    Type        = ModelConstants.ResourceMessageType,
                                    Key         = messageDefinition.ResourceKey,
                                    ParentRefId = schemaResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                messageDefinition.Resource      = messageDefResource; // Maintain pointer to the resource.
                                messageDefResource.SourceObject = messageDefinition;  // Maintain backward pointer.
                                messageDefResource.Properties.Add(ResourceItemProperties.RootNodeNameProperty, messageDefinition.RootElementName);
                                messageDefResource.Properties.Add(ResourceItemProperties.XmlNamespaceProperty, messageDefinition.XmlNamespace);

                                schemaResource.Resources.Add(messageDefResource);
                            }

                            resourceDefinition.Resources.Add(schemaResource);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(schemaResource.RefId, ResourceRelationshipType.Child));
                                schemaResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }
                        }
                        else
                        {
                            _logger.LogError(ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionSchema, schema.ResourceDefinitionKey);
                            context.Errors.Add(new ErrorMessage(string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionSchema, schema.ResourceDefinitionKey)));
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(DocumentSchemaParser));
            }
        }
예제 #3
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BizTalkOrchestrationParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(BizTalkOrchestrationParser));

                foreach (var application in group.Applications)
                {
                    _logger.LogDebug(TraceMessages.ParsingBizTalkOrchestrationsInApplication, application.Application.Name);

                    // Loop through all of the orchestrations.
                    foreach (var orchestration in application.Application.Orchestrations)
                    {
                        var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                        try
                        {
                            var orchestrationResourceDefinition = model.FindResourceDefinitionByKey(orchestration.ResourceDefinitionKey, ModelConstants.ResourceDefinitionOrchestration);
                            if (orchestrationResourceDefinition != null)
                            {
                                // Load metamodel
                                orchestration.Model = MetaModel.FromXml((string)orchestrationResourceDefinition.ResourceContent);

                                _logger.LogDebug(TraceMessages.ParsedBizTalkOrchestration, orchestration.FullName);

                                // Create resource for metamodel
                                var metaModelResource = new ResourceItem()
                                {
                                    Name        = orchestration.Name,
                                    Key         = string.Concat(orchestrationResourceDefinition.Key, ":", MetaModelConstants.MetaModelRootElement),
                                    Type        = ModelConstants.ResourceMetaModel,
                                    ParentRefId = orchestrationResourceDefinition.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                orchestration.Model.Resource   = metaModelResource;   // Maintain pointer to resource.
                                metaModelResource.SourceObject = orchestration.Model; // Maintain backward pointer.
                                orchestrationResourceDefinition.Resources.Add(metaModelResource);

                                if (applicationResource != null)
                                {
                                    applicationResource.AddRelationship(new ResourceRelationship(metaModelResource.RefId, ResourceRelationshipType.Child));
                                    metaModelResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                                }
                                else
                                {
                                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                    _logger.LogError(error);
                                    context.Errors.Add(new ErrorMessage(error));
                                }

                                _logger.LogTrace(TraceMessages.ResourceCreated, nameof(BizTalkOrchestrationParser), metaModelResource.Key, metaModelResource.Name, metaModelResource.Type, orchestrationResourceDefinition.Key);

                                var module = orchestration.FindModule();
                                if (module != null)
                                {
                                    var resourceName = module.FindPropertyValue(MetaModelConstants.PropertyKeyName);
                                    var resourceKey  = string.Concat(metaModelResource.Key, ":", resourceName);

                                    // Create resource for module
                                    var moduleResource = new ResourceItem()
                                    {
                                        Name        = resourceName,
                                        Key         = resourceKey,
                                        Type        = ModelConstants.ResourceModule,
                                        ParentRefId = metaModelResource.RefId,
                                        Rating      = ConversionRating.NotSupported
                                    };

                                    module.Resource             = moduleResource; // Maintain pointer to resource.
                                    moduleResource.SourceObject = module;         // Maintain backward pointer.
                                    metaModelResource.Resources.Add(moduleResource);

                                    _logger.LogTrace(TraceMessages.ResourceCreated, nameof(BizTalkOrchestrationParser), moduleResource.Key, moduleResource.Name, moduleResource.Type, metaModelResource.Key);
                                }
                                else
                                {
                                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindModuleInOrchestrationModel, orchestration.ResourceContainerKey, orchestration.FullName);
                                    _logger.LogError(error);
                                    context.Errors.Add(new ErrorMessage(error));
                                }
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionOrchestration, orchestration.ResourceDefinitionKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingMetaModel, orchestration.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(BizTalkOrchestrationParser));
            }
        }
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(DistributionListParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(DistributionListParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    _logger.LogDebug(TraceMessages.ParsingBizTalkSendPortGroupFilterForApplication, application.Application.Name);

                    var bindingFileDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);
                    var applicationResource   = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    foreach (var distributionList in application.Application.Bindings.BindingInfo.DistributionListCollection)
                    {
                        _logger.LogDebug(TraceMessages.ParsingBizTalkSendPortGroupFilterForDistributionList, distributionList.Name);

                        // Set the resource key for the distribution list.
                        distributionList.ResourceKey = string.Concat(application.Application.Bindings.ResourceDefinitionKey, ":", distributionList.Name);

                        // Create the resource under the application.
                        var distributionListResource = new ResourceItem
                        {
                            Key         = distributionList.ResourceKey,
                            Name        = distributionList.Name,
                            Description = distributionList.Description,
                            Type        = ModelConstants.ResourceDistributionList,
                            ParentRefId = bindingFileDefinition.RefId,
                            Rating      = ConversionRating.NotSupported
                        };

                        distributionList.Resource             = distributionListResource; // Maintain pointer to the resource.
                        distributionListResource.SourceObject = distributionList;         // Maintain backward pointer.

                        bindingFileDefinition.Resources.Add(distributionListResource);

                        if (applicationResource != null)
                        {
                            applicationResource.AddRelationship(new ResourceRelationship(distributionListResource.RefId, ResourceRelationshipType.Child));
                            distributionListResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                        }
                        else
                        {
                            var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                            _logger.LogError(error);
                            context.Errors.Add(new ErrorMessage(error));
                        }

                        try
                        {
                            if (!string.IsNullOrEmpty(distributionList.Filter))
                            {
                                distributionList.FilterExpression             = Filter.FromXml(distributionList.Filter);
                                distributionList.FilterExpression.ResourceKey = string.Concat(distributionList.Name, ":", "filter");

                                // Create the distribution filter resource.
                                var filterReportResource = new ResourceItem
                                {
                                    Key         = distributionList.FilterExpression.ResourceKey,
                                    Name        = distributionListResource.Name + " filter expression",
                                    Type        = ModelConstants.ResourceFilterExpression,
                                    ParentRefId = distributionListResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                distributionList.FilterExpression.Resource = filterReportResource;              // Maintain pointer to the resource.
                                filterReportResource.SourceObject          = distributionList.FilterExpression; // Maintain backward pointer.
                                distributionListResource.Resources.Add(filterReportResource);
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingDistributionListFilter, distributionList.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(DistributionListParser));
            }
        }
예제 #5
0
        /// <summary>
        /// Parses the receive location data stored as XML in the bindings.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The migration context.</param>
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(ReceivePortParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(ReceivePortParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    if (application.Application.Bindings.BindingInfo.ReceivePortCollection != null)
                    {
                        _logger.LogDebug(TraceMessages.ParsingBizTalkReceivePortCollectionInApplication, application.Application.Name);

                        var bindingFileDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);
                        var applicationResource   = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                        foreach (var receivePort in application.Application.Bindings.BindingInfo.ReceivePortCollection)
                        {
                            _logger.LogDebug(TraceMessages.ParsingBizTalkReceivePort, receivePort.Name);

                            receivePort.ResourceKey = string.Concat(application.Application.Bindings.ResourceDefinitionKey, ":", receivePort.Name);

                            // Create the resource under the binding file.
                            var receivePortResource = new ResourceItem
                            {
                                Key         = receivePort.ResourceKey,
                                Name        = receivePort.Name,
                                Description = receivePort.Description,
                                Type        = ModelConstants.ResourceReceivePort,
                                ParentRefId = bindingFileDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            receivePort.Resource             = receivePortResource; // Maintain pointer to the resource.
                            receivePortResource.SourceObject = receivePort;         // Maintain backward pointer.
                            bindingFileDefinition.Resources.Add(receivePortResource);
                            receivePortResource.Properties.Add(ResourceItemProperties.PortDirectionProperty, receivePort.IsTwoWay ? ResourceItemProperties.PortDirectionTwoWay : ResourceItemProperties.PortDirectionOneWay);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(receivePortResource.RefId, ResourceRelationshipType.Child));
                                receivePortResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }

                            if (receivePort.ReceiveLocations != null)
                            {
                                foreach (var receiveLocation in receivePort.ReceiveLocations)
                                {
                                    _logger.LogDebug(TraceMessages.ParsingBizTalkReceiveLocationPipelineData, receiveLocation.Name);

                                    // Extract the send pipeline custom config.
                                    receiveLocation.SendPipelineCustomConfiguration = ParsePipelineData(application, receiveLocation.Name, receiveLocation.SendPipelineData, PipelineDirection.Send, context.Errors);

                                    // Extract the receive pipeline custom config.
                                    receiveLocation.ReceivePipelineCustomConfiguration = ParsePipelineData(application, receiveLocation.Name, receiveLocation.ReceivePipelineData, PipelineDirection.Receive, context.Errors);

                                    receiveLocation.ResourceKey = string.Concat(receivePort.Name, ":", receiveLocation.Name);

                                    // Create the resource item for the receive location.
                                    var receiveLocationResource = new ResourceItem
                                    {
                                        Key         = receiveLocation.ResourceKey,
                                        Name        = receiveLocation.Name,
                                        Description = receiveLocation.Description,
                                        Type        = ModelConstants.ResourceReceiveLocation,
                                        ParentRefId = receivePortResource.RefId,
                                        Rating      = ConversionRating.NotSupported
                                    };

                                    receiveLocation.Resource             = receiveLocationResource; // Maintain pointer to the resource.
                                    receiveLocationResource.SourceObject = receiveLocation;         // Maintain backward pointer.
                                    receiveLocationResource.Properties.Add(ResourceItemProperties.PortTransportTypeProperty, receiveLocation.ReceiveLocationTransportType.Name);
                                    receiveLocationResource.Properties.Add(ResourceItemProperties.ReceiveLocationAddressProperty, receiveLocation.Address);

                                    receivePortResource.Resources.Add(receiveLocationResource);
                                }
                            }
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(ReceivePortParser));
            }
        }
예제 #6
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(TransformParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(TransformParser));

                // Find all transforms in source model
                foreach (var application in group.Applications)
                {
                    var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    var transforms = application.Application.Transforms;
                    if (transforms != null && transforms.Any())
                    {
                        foreach (var transform in transforms)
                        {
                            // Find transform resource definition
                            var transformResourceDefinition = model.FindResourceDefinitionByKey(transform.ResourceDefinitionKey, ModelConstants.ResourceDefinitionMap);
                            if (transformResourceDefinition != null)
                            {
                                // Add transform resource to source
                                var transformResource = new ResourceItem()
                                {
                                    Name        = transform.Name,
                                    Description = transform.FullName,
                                    Key         = transformResourceDefinition.Key + ":map",
                                    Type        = ModelConstants.ResourceMap,
                                    ParentRefId = transformResourceDefinition.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                transform.Resource             = transformResource; // Maintain pointer to the resource.
                                transformResource.SourceObject = transform;         // Maintain backward pointer.
                                transformResourceDefinition.Resources.Add(transformResource);

                                if (applicationResource != null)
                                {
                                    applicationResource.AddRelationship(new ResourceRelationship(transformResource.RefId, ResourceRelationshipType.Child));
                                    transformResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                                }
                                else
                                {
                                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                    _logger.LogError(error);
                                    context.Errors.Add(new ErrorMessage(error));
                                }

                                _logger.LogTrace(TraceMessages.ResourceCreated, nameof(TransformParser), transformResource.Key, transformResource.Name, transformResource.Type, transformResourceDefinition.Key);
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionMap, transform.ResourceDefinitionKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(TransformParser));
            }
        }
예제 #7
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(SendPortParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(SendPortParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    _logger.LogDebug(TraceMessages.ParsingBizTalkSendPortFiltersInApplication, application.Application.Name);

                    var bindingFileDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);
                    var applicationResource   = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    foreach (var sendPort in application.Application.Bindings.BindingInfo.SendPortCollection)
                    {
                        try
                        {
                            sendPort.ResourceKey = string.Concat(application.Application.Bindings.ResourceDefinitionKey, ":", sendPort.Name);

                            // Create the resource under the binding file.
                            var sendPortResource = new ResourceItem
                            {
                                Key         = sendPort.ResourceKey,
                                Name        = sendPort.Name,
                                Description = sendPort.Description,
                                Type        = ModelConstants.ResourceSendPort,
                                ParentRefId = bindingFileDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            sendPort.Resource             = sendPortResource; // Maintain pointer to the resource.
                            sendPortResource.SourceObject = sendPort;         // Maintain backward pointer.

                            // Static or dynamic port?
                            if (sendPort.IsStatic)
                            {
                                // Static port
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortTypeProperty, ResourceItemProperties.StaticSendPortType);
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortPrimaryTransportTypeProperty, sendPort.PrimaryTransport.TransportType?.Name);
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortPrimaryAddressProperty, sendPort.PrimaryTransport.Address);
                                if (sendPort.SecondaryTransport != null && !string.IsNullOrEmpty(sendPort.SecondaryTransport.Address))
                                {
                                    sendPortResource.Properties.Add(ResourceItemProperties.SendPortSecondaryTransportTypeProperty, sendPort.SecondaryTransport.TransportType?.Name);
                                    sendPortResource.Properties.Add(ResourceItemProperties.SendPortSecondaryAddressProperty, sendPort.SecondaryTransport.Address);
                                }
                            }
                            else
                            {
                                // Dynamic port
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortTypeProperty, ResourceItemProperties.DynamicSendPortType);
                            }

                            sendPortResource.Properties.Add(ResourceItemProperties.PortDirectionProperty, sendPort.IsTwoWay ? ResourceItemProperties.PortDirectionTwoWay : ResourceItemProperties.PortDirectionOneWay);

                            bindingFileDefinition.Resources.Add(sendPortResource);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(sendPortResource.RefId, ResourceRelationshipType.Child));
                                sendPortResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }

                            if (!string.IsNullOrEmpty(sendPort.Filter))
                            {
                                sendPort.FilterExpression             = Filter.FromXml(sendPort.Filter);
                                sendPort.FilterExpression.ResourceKey = string.Concat(sendPort.Name, ":", "filter");

                                var filterResource = new ResourceItem
                                {
                                    Key         = sendPort.FilterExpression.ResourceKey,
                                    Name        = sendPortResource.Name + " filter expression",
                                    Type        = ModelConstants.ResourceFilterExpression,
                                    ParentRefId = sendPortResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                sendPort.FilterExpression.Resource = filterResource;            // Maintain pointer to the resource.
                                filterResource.SourceObject        = sendPort.FilterExpression; // Maintain backward pointer.
                                sendPortResource.Resources.Add(filterResource);

                                _logger.LogDebug(TraceMessages.ParsedBizTalkSendPortFilterExpression, sendPort.Name);
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingSendPort, sendPort.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(SendPortParser));
            }
        }