public DataContract2ClassBuilder(string ns, Command cmd, DataTable dt) : base(ns, cmd) { this.dt = dt; foreach (DataColumn column in dt.Columns) { TypeInfo ty = new TypeInfo { type = column.DataType }; foreach (DataRow row in dt.Rows) { if (row[column] == DBNull.Value) ty.Nullable = true; break; } dict.Add(column, ty); } builder.AddUsing("System"); builder.AddUsing("System.Collections.Generic"); builder.AddUsing("System.Data"); builder.AddUsing("System.Linq"); builder.AddUsing("Sys.Data"); AddOptionalUsing(); }
public TheClassBuilder(string ns, Command cmd) { this.cmd = cmd; this._using = cmd.GetValue("using"); this._base = cmd.GetValue("base"); builder = new CSharpBuilder { nameSpace = ns }; }
public bool TypeFile(TreeNode<IDataPath> pt, Command cmd) { if (TypeFileData(pt, cmd)) return true; if (TypeLocatorData(pt, cmd)) return true; if (TypeLocatorColumnData(pt, cmd)) return true; return false; }
public void Display(TreeNode<IDataPath> pt, Command cmd) { if (DisplayServerNodes(pt, cmd)) return; if (DisplayDatabaseNodes(pt, cmd)) return; if (DisplayTableNodes(pt, cmd)) return; if (DisplayTableSubNodes(pt, cmd)) return; if (_DisplayLocatorNodes(pt, cmd)) return; if (DisplayViewNodes(pt, cmd)) return; }
private bool TypeFileData(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is TableName)) return false; TableName tname = (TableName)pt.Item; tout = new TableOut(tname); return tout.Display(cmd); }
public PathBothSide(PathManager mgr, Command cmd) { this.mgr = mgr; ps1 = new PathSide(mgr); ps2 = new PathSide(mgr); var f1 = ps1.SetSource(cmd.arg1); var f2 = ps2.SetSink(cmd.arg2); valid = f1 && f2; }
public EntityClassBuilder(string ns, Command cmd, TableName tname) : base(ns, cmd) { this.tname = tname; this.cname = tname.Name; builder.AddUsing("System"); builder.AddUsing("System.Collections.Generic"); builder.AddUsing("System.Data"); builder.AddUsing("System.Linq"); AddOptionalUsing(); }
public Linq2SQLClassBuilder(string ns, Command cmd, TableName tname, Dictionary<TableName, TableSchema> schemas) : base(ns, cmd) { this.tname = tname; this.cname = tname.ToClassName(null); this.schemas = schemas; builder.AddUsing("System"); //builder.AddUsing("System.Collections.Generic"); //builder.AddUsing("System.Data"); builder.AddUsing("System.Data.Linq"); builder.AddUsing("System.Data.Linq.Mapping"); }
private bool TypeLocatorData(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is Locator)) return false; TableName tname = this.GetCurrentPath<TableName>(); Locator locator = GetCombinedLocator(pt); var xnode = pt; while (xnode.Parent.Item is Locator) { xnode = xnode.Parent; locator.And((Locator)xnode.Item); } tout = new TableOut(tname); return tout.Display(cmd, "*", locator); }
private bool TypeLocatorColumnData(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is ColumnPath)) return false; ColumnPath column = (ColumnPath)pt.Item; Locator locator = null; TableName tname = null; if (pt.Parent.Item is Locator) { locator = (Locator)pt.Parent.Item; tname = (TableName)pt.Parent.Parent.Item; } else tname = (TableName)pt.Parent.Item; tout = new TableOut(tname); return tout.Display(cmd, column.Columns, locator); }
private static bool DisplayTableNodes(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is DatabaseName)) return false; DatabaseName dname = (DatabaseName)pt.Item; if (cmd.HasStorage) { displayTable(dname.StorageSchema(), "Storage"); return true; } int i = 0; int[] count = new int[] { 0, 0 }; int h = 0; foreach (var node in pt.Nodes) { TableName tname = (TableName)node.Item; ++i; if (IsMatch(cmd.wildcard, tname.Path)) { if (!tname.IsViewName) count[0]++; if (tname.IsViewName) count[1]++; stdio.WriteLine("{0,5} {1,15}.{2,-37} <{3}>", sub(i), tname.SchemaName, tname.Name, tname.IsViewName ? "VIEW" : "TABLE"); h = PagePause(cmd, ++h); } } stdio.WriteLine("\t{0} Table(s)", count[0]); stdio.WriteLine("\t{0} View(s)", count[1]); return true; }
private static bool DisplayDatabaseNodes(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is ServerName)) return false; ServerName sname = (ServerName)pt.Item; if (sname.Disconnected) { stdio.WriteLine("\t? Database(s)"); } else { int i = 0; int count = 0; int h = 0; foreach (var node in pt.Nodes) { DatabaseName dname = (DatabaseName)node.Item; ++i; if (IsMatch(cmd.wildcard, dname.Path)) { count++; if (node.Nodes.Count == 0) ExpandDatabaseName(node, cmd.Refresh); stdio.WriteLine("{0,4} {1,26} <DB> {2,10} Tables/Views", sub(i), dname.Name, node.Nodes.Count); h = PagePause(cmd, ++h); } } stdio.WriteLine("\t{0} Database(s)", count); } return true; }
private static bool DisplayViewNodes(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is TableName)) return false; TableName vname = (TableName)pt.Item; if (!vname.IsViewName) return false; DataTable schema = vname.ViewSchema(); stdio.WriteLine("VIEW: {0}", vname.Path); int i = 0; int count = 0; int h = 0; foreach (DataRow row in schema.Rows) { string columnName = string.Format("{0}", row["COLUMN_NAME"]); if (IsMatch(cmd.wildcard, columnName)) { count++; stdio.WriteLine("{0,5} {1,26} {2,-16} {3,10}", sub(++i), string.Format("{0}", columnName), row["DATA_TYPE"], (string)row["IS_NULLABLE"] =="YES" ? "null" : "not null"); h = PagePause(cmd, ++h); } } stdio.WriteLine("\t{0} Column(s)", count); return true; }
private static int PagePause(Command cmd, int h) { if (cmd.HasPage && h >= Console.WindowHeight - 1) { h = 0; stdio.Write("press any key to continue..."); stdio.ReadKey(); stdio.WriteLine(); } return h; }
private static void _DisplayColumnNodes(Command cmd, TableName tname) { TableSchema schema = new TableSchema(tname); stdio.WriteLine("TABLE: {0}", tname.Path); int i = 0; int count = 0; int h = 0; foreach (IColumn column in schema.Columns) { if (IsMatch(cmd.wildcard, column.ColumnName)) { count++; List<string> L = new List<string>(); if (column.IsIdentity) L.Add("++"); if (column.IsPrimary) L.Add("pk"); if ((column as ColumnSchema).FkContraintName != null) L.Add("fk"); string keys = string.Join(",", L); stdio.WriteLine("{0,5} {1,26} {2,-16} {3,10} {4,10}", sub(++i), string.Format("[{0}]", column.ColumnName), ColumnSchema.GetSQLType(column), keys, column.Nullable ? "null" : "not null"); h = PagePause(cmd, ++h); } } stdio.WriteLine("\t{0} Column(s)", count); }
private static bool _DisplayLocatorNodes(TreeNode<IDataPath> pt, Command cmd) { int i = 0; int count = 0; foreach (var node in pt.Nodes) { IDataPath item = node.Item; ++i; if (IsMatch(cmd.wildcard, item.Path)) { count++; stdio.WriteLine("{0,5} {1}", sub(i), item); } } stdio.WriteLine("\t{0} Item(s)", count); return true; }
private bool DisplayServerNodes(TreeNode<IDataPath> pt, Command cmd) { if (pt != RootNode) return false; int i = 0; int count = 0; int h = 0; CancelableWork.CanCancel(cts => { foreach (var node in pt.Nodes) { if (cts.IsCancellationRequested) return; ServerName sname = (ServerName)node.Item; ++i; if (IsMatch(cmd.wildcard, sname.Path)) { count++; if (node.Nodes.Count == 0) { ExpandServerName(node, Refreshing); } stdio.WriteLine("{0,4} {1,26} <SVR> {2,10} Databases", sub(i), sname.Path, sname.Disconnected ? "?" : node.Nodes.Count.ToString()); h = PagePause(cmd, ++h); } } stdio.WriteLine("\t{0} Server(s)", count); }); return true; }
private static bool DisplayTableSubNodes(TreeNode<IDataPath> pt, Command cmd) { if (!(pt.Item is TableName)) return false; TableName tname = (TableName)pt.Item; bool flag = false; if (cmd.HasDefinition) { if (tname.IsViewName) { stdio.WriteLine("cannot display view structure"); return false; } _DisplayColumnNodes(cmd, tname); flag = true; } if (cmd.HasPrimaryKey) { displayTable(tname.PrimaryKeySchema(), "Primary Key(s)"); flag = true; } if (cmd.HasForeignKey) { displayTable(tname.ForeignKeySchema(), "Foreign Key(s)"); flag = true; } if (cmd.HasDependency) { displayTable(tname.DependenySchema(), "Dependencies"); flag = true; } if (cmd.HasIdentityKey) { displayTable(tname.IdentityKeySchema(), "Identity Key(s)"); flag = true; } if (cmd.HasIndex) { displayTable(tname.IndexSchema(), "Indices"); flag = true; } if (cmd.HasStorage) { displayTable(tname.StorageSchema(), "Storage"); flag = true; } if (flag) return true; _DisplayLocatorNodes(pt, cmd); return true; }