public override void CreateFiles(string schemaName)
        {
            var foreignKeys = DbContext.DBA_CONSTRAINTS
                              .Where(c => (schemaName == null || c.OWNER == schemaName) && c.CONSTRAINT_TYPE == "R")
                              .OrderBy(c => c.OWNER)
                              .ThenBy(c => c.CONSTRAINT_NAME)
                              .ToList();

            foreach (var foreignKey in foreignKeys)
            {
                var dbObject = DependencyMatrix.GetDbObject(ObjectType.ToUpperInvariant(), foreignKey.OWNER, foreignKey.CONSTRAINT_NAME);

                var fileName = foreignKey.CONSTRAINT_NAME.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, foreignKey.OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, foreignKey.CONSTRAINT_NAME).GetSqlString());
                sqlStringBuilder.AppendLine(new DependenciesSqlGenerator(DbContext, foreignKey, DependencyMatrix).GetSqlString());
                sqlStringBuilder.AppendLine(new ForeignKeyConstraintSqlGenerator(DbContext, foreignKey).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }
예제 #2
0
        public override void CreateFiles(string schemaName)
        {
            var views = DbContext.DBA_VIEWS
                        .Where(t => schemaName == null || t.OWNER == schemaName)
                        .OrderBy(t => t.OWNER)
                        .ThenBy(t => t.VIEW_NAME)
                        .ToList();

            foreach (var view in views)
            {
                var dbObject = DependencyMatrix.GetDbObject(ObjectType.ToUpperInvariant(), view.OWNER, view.VIEW_NAME);

                var fileName = view.VIEW_NAME.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, view.OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, view.VIEW_NAME).GetSqlString());
                sqlStringBuilder.AppendLine(new DependenciesSqlGenerator(DbContext, view, DependencyMatrix).GetSqlString());
                sqlStringBuilder.AppendLine(new ViewSqlGenerator(DbContext, view).GetSqlString());
                sqlStringBuilder.AppendLine(new TableCommentGenerator(DbContext, view).GetSqlString());
                sqlStringBuilder.AppendLine(new ColumnCommentsGenerator(DbContext, view).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }
        public override void CreateFiles(string schemaName)
        {
            var objectTypeUpper = ObjectType.ToUpperInvariant();
            var packages        = DbContext.DBA_PROCEDURES
                                  .Where(
                p =>
                (schemaName == null || p.OWNER == schemaName) &&
                (p.OBJECT_TYPE == objectTypeUpper && p.SUBPROGRAM_ID == 0))
                                  .OrderBy(p => p.OBJECT_TYPE)
                                  .ThenBy(p => p.OWNER)
                                  .ThenBy(p => p.OBJECT_NAME)
                                  .ToList();

            foreach (var package in packages)
            {
                var dbObject = DependencyMatrix.GetDbObject(objectTypeUpper, package.OWNER, package.OBJECT_NAME);

                var fileName = package.OBJECT_NAME.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, package.OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, package.OBJECT_NAME).GetSqlString());
                sqlStringBuilder.AppendLine(new DependenciesSqlGenerator(DbContext, package, DependencyMatrix).GetSqlString());
                sqlStringBuilder.AppendLine(new PackageSqlGenerator(DbContext, package).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }
        public override void CreateFiles(string schemaName)
        {
            var jobs = DbContext.DBA_SCHEDULER_JOBS
                       .Where(p => (schemaName == null || p.OWNER == schemaName))
                       .OrderBy(p => p.OWNER)
                       .ThenBy(p => p.JOB_NAME)
                       .ToList();

            foreach (var job in jobs)
            {
                var dbObject = DependencyMatrix.GetDbObject(ObjectType.ToUpperInvariant(), job.OWNER, job.JOB_NAME);
                var fileName = job.JOB_NAME.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, job.OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, job.JOB_NAME).GetSqlString());
                sqlStringBuilder.AppendLine(new DbmsSchedulerJobSqlGenerator(DbContext, job).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }
예제 #5
0
        public override void CreateFiles(string schemaName)
        {
            var sequences = DbContext.DBA_SEQUENCES
                            .Where(p => (schemaName == null || p.SEQUENCE_OWNER == schemaName))
                            .OrderBy(p => p.SEQUENCE_OWNER)
                            .ThenBy(p => p.SEQUENCE_NAME)
                            .ToList();

            foreach (var seq in sequences)
            {
                var dbObject = DependencyMatrix.GetDbObject(ObjectType.ToUpperInvariant(), seq.SEQUENCE_OWNER, seq.SEQUENCE_NAME);
                var fileName = seq.SEQUENCE_NAME.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, seq.SEQUENCE_OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, seq.SEQUENCE_NAME).GetSqlString());
                sqlStringBuilder.AppendLine(new SequenceSqlGenerator(DbContext, seq).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }
예제 #6
0
        public override void CreateFiles(string schemaName)
        {
            var dbLinks = DbContext.DBA_DB_LINKS
                          .Where(p => (schemaName == null || p.OWNER == schemaName))
                          .OrderBy(p => p.OWNER)
                          .ThenBy(p => p.DB_LINK)
                          .ToList();

            foreach (var dbLink in dbLinks)
            {
                var dbObject = DependencyMatrix.GetDbObject(ObjectType.ToUpperInvariant(), dbLink.OWNER, dbLink.DB_LINK);
                var fileName = dbLink.DB_LINK.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, dbLink.OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, dbLink.DB_LINK).GetSqlString());
                sqlStringBuilder.AppendLine(new DbLinkSqlGenerator(DbContext, dbLink).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }
예제 #7
0
        public override void CreateFiles(string schemaName)
        {
            var objectTypeUpper = ObjectType.ToUpperInvariant();
            var triggers        = DbContext.DBA_PROCEDURES
                                  .Where(
                p =>
                (schemaName == null || p.OWNER == schemaName) &&
                p.OBJECT_TYPE == objectTypeUpper)
                                  .OrderBy(p => p.OWNER)
                                  .ThenBy(p => p.OBJECT_NAME)
                                  .ToList();

            foreach (var trigger in triggers)
            {
                var triggerData = DbContext.DBA_TRIGGERS
                                  .FirstOrDefault(t => t.OWNER == trigger.OWNER && t.TRIGGER_NAME == trigger.OBJECT_NAME);

                if (triggerData == null)
                {
                    continue;
                }

                var dbObject = DependencyMatrix.GetDbObject(objectTypeUpper, trigger.OWNER, trigger.OBJECT_NAME);
                var fileName = trigger.OBJECT_NAME.ToLowerInvariant() + SqlFileExtension;
                dbObject.FilePath = FileSystemHelper.GetOutputPath(SubFolderName, trigger.OWNER) + fileName;

                var sqlStringBuilder = new StringBuilder();

                sqlStringBuilder.AppendLine(new CommonHeaderFragmentCreator(DbContext, fileName, ObjectType, trigger.OBJECT_NAME).GetSqlString());
                sqlStringBuilder.AppendLine(new DependenciesSqlGenerator(DbContext, trigger, DependencyMatrix).GetSqlString());
                sqlStringBuilder.AppendLine(new TriggerSqlGenerator(DbContext, triggerData).GetSqlString());
                sqlStringBuilder.AppendLine(new CommonFileFooterFragmentCreator(DbContext, fileName).GetSqlString());

                FileSystemHelper.SaveContentToFile(dbObject.FilePath, sqlStringBuilder.ToString());
            }
        }