static string DumpCreateStatements(M.Database db) { // collect component names List <string> names = Names(db); StringBuilder builder = new StringBuilder(); builder.AppendLine("---- Mapfile: " + MapFilePath(db)); // report components foreach (string name in names) { string checkFolder = db.GetProperty(name, "Folder"); if (!checkFolder.StartsWith("System Data")) { string type = db.GetComponentType(name).ToUpper(); builder.AppendLine(String.Format("---- {0}: {1}", type, name)); builder.AppendLine(String.Format("--{0}", DropStatement(type, name))); string body = CreateStatementBody(db, name); builder.Append(CreateStatement(name, type, body)); builder.AppendLine(); builder.AppendLine(); builder.AppendLine(); } } return(builder.ToString()); }
static string CreateStatementBody(M.Database db, string name) { List <string> items = new List <string>(); string type = db.GetComponentType(name).ToUpper(); if (type == "TABLE") { using (M.Table table = db.Search(name)) { M.Schema schema = table.GetSchema(); items.AddRange(FieldItems(schema.Fields)); items.AddRange(IndexItems(schema.Indexes)); items.AddRange(ConstraintItems(schema.Constraints)); } } M.PropertySet propertySet = db.GetProperties(name); items.AddRange(PropertyItems(propertySet)); string body = String.Join("," + Environment.NewLine, items.Select(i => String.Concat(Indent, i))); return(body); }
static string DumpCleanupStatements(M.Database db) { StringBuilder builder = new StringBuilder(); builder.AppendLine("---- Mapfile: " + MapFilePath(db)); foreach (string name in Names(db)) { string type = db.GetComponentType(name); string checkFolder = db.GetProperty(name, "Folder"); if (!checkFolder.StartsWith("System Data") & type == "table") { builder.AppendLine(CleanupStatement(name)); } } return(builder.ToString()); }