/// <summary> /// Processes a <paramref name="sql"/> statement that was /// issued by the <see cref="Engine"/>. /// </summary> /// <param name="context">The context.</param> /// <param name="sql">The SQL.</param> public void ProcessEngineStatement(MigrationContext context, string sql) { using (var cmd = context.Connection.CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); } }
/// <summary> /// Stores a new migration history record in the database. /// </summary> /// <param name="context">The migration context.</param> /// <param name="item">The item.</param> public virtual void AddItem(MigrationContext context, MigrationHistoryItem item) { EnsureMigrationHistorySchemaExists(context); Database model = new Database(null); Table t = model.AlterTable(TableName); var row = new Dictionary<string, object>(); row.Add(DateColumnName, item.Date); row.Add(VersionColumnName, item.Version); row.Add(DirectionColumnName, (int)item.Direction); t.Insert(row); foreach (string sql in context.SqlProvider.GenerateSqlCommands(model)) { context.SqlProcessor.ProcessEngineStatement(context, sql); } }
private static void Test(Language language, CodeDomProvider provider) { MigrationSettings settings = new MigrationSettings(); settings.VSProjectName = "ClassLibrary1"; settings.Namespace = "ClassLibrary1"; settings.Language = language; MigrationContext context = new MigrationContext( settings, null, null, null, null, provider, null, null, new EmptyOperationStatus(), null); context.LocalizedStrings.Add("One", "Uno"); context.References.Add("AxSLXControls, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL", @"AxSLXControls.dll"); context.References.Add(typeof (Form).Assembly.GetName().Name, null); Plugin plugin = new Plugin(); plugin.Family = "Test"; plugin.Name = "Class1"; plugin.Blob.Data = new byte[0]; ScriptInfo script = new ScriptInfo(plugin); context.Scripts.Add("0", script); MigrationContextHolderService holder = new MigrationContextHolderService(); holder.Context = context; VSProjectService p = new VSProjectService(); p.ContextHolder = holder; p.Generate(); }
/// <summary> /// Stores a new migration history record in the database. /// </summary> /// <param name="context">The migration context.</param> /// <param name="item">The item.</param> public override void AddItem(MigrationContext context, MigrationHistoryItem item) { // ignore ... }
public void ConstructWithNullLogger(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given a parser" .x(() => parser.Should().BeNull()); "And null logger" .x(() => logger.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = new MigrationContext()); "When constructing with null logger" .x(() => e = Record.Exception(() => new DocumentSchemaParser(model, context, logger))); "Then the parser constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("logger")); }
/// <summary> /// Creates a new instance of the <see cref="BizTalkApplicationParser" class./> /// </summary> /// <param name="model">The application model.</param> /// <param name="context">The context that gathers migration information.</param> /// <param name="logger">A logger.</param> public BizTalkApplicationParser(IApplicationModel model, MigrationContext context, ILogger logger) : base(ParserName, model, context, logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public void ConstructWithNullContext(AP002SystemApplicationAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And null context" .x(() => context.Should().BeNull()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing with a null context" .x(() => e = Record.Exception(() => new AP002SystemApplicationAnalyzer(model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("context")); }
/// <summary> /// Retrieves information about all migrations that have /// been applied to the database so far. /// </summary> /// <param name="context">The migration context.</param> /// <param name="error">if set to <c>true</c> an error occured while querying the database.</param> /// <returns>The migration history.</returns> private MigrationHistoryItem[] InternalRetrieveHistory(MigrationContext context, out bool error) { error = false; var result = new List<MigrationHistoryItem>(); try { using (var cmd = context.Connection.CreateCommand()) { cmd.CommandText = string.Format("SELECT * FROM {0} ORDER BY {1}", TableName, DateColumnName); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { result.Add(new MigrationHistoryItem() { Date = reader.GetDateTime(reader.GetOrdinal(DateColumnName)), Version = reader.GetInt64(reader.GetOrdinal(VersionColumnName)), Direction = (MigrationDirection)(int)reader.GetByte(reader.GetOrdinal(DirectionColumnName)) }); } } } } catch { /* ignore, schema doesn't exist yet */ error = true; } return result.ToArray(); }
/// <summary> /// Creates a new instance of the <see cref="OrchestrationCorrelationTypeParser" class./> /// </summary> /// <param name="model">The application model.</param> /// <param name="context">The context that gathers migration information.</param> /// <param name="logger">A logger.</param> public OrchestrationCorrelationTypeParser(IApplicationModel model, MigrationContext context, ILogger logger) : base(nameof(OrchestrationCorrelationTypeParser), model, context, logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Retrieves information about all migrations that have /// been applied to the database so far. /// </summary> /// <param name="context">The migration context.</param> /// <returns>The migration history.</returns> public virtual MigrationHistoryItem[] RetrieveHistory(MigrationContext context) { bool historySchemaExists; return InternalRetrieveHistory(context, out historySchemaExists); }
public void DP001RuleSkippedIfModelIsEmpty(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an source model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP001SchemaDependencyAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then there should be no exception" .x(() => e.Should().BeNull()); "And there should be no context errors" .x(() => context.Errors.Should().HaveCount(0)); }
public void ConstructWithNullLogger(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And null logger" .x(() => logger.Should().BeNull()); "When constructing with a null logger" .x(() => e = Record.Exception(() => new DP001SchemaDependencyAnalyzer(model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("logger")); }
public ReorderMethodArgumentsVisitor(MigrationContext context, string fullTypeName, string methodName, int[] argumentOrder) : base(context) { FullTypeName = fullTypeName; MethodName = methodName; ArgumentOrder = argumentOrder; }
public void InitializeField(MigrationContext context) { _custom.InitializeField(context); }
public Migration() { InitializeComponent(); DataContext = new MigrationContext(); }
private static async Task PerformMigration(CliOptions options) { if (string.IsNullOrEmpty(options.SolutionPath) && string.IsNullOrEmpty(options.MigrationPath)) { Console.WriteLine("Either project or sulution path must be provided."); return; } var workspace = new AdhocWorkspace(); if (!string.IsNullOrEmpty(options.SolutionPath)) { Console.WriteLine("Loading solution:"); var manager = new AnalyzerManager(options.SolutionPath); foreach (var p in manager.Projects.Values) { Console.WriteLine($"Loading project: {p.ProjectFile.Path}"); p.AddToWorkspace(workspace); } } else { Console.WriteLine("Loading project"); var manager = new AnalyzerManager(); manager.GetProject(options.ProjectPath).AddToWorkspace(workspace); } Console.WriteLine("Loading migration file"); var migration = MigrationLoader.FromPath(options.MigrationPath); var timer = Stopwatch.StartNew(); await Task.WhenAll(workspace.CurrentSolution.Projects.Select(async project => { Console.WriteLine($"Migrating project {project.Name}"); var compilation = (CSharpCompilation)await project.GetCompilationAsync(); await Task.WhenAll(compilation.SyntaxTrees.Select(async tree => { var annotatedTree = tree.WithRootAndOptions( new AnnotationVisitor().Visit(await tree.GetRootAsync()), tree.Options); compilation = compilation.ReplaceSyntaxTree(tree, annotatedTree); if (options.Verbose) { Console.WriteLine("Running migration on " + tree.FilePath); } var context = new MigrationContext(); context.Populate(compilation, annotatedTree); var ast = migration.Apply(annotatedTree, context); if (ast != annotatedTree) { await File.WriteAllTextAsync(tree.FilePath, ast.ToString()); } })); })); Console.WriteLine("Migration took: " + timer.Elapsed); }
public void DP001ResolveContextPropertyDependenciesWithSuccess(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForAnalyzing(); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP001SchemaDependencyAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then there should be no exception" .x(() => e.Should().BeNull()); "And there should be no context errors" .x(() => context.Errors.Should().HaveCount(0)); "And report node should have the correct resources created" .x(() => { var group = (ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel; // Test the document schema var dsResource = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document).First().Resource; dsResource.ResourceRelationships.Count.Should().Be(3); dsResource.ResourceRelationships[1].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencesTo); dsResource.ResourceRelationships[2].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencesTo); // Test the property schema var psResource = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Property).First().Resource; psResource.ResourceRelationships.Count.Should().Be(1); psResource.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencedBy); // Test the first context property - this should be referenced var cpResource1 = psResource.Resources.Where(r => r.Key == "property-schema-1:schema:Property1").First(); cpResource1.ResourceRelationships.Count.Should().Be(1); cpResource1.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencedBy); // Test the first context property - this should NOT be referenced var cpResource2 = psResource.Resources.Where(r => r.Key == "property-schema-1:schema:Property2").First(); cpResource2.ResourceRelationships.Count.Should().Be(0); }); }
public void InitializeTarget() { MigrationContext context = new MigrationContext(); Target = new Database(context); }
public void DP001ResolveContextPropertyDependenciesWithWarnings(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForAnalyzing(); var schemas = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications.SelectMany(a => a.Application.Schemas); foreach (var schema in schemas) { if (schema.SchemaType == Types.Enumerations.BizTalkSchemaType.Property) { schema.ContextProperties.Clear(); } } }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP001SchemaDependencyAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then there should be no exception" .x(() => e.Should().BeNull()); "And there should be no context errors" .x(() => context.Errors.Should().HaveCount(0)); "And report resource node should have warnings" .x(() => { // Check the application resource has been created. var group = (ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel; var schemas = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document).ToList(); schemas.Should().HaveCount(3); schemas[0].Resource.ReportMessages.Should().HaveCountGreaterThan(0); schemas[1].Resource.ReportMessages.Should().HaveCount(0); }); }
/// <summary> /// Processes a <paramref name="sql"/> statement that was /// issued by the <see cref="Engine"/>. /// </summary> /// <param name="context">The context.</param> /// <param name="sql">The SQL.</param> public void ProcessEngineStatement(MigrationContext context, string sql) { ProcessMigrationStatement(context, sql); }
public void ConstructWithSuccess(AP005SendRoutingPropertyGenerator generator, IFileRepository fileRepository, IScenarioRouteWalker routeWalker, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an generator" .x(() => generator.Should().BeNull()); "And a file repository" .x(() => fileRepository = _mockFileRepository.Object); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And a route walker" .x(() => routeWalker = new ScenarioRouteWalker(TestHelper.BuildContext(), _mockLogger.Object)); "When constructing" .x(() => e = Record.Exception(() => new AP005SendRoutingPropertyGenerator(fileRepository, routeWalker, model, context, logger))); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); }
/// <summary> /// Retrieves information about all migrations that have /// been applied to the database so far. /// </summary> /// <param name="context">The migration context.</param> /// <returns>The migration history.</returns> public virtual MigrationHistoryItem[] RetrieveHistory(MigrationContext context) { bool error; return InternalRetrieveHistory(context, out error); }
public void GenerateWithNoApplications(AP005SendRoutingPropertyGenerator generator, IFileRepository fileRepository, IScenarioRouteWalker routeWalker, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an generator" .x(() => generator.Should().BeNull()); "And a file repository" .x(() => fileRepository = _mockFileRepository.Object); "And a model" .x(() => { model = new AzureIntegrationServicesModel(); model.MigrationTarget.MessageBus = new MessageBus(); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And a route walker" .x(() => routeWalker = new Mock <IScenarioRouteWalker>().Object); "And a generator" .x(() => generator = new AP005SendRoutingPropertyGenerator(fileRepository, routeWalker, 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()); }
public override Task RunAsync(MigrationContext context) { Runs++; return(Task.CompletedTask); }
public void GenerateFailsWhenMissingConfig(AP005SendRoutingPropertyGenerator generator, IFileRepository fileRepository, IScenarioRouteWalker routeWalker, ILogger logger, AzureIntegrationServicesModel model, Application application, MigrationContext context, Exception e) { var generatedFileName = string.Empty; JObject generatedJson = null; var resourcemapkey = "resourcemapkey"; var scenarioName = "scenarioName"; var activatingIntermediaryName = "activatingIntermediaryName"; var routingProperties = new List <(string PropertyName, string PropertyValue)> { ("propertyOneName", "propertyOneValue"), ("propertyTwoName", "propertyTwoValue") }; "Given an generator" .x(() => generator.Should().BeNull()); "And a file repository" .x(() => { _mockFileRepository.Setup(f => f.WriteJsonFile( It.IsAny <string>(), It.IsAny <JObject>() )) .Callback <string, JObject>( (p1, p2) => { generatedFileName = p1; generatedJson = p2; }); fileRepository = _mockFileRepository.Object; }); "And an application" .x(() => { var activatingIntermediary = new MessageSubscriber { Activator = true, ResourceMapKey = resourcemapkey, Name = activatingIntermediaryName }; var routingProperties1 = new Dictionary <string, object>(); var intermediaryRoutingProperties = routingProperties[0]; routingProperties1[intermediaryRoutingProperties.PropertyName] = intermediaryRoutingProperties.PropertyValue; activatingIntermediary.Properties[ModelConstants.ScenarioName] = scenarioName; activatingIntermediary.Properties[ModelConstants.RoutingProperties] = routingProperties1; activatingIntermediary.Resources.Add( new TargetResourceTemplate { ResourceType = "WrongResourceType", OutputPath = "outputpath" }); var secondIntermediary = new GenericFilter { Name = "SecondIntermediary" }; var endpoint = new AdapterEndpoint { Name = "Endpoint" }; var routingProperties2 = new Dictionary <string, object>(); var endpointRoutingProperties = routingProperties[1]; routingProperties2[endpointRoutingProperties.PropertyName] = endpointRoutingProperties.PropertyValue; endpoint.Properties[ModelConstants.RoutingProperties] = routingProperties2; application = new Application(); application.Intermediaries.Add(activatingIntermediary); application.Intermediaries.Add(secondIntermediary); application.Endpoints.Add(endpoint); }); "And a model" .x(() => { model = new AzureIntegrationServicesModel(); model.MigrationTarget.MessageBus = new MessageBus(); model.MigrationTarget.MessageBus.Applications.Add(application); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And a route walker" .x(() => { var route = new List <(MessagingObject RoutingObject, Channel InputChannel)>(); foreach (var intermediary in application.Intermediaries) { route.Add((intermediary, null)); } foreach (var endpoint in application.Endpoints) { route.Add((endpoint, null)); } var mockRouteWalker = new Mock <IScenarioRouteWalker>(); mockRouteWalker.Setup(w => w.WalkSendRoute( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Intermediary>(), It.IsAny <IEnumerable <Intermediary> >(), It.IsAny <IEnumerable <Channel> >(), It.IsAny <IEnumerable <Endpoint> >() )).Returns(route); routeWalker = mockRouteWalker.Object; }); "And a generator" .x(() => generator = new AP005SendRoutingPropertyGenerator(fileRepository, routeWalker, 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 one context error" .x(() => { context.Errors.Should().NotBeNullOrEmpty(); context.Errors.Should().HaveCount(1); context.Errors[0].Message.Should().Contain(ModelConstants.ResourceTypeRoutingProperties); context.Errors[0].Message.Should().Contain(activatingIntermediaryName); }); }
/// <summary> /// Initializes a new instance of the <see cref="UpdateExpressionRoot" /> class. /// </summary> /// <param name="context">The migration context</param> public UpdateExpressionRoot(MigrationContext context) { _context = context; }
public void ConstructWithNullFileRepository(AP005SendRoutingPropertyGenerator generator, IFileRepository fileRepository, IScenarioRouteWalker routeWalker, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an generator" .x(() => generator.Should().BeNull()); "And a null file repository" .x(() => fileRepository.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And a route walker" .x(() => routeWalker = new ScenarioRouteWalker(TestHelper.BuildContext(), _mockLogger.Object)); "When constructing with a null file repository" .x(() => e = Record.Exception(() => new AP005SendRoutingPropertyGenerator(fileRepository, routeWalker, model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("fileRepository")); }
protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context) { var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>(); if (group?.Applications == null) { _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BizTalkApplicationParser)); } else { _logger.LogDebug(TraceMessages.RunningParser, nameof(BizTalkApplicationParser)); foreach (var application in group.Applications) { try { // Defensive check if (application.Application.ApplicationDefinition == null) { _logger.LogWarning(WarningMessages.ApplicationDefinitionNotFound, application.Application.Name); continue; } _logger.LogDebug(TraceMessages.ParsingBizTalkApplicationFromResourceContainer, application.Application.ApplicationDefinition.ResourceContainerKey); var adf = from resourceContainer in model.MigrationSource.ResourceContainers from resourceDefinition in resourceContainer.ResourceDefinitions where resourceContainer.Key == application.ResourceContainerKey && application.Application.ApplicationDefinition.ResourceContainerKey == resourceContainer.Key && application.Application.ApplicationDefinition.ResourceDefinitionKey == resourceDefinition.Key && resourceDefinition.Type == ModelConstants.ResourceDefinitionApplicationDefinition select resourceDefinition; var applicationResourceDefinition = adf.SingleOrDefault(); if (applicationResourceDefinition == null) { _logger.LogWarning(WarningMessages.ApplicationDefinitionNotFound, application.Application.Name); continue; } var applicationDefinition = application.Application.ApplicationDefinition.ApplicationDefinition ?? ApplicationDefinition.FromXml((string)applicationResourceDefinition.ResourceContent); // Only parse if not already deserialized. var applicationName = applicationDefinition.Properties.Where(p => p.Name == BizTalkApplicationParser.ApplicationDisplayNameProperty).SingleOrDefault(); if (applicationName != null && !string.IsNullOrWhiteSpace(applicationName.Value)) { // Check to see if there is already an application in the source with this name (duplicate names can occur is passing multiple unrelated // MSI files). var duplicateApplication = model.FindResourcesByType(ModelConstants.ResourceApplication).Any(a => a.Name == applicationName.Value); // Set application name application.Application.Name = applicationName.Value; if (duplicateApplication) { application.Application.Name = $"{application.Application.Name} {ResourceItemProperties.Duplicate}"; } // Define resource key for application. var resourceKey = string.Concat(applicationResourceDefinition.Key, ":", applicationName); application.Application.ApplicationDefinition.ResourceKey = resourceKey; // Create the application resource under the application definition resource. var applicationResource = new ResourceItem { Name = applicationName.Value, Description = applicationDefinition.Properties.Where(p => p.Name == BizTalkApplicationParser.ApplicationDescriptionProperty).SingleOrDefault()?.Value, Key = resourceKey, Type = ModelConstants.ResourceApplication, ParentRefId = applicationResourceDefinition.RefId, Rating = ConversionRating.NotSupported }; application.Application.ApplicationDefinition.Resource = applicationResource; // Maintain pointer to the resource. applicationResource.SourceObject = applicationDefinition; // Maintain backward pointer. applicationResourceDefinition.Resources.Add(applicationResource); _logger.LogTrace(TraceMessages.ResourceCreated, nameof(BizTalkApplicationParser), applicationResource.Key, applicationResource.Name, applicationResource.Type, applicationResource.Key); // If this does not exist then update on the source model. if (application.Application.ApplicationDefinition.ApplicationDefinition == null) { application.Application.ApplicationDefinition.ApplicationDefinition = applicationDefinition; } _logger.LogDebug(TraceMessages.ParsedTheBizTalkApplicationWithName, application.Application.Name); // Raise an error if this was a duplicate application if (duplicateApplication) { // Raise an error that there is already an application with this name var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.DuplicateApplicationFound, applicationName.Value); context.Errors.Add(new ErrorMessage(message)); _logger.LogError(message); } } else { var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ApplicationNameNotFound, applicationResourceDefinition.Key); context.Errors.Add(new ErrorMessage(message)); _logger.LogError(message); } } catch (Exception ex) { var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorReadingApplicationFromAdf, application.Application.ApplicationDefinition.ResourceDefinitionKey, ex.Message); context.Errors.Add(new ErrorMessage(message)); _logger.LogError(message); } } _logger.LogDebug(TraceMessages.CompletedParser, nameof(BizTalkApplicationParser)); } }
public void CreateFtpEndpointSuccess(RP001FtpReceivePortAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And the model has a migration target " .x(() => { TestHelper.CopySourceToTarget(model, includeFtpReceive: true); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new RP001FtpReceivePortAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); "And the message bus will have been created" .x(() => { model.Should().NotBeNull(); model.MigrationTarget.Should().NotBeNull(); model.MigrationTarget.MessageBus.Should().NotBeNull(); model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3); model.MigrationTarget.MessageBus.Applications[0].Endpoints.Should().HaveCount(1); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].Name.Should().Be("FTP Receive Adapter"); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].Key.Should().Be("MessageBus:TestApp1:ReceivePort1:ReceiveLocation1:AdapterEndpoint"); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].ResourceMapKey.Should().Be("ftpReceiveAdapterEndpointTestApp1FTPReceiveAdapter"); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].Properties.Should().HaveCount(13); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].ReportLinks.Should().HaveCount(1); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].ReportMessages.Should().HaveCount(16); }); }
public void ConstructWithSuccess(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given a parser" .x(() => parser.Should().BeNull()); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = new MigrationContext()); "When constructing" .x(() => e = Record.Exception(() => parser = new DocumentSchemaParser(model, context, logger))); "Then the parser constructor should succeed" .x(() => { e.Should().BeNull(); parser.Should().NotBeNull(); }); }
public void FtpEndpointMissingWithError(RP001FtpReceivePortAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And an empty model" .x(() => model = new AzureIntegrationServicesModel()); "And a populated model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And the model has a migration target" .x(() => { TestHelper.CopySourceToTarget(model, includeFtpReceive: true); }); "And the target model is missing the endpoint" .x(() => { model.MigrationTarget.MessageBus.Applications[0].Endpoints.Clear(); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new RP001FtpReceivePortAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); "And an error should be raised" .x(() => { model.Should().NotBeNull(); model.MigrationTarget.Should().NotBeNull(); model.MigrationTarget.MessageBus.Should().NotBeNull(); model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3); model.MigrationTarget.MessageBus.Applications[0].Endpoints.Should().HaveCount(0); context.Errors.Should().HaveCount(1); }); }
/// <summary> /// Ensures that the schema for the migration history exists. /// </summary> /// <param name="context">The context.</param> protected override void EnsureMigrationHistorySchemaExists(MigrationContext context) { // ignore ... }
public void CreateFtpEndpointEmptyTransportData(RP001FtpReceivePortAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And the model receive location has no TransportTypeData" .x(() => { model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications[0].Application.Bindings.BindingInfo.ReceivePortCollection[0].ReceiveLocations[0].ReceiveLocationTransportTypeData = "<CustomProps><AdapterConfig vt=\"8\"><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"></Config></AdapterConfig></CustomProps>"; }); "And the model has a migration target " .x(() => { TestHelper.CopySourceToTarget(model, includeFtpReceive: true); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new RP001FtpReceivePortAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); "And the message bus will have been created" .x(() => { model.Should().NotBeNull(); model.MigrationTarget.Should().NotBeNull(); model.MigrationTarget.MessageBus.Should().NotBeNull(); model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3); model.MigrationTarget.MessageBus.Applications[0].Endpoints.Should().HaveCount(1); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].Name.Should().Be("FTP Receive Adapter"); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].Key.Should().Be("MessageBus:TestApp1:ReceivePort1:ReceiveLocation1:AdapterEndpoint"); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].ResourceMapKey.Should().Be("ftpReceiveAdapterEndpointTestApp1FTPReceiveAdapter"); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].Properties.Should().HaveCount(13); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].ReportLinks.Should().HaveCount(1); model.MigrationTarget.MessageBus.Applications[0].Endpoints[0].ReportMessages.Should().HaveCount(1); }); }
public static void Migrate(string connectionString,string path="") { _ConnectionStringName = connectionString; Context = new MigrationContext(connectionString); _ConnectionString = ConfigurationManager.ConnectionStrings[connectionString].ConnectionString; //Create the Migrations table if does not exists var createMigrationTableScript = "SET ANSI_NULLS ON" + " SET QUOTED_IDENTIFIER ON" + " SET ANSI_PADDING ON" + " IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Migration]') AND type in (N'U'))" + " BEGIN" + " CREATE TABLE [dbo].[Migration](" + " [Id] [uniqueidentifier] NOT NULL," + " [Script] [varchar](250) NOT NULL," + " [ExecutedOn] [datetime] NOT NULL," + " CONSTRAINT [PK_Migration] PRIMARY KEY CLUSTERED " + " (" + " [Id] ASC" + " )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]" + " ) ON [PRIMARY]" + " END" + " SET ANSI_PADDING OFF "; Context.ExecuteNonQuery(createMigrationTableScript, new Dictionary<string,object> ()); //Get all the scripts in the Migrations Folder var di = new DirectoryInfo(Path.Combine(path,"Migrations")); //check if the folder exists and if there is any file inside of it if (di.Exists && di.GetFiles("*.sql").Length > 0) { var scripts = di.GetFiles("*.sql").ToList(); //get all the scripts that have been executed var executed = Context.GetAll(); //check if the initial script has been executed var initialized = executed.FirstOrDefault(s => s.Script == "initializedatabase.sql") != null; //compare both lists foreach (var e in executed) { var s = scripts.FirstOrDefault(sc => sc.Name.ToLower() == e.Script); if (s != null) scripts.Remove(s); } //check if there is any script pending to run if (scripts.Count > 0) { //check if the initializedatabase script is not on the list var initScript = scripts.FirstOrDefault(s => s.Name.ToLower() == "initializedatabase.sql"); //if the init script is there and the DB has not been initialized run it and record it if (initScript != null && !initialized) { RunScript(initScript); scripts.Remove(initScript); } else if (initScript != null)//remove it from the list, the init script can only be run once scripts.Remove(initScript); else if (initScript == null && !initialized) //if the init script is not there and the database has not been initialized, Context.Insert(new Migration { Id = Guid.NewGuid(), Script = "initializedatabase.sql", ExecutedOn = DateTime.Now }); //asume that we will not provive and init script, so the current state of the DB is the initial state and we will just be tracking patches //order the scripts by number var scriptList = new SortedList<int, FileInfo>(); foreach (var s in scripts) { var orderS = s.Name.ToLower().Replace("patch_", "").Replace(".sql", ""); int order; if (int.TryParse(orderS, out order)) { scriptList.Add(order, s); } } if (executed.Count() == 0) return; //Get the latest script ran var latest = executed.OrderBy(e => e.ExecutedOn).Last(); int latestExecuted = !latest.Script.Contains("patch") ? 0 : int.Parse(latest.Script.Replace("patch_", "").Replace(".sql", "")); //run the rest of the scripts foreach (var s in scriptList.Keys) { if (s > latestExecuted) { RunScript(scriptList[s]); } } } } }
public void ConstructWithNullModel(RP001FtpReceivePortAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And null model" .x(() => model.Should().BeNull()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing with a null model" .x(() => e = Record.Exception(() => new RP001FtpReceivePortAnalyzer(model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model")); }
public void DatabaseConstructorTest() { MigrationContext context = new MigrationContext(); Database target = new Database(context); Assert.AreEqual(context, target.Context); Assert.IsNotNull(target.MigrationSteps); Assert.AreEqual(0, target.MigrationSteps.Count); }
/// <summary> /// Processes a <paramref name="sql"/> statement that was /// issued by the migration model (<see cref="Database"/>). /// </summary> /// <param name="context">The context.</param> /// <param name="sql">The SQL.</param> public void ProcessMigrationStatement(MigrationContext context, string sql) { // ignore ... }
/// <summary> /// Retrieves information about all migrations that have /// been applied to the database so far. /// </summary> /// <param name="context">The migration context.</param> /// <param name="historySchemaExists">if set to <c>false</c> an error occured while querying the database.</param> /// <returns>The migration history.</returns> private MigrationHistoryItem[] InternalRetrieveHistory(MigrationContext context, out bool historySchemaExists) { historySchemaExists = true; try { string sql = context.SqlProvider.GetTableExistenceSql(TableName); using (var cmd = context.Connection.CreateCommand()) { cmd.CommandText = sql; var tableExists = Convert.ToBoolean(cmd.ExecuteScalar()); if (!tableExists) { // If the table doesn't exist, we'll just ride on the error. historySchemaExists = false; return new MigrationHistoryItem[0]; } } } catch(NotImplementedException) { // If it's not implemented, hope we can just catch the error later. } // All other errors bubble up. var result = new List<MigrationHistoryItem>(); try { using (var cmd = context.Connection.CreateCommand()) { cmd.CommandText = string.Format("SELECT * FROM {0} ORDER BY {1}", TableName, DateColumnName); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { result.Add(new MigrationHistoryItem() { Date = reader.GetDateTime(reader.GetOrdinal(DateColumnName)), Version = reader.GetInt64(reader.GetOrdinal(VersionColumnName)), Direction = (MigrationDirection)(int)reader.GetByte(reader.GetOrdinal(DirectionColumnName)) }); } } } } catch { /* ignore, schema doesn't exist yet */ // NOTE: Some providers may abort the transaction in the event of an error. If this is the case make sure to override // the provider-specific method ISqlProvider.GetTableExistenceSql() (see above). historySchemaExists = false; } return result.ToArray(); }
/// <summary> /// Applies the specified <paramref name="migration"/> within the /// specified <paramref name="context"/>. /// </summary> /// <param name="migration">The migration to apply.</param> /// <param name="direction">The migration direction.</param> /// <param name="context">The context.</param> protected virtual void ApplyMigration(IMigration migration, MigrationDirection direction, MigrationContext context) { // // Notify environment // var beforeArgs = new BeforeMigrationEventArgs(migration.GetVersion(), migration, direction); OnBeforeMigration(beforeArgs); if (beforeArgs.Cancel) throw new Exception("environment cancelled migration"); // // Generate model // Database model = new Database(context); // // Send SQL statements on flush notification // model.FlushChanges += delegate(object sender, EventArgs e) { foreach (string sql in context.SqlProvider.GenerateSqlCommands(model)) { // Notify environment var beforeSqlArgs = new BeforeSqlEventArgs(sql); OnBeforeSql(beforeSqlArgs); if (beforeSqlArgs.Cancel) throw new Exception("environment cancelled migration"); // Execute SqlProcessor.ProcessMigrationStatement(context, sql); // Notify environment var afterSqlArgs = new AfterSqlEventArgs(sql, true); OnAfterSql(afterSqlArgs); } }; // // Run migration // if (direction == MigrationDirection.Up) migration.Up(model); else migration.Down(model); // // Flush changes // model.Flush(); // // Memorize migration // HistoryRepository.AddItem(context, new MigrationHistoryItem() { Date = DateTime.Now, Direction = direction, Version = migration.GetVersion() } ); // // Notify enviroment // var afterArgs = new AfterMigrationEventArgs(migration.GetVersion(), migration, direction, true); OnAfterMigration(afterArgs); }
/// <summary> /// Creates a new instance of a <see cref="AP007ProcessManagerRoutingSlipGenerator"/> class. /// </summary> /// <param name="fileRepository">The file repository.</param> /// <param name="routeWalker">The scenario route walker.</param> /// <param name="model">The model.</param> /// <param name="context">The context.</param> /// <param name="logger">A logger.</param> public AP007ProcessManagerRoutingSlipGenerator(IFileRepository fileRepository, IScenarioRouteWalker routeWalker, IApplicationModel model, MigrationContext context, ILogger logger) : base(nameof(AP007ProcessManagerRoutingSlipGenerator), model, context, logger) { // Validate and set the member. _fileRepository = fileRepository ?? throw new ArgumentNullException(nameof(fileRepository)); _routeWalker = routeWalker ?? throw new ArgumentNullException(nameof(routeWalker)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Creates a new instance of a <see cref="MB002MessageBoxAnalyzer"/> class. /// </summary> /// <param name="model">The model.</param> /// <param name="context">The context.</param> /// <param name="logger">A logger.</param> public MB002MessageBoxAnalyzer(IApplicationModel model, MigrationContext context, ILogger logger) : base(nameof(MB002MessageBoxAnalyzer), model, context, logger) { // Validate and set the member. _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public void InitializeTarget() { MigrationContext context = new MigrationContext() { SqlProvider = new Sql.SqlServer.SqlServerProvider() }; Database db = new Database(context); Table t = db.AddTable("Table"); Target = t.AddColumn("MyColumn", SqlTypes.Int); }
/// <summary> /// Initializes a new instance of the <see cref="SchemaConstraintQuery" /> class. /// </summary> /// <param name="schemaName">The schema name</param> /// <param name="tableName">The table name</param> /// <param name="constraintName">The constraint name</param> /// <param name="context">The migration context</param> public SchemaConstraintQuery(string schemaName, string tableName, string constraintName, MigrationContext context) { _schemaName = schemaName; _tableName = tableName; _constraintName = constraintName; _context = context; }
public void InitializeTarget() { MigrationContext context = new MigrationContext(); Database db = new Database(context); Target = db.AddTable("Table"); }
public override void Setup() { base.Setup(); _dbProvider = _mocks.DynamicMock <IDatabaseProvider>(); _mockedMigrationContext = new MigrationContext(_mocks.Stub <IConfiguration>(), _dbProvider, _mocks.Stub <ISchemaProvider>(), _mocks.Stub <ICommonTransformations>(), _mocks.Stub <IConnectionProvider>()); }
/// <summary> /// Ensures that the schema for the migration history exists. /// </summary> /// <param name="context">The context.</param> protected virtual void EnsureMigrationHistorySchemaExists(MigrationContext context) { if (schemaDone) return; // // Check if schema already exists // bool error; InternalRetrieveHistory(context, out error); if (error) { // // Try to create schema ... if it already exits the // SQL commands will simply fail // Database model = new Database(null); Table t = model.AddTable(TableName); { t.AddColumn(DateColumnName, SqlTypes.DateTime).NotNull(); t.AddColumn(VersionColumnName, SqlTypes.BigInt).NotNull(); t.AddColumn(DirectionColumnName, SqlTypes.TinyInt).NotNull(); } foreach (string sql in context.SqlProvider.GenerateSqlCommands(model)) { try { context.SqlProcessor.ProcessMigrationStatement(context, sql); } catch { // The schema probaly already exists, // just ignore the exception break; } } } schemaDone = true; }
public void ConstructWithSuccess(AP002SystemApplicationAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing" .x(() => e = Record.Exception(() => new AP002SystemApplicationAnalyzer(model, context, logger))); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); }
public void CreateSystemApplicationWithSuccess(AP002SystemApplicationAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { var messageBusKey = "messageBusKey"; "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And the model has a message bus" .x(() => { model.MigrationTarget.MessageBus = new ApplicationModel.Target.MessageBus { Name = "Message Bus", Key = messageBusKey, ResourceMapKey = "messageBusResourceMapKey", }; }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new AP002SystemApplicationAnalyzer(model, context, logger)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then there should be no exception" .x(() => e.Should().BeNull()); "And the system application will have been created" .x(() => { model.Should().NotBeNull(); model.MigrationTarget.Should().NotBeNull(); model.MigrationTarget.MessageBus.Should().NotBeNull(); model.MigrationTarget.MessageBus.Applications.Should().NotBeNullOrEmpty(); model.MigrationTarget.MessageBus.Applications.Should().HaveCount(1); var application = model.MigrationTarget.MessageBus.Applications[0]; application.Name.Should().Be("System Application"); application.Key.Should().Be($"{messageBusKey}:SystemApplication"); application.ResourceMapKey.Should().Be("systemApplication"); application.Description.Should().NotBeNullOrEmpty(); application.Rating.Should().Be(ApplicationModel.Report.ConversionRating.FullConversion); }); }
public static void Test(MigrationWorkItem workItem) { //TODO: remove workItem depency, add context holder, uncomment broken bits IProject project = workItem.Services.Get<IProjectContextService>().ActiveProject; OrmModel orm = project.Models.Get<OrmModel>(); QuickFormModel qfModel = project.Models.Get<QuickFormModel>(); MigrationSettings s = new MigrationSettings(); s.PackageName = "test"; MigrationContext c = new MigrationContext( s, orm.Packages[0], null, null, null, null, null, workItem.Log, new EmptyOperationStatus(), null); OrmEntity entity = orm.Packages[1].Entities[0]; IList<IQuickFormDefinition> forms = qfModel.LoadDefinitions(entity); FormInfo form = new FormInfo(null, "0", false, "0", "0", 0, 0); form.QuickForm = (IQuickFormDefinition) forms[0]; c.Forms.Add("0", form); c.Forms.Add("0x", form); form = new FormInfo(null, "1", false, "1", "1", 1, 1); form.QuickForm = (IQuickFormDefinition) forms[1]; form.Entity = entity; c.Forms.Add("1", form); c.Forms.Add("1x", form); entity = orm.Packages[1].Entities[12]; forms = qfModel.LoadDefinitions(entity); form = new FormInfo(null, "2", false, "2", "2", 2, 2); form.QuickForm = (IQuickFormDefinition) forms[0]; c.Forms.Add("2", form); c.Forms.Add("2x", form); form = new FormInfo(null, "3", false, "3", "3", 3, 3); form.QuickForm = (IQuickFormDefinition) forms[1]; form.Entity = entity; c.Forms.Add("3", form); c.Forms.Add("3x", form); //c.Relationships.Add("0", new OrmRelationship(orm.Relationships[0], true)); //c.Relationships.Add("0x", new OrmRelationship(orm.Relationships[0], true)); //c.Relationships.Add("1", new OrmRelationship(orm.Relationships[1], true)); //c.Relationships.Add("1x", new OrmRelationship(orm.Relationships[1], true)); PortalApplication portalApp = PortalApplication.Get("SlxClient"); portalApp.Model = project.Models.Get<PortalModel>(); LinkedFile file = portalApp.SupportFiles.GetFiles()[0]; c.LinkedFiles.Add(file); c.LinkedFiles.Add(file); file = portalApp.SupportFiles.GetFiles()[1]; c.LinkedFiles.Add(file); c.LinkedFiles.Add(file); file = portalApp.SupportFiles.GetFolders()[1].GetFiles()[0]; c.LinkedFiles.Add(file); c.LinkedFiles.Add(file); file = portalApp.SupportFiles.GetFolders()[1].GetFiles()[1]; c.LinkedFiles.Add(file); c.LinkedFiles.Add(file); //SmartPartMapping part = portalApp.Pages[0].SmartParts[0]; //c.SmartParts.Add("0", part); //c.SmartParts.Add("0x", part); //part = portalApp.Pages[0].SmartParts[1]; //c.SmartParts.Add("1", part); //c.SmartParts.Add("1x", part); //part = portalApp.Pages[1].SmartParts[0]; //c.SmartParts.Add("2", part); //c.SmartParts.Add("2x", part); //part = portalApp.Pages[1].SmartParts[1]; //c.SmartParts.Add("3", part); //c.SmartParts.Add("3x", part); IManifestService b = workItem.Services.Get<IManifestService>(); b.Generate(); }