Ejemplo n.º 1
0
        private static bool ExpandDatabaseName(TreeNode <IDataPath> pt, bool refresh)
        {
            if (!(pt.Item is DatabaseName))
            {
                return(false);
            }

            DatabaseName dname = (DatabaseName)pt.Item;

            if (refresh || pt.Nodes.Count == 0)
            {
                if (refresh)
                {
                    pt.Nodes.Clear();
                }

                try
                {
                    TableName[] tnames = dname.GetTableNames();
                    if (tnames == null)
                    {
                        return(false);
                    }

                    foreach (var tname in tnames)
                    {
                        pt.Nodes.Add(new TreeNode <IDataPath>(tname));
                    }

                    TableName[] vnames = dname.GetViewNames();
                    foreach (var vname in vnames)
                    {
                        pt.Nodes.Add(new TreeNode <IDataPath>(vname));
                    }

                    TableName[] pnames = dname.GetProcedureNames();
                    foreach (var pname in pnames)
                    {
                        pt.Nodes.Add(new TreeNode <IDataPath>(pname));
                    }
                }
                catch (Exception ex)
                {
                    cerr.WriteLine($"failed to retrieve table names from {dname}, {ex.Message}");
                    return(false);
                }
            }

            return(true);
        }