Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 public GenerateDefaults(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 3
0
 public GenerateXMLSchemas(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 4
0
 public GenerateDDLTriggers(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 5
0
        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;
 }
Ejemplo n.º 7
0
 public GenerateFullText(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 8
0
 public GenerateTables(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 9
0
 public GenerateRules(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 10
0
 public GenerateIndex(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 11
0
 public GenerateStoreProcedures(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 12
0
 public GenerateAssemblies(Generate root)
 {
     this.root = root;
 }
 public GenerateExtendedProperties(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 14
0
 public GenerateFileGroups(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 15
0
 public GenerateConstraint(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 16
0
 public GenerateFullText(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 17
0
 public GenerateTextObjects(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 18
0
 public GenerateSynonyms(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 19
0
 public GenerateFunctions(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 20
0
 public GenerateViews(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 21
0
 public GenerateExtendedProperties(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 22
0
 public GenerateViews(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 23
0
 public GenerateDDLTriggers(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 24
0
 public GenerateStoreProcedures(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 25
0
 public GenerateUsers(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 26
0
 public GenerateFileGroups(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 27
0
 public GeneratePartitionScheme(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 28
0
 public GenerateFunctions(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 29
0
 public GenerateAssemblies(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 30
0
 public GenerateUserDataTypes(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 31
0
 public GenerateUsers(Generate root)
 {
     this.root = root;
 }
Ejemplo n.º 32
0
 public GenerateTextObjects(Generate root)
 {
     this.root = root;
 }