Ejemplo n.º 1
0
        public string getTableColumns(string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);
            List <Dictionary <string, dynamic> > list = new List <Dictionary <string, dynamic> >();
            DatabaseXML db    = udb.getDatabaseByName(databaseName);
            Table       table = db.getTableByName(tableName);

            foreach (Column column in table.Columns)
            {
                Dictionary <string, dynamic> dic = new Dictionary <string, dynamic>();
                dic.Add("Name", column.Name);
                dic.Add("Type", TypeString.ToString(column.Type));
                dic.Add("Length", column.getLength());
                dic.Add("PK", table.PrimaryKey.IndexOf(column.Name));
                List <ForeignKey> listFK = new List <ForeignKey>();
                foreach (ForeignKey fk in table.ForeignKeys)
                {
                    foreach (ForeignKeyInside fki in fk.Info)
                    {
                        if (fki.ColumnName == column.Name)
                        {
                            listFK.Add(fk);
                        }
                    }
                }
                dic.Add("FK", listFK);
                list.Add(dic);
            }
            return(JsonConvert.SerializeObject(list));
        }
Ejemplo n.º 2
0
        public UserDatabases getDatabases()
        {
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            UserDatabases    udb       = dao.findByMatricule(matricule);

            return(udb);
        }
Ejemplo n.º 3
0
        public ActionResult addPrimaryKey(List <string> columnNames, string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).PrimaryKey = columnNames;
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 4
0
        public ActionResult removeDatabase(string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.removeDatabaseByName(databaseName);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 5
0
        public ActionResult removePrimaryKey(string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).PrimaryKey.Clear();
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 6
0
        public void update(Column column, string previousName, string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);
            DatabaseXML      db        = udb.getDatabaseByName(databaseName);

            db.getTableByName(tableName).updateColumn(previousName, column, db);
            dao.update(udb);
        }
Ejemplo n.º 7
0
        public ActionResult AjaxTemplate(string databaseName, string tableName, string matricule)
        {
            initUser();
            UserDatabasesDAO dao = new UserDatabasesDAO();
            UserDatabases    udb = dao.findByMatricule(matricule);
            DatabaseXML      db  = udb.getDatabaseByName(databaseName);

            ViewBag.db = db;
            return(View());
        }
Ejemplo n.º 8
0
        public ActionResult addUniqueKey(UniqueKey uk, string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).addUniqueKey(uk);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 9
0
        public ActionResult addDatabase(DatabaseXML database)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.Databases.Add(database);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 10
0
        public ActionResult updateIndex(Index index, string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).updateIndex(index);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 11
0
        public string getTableForeignKeys(string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);
            List <Dictionary <string, dynamic> > list = new List <Dictionary <string, dynamic> >();
            DatabaseXML db    = udb.getDatabaseByName(databaseName);
            Table       table = db.getTableByName(tableName);

            return(JsonConvert.SerializeObject(table.ForeignKeys));
        }
Ejemplo n.º 12
0
        public ActionResult getTableByName(string tableName, string databaseName)
        {
            initUser();
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);
            Table            table     = udb.getDatabaseByName(databaseName).getTableByName(tableName);
            string           json      = new JavaScriptSerializer().Serialize(table);

            return(Json(json));
        }
Ejemplo n.º 13
0
        public ActionResult addForeignKey(ForeignKey fk, string tableName, string databaseName)
        {
            initUser();
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).ForeignKeys.Add(fk);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 14
0
        public ActionResult ViewDatasScript(string databaseName, string tableName, string matricule)
        {
            initUser();
            UserDatabasesDAO dao   = new UserDatabasesDAO();
            UserDatabases    udb   = dao.findByMatricule(matricule);
            DatabaseXML      db    = udb.getDatabaseByName(databaseName);
            Table            table = db.getTableByName(tableName);

            ViewBag.database = db;
            ViewBag.table    = table;
            return(View());
        }
Ejemplo n.º 15
0
        public ActionResult removeUniqueKey(UniqueKey uniqueKey, string tableName, string databaseName)
        {
            initUser();

            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).UniqueKeys.Remove(uniqueKey);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 16
