コード例 #1
0
        public override string Execute(params string[] args)
        {
            FileInfo descFile          = new FileInfo(GetValue <string>(args, 0, "descFile"));
            FileInfo metaFile          = new FileInfo(GetValue <string>(args, 1, "metaFile"));
            string   npdmFilePath      = GetValue <string>(args, 2);
            FileInfo npdmFile          = new FileInfo(string.IsNullOrEmpty(npdmFilePath) ? Path.ChangeExtension(descFile.FullName, ".npdm") : npdmFilePath);
            bool     forceGenerateAcid = false; // GetValue<bool>(args, 3);

            if (!descFile.Exists)
            {
                throw new CommandException("Desc Not Found");
            }
            if (!metaFile.Exists)
            {
                throw new CommandException("Meta Not Found");
            }

            if (!npdmFile.Exists && Directory.Exists(npdmFile.FullName) && npdmFile.Attributes.HasFlag(FileAttributes.Directory))
            {
                npdmFile = new FileInfo(Path.Combine(npdmFile.FullName, Path.ChangeExtension(descFile.Name, ".npdm")));
            }

            try
            {
                DescModel desc = DescModel.FromXml(descFile.FullName);
                MetaModel meta = MetaModel.FromXml(metaFile.FullName);
                NpdmGenerator.CreateNpdm(desc, meta, forceGenerateAcid, npdmFile.FullName);
            }
            catch (Exception ex)
            {
                throw new CommandException(ex.Message);
            }

            return($"Done {npdmFile.FullName}");
        }
コード例 #2
0
        public override string Execute(params string[] args)
        {
            FileInfo descFile     = new FileInfo(GetValue <string>(args, 0, "descFile"));
            string   metaFilePath = GetValue <string>(args, 1);

            if (!descFile.Exists)
            {
                throw new CommandException("Desc Not Found");
            }

            try
            {
                DescModel desc = DescModel.FromXml(descFile.FullName);
                MetaModel meta = (File.Exists(metaFilePath)) ? MetaModel.FromXml(metaFilePath) : null;

                desc.Acid = Convert.ToBase64String(NpdmGenerator.GetAcidBytes(desc, meta));

                File.WriteAllText(descFile.FullName, desc.XMLSerialize());
            }
            catch (Exception ex)
            {
                throw new CommandException(ex.Message);
            }

            return($"Done {descFile.FullName}");
        }
コード例 #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));
            }
        }