Beispiel #1
0
        public static void ScriptSchema()
        {
            SetProvider();

            foreach (DataProvider provider in DataService.Providers)
            {
                string sConn = provider.DefaultConnectionString; //GetConnnectionString();


                if (sConn != string.Empty)
                {
                    Utility.WriteTrace("Scripting Schema:" + provider.Name);
                    Utility.WriteTrace("#####################################");
                    //string db = GetArg("db");
                    string outDir = GetOutputDirectory();

                    string schema      = DBScripter.ScriptSchema(sConn);
                    string outFileName = string.Format("{0}_Schema_{1}_{2}_{3}.sql", provider.Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                    string outPath     = Path.Combine(outDir, outFileName);

                    OutputFile(outPath, schema);
                    AddLogEntry(LogState.Information, "Finished!");
                }
            }
        }
Beispiel #2
0
        private static void ScriptData()
        {
            //SetProvider();
            SetProviderManually();
            //for this to work, we need a Servername, DB, and output. Optional elements are table list and user id/password
            //string[] tables = DataService.GetTableNames(SubSonicConfig.ProviderName);
            foreach (DataProvider provider in DataService.Providers)
            {
                //string[] tables = DataService.GetTableNames(provider.Name);
                string[] tables = DataService.GetOrderedTableNames(provider.Name);

                string outDir = GetOutputDirectory();
                if (outDir == string.Empty)
                {
                    outDir = Directory.GetCurrentDirectory();
                }

                AddLogEntry(LogState.Information, "Scripting Data");
                Utility.WriteTrace("#####################################");
                StringBuilder sb = new StringBuilder();
                foreach (string tbl in tables)
                {
                    if (IsInList(tbl) || CodeService.ShouldGenerate(tbl, provider.Name))
                    {
                        Utility.WriteTrace("Scripting Table: " + tbl);
                        string dataScript = DBScripter.ScriptData(tbl, provider.Name);
                        sb.Append(dataScript + Environment.NewLine + Environment.NewLine);
                    }
                }
                string outFileName = string.Format("{0}_Data_{1}_{2}_{3}.sql", provider.Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                string outPath     = Path.Combine(outDir, outFileName);

                OutputFile(outPath, sb.ToString());
                AddLogEntry(LogState.Information, "Finished!");
            }
        }