コード例 #1
0
ファイル: Program.cs プロジェクト: Renan-Saraiva/syspec
        static void CompareDatabase(string schema, string connStr, string prefix, string server, string database, string user)
        {
            SchemaManager sm  = new SchemaManager();
            Database      db1 = GetDatabase(connStr, prefix, server, database, user);
            Database      db2 = sm.LoadFile("", schema);

            writeLog(String.Format("--Checking database '{0}:{1}' against schema '{2}'...", server, database, schema));
            writeLog(string.Empty);
            Compare(db1, db2);
            WriteVersionLog(Assembly.GetExecutingAssembly());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Renan-Saraiva/syspec
        static void GenerateScripts(string schema)
        {
            SchemaManager sm = new SchemaManager();
            Database      db = sm.LoadFile("", schema);

            foreach (Table t in db.Tables)
            {
                logFile.WriteLine(t.SqlCreate());
            }

            logFile.WriteLine("");
            logFile.WriteLine("/*--------------------------------------------------*/");
            logFile.WriteLine("");

            foreach (Table t in db.Tables)
            {
                foreach (Index i in t.Indexes)
                {
                    logFile.WriteLine(i.SqlCreate(t.Name));
                }
            }

            logFile.WriteLine("");
            logFile.WriteLine("/*--------------------------------------------------*/");
            logFile.WriteLine("");

            foreach (Table t in db.Tables)
            {
                foreach (Key k in t.Keys)
                {
                    if (String.Compare(k.Type, "primary key", true) == 0)
                    {
                        logFile.WriteLine(k.SqlCreate(t.Name));
                    }
                }
            }

            logFile.WriteLine("");
            logFile.WriteLine("/*--------------------------------------------------*/");
            logFile.WriteLine("");

            foreach (Table t in db.Tables)
            {
                foreach (Key k in t.Keys)
                {
                    if (String.Compare(k.Type, "primary key", true) != 0)
                    {
                        logFile.WriteLine(k.SqlCreate(t.Name));
                    }
                }
            }

            logFile.WriteLine("");
            logFile.WriteLine("/*--------------------------------------------------*/");
            logFile.WriteLine("GO");
            logFile.WriteLine("");

            foreach (Table t in db.Tables)
            {
                foreach (Trigger x in t.Triggers)
                {
                    logFile.WriteLine(x.SqlCreate());
                }
            }

            logFile.WriteLine("");
            logFile.WriteLine("/*--------------------------------------------------*/");
            logFile.WriteLine("");

            foreach (Program p in db.Programs)
            {
                logFile.WriteLine(p.SqlCreate());
            }

            Console.WriteLine("Script generated into 'dbcheck.txt' file.");
        }