0
        public ActionResult removeColumn(string columnName, string tableName, string databaseName)
        {
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            try
            {
                udb.getDatabaseByName(databaseName).getTableByName(tableName).removeColumnByName(columnName);
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 17
0
        public ActionResult addForeignKey(ForeignKey fk, List <string> ColumnName, List <string> ExternColumnName, string tableName, string databaseName)
        {
            for (int i = 0; i < ColumnName.Count; i++)
            {
                fk.Info.Add(new ForeignKeyInside
                {
                    ColumnName       = ColumnName[i],
                    ExternColumnName = ExternColumnName[i]
                });
            }
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).addForeignKey(fk);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 18
0
        public ActionResult addTable(string tableName, string databaseName, string type)
        {
            initUser();
            Table table = new Table();

            if (type != null)
            {
                table.Type = type;
            }
            table.Name = tableName;
            Column pk = new Column
            {
                DecimalLength = 0,
                isNull        = 0,
                Length        = 0,
                Name          = "Id_" + tableName,
                Type          = Database.Type.Int_AI
            };
            Column isSuppr = new Column
            {
                DecimalLength = 0,
                isNull        = 0,
                Length        = 0,
                Name          = "IsSuppr",
                Type          = Database.Type.Boolean
            };

            table.Columns.Add(pk);
            table.Columns.Add(isSuppr);
            table.PrimaryKey.Add("Id_" + tableName);
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).Content.Add(table);
            dao.update(udb);

            /*table.ForeignKeys;
             * table.Indexes;
             * table.PrimaryKey;
             * table.UniqueKeys;*/
            return(Json(""));
        }
Ejemplo n.º 19
0
        public void resetDatabase(string dbName)
        {
            initUser();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            UserDatabases    udb       = dao.findByMatricule(matricule);
            DatabaseXML      db        = udb.getDatabaseByName(dbName);

            db = loadDBFromConnectionString(dbName, db.ConnectionString, "");
            for (int i = 0; i < udb.Databases.Count; i++)
            {
                if (udb.Databases[i].Name == dbName)
                {
                    udb.Databases.RemoveAt(i);
                    break;
                }
            }
            udb.Databases.Add(db);
            dao.update(udb);
        }
Ejemplo n.º 20
0
        public ActionResult loadDatabase(string projectName, string host, string instance, string databaseName, string username, string password)
        {
            initUser();

            string matricule = ((User)Session["user"]).Matricule;

            UserDatabasesDAO dao = new UserDatabasesDAO();
            UserDatabases    udb = dao.findByMatricule(matricule);
            string           connectionString = "Data Source=" + host + "\\" + instance + ";Initial Catalog=" + databaseName + ";Persist Security Info=True;User ID=" + username + ";Password="******"")
            {
                connectionString = "Data Source=" + host + ";Initial Catalog=" + databaseName + ";Persist Security Info=True;User ID=" + username + ";Password="******"")
            {
                if (instance == null || instance == "")
                {
                    connectionString = "Data Source=" + host + ";initial catalog=" + databaseName + ";integrated security=True;MultipleActiveResultSets=True;App=EntityFramework";
                }
                else
                {
                    connectionString = "Data Source=" + host + "\\" + instance + ";initial catalog=" + databaseName + ";integrated security=True;MultipleActiveResultSets=True;App=EntityFramework";
                }
            }

            DatabaseXML db = loadDBFromConnectionString(projectName, connectionString, databaseName);

            for (int i = 0; i < udb.Databases.Count; i++)
            {
                if (udb.Databases[i].Name == databaseName)
                {
                    udb.Databases.RemoveAt(i);
                    break;
                }
            }
            udb.Databases.Add(db);
            dao.update(udb);
            return(RedirectToAction("index"));
        }
Ejemplo n.º 21
0
        public ActionResult addColumn(Column column, string IsNull, string columnType, string tableName, string databaseName)
        {
            if (IsNull == "on")
            {
                column.isNull = 1;
            }
            else
            {
                column.isNull = 0;
            }
            if (column.Length == null)
            {
                column.Length = 0;
            }
            column.Type = Database.TypeString.toType(columnType);
            UserDatabasesDAO dao       = new UserDatabasesDAO();
            string           matricule = ((User)Session["user"]).Matricule;
            UserDatabases    udb       = dao.findByMatricule(matricule);

            udb.getDatabaseByName(databaseName).getTableByName(tableName).Columns.Add(column);
            dao.update(udb);
            return(Json(""));
        }
