Example #1
0
        private DataSet LastOrCurrentDataSet()
        {
            var ds = ShellHistory.LastOrCurrentTable(tname);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(null);
            }

            return(ds);
        }
Example #2
0
        public static void ToConsole(this DataTable dt, bool vertical = false, bool more = false, bool outputDbNull = true, int maxColumnWidth = 0)
        {
            ShellHistory.SetLastResult(dt);
            OutputDataTable odt = new OutputDataTable(dt, cout.TrimWriteLine, vertical)
            {
                OutputDbNull   = outputDbNull,
                MaxColumnWidth = maxColumnWidth,
            };

            odt.Output();

            cout.WriteLine("<{0}{1} row{2}>", more ? "top " : "", dt.Rows.Count, dt.Rows.Count > 1 ? "s" : "");
        }
Example #3
0
        private bool Display(ApplicationCommand cmd, SqlBuilder builder, TableName tname, int top)
        {
            try
            {
                DataTable table = builder.SqlCmd.FillDataTable();
                table.SetSchemaAndTableName(tname);
                ShellHistory.SetLastResult(table);

                return(Display(cmd, table, top));
            }
            catch (Exception ex)
            {
                cerr.WriteLine(ex.Message);
                return(false);
            }
        }
Example #4
0
        public void ExportDataContract(int version)
        {
            bool last = cmd.Has("last");

            List <TableNameData> list = new List <TableNameData>();

            if (last)
            {
                DataSet ds = ShellHistory.LastDataSet();

                if (ds != null)
                {
                    string[] items = new string[] { };
                    string   clss  = cmd.GetValue("class");
                    if (clss != null)
                    {
                        items = clss.Split(',');
                    }

                    int i = 0;
                    foreach (DataTable dt in ds.Tables)
                    {
                        list.Add(new TableNameData {
                            Data = dt
                        });
                        if (i < items.Length)
                        {
                            dt.TableName = items[i];
                        }

                        i++;
                    }
                }
            }
            else if (tname != null)
            {
                var dt = FillTable(tname);
                list.Add(new TableNameData {
                    Name = tname, Data = dt
                });
            }
            else if (dname != null)
            {
                TableName[] tnames = getTableNames(cmd);
                foreach (var tn in tnames)
                {
                    var dt = FillTable(tn);
                    list.Add(new TableNameData {
                        Name = tn, Data = dt
                    });
                }
            }
            else
            {
                cerr.WriteLine("data table cannot find, use command type or select first");
                return;
            }

            foreach (TableNameData dt in list)
            {
                ExportDataContractClass(version, dt);
            }
        }