Ejemplo n.º 1
0
        public static TableName[] GetTableNames(ApplicationCommand cmd, PathManager mgr)
        {
            var pt = mgr.current;

            if (!(pt.Item is Locator) && !(pt.Item is TableName))
            {
                if (cmd.arg1 != null)
                {
                    PathName path = new PathName(cmd.arg1);
                    var      node = mgr.Navigate(path);
                    if (node != null)
                    {
                        var dname = mgr.GetPathFrom <DatabaseName>(node);
                        if (dname != null)
                        {
                            if (cmd.wildcard != null)
                            {
                                var m = new MatchedDatabase(dname, cmd);
                                return(m.TableNames());
                            }
                            else
                            {
                                var _tname = mgr.GetPathFrom <TableName>(node);
                                if (_tname != null)
                                {
                                    return new TableName[] { _tname }
                                }
                                ;
                                else
                                {
                                    cerr.WriteLine("invalid path");

                                    return(null);
                                }
                            }
                        }
                        else
                        {
                            cerr.WriteLine("database is unavailable");
                            return(null);
                        }
                    }
                    else
                    {
                        cerr.WriteLine("invalid path");
                        return(null);
                    }
                }
            }


            if (pt.Item is TableName)
            {
                var tname = (TableName)pt.Item;
                return(new TableName[] { tname });
            }

            return(null);
        }
Ejemplo n.º 2
0
 public Exporter(PathManager mgr, TreeNode<IDataPath> pt, Configuration cfg)
 {
     this.mgr = mgr;
     this.cfg = cfg;
     this.xml = new XmlDbFile { XmlDbFolder = cfg.XmlDbFolder };
     this.fileName = cfg.OutputFile;
     if (pt.Item is Locator)
     {
         this.tname = mgr.GetPathFrom<TableName>(pt);
         this.dname = tname.DatabaseName;
         this.sname = dname.ServerName;
     }
     else if (pt.Item is TableName)
     {
         this.tname = (TableName)pt.Item;
         this.dname = tname.DatabaseName;
         this.sname = dname.ServerName;
     }
     else if (pt.Item is DatabaseName)
     {
         this.tname = null;
         this.dname = (DatabaseName)pt.Item;
         this.sname = dname.ServerName;
     }
     else if (pt.Item is ServerName)
     {
         this.tname = null;
         this.dname = null;
         this.sname = (ServerName)pt.Item;
     }
 }
Ejemplo n.º 3
0
        public void Run(Action <TableName, TableName> action)
        {
            if (!valid)
            {
                return;
            }

            var dname2 = mgr.GetPathFrom <DatabaseName>(ps2.Node);

            foreach (var tname1 in ps1.MatchedTables)
            {
                TableName tname2 = mgr.GetPathFrom <TableName>(ps2.Node);
                if (tname2 == null)
                {
                    tname2 = new TableName(dname2, tname1.SchemaName, tname1.Name);
                }

                action(tname1, tname2);
            }
        }
Ejemplo n.º 4
0
        private bool SetSource(string source, string sourceText)
        {
            if (source == null)
            {
                cerr.WriteLine("invalid argument");
                return(false);
            }

            var path = new PathName(source);

            node = mgr.Navigate(path);
            if (node == null)
            {
                cerr.WriteLine("invalid path:" + path);
                return(false);
            }

            dname = mgr.GetPathFrom <DatabaseName>(node);
            if (dname == null)
            {
                cerr.WriteLine($"warning: {sourceText} database is unavailable");
                return(false);
            }

            var server = mgr.GetPathFrom <ServerName>(node);

            side = new Side(dname);

            T = new TableName[] { };

            if (path.wildcard != null)
            {
                var m1 = new MatchedDatabase(dname, path.wildcard)
                {
                    Includedtables = cmd.Includes,
                    Excludedtables = cmd.Excludes
                };

                T = m1.TableNames();
            }
            else
            {
                TableName tname = mgr.GetPathFrom <TableName>(node);
                if (tname == null)
                {
                    T = dname.GetTableNames();
                }
                else
                {
                    T = new TableName[] { tname };
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
        public Exporter(PathManager mgr, TreeNode <IDataPath> pt, ApplicationCommand cmd, IApplicationConfiguration cfg)
        {
            this.mgr = mgr;
            this.cmd = cmd;
            this.cfg = cfg;

            this.xmlDbFile = new XmlDbCreator
            {
                XmlDbFolder = cfg.XmlDbDirectory
            };

            if (pt.Item is Locator)
            {
                this.tname = mgr.GetPathFrom <TableName>(pt);
                this.dname = tname.DatabaseName;
                this.sname = dname.ServerName;
            }
            else if (pt.Item is TableName)
            {
                this.tname = (TableName)pt.Item;
                this.dname = tname.DatabaseName;
                this.sname = dname.ServerName;
            }
            else if (pt.Item is DatabaseName)
            {
                this.tname = null;
                this.dname = (DatabaseName)pt.Item;
                this.sname = dname.ServerName;
            }
            else if (pt.Item is ServerName)
            {
                this.tname = null;
                this.dname = null;
                this.sname = (ServerName)pt.Item;
            }
        }