Ejemplo n.º 22
0
        private void generateCode(string databaseName, string codeType, string path, string zipPath, string matricule)
        {
            UserDatabasesDAO dao = new UserDatabasesDAO();
            UserDatabases    udb = dao.findByMatricule(matricule);
            DatabaseXML      db  = udb.getDatabaseByName(databaseName);

            emptyUserTmp(path, zipPath);
            string abstractDao = "";

            if (codeType == "CS")
            {
                //abstractDao = CRUDGenerator.Templates.Classes.CS.AbstractDAOGenerator.getAbstractDAOClass(db);
                //System.IO.File.WriteAllText(path + "DAO"+Path.DirectorySeparatorChar+"AbstractDao.cs", abstractDao);
            }
            else if (codeType == "PHP")
            {
                abstractDao = CRUDGenerator.Templates.Classes.PHP.AbstractDAOGenerator.getAbstractDAOClass(db);
                System.IO.File.WriteAllText(path + "DAO" + Path.DirectorySeparatorChar + "AbstractDao.php", abstractDao);
            }
            foreach (Table table in db.Content)
            {
                //string entity = "";
                string daoString = "";
                if (codeType == "CS")
                {
                    if (table.Type == "Normal")
                    {
                        Directory.CreateDirectory(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar);
                        Directory.CreateDirectory(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "Scripts");
                        //Directory.CreateDirectory(path + "Scripts" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar);
                        //entity = CRUDGenerator.Templates.Classes.CS.EntityGenerator.getEntityClassString(table, db.Name);
                        daoString = CRUDGenerator.Templates.Classes.CS.DAOGenerator.getDAOClass(table, db.Name).Replace("&lt;", "<").Replace("&gt;", ">");;
                        //System.IO.File.WriteAllText(path + "DAO"+Path.DirectorySeparatorChar+"Entity"+Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + ".cs", entity);
                        string controller = CRUDGenerator.Templates.Classes.CS.ControllerGenerator.getControllerClass(table, db).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                        System.IO.File.WriteAllText(path + "DataAccessObject" + Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + "DataAccess.cs", daoString);
                        System.IO.File.WriteAllText(path + "Controllers" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + "Controller.cs", controller);

                        /*string InsertForm = getHtml(db.Name, table.Name, "InsertForm", matricule).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                         * string ModifyForm = getHtml(db.Name, table.Name, "ModifyForm", matricule).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                         * string ViewDatas = getHtml(db.Name, table.Name, "ViewDatas", matricule).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                         * string InsertFormScript = getHtml(db.Name, table.Name, "InsertFormScript", matricule).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                         * string ModifyFormScript = getHtml(db.Name, table.Name, "ModifyFormScript", matricule).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                         * string ViewDatasScript = getHtml(db.Name, table.Name, "ViewDatasScript", matricule).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                         * System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "create.cshtml", InsertForm);
                         * System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "modify.cshtml", ModifyForm);
                         * System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "list.cshtml", ViewDatas);
                         * System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + "createScript.cshtml", InsertFormScript);
                         * System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + "modifyScript.cshtml", ModifyFormScript);
                         * System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + table.Name + "" + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + "listScript.cshtml", ViewDatasScript);
                         */
                    }
                    else
                    {
                        daoString = CRUDGenerator.Templates.Classes.CS.DAOGenerator.getDAOClass(table, db.Name).Replace("&lt;", "<").Replace("&gt;", ">");;
                        System.IO.File.WriteAllText(path + "DataAccessObject" + Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + "DataAccess.cs", daoString);
                        string controller = CRUDGenerator.Templates.Classes.CS.ControllerGenerator.getControllerClass(table, db).Replace("&lt;", "<").Replace("&gt;", ">").Replace("é", "é");
                        System.IO.File.WriteAllText(path + "Controllers" + Path.DirectorySeparatorChar + "Ajax" + Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + "Controller.cs", controller);
                    }
                }
                else if (codeType == "PHP")
                {
                    //entity = CRUDGenerator.Templates.Classes.PHP.EntityGenerator.getEntityClassString(table, db.Name);
                    daoString = CRUDGenerator.Templates.Classes.PHP.DAOGenerator.getDAOClass(table, db.Name);
                    //System.IO.File.WriteAllText(path + "DAO"+Path.DirectorySeparatorChar+"Entity"+Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + ".php", entity);
                    System.IO.File.WriteAllText(path + "DAO" + Path.DirectorySeparatorChar + FirstCharToUpper(table.Name) + "Dao.php", daoString);
                }
            }

            if (codeType == "CS")
            {
                System.IO.File.WriteAllText(path + "addToBundleConfig.txt", @"
            var ajaxCssBundle = new Bundle(""~/bundles/AjaxCss"", new CssMinify());
            ajaxCssBundle.Include(
                ""~/Content/lib/bootstrap.css"",
                ""~/Content/lib/font-awesome.css"",
                ""~/Content/lib/jquery.dataTables.css"",
                ""~/Content/lib/fixedHeader.dataTables.css"",
                ""~/Content/lib/jquery-ui-smoothness.css"",
                ""~/Content/lib/jquery-ui-smoothness.theme.css"",
                ""~/Content/lib/jquery-ui-timepicker-addon.css"",
                ""~/Content/lib/chosen.css"",
                ""~/Content/lib/sweetalert2.css"",
                ""~/Content/app/Site.css""
                );
            var ajaxJsBundle = new Bundle(""~/bundles/AjaxJs"", new JsMinify());
            ajaxJsBundle.Include(
                ""~/Scripts/lib/jquery-2.2.4.js"",
                ""~/Scripts/lib/bootstrap.js"",
                ""~/Scripts/lib/jquery.dataTables.js"",
                ""~/Scripts/lib/jquery-ui.js"",
                ""~/Scripts/lib/datepicker-fr.js"",
                ""~/Scripts/lib/jquery-ui-timepicker-addon.js"",
                ""~/Scripts/lib/chosen.jquery.js"",
                ""~/Scripts/lib/chosen.proto.js"",
                ""~/Scripts/lib/sweetalert2.js"",
                ""~/Scripts/lib/date.format.js"",
                ""~/Scripts/app/globalUtils.js""
                ); 
            bundles.Add(ajaxCssBundle);
            bundles.Add(ajaxJsBundle);");
                string AjaxTemplate = getHtml(db.Name, "truc", "AjaxTemplate", matricule);
                System.IO.File.WriteAllText(path + "Views" + Path.DirectorySeparatorChar + "Shared" + Path.DirectorySeparatorChar + "AjaxTemplate.cshtml", AjaxTemplate);
            }

            string SourcePath      = System.AppDomain.CurrentDomain.BaseDirectory + "tmp" + Path.DirectorySeparatorChar + "addToArchive";
            string DestinationPath = path + "";

            //Now Create all of the directories
            foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
                                                                SearchOption.AllDirectories))
            {
                Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
            }

            //Copy all the files & Replaces any files with the same name
            foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
                                                          SearchOption.AllDirectories))
            {
                System.IO.File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
            }

            /*SourcePath = System.AppDomain.CurrentDomain.BaseDirectory + "tmp"+Path.DirectorySeparatorChar+"Fonts";
             * DestinationPath = path + "Fonts";
             *
             * //Now Create all of the directories
             * foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
             *  SearchOption.AllDirectories))
             *  Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
             *
             * //Copy all the files & Replaces any files with the same name
             * foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
             *  SearchOption.AllDirectories))
             *  System.IO.File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
             *
             * SourcePath = System.AppDomain.CurrentDomain.BaseDirectory + "tmp"+Path.DirectorySeparatorChar+"Images";
             * DestinationPath = path + "Images";
             *
             * //Now Create all of the directories
             * foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
             *  SearchOption.AllDirectories))
             *  Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
             *
             * //Copy all the files & Replaces any files with the same name
             * foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
             *  SearchOption.AllDirectories))
             *  System.IO.File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
             */
        }
