Example #1
0
        public void TestGenerator()
        {
            var generate = new Generate {
                ConnectionString = "Server=localhost;Database=NorthWind;Trusted_Connection=True;",
                Options = new SqlOption {
                    Ignore = {
                        FilterAssemblies = !true,
                        FilterCLRFunction = !true,
                        FilterCLRStoreProcedure = !true,
                        FilterCLRTrigger = !true,
                        FilterCLRUDT = !true,
                        FilterDDLTriggers = !true,
                        FilterPartitionFunction = !true,
                        FilterPartitionScheme = !true,
                        FilterUsers = !true,
                        FilterXMLSchema = !true
                    }
                }
            };

            var results = generate.Process();
            Assert.AreEqual(14, results.Procedures.Count);
            Assert.AreEqual(0, results.Users.Count);
        }
Example #2
0
 public GenerateDefaults(Generate root)
 {
     this.root = root;
 }
 public GenerateXMLSchemas(Generate root)
 {
     this.root = root;
 }
 public GenerateDDLTriggers(Generate root)
 {
     this.root = root;
 }
        public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
        {
            var counter = 0;
            foreach (var row in rows) {
                counter++;
                if (counter == 1) {
                    Guard.Against(!row.Contains(CONNECTION_STRING_KEY), "Row must contain connectionstring key.");
                }

                _connectionStringBuilder = new SqlConnectionStringBuilder(row[CONNECTION_STRING_KEY].ToString());
                var sqlConnectionChecker = new SqlConnectionChecker(new[] { _connectionStringBuilder.ConnectionString });

                if (!sqlConnectionChecker.AllGood())
                    continue;

                var results = new Database();
                var subRows = new List<Row>();
                var generator = new Generate() { ConnectionString = _connectionStringBuilder.ConnectionString };

                Debug("Started generating definitions on {0} for {1}", _connectionStringBuilder.DataSource, _connectionStringBuilder.InitialCatalog);

                try {
                    results = generator.Process();
                }
                catch (Exception e) {
                    Warn("Trouble processing objects from {0}.{1}.\nError Message: {2}.", _connectionStringBuilder.DataSource, _connectionStringBuilder.InitialCatalog, e.Message);
                }

                Debug("Finished generating defs on {0} for {1}", _connectionStringBuilder.DataSource, _connectionStringBuilder.InitialCatalog);

                subRows.AddRange(ToRows(results.Procedures, "StoredProcedures", "Stored Procedure"));
                subRows.AddRange(ToRows(results.Functions, "Functions", "Function"));
                subRows.AddRange(ToRows(results.Tables, "Tables", "Table"));
                subRows.AddRange(ToRows(results.Views, "Views", "View"));
                subRows.AddRange(ToRows(results.Schemas, "Schemas", "Schema"));
                subRows.AddRange(ToRows(results.Synonyms, "Synonyms", "Synonym"));
                subRows.AddRange(ToRows(results.FullText, "FullTextCatalogs", "Full Text Catalog"));

                foreach (var table in results.Tables) {
                    subRows.AddRange(ToRows(table.Indexes, "Indexes", "Index", true));
                    subRows.AddRange(ToRows(table.Triggers, "Triggers", "Trigger", true));
                    foreach (var constraint in table.Constraints) {
                        switch (constraint.Type) {
                            case Constraint.ConstraintType.Check:
                                subRows.AddRange(ToRows(Enumerable.Repeat(constraint, 1), "CheckConstraints", "Check Constraint", true, true));
                                break;
                            case Constraint.ConstraintType.Default:
                                subRows.AddRange(ToRows(Enumerable.Repeat(constraint, 1), "DefaultConstraints", "Default Constraint", true, true));
                                break;
                            case Constraint.ConstraintType.ForeignKey:
                                subRows.AddRange(ToRows(Enumerable.Repeat(constraint, 1), "ForeignKeys", "Foreign Key", true, true));
                                break;
                            case Constraint.ConstraintType.PrimaryKey:
                                subRows.AddRange(ToRows(Enumerable.Repeat(constraint, 1), "PrimaryKeys", "Primary Key", true, true));
                                break;
                            case Constraint.ConstraintType.Unique:
                                subRows.AddRange(ToRows(Enumerable.Repeat(constraint, 1), "UniqueConstraints", "Unique Constraint", true, true));
                                break;
                        }
                    }

                    foreach (var index in table.FullTextIndex)
                        subRows.AddRange(ToRows(Enumerable.Repeat(index, 1), "FullTextIndexes", "Full Text Index", true));
                }

                Info("Found {0} in {1}.", subRows.Count, _connectionStringBuilder.InitialCatalog);

                foreach (var subRow in subRows) {
                    yield return subRow;
                }

            }
        }
 public GeneratePartitionFunctions(Generate root)
 {
     this.root = root;
 }
Example #7
0
 public GenerateFullText(Generate root)
 {
     this.root = root;
 }
Example #8
0
 public GenerateTables(Generate root)
 {
     this.root = root;
 }
Example #9
0
 public GenerateRules(Generate root)
 {
     this.root = root;
 }
Example #10
0
 public GenerateIndex(Generate root)
 {
     this.root = root;
 }
Example #11
0
 public GenerateStoreProcedures(Generate root)
 {
     this.root = root;
 }
Example #12
0
 public GenerateAssemblies(Generate root)
 {
     this.root = root;
 }
 public GenerateExtendedProperties(Generate root)
 {
     this.root = root;
 }
 public GenerateFileGroups(Generate root)
 {
     this.root = root;
 }
 public GenerateConstraint(Generate root)
 {
     this.root = root;
 }
Example #16
0
 public GenerateFullText(Generate root)
 {
     this.root = root;
 }
 public GenerateTextObjects(Generate root)
 {
     this.root = root;
 }
Example #18
0
 public GenerateSynonyms(Generate root)
 {
     this.root = root;
 }
Example #19
0
 public GenerateFunctions(Generate root)
 {
     this.root = root;
 }
Example #20
0
 public GenerateViews(Generate root)
 {
     this.root = root;
 }
 public GenerateExtendedProperties(Generate root)
 {
     this.root = root;
 }
Example #22
0
 public GenerateViews(Generate root)
 {
     this.root = root;
 }
Example #23
0
 public GenerateDDLTriggers(Generate root)
 {
     this.root = root;
 }
 public GenerateStoreProcedures(Generate root)
 {
     this.root = root;
 }
Example #25
0
 public GenerateUsers(Generate root)
 {
     this.root = root;
 }
Example #26
0
 public GenerateFileGroups(Generate root)
 {
     this.root = root;
 }
 public GeneratePartitionScheme(Generate root)
 {
     this.root = root;
 }
Example #28
0
 public GenerateFunctions(Generate root)
 {
     this.root = root;
 }
 public GenerateAssemblies(Generate root)
 {
     this.root = root;
 }
 public GenerateUserDataTypes(Generate root)
 {
     this.root = root;
 }
Example #31
0
 public GenerateUsers(Generate root)
 {
     this.root = root;
 }
Example #32
0
 public GenerateTextObjects(Generate root)
 {
     this.root = root;
 }