Exemple #1
0
        internal static Collection<PgView> GetViews(string schemaPattern = ".*", string xSchemaPattern = "")
        {
            Collection<PgView> views = new Collection<PgView>();

            string sql = FileHelper.ReadSqlResource("views-by-schema.sql");

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@SchemaPattern", schemaPattern);
                command.Parameters.AddWithValue("@xSchemaPattern", xSchemaPattern);
                using (DataTable table = DbOperation.GetDataTable(command))
                {
                    if (table.Rows.Count > 0)
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            PgView view = new PgView
                            {
                                RowNumber = Conversion.TryCastLong(row["row_number"]),
                                Name = Conversion.TryCastString(row["object_name"]),
                                SchemaName = Conversion.TryCastString(row["object_schema"]),
                                Tablespace = Conversion.TryCastString(row["tablespace"]),
                                Owner = Conversion.TryCastString(row["owner"]),
                                Definition = Conversion.TryCastString(row["definition"]),
                                Description = Conversion.TryCastString(row["description"])
                            };

                            views.Add(view);
                        }
                    }
                }
            }

            return views;
        }
Exemple #2
0
        private static void BuildDocumentation(string content, PgView view)
        {
            content = content.Replace("[DBName]", Program.Database.ToUpperInvariant());

            content = Parsers.ViewParser.Parse(content, view);

            string targetPath = System.IO.Path.Combine (OutputPath, view.SchemaName, view.Name + ".html");
            FileHelper.WriteFile(content, targetPath);
        }
Exemple #3
0
        internal static string Parse(string content, PgView view)
        {
            StringBuilder items = new StringBuilder();
            items.Append(content.Replace("[Name]", view.Name)
                .Replace("[ViewSchema]", view.SchemaName)
                .Replace("[RowNumber]", view.RowNumber.ToString())
                .Replace("[Owner]", view.Owner)
                .Replace("[Tablespace]", view.Tablespace)
                .Replace("[Definition]", view.Definition)
                .Replace("[Description]", view.Description));

            content = content.Replace(content, items.ToString());

            return content;
        }
Exemple #4
0
        internal static void Run(PgView view)
        {
            string content = FileHelper.ReadResource(TemplatePath);

            BuildDocumentation(content, view);
        }