Esempio n. 1
0
        protected List <string> ApplyChangesToDatabase_Insert(List <NewConceptApplication> toBeInserted, List <NewConceptApplication> newApplications)
        {
            var newScripts = new List <string>();

            Graph.TopologicalSort(toBeInserted, GetDependencyPairs(newApplications));

            int insertedCACount = 0;

            foreach (var ca in toBeInserted)
            {
                string[] createSqlScripts = SplitSqlScript(ca.CreateQuery);
                if (createSqlScripts.Length > 0)
                {
                    LogDatabaseChanges(ca, "Creating");
                    insertedCACount++;
                }

                newScripts.AddRange(createSqlScripts);
                newScripts.AddRange(_sqlTransactionBatches.JoinScripts(_conceptApplicationRepository.InsertMetadataSql(ca)));
                newScripts.AddRange(MaybeCommitMetadataAfterDdl(createSqlScripts));
            }

            var logLevel = insertedCACount > 0 ? EventType.Info : EventType.Trace;

            _deployPackagesLogger.Write(logLevel, "DatabaseGenerator creating " + insertedCACount + " concept applications.");
            return(newScripts);
        }
Esempio n. 2
0
        private List <string> ApplyChangesToDatabase_Insert(List <ConceptApplication> toBeInserted, List <ConceptApplication> newApplications)
        {
            var newScripts = new List <string>();

            Graph.TopologicalSort(toBeInserted, ConceptApplication.GetDependencyPairs(newApplications));

            int insertedCACount = 0;

            foreach (var ca in toBeInserted)
            {
                string[] createSqlScripts = SplitSqlScript(ca.CreateQuery);
                if (createSqlScripts.Length > 0)
                {
                    LogDatabaseChanges(ca, "Creating");
                    insertedCACount++;
                }

                newScripts.AddRange(createSqlScripts);
                newScripts.AddRange(_sqlTransactionBatches.JoinScripts(_conceptApplicationRepository.InsertMetadataSql(ca)));
                newScripts.AddRange(MaybeCommitMetadataAfterDdl(createSqlScripts));
            }

            _logger.Info($"Creating {insertedCACount} concept applications.");
            return(newScripts);
        }
        private List <SqlBatchScript> ApplyChangesToDatabase_Insert(List <ConceptApplication> toBeInserted, List <ConceptApplication> newApplications)
        {
            var newScripts = new List <SqlBatchScript>();

            Graph.TopologicalSort(toBeInserted, ConceptApplication.GetDependencyPairs(newApplications));

            int insertedCACount = 0;

            foreach (var ca in toBeInserted)
            {
                if (!string.IsNullOrWhiteSpace(ca.CreateQuery))
                {
                    LogDatabaseChanges(ca, "Creating");
                    insertedCACount++;
                }

                newScripts.Add(new SqlBatchScript {
                    Sql = ca.CreateQuery, IsBatch = true, Name = $"Creating {ca}."
                });
                newScripts.AddRange(_sqlTransactionBatches.JoinScripts(_conceptApplicationRepository.InsertMetadataSql(ca))
                                    .Select((sql, x) => new SqlBatchScript {
                    Sql = sql, IsBatch = false, Name = $"Creating {ca} metadata ({x + 1})."
                }));
                newScripts.AddRange(MaybeCommitMetadataAfterDdl(ca.CreateQuery));
            }

            _logger.Info($"Creating {insertedCACount} database objects.");
            return(newScripts);
        }