Ejemplo n.º 23
0
        private void generateScript(string databaseName, string scriptType, string scriptPath, string matricule)
        {
            UserDatabasesDAO dao = new UserDatabasesDAO();
            UserDatabases    udb = dao.findByMatricule(matricule);
            DatabaseXML      db  = udb.getDatabaseByName(databaseName);


            List <int>   list   = new List <int>();
            List <Table> tables = db.Content;

            /*for (int i = 0; i < tables.Count; i++)
             * {
             *  for (int j = 0; j < tables.Count; j++)
             *  {
             *      if(j == 2 || j == 8 || j == 9 || j == 10 || j == 16)
             *      {
             *
             *      }
             *      if (!list.Contains(j))
             *      {
             *          bool isOk = true;
             *          if (tables[j].ForeignKeys.Count == 0)
             *              isOk = true;
             *          foreach (ForeignKey fk in tables[j].ForeignKeys)
             *          {
             *              if(fk.ExternTableName != tables[j].Name)
             *              {
             *                  bool tmp = false;
             *                  for (int k = 0; k < list.Count && tmp == false; k++)
             *                  {
             *                      if (tables[list[k]].Name == fk.ExternTableName)
             *                      {
             *                          tmp = true;
             *                      }
             *                  }
             *                  if (tmp == false)
             *                      isOk = false;
             *              }
             *          }
             *          if (isOk == true)
             *          {
             *              list.Add(j);
             *          }
             *      }
             *  }
             * }*/
            string script   = "";
            string fkString = "";

            for (int i = 0; i < tables.Count; i++)
            {
                string tableFK = "";
                if (i == 0)
                {
                    if (scriptType == "SQLServer")
                    {
                        script = CRUDGenerator.Templates.Scripts.SQLServer.TableScriptGenerator.getTableScript(tables[i], out tableFK);
                    }
                    else if (scriptType == "MySQL")
                    {
                        script = CRUDGenerator.Templates.Scripts.MySQL.TableScriptGenerator.getTableScript(tables[i]);
                    }
                }
                else
                {
                    if (scriptType == "SQLServer")
                    {
                        script += "\n\n\n" + CRUDGenerator.Templates.Scripts.SQLServer.TableScriptGenerator.getTableScript(tables[i], out tableFK);
                    }
                    else if (scriptType == "MySQL")
                    {
                        script += "\n\n\n" + CRUDGenerator.Templates.Scripts.MySQL.TableScriptGenerator.getTableScript(tables[i]);
                    }
                }
                fkString += "\n\n\n" + tableFK;
            }
            System.IO.File.WriteAllText(scriptPath, script + fkString);
        }