예제 #1
0
        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();
        }
예제 #2
0
        public TheClassBuilder(string ns, Command cmd)
        {
            this.cmd = cmd;
            this._using = cmd.GetValue("using");
            this._base = cmd.GetValue("base");

            builder = new CSharpBuilder { nameSpace = ns };
        }
예제 #3
0
        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;
        }
예제 #4
0
 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;
 }
예제 #5
0
        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);
        }
예제 #6
0
        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;
        }
예제 #7
0
        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();
        }
예제 #8
0
        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");
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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;
        }
예제 #12
0
        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;
        }
예제 #13
0
        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;
        }
예제 #14
0
 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;
 }
예제 #15
0
        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);
        }
예제 #16
0
        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;
        }
예제 #17
0
        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;
        }
예제 #18
0
        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;
        }