예제 #1
0
        /// <summary>
        /// Create a project file for the given source file by group comment that is with each table: 
        ///   for example: 
        /// -- my table description  
        /// -- GROUP: account
        /// CREATE TABLE a_ledger ...
        /// </summary>
        static void DumpProjectAllTablesByGroup( string sqlfilename)
        {
            ParserSQL sql = new ParserSQL();

            if ( sql.readSQL( sqlfilename )) {
                DataBaseHTML db = new DataBaseHTML(sql.getDatabase());
                List<string> groups = db.getGroupNames();

                Console.WriteLine("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>");
                Console.WriteLine();
                Console.WriteLine("<database>");

                foreach (string itGroup in groups)
                {
                    Console.WriteLine("\t<group name=\"" + itGroup + "\">");
                    // For all tables in that group dump their names here
                    List<string> tableNamesInGroup = db.getTableNamesInGroup(itGroup);
                    foreach (string itTable in tableNamesInGroup)
                    {
                        Console.WriteLine("\t\t<tablename name=\"" + itTable + "\"/>");
                    }
                    // End of this group
                    Console.WriteLine("\t</group>");
                }

                Console.WriteLine("</database>");

                db.writeMenus();
            }
        }
예제 #2
0
        static void RunProject( string szProject, string szDBSqlfile, string strPathDiaOutput)
        {
            // Open the project file and check the structure
            XmlDocument doc = new XmlDocument();
            doc.Load (szProject);
            if (doc.DocumentElement.Name != "database")
            {
                Console.WriteLine("document " + szProject + " of the wrong type, root node != database but " + doc.DocumentElement.FirstChild.Name);
                Environment.Exit (-3);
            }

            // Read all the source-files
            Console.WriteLine("Reading source-files...");
            ParserSQL sql = new ParserSQL();

            Console.WriteLine("Source: " + szDBSqlfile);
            if ( !sql.readSQL( szDBSqlfile )) {
                Console.WriteLine("\tProblem reading sql file: " + szDBSqlfile);
                Environment.Exit (-3);
            }

            // Group the tables.
            Console.WriteLine("Grouping tables...");
            DataBaseHTML db = new DataBaseHTML(sql.getDatabase());
            db.prepareLinks();
            db.prepareDisplay( "", false);
            XmlNode cur = doc.DocumentElement;
            // on the diagram, tables that don't have all links displayed on that diagram get a special color marking
            // but sometimes, one table is referenced by each table; this table can be excluded (eg. s_user); use format [s_user],[s_other]
            string strColorTableIgnoreReferencedTables;
            if (((XmlElement)cur).HasAttribute("ColorIgnoreReferencedTables")) {
                strColorTableIgnoreReferencedTables = cur.Attributes["ColorIgnoreReferencedTables"].Value;
            }
            cur = cur.FirstChild;
            while ( cur != null) {
                if ( cur.Name == "group") {
                    Console.WriteLine ("Group: " + cur.Attributes["name"].Value);
                    string strGroup = cur.Attributes["name"].Value;
                    XmlNode tables = cur.FirstChild;
                    // Run over tables...
                    string strTableList = String.Empty;
                    while ( tables != null) {
                        if ( tables.Name == "tablename") {
                            if ( strTableList.Length > 0) {
                                strTableList += ",";
                            }
                            strTableList += "[" + tables.Attributes["name"].Value + "]";
                        }
                        tables = tables.NextSibling;
                    }

                    // TODO processDia( strPathDiaOutput, strGroup, strTableList, strColorTableIgnoreReferencedTables);
                }
                cur = cur.NextSibling;
            }
        }
예제 #3
0
        static void DumpProjectAllTables( string sqlfilename)
        {
            // Create a sample project file for the given source file(s)
            Console.WriteLine("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>");
            Console.WriteLine();
            Console.WriteLine("<database>");
            ParserSQL sql = new ParserSQL();

            Console.WriteLine("\t<group name=\"all\">");
            if ( !sql.readSQL( sqlfilename)) {
                Console.WriteLine("Problem reading sql create script file: " + sqlfilename);
                Environment.Exit( -1);
            }
            DataBase db = sql.getDatabase();
            // For all tables read, dump their names in this group
            Console.Write(db.ToString());
            // End of this group
            Console.WriteLine("\t</group>");
            Console.WriteLine("</database>");
        }