internal static Collection<PgMaterializedView> GetMaterializedViews(string schemaPattern = ".*", string xSchemaPattern = "")
        {
            Collection<PgMaterializedView> materializedViews = new Collection<PgMaterializedView>();

            string sql = FileHelper.ReadSqlResource("materialized-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)
                        {
                            PgMaterializedView materializedView = new PgMaterializedView
                            {
                                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"])
                            };

                            materializedViews.Add(materializedView);
                        }
                    }
                }
            }

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

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

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

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

            BuildDocumentation(content, view);
        }